static gboolean gegl_post_parse_hook (GOptionContext *context, GOptionGroup *group, gpointer data, GError **error) { glong time; if (config) return TRUE; g_assert (global_time == 0); global_time = gegl_ticks (); g_type_init (); gegl_instrument ("gegl", "gegl_init", 0); config = (void*)gegl_config (); if (cmd_gegl_swap) g_object_set (config, "swap", cmd_gegl_swap, NULL); if (cmd_gegl_quality) config->quality = atof (cmd_gegl_quality); if (cmd_gegl_cache_size) config->cache_size = atoi (cmd_gegl_cache_size)*1024*1024; if (cmd_gegl_chunk_size) config->chunk_size = atoi (cmd_gegl_chunk_size); if (cmd_gegl_tile_size) { const gchar *str = cmd_gegl_tile_size; config->tile_width = atoi(str); str = strchr (str, 'x'); if (str) config->tile_height = atoi(str+1); } if (cmd_gegl_threads) config->threads = atoi (cmd_gegl_threads); if (cmd_babl_tolerance) g_object_set (config, "babl-tolerance", atof(cmd_babl_tolerance), NULL); #ifdef GEGL_ENABLE_DEBUG { const char *env_string; env_string = g_getenv ("GEGL_DEBUG"); if (env_string != NULL) { gegl_debug_flags = g_parse_debug_string (env_string, gegl_debug_keys, G_N_ELEMENTS (gegl_debug_keys)); env_string = NULL; } } #endif /* GEGL_ENABLE_DEBUG */ time = gegl_ticks (); babl_init (); gegl_instrument ("gegl_init", "babl_init", gegl_ticks () - time); gegl_init_i18n (); time = gegl_ticks (); if (!module_db) { const gchar *gegl_path = g_getenv ("GEGL_PATH"); module_db = gegl_module_db_new (FALSE); if (gegl_path) { gegl_module_db_load (module_db, gegl_path); } else { gchar *module_path; #ifdef G_OS_WIN32 { gchar *prefix; prefix = g_win32_get_package_installation_directory_of_module ( hLibGeglModule ); module_path = g_build_filename (prefix, "lib", GEGL_LIBRARY, NULL); g_free(prefix); } #else module_path = g_build_filename (LIBDIR, GEGL_LIBRARY, NULL); #endif gegl_module_db_load (module_db, module_path); g_free (module_path); /* also load plug-ins from ~/.local/share/gegl-0.0/plugins */ module_path = g_build_filename (g_get_user_data_dir (), GEGL_LIBRARY, "plug-ins", NULL); if (g_mkdir_with_parents (module_path, S_IRUSR | S_IWUSR | S_IXUSR) == 0) { gchar *makefile_path = g_build_filename (module_path, "Makefile", NULL); if (! g_file_test (makefile_path, G_FILE_TEST_EXISTS)) g_file_set_contents (makefile_path, makefile (), -1, NULL); g_free (makefile_path); } gegl_module_db_load (module_db, module_path); g_free (module_path); } gegl_instrument ("gegl_init", "load modules", gegl_ticks () - time); } gegl_instrument ("gegl", "gegl_init", gegl_ticks () - global_time); if (g_getenv ("GEGL_SWAP")) g_object_set (config, "swap", g_getenv ("GEGL_SWAP"), NULL); if (g_getenv ("GEGL_QUALITY")) { const gchar *quality = g_getenv ("GEGL_QUALITY"); if (g_str_equal (quality, "fast")) g_object_set (config, "quality", 0.0, NULL); if (g_str_equal (quality, "good")) g_object_set (config, "quality", 0.5, NULL); if (g_str_equal (quality, "best")) g_object_set (config, "quality", 1.0, NULL); } swap_clean (); return TRUE; }
static gboolean gegl_post_parse_hook (GOptionContext *context, GOptionGroup *group, gpointer data, GError **error) { GeglConfig *config; g_assert (global_time == 0); global_time = gegl_ticks (); if (g_getenv ("GEGL_DEBUG_TIME") != NULL) gegl_instrument_enable (); gegl_instrument ("gegl", "gegl_init", 0); config = gegl_config (); gegl_config_parse_env (config); babl_init (); #ifdef GEGL_ENABLE_DEBUG { const char *env_string; env_string = g_getenv ("GEGL_DEBUG"); if (env_string != NULL) { gegl_debug_flags = g_parse_debug_string (env_string, gegl_debug_keys, G_N_ELEMENTS (gegl_debug_keys)); env_string = NULL; } } #endif /* GEGL_ENABLE_DEBUG */ if (cmd_gegl_swap) g_object_set (config, "swap", cmd_gegl_swap, NULL); if (cmd_gegl_quality) config->quality = atof (cmd_gegl_quality); if (cmd_gegl_cache_size) config->tile_cache_size = atoll (cmd_gegl_cache_size)*1024*1024; if (cmd_gegl_chunk_size) config->chunk_size = atoi (cmd_gegl_chunk_size); if (cmd_gegl_tile_size) { const gchar *str = cmd_gegl_tile_size; config->tile_width = atoi(str); str = strchr (str, 'x'); if (str) config->tile_height = atoi(str+1); } if (cmd_gegl_threads) { _gegl_threads = atoi (cmd_gegl_threads); if (_gegl_threads > GEGL_MAX_THREADS) { g_warning ("Tried to use %i threads, max is %i", _gegl_threads, GEGL_MAX_THREADS); _gegl_threads = GEGL_MAX_THREADS; } } if (cmd_gegl_disable_opencl) gegl_cl_hard_disable (); gegl_init_swap_dir (); GEGL_INSTRUMENT_START(); gegl_operation_gtype_init (); if (!module_db) { GSList *paths = gegl_get_default_module_paths (); module_db = gegl_module_db_new (FALSE); g_slist_foreach(paths, (GFunc)load_module_path, module_db); g_slist_free_full (paths, g_free); } GEGL_INSTRUMENT_END ("gegl_init", "load modules"); gegl_instrument ("gegl", "gegl_init", gegl_ticks () - global_time); swap_clean (); g_signal_connect (G_OBJECT (config), "notify::use-opencl", G_CALLBACK (gegl_config_use_opencl_notify), NULL); g_object_set (config, "use-opencl", config->use_opencl, NULL); g_signal_connect (G_OBJECT (config), "notify::application-license", G_CALLBACK (gegl_config_application_license_notify), NULL); gegl_operations_set_licenses_from_string (config->application_license); return TRUE; }