[gimp] app: add a fast path in GimpOperationMaskComponent



commit 2dc36a9deed5616abe930715d28395ee00dc5d5f
Author: Michael Natterer <mitch gimp org>
Date:   Mon Mar 11 00:19:58 2013 +0100

    app: add a fast path in GimpOperationMaskComponent
    
    Pass through the input buffers nop-style if the mask is either 0 or ALL.

 app/operations/gimpoperationmaskcomponents.c |   37 ++++++++++++++++++++++++++
 1 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/app/operations/gimpoperationmaskcomponents.c b/app/operations/gimpoperationmaskcomponents.c
index 3df9f4c..1df1b58 100644
--- a/app/operations/gimpoperationmaskcomponents.c
+++ b/app/operations/gimpoperationmaskcomponents.c
@@ -44,6 +44,11 @@ static void       gimp_operation_mask_components_set_property (GObject
                                                                GParamSpec          *pspec);
 
 static void       gimp_operation_mask_components_prepare      (GeglOperation       *operation);
+static gboolean gimp_operation_mask_components_parent_process (GeglOperation        *operation,
+                                                               GeglOperationContext *context,
+                                                               const gchar          *output_prop,
+                                                               const GeglRectangle  *result,
+                                                               gint                  level);
 static gboolean   gimp_operation_mask_components_process      (GeglOperation       *operation,
                                                                void                *in_buf,
                                                                void                *aux_buf,
@@ -76,6 +81,7 @@ gimp_operation_mask_components_class_init (GimpOperationMaskComponentsClass *kla
                                  NULL);
 
   operation_class->prepare = gimp_operation_mask_components_prepare;
+  operation_class->process = gimp_operation_mask_components_parent_process;
 
   point_class->process     = gimp_operation_mask_components_process;
 
@@ -143,6 +149,37 @@ gimp_operation_mask_components_prepare (GeglOperation *operation)
 }
 
 static gboolean
+gimp_operation_mask_components_parent_process (GeglOperation        *operation,
+                                               GeglOperationContext *context,
+                                               const gchar          *output_prop,
+                                               const GeglRectangle  *result,
+                                               gint                  level)
+{
+  GimpOperationMaskComponents *self = GIMP_OPERATION_MASK_COMPONENTS (operation);
+
+  if (self->mask == 0)
+    {
+      GObject *input = gegl_operation_context_get_object (context, "input");
+
+      gegl_operation_context_set_object (context, "output", input);
+
+      return TRUE;
+    }
+  else if (self->mask == GIMP_COMPONENT_ALL)
+    {
+      GObject *aux = gegl_operation_context_get_object (context, "aux");
+
+      gegl_operation_context_set_object (context, "output", aux);
+
+      return TRUE;
+    }
+
+  return GEGL_OPERATION_CLASS (parent_class)->process (operation, context,
+                                                       output_prop, result,
+                                                       level);
+}
+
+static gboolean
 gimp_operation_mask_components_process (GeglOperation       *operation,
                                         void                *in_buf,
                                         void                *aux_buf,


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