[gegl] color: use gegl_buffer_set_color()



commit 5c796601b656fc3432f9be2674fc8eeffaa5aa8a
Author: Ell <ell_se yahoo com>
Date:   Mon Feb 25 11:25:01 2019 -0500

    color: use gegl_buffer_set_color()
    
    In gegl:color, override GeglOperationSource::process(), instead of
    GeglOperationPointRender::process(), and simply call
    gegl_buffer_set_color() to fill the output buffer, instead of doing
    this manually.  gegl_buffer_set_color() can more efficiently reuse
    a single COW-ed tile.
    
    Opt out of multithreading, since it's no longer beneficial.

 operations/common/color.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)
---
diff --git a/operations/common/color.c b/operations/common/color.c
index e0a468d75..67aa093a6 100644
--- a/operations/common/color.c
+++ b/operations/common/color.c
@@ -56,19 +56,13 @@ gegl_color_op_get_bounding_box (GeglOperation *operation)
 
 static gboolean
 gegl_color_op_process (GeglOperation       *operation,
-                       void                *out_buf,
-                       glong                n_pixels,
+                       GeglBuffer          *output,
                        const GeglRectangle *roi,
                        gint                 level)
 {
   GeglProperties *o = GEGL_PROPERTIES (operation);
-  const Babl *out_format = gegl_operation_get_format (operation, "output");
-  gint        pixel_size = babl_format_get_bytes_per_pixel (out_format);
-  void       *out_color  = alloca(pixel_size);
 
-  gegl_color_get_pixel (o->value, out_format, out_color);
-
-  gegl_memset_pattern (out_buf, out_color, pixel_size, n_pixels);
+  gegl_buffer_set_color (output, roi, o->value);
 
   return TRUE;
 }
@@ -77,15 +71,16 @@ gegl_color_op_process (GeglOperation       *operation,
 static void
 gegl_op_class_init (GeglOpClass *klass)
 {
-  GeglOperationClass            *operation_class;
-  GeglOperationPointRenderClass *point_render_class;
+  GeglOperationClass       *operation_class;
+  GeglOperationSourceClass *source_class;
 
-  operation_class    = GEGL_OPERATION_CLASS (klass);
-  point_render_class = GEGL_OPERATION_POINT_RENDER_CLASS (klass);
+  operation_class = GEGL_OPERATION_CLASS (klass);
+  source_class    = GEGL_OPERATION_SOURCE_CLASS (klass);
 
-  point_render_class->process       = gegl_color_op_process;
+  source_class->process             = gegl_color_op_process;
   operation_class->get_bounding_box = gegl_color_op_get_bounding_box;
   operation_class->prepare          = gegl_color_op_prepare;
+  operation_class->threaded         = FALSE;
 
   gegl_operation_class_set_keys (operation_class,
     "name",        "gegl:color",


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