[gimp/gimp-2-10] app: simpler code with gegl_node_blit().



commit 53fdd19d84235a506c649d60b89d27b87a818e71
Author: Jehan <jehan girinstud io>
Date:   Mon Nov 26 12:26:54 2018 +0100

    app: simpler code with gegl_node_blit().
    
    No need to go through an intermediate GeglBuffer when unneeded.
    
    (cherry picked from commit c32b0ecc92a6accd5800796846762370d08b4d28)

 app/core/gimplineart.c | 22 +++++-----------------
 1 file changed, 5 insertions(+), 17 deletions(-)
---
diff --git a/app/core/gimplineart.c b/app/core/gimplineart.c
index 4c9648262f..0432c9453e 100644
--- a/app/core/gimplineart.c
+++ b/app/core/gimplineart.c
@@ -1307,15 +1307,15 @@ gimp_lineart_estimate_strokes_radii (GeglBuffer *mask)
   GeglBufferIterator *gi;
   gfloat             *dist;
   gfloat             *thickness;
-  GeglBuffer         *distmap;
   GeglNode           *graph;
   GeglNode           *input;
   GeglNode           *op;
-  GeglNode           *sink;
   gint                width  = gegl_buffer_get_width (mask);
   gint                height = gegl_buffer_get_height (mask);
 
   /* Compute a distance map for the line art. */
+  dist = g_new (gfloat, width * height);
+
   graph = gegl_node_new ();
   input = gegl_node_new_child (graph,
                                "operation", "gegl:buffer-source",
@@ -1326,23 +1326,12 @@ gimp_lineart_estimate_strokes_radii (GeglBuffer *mask)
                              "metric",    GEGL_DISTANCE_METRIC_EUCLIDEAN,
                              "normalize", FALSE,
                              NULL);
-  sink  = gegl_node_new_child (graph,
-                               "operation", "gegl:buffer-sink",
-                               "buffer", &distmap,
-                               NULL);
-  gegl_node_connect_to (input, "output",
-                        op, "input");
-  gegl_node_connect_to (op, "output",
-                        sink, "input");
-  gegl_node_process (sink);
+  gegl_node_connect_to (input, "output", op, "input");
+  gegl_node_blit (op, 1.0, gegl_buffer_get_extent (mask),
+                  NULL, dist, GEGL_AUTO_ROWSTRIDE, GEGL_BLIT_DEFAULT);
   g_object_unref (graph);
 
-  dist = g_new (gfloat, width * height);
-  gegl_buffer_get (distmap, NULL, 1.0, NULL, dist,
-                   GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
-
   thickness = g_new0 (gfloat, width * height);
-
   gi = gegl_buffer_iterator_new (mask, NULL, 0, NULL,
                                  GEGL_ACCESS_READ, GEGL_ABYSS_NONE, 1);
   while (gegl_buffer_iterator_next (gi))
@@ -1448,7 +1437,6 @@ gimp_lineart_estimate_strokes_radii (GeglBuffer *mask)
     }
 
   g_free (dist);
-  g_object_unref (distmap);
 
   return thickness;
 }


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