app: simpler code with gegl_node_blit().
No need to go through an intermediate GeglBuffer when unneeded.
This commit is contained in:
@ -1307,15 +1307,15 @@ gimp_lineart_estimate_strokes_radii (GeglBuffer *mask)
|
|||||||
GeglBufferIterator *gi;
|
GeglBufferIterator *gi;
|
||||||
gfloat *dist;
|
gfloat *dist;
|
||||||
gfloat *thickness;
|
gfloat *thickness;
|
||||||
GeglBuffer *distmap;
|
|
||||||
GeglNode *graph;
|
GeglNode *graph;
|
||||||
GeglNode *input;
|
GeglNode *input;
|
||||||
GeglNode *op;
|
GeglNode *op;
|
||||||
GeglNode *sink;
|
|
||||||
gint width = gegl_buffer_get_width (mask);
|
gint width = gegl_buffer_get_width (mask);
|
||||||
gint height = gegl_buffer_get_height (mask);
|
gint height = gegl_buffer_get_height (mask);
|
||||||
|
|
||||||
/* Compute a distance map for the line art. */
|
/* Compute a distance map for the line art. */
|
||||||
|
dist = g_new (gfloat, width * height);
|
||||||
|
|
||||||
graph = gegl_node_new ();
|
graph = gegl_node_new ();
|
||||||
input = gegl_node_new_child (graph,
|
input = gegl_node_new_child (graph,
|
||||||
"operation", "gegl:buffer-source",
|
"operation", "gegl:buffer-source",
|
||||||
@ -1326,23 +1326,12 @@ gimp_lineart_estimate_strokes_radii (GeglBuffer *mask)
|
|||||||
"metric", GEGL_DISTANCE_METRIC_EUCLIDEAN,
|
"metric", GEGL_DISTANCE_METRIC_EUCLIDEAN,
|
||||||
"normalize", FALSE,
|
"normalize", FALSE,
|
||||||
NULL);
|
NULL);
|
||||||
sink = gegl_node_new_child (graph,
|
gegl_node_connect_to (input, "output", op, "input");
|
||||||
"operation", "gegl:buffer-sink",
|
gegl_node_blit (op, 1.0, gegl_buffer_get_extent (mask),
|
||||||
"buffer", &distmap,
|
NULL, dist, GEGL_AUTO_ROWSTRIDE, GEGL_BLIT_DEFAULT);
|
||||||
NULL);
|
|
||||||
gegl_node_connect_to (input, "output",
|
|
||||||
op, "input");
|
|
||||||
gegl_node_connect_to (op, "output",
|
|
||||||
sink, "input");
|
|
||||||
gegl_node_process (sink);
|
|
||||||
g_object_unref (graph);
|
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);
|
thickness = g_new0 (gfloat, width * height);
|
||||||
|
|
||||||
gi = gegl_buffer_iterator_new (mask, NULL, 0, NULL,
|
gi = gegl_buffer_iterator_new (mask, NULL, 0, NULL,
|
||||||
GEGL_ACCESS_READ, GEGL_ABYSS_NONE, 1);
|
GEGL_ACCESS_READ, GEGL_ABYSS_NONE, 1);
|
||||||
while (gegl_buffer_iterator_next (gi))
|
while (gegl_buffer_iterator_next (gi))
|
||||||
@ -1448,7 +1437,6 @@ gimp_lineart_estimate_strokes_radii (GeglBuffer *mask)
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_free (dist);
|
g_free (dist);
|
||||||
g_object_unref (distmap);
|
|
||||||
|
|
||||||
return thickness;
|
return thickness;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user