/* name must be of the form lib*.so (Unix) or *.dll (Win32) */ static gboolean valid_module_name (const gchar *filename) { gchar *basename = g_path_get_basename (filename); if (gegl_config()->application_license == NULL || (strcmp (gegl_config ()->application_license, "GPL3") && strcmp (gegl_config ()->application_license, "GPL3+"))) { if (strstr (basename, "-gpl3")) { g_free (basename); return FALSE; } } if (! gegl_datafiles_check_extension (basename, "." G_MODULE_SUFFIX)) { g_free (basename); return FALSE; } g_free (basename); return TRUE; }
gint main (gint argc, gchar **argv) { GeglBuffer *buffer, *buffer2; GeglNode *gegl, *sink; gint i; g_thread_init (NULL); gegl_init (&argc, &argv); g_object_set (gegl_config (), "chunk-size", 128 * 128, NULL); buffer = test_buffer (1024, 1024, babl_format ("RGBA float")); #define ITERATIONS 6 test_start (); for (i=0;i< ITERATIONS;i++) { gegl = gegl_graph (sink = gegl_node ("gegl:buffer-sink", "buffer", &buffer2, NULL, gegl_node ("gegl:brightness-contrast", "contrast", 0.2, NULL, gegl_node ("gegl:buffer-source", "buffer", buffer, NULL)))); gegl_node_process (sink); g_object_unref (gegl); g_object_unref (buffer2); } test_end ("bcontrast-minichunk", gegl_buffer_get_pixel_count (buffer) * 16 * ITERATIONS); return 0; }
int main(int argc, char **argv) { gint tests_run = 0; gint tests_passed = 0; gint tests_failed = 0; gegl_init(0, NULL); g_object_set(G_OBJECT(gegl_config()), "swap", "RAM", "use-opencl", FALSE, NULL); RUN_TEST (test_buffer_path) RUN_TEST (test_buffer_path_from_backend) RUN_TEST (test_buffer_load) RUN_TEST (test_buffer_same_path) RUN_TEST (test_buffer_open) RUN_TEST (test_buffer_change_extent) gegl_exit(); if (tests_passed == tests_run) return 0; return -1; return 0; }
static void gimp_gegl_notify_tile_cache_size (GimpGeglConfig *config) { g_object_set (gegl_config (), "tile-cache-size", (guint64) config->tile_cache_size, NULL); }
static void gimp_gegl_notify_use_opencl (GimpGeglConfig *config) { g_object_set (gegl_config (), "use-opencl", config->use_opencl, NULL); }
static void gimp_gegl_notify_num_processors (GimpGeglConfig *config) { #if 0 g_object_set (gegl_config (), "threads", config->num_processors, NULL); #endif }
void gimp_gegl_init (Gimp *gimp) { GimpGeglConfig *config; g_return_if_fail (GIMP_IS_GIMP (gimp)); config = GIMP_GEGL_CONFIG (gimp->config); #ifdef __GNUC__ #warning not setting GeglConfig:threads #endif g_object_set (gegl_config (), "tile-cache-size", (guint64) config->tile_cache_size, #if 0 "threads", config->num_processors, #endif "use-opencl", config->use_opencl, NULL); /* turn down the precision of babl - permitting use of lookup tables for * gamma conversions, this precision is anyways high enough for both 8bit * and 16bit operation */ g_object_set (gegl_config (), "babl-tolerance", 0.00015, NULL); g_signal_connect (config, "notify::tile-cache-size", G_CALLBACK (gimp_gegl_notify_tile_cache_size), NULL); g_signal_connect (config, "notify::num-processors", G_CALLBACK (gimp_gegl_notify_num_processors), NULL); g_signal_connect (config, "notify::use-opencl", G_CALLBACK (gimp_gegl_notify_use_opencl), NULL); gimp_babl_init (); gimp_operations_init (); }
int main(int argc, char **argv) { gint tests_run = 0; gint tests_passed = 0; gint tests_failed = 0; gint i; const char *operation_names[] = { "svg:src", "svg:dst", "svg:src-over", "svg:dst-over", "svg:src-in", "svg:dst-in", "svg:src-out", "svg:dst-out", "svg:src-atop", "svg:dst-atop", "svg:clear", "svg:xor", }; gegl_init(0, NULL); g_object_set(G_OBJECT(gegl_config()), "swap", "RAM", "use-opencl", FALSE, NULL); printf ("testing abyss handling of svg blends\n"); for (i = 0; i < G_N_ELEMENTS(operation_names); ++i) { if (test_operation (operation_names[i])) tests_passed++; else tests_failed++; tests_run++; } gegl_exit(); printf ("\n"); if (tests_passed == tests_run) return 0; return -1; return 0; }
void gegl_tile_backend_unlink_swap (gchar *path) { gchar *dirname = g_path_get_dirname (path); /* Ensure we delete only files in our known swap directory for safety. */ if (g_file_test (path, G_FILE_TEST_EXISTS) && g_strcmp0 (dirname, gegl_config()->swap) == 0) g_unlink (path); g_free (dirname); }
gint main (gint argc, gchar **argv) { gboolean result; GError *error = NULL; GOptionContext *context; setlocale (LC_ALL, ""); context = g_option_context_new (NULL); g_option_context_add_main_entries (context, options, NULL); g_option_context_add_group (context, gegl_get_option_group ()); g_object_set (gegl_config (), "application-license", "GPL3", NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_printf ("%s\n", error->message); g_error_free (error); result = FALSE; } else if (output_all && !(data_dir && output_dir)) { g_printf ("Data and output directories must be specified\n"); result = FALSE; } else if (!(output_all || (data_dir && output_dir && reference_dir))) { g_printf ("Data, reference and output directories must be specified\n"); result = FALSE; } else { regex = g_regex_new (pattern, 0, 0, NULL); exc_regex = g_regex_new (exclusion_pattern, 0, 0, NULL); result = process_operations (GEGL_TYPE_OPERATION); g_regex_unref (regex); g_regex_unref (exc_regex); } gegl_exit (); if (output_all) return 0; else return result; }
int main(int argc, char **argv) { gint tests_run = 0; gint tests_passed = 0; gint tests_failed = 0; gdouble scale_list[] = {5.0, 2.5, 2.0, 1.5, 1.0, 0.9, 0.5, 0.3, 0.1, 0.09, 0.05, 0.03}; gint x_list[] = {-16, 0, 15}; gint i, j, k; gegl_init(0, NULL); g_object_set(G_OBJECT(gegl_config()), "swap", "RAM", "use-opencl", FALSE, NULL); printf ("testing scaled blit\n"); for (i = 0; i < sizeof(x_list) / sizeof(x_list[0]); ++i) { for (j = 0; j < sizeof(scale_list) / sizeof(scale_list[0]); ++j) { const Babl *format_list[] = {babl_format ("RGBA u8"), babl_format ("RGBA u16")}; for (k = 0; k < sizeof(format_list) / sizeof(format_list[0]); ++k) { if (test_scale (scale_list[j], x_list[i], 0, format_list[k])) tests_passed++; else tests_failed++; tests_run++; } } } gegl_exit(); printf ("\n"); if (tests_passed == tests_run) return 0; return -1; return 0; }
static void gegl_tile_backend_swap_ensure_exist (void) { if (in_fd == -1 || out_fd == -1) { gchar *filename = g_strdup_printf ("%i-shared.swap", getpid ()); path = g_build_filename (gegl_config ()->swap, filename, NULL); g_free (filename); GEGL_NOTE (GEGL_DEBUG_TILE_BACKEND, "creating swapfile %s", path); out_fd = g_open (path, O_RDWR|O_CREAT, 0770); in_fd = g_open (path, O_RDONLY, 0); if (out_fd == -1 || in_fd == -1) g_warning ("Could not open swap file '%s': %s", path, g_strerror (errno)); } }
void app_libs_init (GOptionContext *context, gboolean no_interface) { /* disable OpenCL before GEGL is even initialized; this way we only * enable if wanted in gimprc, instead of always enabling, and then * disabling again if wanted in gimprc */ g_object_set (gegl_config (), "use-opencl", FALSE, "application-license", "GPL3", NULL); g_option_context_add_group (context, gegl_get_option_group ()); #ifndef GIMP_CONSOLE_COMPILATION if (! no_interface) { gui_libs_init (context); } #endif }
static void gegl_tile_backend_swap_push_queue (ThreadParams *params) { g_mutex_lock (&mutex); /* block if the queue has gotten too big */ while (queue_size > gegl_config ()->queue_size) g_cond_wait (&max_cond, &mutex); g_queue_push_tail (queue, params); if (params->operation == OP_WRITE) { params->entry->link = g_queue_peek_tail_link (queue); queue_size += params->length + sizeof (GList) + sizeof (ThreadParams); } /* wake up the writer thread */ g_cond_signal (&queue_cond); g_mutex_unlock (&mutex); }
gint main (gint argc, gchar **argv) { GList *operations; GList *iter; gboolean first = TRUE; gegl_init (&argc, &argv); g_object_set (gegl_config (), "application-license", "GPL3", NULL); operations = gegl_operations (); g_print ("window.opdb=[\n"); for (iter=operations;iter;iter = g_list_next (iter)) { GeglOperationClass *klass = iter->data; const char *name = gegl_operation_class_get_key (klass, "name"); const char *categoris = gegl_operation_class_get_key (klass, "categories"); if (first) first = FALSE; else g_print (","); g_print ("{'op':'%s'\n", name); if (klass->compat_name) g_print (",'compat-op':'%s'\n", klass->compat_name); if (klass->opencl_support) g_print (",'opencl-support':'true'\n"); g_print (",'parent':'%s'\n", g_type_name (g_type_parent(G_OBJECT_CLASS_TYPE(klass)))); { char *image = operation_to_path (name); if (g_file_test (image, G_FILE_TEST_EXISTS)) g_print (",'image':'%s'\n", image); g_free (image); } { gchar *commandline = g_strdup_printf ( "sh -c \"(cd " TOP_SRCDIR ";grep -r '\\\"%s\\\"' operations) | grep operations | grep -v '~:' | grep '\\\"name\\\"' | cut -f 1 -d ':'\"", name); gchar *output = NULL; if (g_spawn_command_line_sync (commandline, &output, NULL, NULL, NULL)) { if (strlen(output)) { output[strlen(output)-1] = 0; g_print ( ",'source':'https://git.gnome.org/browse/gegl/tree/%s'\n", output); } g_free (output); } g_free (commandline); } if (categoris) { const gchar *ptr = categoris; gboolean first = TRUE; g_print (",'categories':["); while (ptr && *ptr) { gchar category[64]=""; gint i=0; while (*ptr && *ptr!=':' && i<63) { category[i++]=*(ptr++); category[i]='\0'; } if (*ptr==':') ptr++; { if (first) first = FALSE; else g_print (","); g_print ("'%s'", category); } } g_print ("]\n"); } json_list_properties (G_OBJECT_CLASS_TYPE (klass), name); json_list_pads (G_OBJECT_CLASS_TYPE (klass), name); { guint nkeys; gchar **keys = gegl_operation_list_keys (name, &nkeys); if (keys) { for (gint i = 0; keys[i]; i++) { const gchar *value = gegl_operation_get_key (name, keys[i]); if (g_str_equal (keys[i], "categories") || g_str_equal (keys[i], "cl-source") || g_str_equal (keys[i], "source") || g_str_equal (keys[i], "name") ) continue; g_print (",\"%s\":\"", keys[i]); json_escape_string (value); g_print ("\"\n"); } g_free (keys); } } g_print (" }\n"); } g_print ("]\n"); return 0; }
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; }
G_MININT / 2, G_MAXINT / 2, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (gobject_class, PROP_FORMAT, g_param_spec_pointer ("format", "format", "babl format", G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); g_object_class_install_property (gobject_class, PROP_BACKEND, g_param_spec_pointer ("backend", "backend", "A custom tile-backend instance to use", G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); g_object_class_install_property (gobject_class, PROP_TILE_HEIGHT, g_param_spec_int ("tile-height", "tile-height", "height of a tile", -1, G_MAXINT, gegl_config()->tile_height, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (gobject_class, PROP_TILE_WIDTH, g_param_spec_int ("tile-width", "tile-width", "width of a tile", -1, G_MAXINT, gegl_config()->tile_width, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (gobject_class, PROP_PATH, g_param_spec_string ("path", "Path", "URI to where the buffer is stored", NULL, G_PARAM_READWRITE|G_PARAM_CONSTRUCT)); gegl_buffer_signals[CHANGED] =
static GObject * gegl_buffer_constructor (GType type, guint n_params, GObjectConstructParam *params) { GObject *object; GeglBuffer *buffer; GeglTileBackend *backend; GeglTileHandler *handler; GeglTileSource *source; object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params); buffer = GEGL_BUFFER (object); handler = GEGL_TILE_HANDLER (object); source = handler->source; backend = gegl_buffer_backend (buffer); if (source) { if (GEGL_IS_TILE_STORAGE (source)) buffer->format = GEGL_TILE_STORAGE (source)->format; else if (GEGL_IS_BUFFER (source)) buffer->format = GEGL_BUFFER (source)->format; } else { if (buffer->backend) { backend = buffer->backend; buffer->format = gegl_tile_backend_get_format (backend); } else { gboolean use_ram = FALSE; const char *maybe_path = NULL; if (!buffer->format) { g_warning ("Buffer constructed without format, assuming RGBA float"); buffer->format = babl_format("RGBA float"); } /* make a new backend & storage */ if (buffer->path) maybe_path = buffer->path; else maybe_path = gegl_config ()->swap; if (maybe_path) use_ram = g_ascii_strcasecmp (maybe_path, "ram") == 0; else use_ram = TRUE; if (use_ram == TRUE) { backend = g_object_new (GEGL_TYPE_TILE_BACKEND_RAM, "tile-width", buffer->tile_width, "tile-height", buffer->tile_height, "format", buffer->format, NULL); } else { if (buffer->path) { backend = g_object_new (GEGL_TYPE_TILE_BACKEND_FILE, "tile-width", buffer->tile_width, "tile-height", buffer->tile_height, "format", buffer->format, "path", buffer->path, NULL); } else { gchar *path = get_next_swap_path(); backend = g_object_new (GEGL_TYPE_TILE_BACKEND_FILE, "tile-width", buffer->tile_width, "tile-height", buffer->tile_height, "format", buffer->format, "path", path, NULL); g_free (path); } } buffer->backend = backend; } source = GEGL_TILE_SOURCE (gegl_tile_storage_new (backend)); gegl_tile_handler_set_source ((GeglTileHandler*)(buffer), source); g_object_unref (source); g_object_unref (backend); } /* Connect to the changed signal of source, this is used by some backends * (e.g. File) to notify of outside changes to the buffer. */ if (GEGL_IS_TILE_STORAGE (source)) { g_signal_connect (source, "changed", G_CALLBACK (gegl_buffer_storage_changed), buffer); } g_assert (backend); if (buffer->extent.width == -1 || buffer->extent.height == -1) /* no specified extents, inheriting from source */ { if (GEGL_IS_BUFFER (source)) { buffer->extent.x = GEGL_BUFFER (source)->extent.x; buffer->extent.y = GEGL_BUFFER (source)->extent.y; buffer->extent.width = GEGL_BUFFER (source)->extent.width; buffer->extent.height = GEGL_BUFFER (source)->extent.height; } else if (GEGL_IS_TILE_STORAGE (source)) { buffer->extent.x = 0; buffer->extent.y = 0; buffer->extent.width = GEGL_TILE_STORAGE (source)->width; buffer->extent.height = GEGL_TILE_STORAGE (source)->height; } else { buffer->extent.x = 0; buffer->extent.y = 0; buffer->extent.width = 0; buffer->extent.height = 0; } } buffer->abyss_tracks_extent = FALSE; if (buffer->abyss.width == 0 && buffer->abyss.height == 0 && buffer->abyss.x == 0 && buffer->abyss.y == 0) /* 0 sized extent == inherit buffer extent */ { buffer->abyss.x = buffer->extent.x; buffer->abyss.y = buffer->extent.y; buffer->abyss.width = buffer->extent.width; buffer->abyss.height = buffer->extent.height; buffer->abyss_tracks_extent = TRUE; } else if (buffer->abyss.width == 0 && buffer->abyss.height == 0) { g_warning ("peculiar abyss dimensions: %i,%i %ix%i", buffer->abyss.x, buffer->abyss.y, buffer->abyss.width, buffer->abyss.height); } else if (buffer->abyss.width == -1 || buffer->abyss.height == -1) { buffer->abyss.x = GEGL_BUFFER (source)->abyss.x - buffer->shift_x; buffer->abyss.y = GEGL_BUFFER (source)->abyss.y - buffer->shift_y; buffer->abyss.width = GEGL_BUFFER (source)->abyss.width; buffer->abyss.height = GEGL_BUFFER (source)->abyss.height; } /* intersect our own abyss with parent's abyss if it exists */ if (GEGL_IS_BUFFER (source)) { GeglRectangle parent; GeglRectangle request; GeglRectangle self; parent.x = GEGL_BUFFER (source)->abyss.x - buffer->shift_x; parent.y = GEGL_BUFFER (source)->abyss.y - buffer->shift_y; parent.width = GEGL_BUFFER (source)->abyss.width; parent.height = GEGL_BUFFER (source)->abyss.height; request.x = buffer->abyss.x; request.y = buffer->abyss.y; request.width = buffer->abyss.width; request.height = buffer->abyss.height; gegl_rectangle_intersect (&self, &parent, &request); /* Don't have the abyss track the extent if the intersection is * not the entire extent. Otherwise, setting the extent identical * to itself could suddenly make the abyss bigger. */ if (buffer->abyss_tracks_extent && (buffer->extent.x != self.x || buffer->extent.y != self.y || buffer->extent.width != self.width || buffer->extent.height != self.height) ) { buffer->abyss_tracks_extent = FALSE; } buffer->abyss.x = self.x; buffer->abyss.y = self.y; buffer->abyss.width = self.width; buffer->abyss.height = self.height; } /* compute our own total shift <- this should probably happen * approximatly first */ if (GEGL_IS_BUFFER (source)) { GeglBuffer *source_buf; source_buf = GEGL_BUFFER (source); buffer->shift_x += source_buf->shift_x; buffer->shift_y += source_buf->shift_y; } else { } buffer->tile_storage = gegl_buffer_tile_storage (buffer); /* intialize the soft format to be equivalent to the actual * format */ buffer->soft_format = buffer->format; return object; }
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 gpointer gegl_tile_backend_swap_writer_thread (gpointer ignored) { while (TRUE) { ThreadParams *params; g_mutex_lock (&mutex); while (g_queue_is_empty (queue) && !exit_thread) g_cond_wait (&queue_cond, &mutex); if (exit_thread) { g_mutex_unlock (&mutex); GEGL_NOTE (GEGL_DEBUG_TILE_BACKEND, "exiting writer thread"); return NULL; } params = (ThreadParams *)g_queue_pop_head (queue); if (params->operation == OP_WRITE) { in_progress = params; params->entry->link = NULL; } g_mutex_unlock (&mutex); switch (params->operation) { case OP_WRITE: gegl_tile_backend_swap_write (params); break; case OP_TRUNCATE: if (ftruncate (out_fd, total) != 0) g_warning ("failed to resize swap file: %s", g_strerror (errno)); break; } g_mutex_lock (&mutex); in_progress = NULL; if (params->operation == OP_WRITE) { queue_size -= params->length + sizeof (GList) + sizeof (ThreadParams); g_free (params->source); /* unblock the main thread if the queue had gotten too big */ if (queue_size < gegl_config ()->queue_size) g_cond_signal (&max_cond); } g_slice_free (ThreadParams, params); g_mutex_unlock (&mutex); } return NULL; }
gint main (gint argc, gchar **argv) { gegl_init (&argc, &argv); /* initialize the GEGL library */ /* license for this application, needed by fractal-explorer */ g_object_set (gegl_config (), "application-license", "GPL3", NULL); { /* instantiate a graph */ GeglNode *gegl = gegl_node_new (); /* This is the graph we're going to construct: .-----------. | display | `-----------' | .--------. | crop | `--------' | .--------. | over | `--------' | \ | \ | \ | | | .------. | | text | | `------' .------------------. | fractal-explorer | `------------------' */ /*< The image nodes representing operations we want to perform */ GeglNode *display = gegl_node_create_child (gegl, "gegl:ff-save"); GeglNode *crop = gegl_node_new_child (gegl, "operation", "gegl:crop", "width", 512.0, "height", 384.0, NULL); GeglNode *over = gegl_node_new_child (gegl, "operation", "gegl:over", NULL); GeglNode *text = gegl_node_new_child (gegl, "operation", "gegl:text", "size", 10.0, "color", gegl_color_new ("rgb(1.0,1.0,1.0)"), NULL); GeglNode *mandelbrot = gegl_node_new_child (gegl, "operation", "gegl:fractal-explorer", "shiftx", -256.0, NULL); gegl_node_link_many (mandelbrot, over, crop, display, NULL); gegl_node_connect_to (text, "output", over, "aux"); /* request that the save node is processed, all dependencies will * be processed as well */ { gint frame; gint frames = 200; for (frame=0; frame<frames; frame++) { gchar string[512]; gdouble t = frame * 1.0/frames; #define INTERPOLATE(min,max) ((max)*(t)+(min)*(1.0-t)) gdouble shiftx = INTERPOLATE(-256.0, -512.0); gdouble shifty = INTERPOLATE(0.0, -256.0); gdouble zoom = INTERPOLATE(300.0, 400.0); gegl_node_set (mandelbrot, "shiftx", shiftx, "shifty", shifty, "zoom", zoom, NULL); g_sprintf (string, "x=%1.3f y=%1.3f z=%1.3f", shiftx, shifty, zoom); gegl_node_set (text, "string", string, NULL); gegl_node_process (display); } } /* free resources used by the graph and the nodes it owns */ g_object_unref (gegl); } /* free resources globally used by GEGL */ gegl_exit (); return 0; }