[gegl] cache: make a GeglOperationFilter



commit ad8aa8f1d2f95d6720e9ad6d7977882b717dc8f4
Author: Ell <ell_se yahoo com>
Date:   Thu Mar 28 16:43:23 2019 -0400

    cache: make a GeglOperationFilter
    
    Since gegl:cache can't actually be used as part of point-op
    pipelines, as it doesn't do in-place processing, let's just make it
    a GeglOperationFilter, like the rest of the core/ ops, to avoid
    redundancy, and make stuff more consistent.

 operations/core/cache.c | 46 +++++++++-------------------------------------
 1 file changed, 9 insertions(+), 37 deletions(-)
---
diff --git a/operations/core/cache.c b/operations/core/cache.c
index 221802e1f..438c01860 100644
--- a/operations/core/cache.c
+++ b/operations/core/cache.c
@@ -26,7 +26,7 @@
       description (_("NULL or a GeglBuffer containing cached rendering results, this is a special buffer 
where gegl_buffer_list_valid_rectangles returns the part of the cache that is valid."))
 #else
 
-#define GEGL_OP_POINT_FILTER
+#define GEGL_OP_FILTER
 #define GEGL_OP_NAME     cache
 #define GEGL_OP_C_SOURCE cache.c
 
@@ -44,40 +44,16 @@ 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,
-         void                *out_buf,
-         glong                n_pixels,
+         GeglBuffer          *input,
+         GeglBuffer          *output,
          const GeglRectangle *roi,
          gint                 level)
 {
   GeglProperties *o  = GEGL_PROPERTIES (operation);
-  const Babl *format = gegl_operation_get_format (operation, "input");
 
-  memcpy (out_buf, in_buf, n_pixels * babl_format_get_bytes_per_pixel (format));
+  gegl_buffer_copy (input, roi, GEGL_ABYSS_NONE, output, roi);
 
   if (o->cache != (void *) operation->node->cache)
     {
@@ -93,20 +69,16 @@ process (GeglOperation       *operation,
 static void
 gegl_op_class_init (GeglOpClass *klass)
 {
-  GeglOperationClass            *operation_class;
-  GeglOperationFilterClass      *filter_class;
-  GeglOperationPointFilterClass *point_filter_class;
+  GeglOperationClass       *operation_class;
+  GeglOperationFilterClass *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 = GEGL_OPERATION_CLASS (klass);
+  filter_class    = GEGL_OPERATION_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;
+  filter_class->process          = process;
 
   gegl_operation_class_set_keys (operation_class,
     "name",        "gegl:cache",


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