[gnome-photos/wip/rishi/unit-tests-gegl: 2/5] gegl, thumbnailer: Don't use gegl:save-pixbuf



commit 38cea1a9002d35dd85ae91d7c8a02a64f997a476
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Nov 30 12:55:30 2018 +0100

    gegl, thumbnailer: Don't use gegl:save-pixbuf
    
    ... to convert a GeglBuffer to a GdkPixbuf. This is part of a general
    trend of moving away from using graphs to convert a GeglBuffer to and
    from GdkPixbuf.

 src/photos-gegl.c        | 13 +++----------
 src/photos-thumbnailer.c | 19 ++++++++-----------
 2 files changed, 11 insertions(+), 21 deletions(-)
---
diff --git a/src/photos-gegl.c b/src/photos-gegl.c
index d385b921..92012268 100644
--- a/src/photos-gegl.c
+++ b/src/photos-gegl.c
@@ -57,7 +57,6 @@ static const gchar *REQUIRED_GEGL_OPS[] =
   "gegl:load",
   "gegl:noise-reduction",
   "gegl:nop",
-  "gegl:save-pixbuf",
   "gegl:scale-ratio",
   "gegl:shadows-highlights",
   "gegl:unsharp-mask",
@@ -512,16 +511,10 @@ GdkPixbuf *
 photos_gegl_create_pixbuf_from_node (GeglNode *node)
 {
   GdkPixbuf *pixbuf = NULL;
-  GeglNode *graph;
-  g_autoptr (GeglNode) save_pixbuf = NULL;
+  g_autoptr (GeglBuffer) buffer = NULL;
 
-  graph = gegl_node_get_parent (node);
-  save_pixbuf = gegl_node_new_child (graph,
-                                     "operation", "gegl:save-pixbuf",
-                                     "pixbuf", &pixbuf,
-                                     NULL);
-  gegl_node_link_many (node, save_pixbuf, NULL);
-  gegl_node_process (save_pixbuf);
+  buffer = photos_gegl_get_buffer_from_node (node, NULL);
+  pixbuf = photos_gegl_pixbuf_new_from_buffer (buffer);
 
   return pixbuf;
 }
diff --git a/src/photos-thumbnailer.c b/src/photos-thumbnailer.c
index 12c801d0..b4be286c 100644
--- a/src/photos-thumbnailer.c
+++ b/src/photos-thumbnailer.c
@@ -1,6 +1,6 @@
 /*
  * Photos - access, organize and share your photos on GNOME
- * Copyright © 2017 Red Hat, Inc.
+ * Copyright © 2017 – 2018 Red Hat, Inc.
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -260,6 +260,7 @@ photos_thumbnailer_generate_thumbnail_process (GObject *source_object, GAsyncRes
   GCancellable *cancellable;
   g_autoptr (GFile) thumbnail_file = NULL;
   g_autoptr (GTask) task = G_TASK (user_data);
+  GeglNode *pipeline_node;
   GeglProcessor *processor = GEGL_PROCESSOR (source_object);
   PhotosThumbnailerGenerateData *data;
   g_autofree gchar *thumbnail_dir = NULL;
@@ -282,6 +283,10 @@ photos_thumbnailer_generate_thumbnail_process (GObject *source_object, GAsyncRes
       }
   }
 
+  g_assert_null (data->pixbuf_thumbnail);
+
+  pipeline_node = photos_pipeline_get_graph (data->pipeline);
+  data->pixbuf_thumbnail = photos_gegl_create_pixbuf_from_node (pipeline_node);
   pixbuf_height = gdk_pixbuf_get_height (data->pixbuf_thumbnail);
   pixbuf_width = gdk_pixbuf_get_width (data->pixbuf_thumbnail);
 
@@ -345,7 +350,6 @@ photos_thumbnailer_generate_thumbnail_pixbuf (GObject *source_object, GAsyncResu
   g_autoptr (GeglBuffer) buffer_oriented = NULL;
   GeglNode *buffer_source;
   GeglNode *pipeline_node;
-  GeglNode *save_pixbuf;
   g_autoptr (GeglProcessor) processor = NULL;
   PhotosThumbnailerGenerateData *data;
 
@@ -363,21 +367,14 @@ photos_thumbnailer_generate_thumbnail_pixbuf (GObject *source_object, GAsyncResu
       }
   }
 
-  g_assert_null (data->pixbuf_thumbnail);
-
   buffer = photos_gegl_buffer_new_from_pixbuf (pixbuf);
   buffer_oriented = photos_gegl_buffer_apply_orientation (buffer, data->orientation);
 
   buffer_source = gegl_node_new_child (data->graph, "operation", "gegl:buffer-source", "buffer", 
buffer_oriented, NULL);
   pipeline_node = photos_pipeline_get_graph (data->pipeline);
-  save_pixbuf = gegl_node_new_child (data->graph,
-                                     "operation", "gegl:save-pixbuf",
-                                     "pixbuf", &data->pixbuf_thumbnail,
-                                     NULL);
-
-  gegl_node_link_many (buffer_source, pipeline_node, save_pixbuf, NULL);
+  gegl_node_link (buffer_source, pipeline_node);
 
-  processor = gegl_node_new_processor (save_pixbuf, NULL);
+  processor = gegl_node_new_processor (pipeline_node, NULL);
   photos_gegl_processor_process_async (processor,
                                        cancellable,
                                        photos_thumbnailer_generate_thumbnail_process,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]