The question is a little too big, mainly because I want to record some of my experiences while reading the code. I will also have a reference later.
First of all, I want to analyze the structure of DT. If you do not understand it, I should first write down that DT uses a lot of things that I don't understand, as shown below:
GTK +/Cairo
OpenMP
Opencl
Sqlite3
Gegl
Gconf
Glade
I also have a lot of image processing knowledge, and git is also the first time... A lot of things to learn!
In the end, you must go deep into the details, especially the snapshot part you want to perform.
Let's take a look at the struct in darktable. h.
Typedef struct darktable_t <br/>{< br/> int32_t thumbnail_size; <br/> int32_t unmuted; <br/> Glist * IOP; <br/> Glist * collection_listeners; <br/> struct dt_conf_t * conf; <br/> struct dt_develop_t * develop; <br/> struct dt_lib_t * LIB; <br/> struct dt_view_manager_t * view_manager; <br/> struct dt_control_t * control; <br/> struct dt_gui_gtk_t * GUI; <br/> struct validation * mipmap_cache; <br/> struct dt_image_cache_t * image_cache; <br/> sqlite3 * dB; <br/> const struct dt_fswatch_t * fswatch; <br/> const struct dt_pwstorage_t * pwstorage; <br/> const struct dt_camctl_t * camctl; <br/> const struct dt_collection_t * Collection; <br/> struct dt_points_t * points; <br/> struct dt_imageio_t * ImageIO; <br/> struct dt_opencl_t * opencl; <br/> dt_pthread_mutex_t db_insert; <br/> dt_pthread_mutex_t plugin_threadsafe; <br/> char * progname; <br/>}< br/> darktable_t;
In darktable. C, there is only one instance of darktable_t darktable, which stores all information during DT runtime.
Db_insert and plugin_threadsafe are two mutex variables. Gui must be the DT interface, but others have not yet seen.
Main. C has two important function calls.
If (dt_init (argc, argv, 1) Exit (1 );
// In darktable. C, this function initializes various resources and calls a bunch of functions, which will be analyzed later.
Dt_gui_gtk_run (darktable. Gui );
// This function is available in GTK. c, call gtk_main (); enter the main loop, wait for the user to input the event, and then call gdk_threads_leave () at the end of the program; because of this function and gdk_threads_enter (); it appears in pairs, so the enter function must be called elsewhere. I checked that these two functions are used in many places, but they all appear in pairs in one function. However, in dt_gui_gtk_init (), there is a leave in which the enter field does not match, this means that dt_init calls dt_gui_gtk_init to initialize the GUI, and then calls leave to exit the critical section when the program exits in dt_gui_gtk_run.
If (! G_thread_supported () g_thread_init (null );
Gdk_threads_init ();
Gdk_threads_enter ();
Gtk_init (& argc, & argv );
The above is the statement in dt_gui_gtk_init (). In fact, you can think that glib is the underlying support. Therefore, you must initialize it before creating and using the gdk thread.
ForGdk_threads_init ();This call must be made before any use of the main loop from GTK +; to be safe, call it beforegtk_init()
. "[Http://developer.gnome.org/gdk/stable/gdk-threads.html]
Go to the inside of dt_init...
# Define gettext_package "darktable"
# Define darktable_localedir "/usr/share/locale"
# Define package_name "darktable"
# Define package_version "0.8 + 235 ~ G44e9db7"
# Define package_string package_name "" package_version
# Define package_bugreport "hanatos@gmail.com"
# Define darktable_libdir "/usr/lib"
# Define darktable_datadir "/usr/share/darktable"
Some macro definitions generated by config. cmake. h are written down in build/config. h,
Bindtextdomain ("Darktable","/Usr/share/locale");
Bind_textdomain_codeset ("Darktable", "UTF-8 ");
Textdomain ("Darktable");
These three statements are replaced by the above macro.Find/usr/share/locale-name darktable *You can find many darktable.mo files in different directories. The first statement is to bind the. Mo file.
The three statements can be viewed by man. In short, it is something related to localization/internationalization (i18n). If it takes too much time to complete, put it first, and the center of gravity is not here !!
Alas, stop first. I feel that once I put my thoughts into words, I will be constrained everywhere. Is my ability to express myself too bad? Can't I explain my thoughts clearly?