[gegl] cache: add fast GeglOperationFilter::process() implementation



commit d9c08c666fde7e380508f0b6e8b1115e5e5905f1
Author: Ell <ell_se yahoo com>
Date:   Thu Mar 28 13:59:55 2019 -0400

    cache: add fast GeglOperationFilter::process() implementation
    
    In gegl:cache, override GeglOperationFilter::process() and simply
    gegl_buffer_copy() input -> output so that tiles can be COWed,
    instead of using memcpy() in GeglOperationPointFilter::process().
    Keep the latter for the sake of wip/pipeline.

 operations/core/cache.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
---
diff --git a/operations/core/cache.c b/operations/core/cache.c
index 928131443..221802e1f 100644
--- a/operations/core/cache.c
+++ b/operations/core/cache.c
@@ -44,6 +44,28 @@ prepare (GeglOperation *operation)
   gegl_operation_set_format (operation, "output", format);
 }
 
+static gboolean
+filter_process (GeglOperation       *operation,
+                GeglBuffer          *input,
+                GeglBuffer          *output,
+                const GeglRectangle *roi,
+                gint                 level)
+{
+  GeglProperties *o  = GEGL_PROPERTIES (operation);
+
+  gegl_buffer_copy (input, roi, GEGL_ABYSS_NONE, output, roi);
+
+  if (o->cache != (void *) operation->node->cache)
+    {
+      g_clear_object (&o->cache);
+
+      if (operation->node->cache)
+        o->cache = g_object_ref ((GObject *) operation->node->cache);
+    }
+
+  return TRUE;
+}
+
 static gboolean
 process (GeglOperation       *operation,
          void                *in_buf,
@@ -72,15 +94,18 @@ static void
 gegl_op_class_init (GeglOpClass *klass)
 {
   GeglOperationClass            *operation_class;
+  GeglOperationFilterClass      *filter_class;
   GeglOperationPointFilterClass *point_filter_class;
 
   operation_class    = GEGL_OPERATION_CLASS (klass);
+  filter_class       = GEGL_OPERATION_FILTER_CLASS (klass);
   point_filter_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
 
   operation_class->cache_policy  = GEGL_CACHE_POLICY_ALWAYS;
   operation_class->want_in_place = FALSE;
   operation_class->threaded      = FALSE;
   operation_class->prepare       = prepare;
+  filter_class->process          = filter_process;
   point_filter_class->process    = process;
 
   gegl_operation_class_set_keys (operation_class,


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