[gegl] Add fast path to pass buffer through opacity op
- From: Øyvind Kolås <ok src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gegl] Add fast path to pass buffer through opacity op
- Date: Thu, 12 Nov 2009 02:35:13 +0000 (UTC)
commit ef18550b9e820f609fe19ffde359b057fc4236a4
Author: �yvind Kolås <pippin gimp org>
Date: Thu Nov 12 02:24:25 2009 +0000
Add fast path to pass buffer through opacity op
operations/common/opacity.c | 35 ++++++++++++++++++++++++++++-------
1 files changed, 28 insertions(+), 7 deletions(-)
---
diff --git a/operations/common/opacity.c b/operations/common/opacity.c
index ec09d98..f2acdcb 100644
--- a/operations/common/opacity.c
+++ b/operations/common/opacity.c
@@ -19,7 +19,6 @@
#include "config.h"
#include <glib/gi18n-lib.h>
-
#ifdef GEGL_CHANT_PROPERTIES
gegl_chant_double (value, _("Opacity"), -10.0, 10.0, 1.0,
@@ -110,6 +109,33 @@ process (GeglOperation *op,
return TRUE;
}
+/* Fast path when opacity is a no-op
+ */
+static gboolean operation_process (GeglOperation *operation,
+ GeglOperationContext *context,
+ const gchar *output_prop,
+ const GeglRectangle *result)
+{
+ GeglOperationClass *operation_class;
+ gpointer in, aux;
+ operation_class = GEGL_OPERATION_CLASS (gegl_chant_parent_class);
+
+ /* get the raw values this does not increase the reference count */
+ in = gegl_operation_context_get_object (context, "input");
+ aux = gegl_operation_context_get_object (context, "aux");
+
+ if (in && !aux && GEGL_CHANT_PROPERTIES (operation)->value == 1.0)
+ {
+ gegl_operation_context_take_object (context, "output",
+ g_object_ref (G_OBJECT (in)));
+ return TRUE;
+ }
+ /* chain up, which will create the needed buffers for our actual
+ * process function
+ */
+ return operation_class->process (operation, context, output_prop, result);
+}
+
static void
gegl_chant_class_init (GeglChantClass *klass)
@@ -120,15 +146,10 @@ gegl_chant_class_init (GeglChantClass *klass)
operation_class = GEGL_OPERATION_CLASS (klass);
point_composer_class = GEGL_OPERATION_POINT_COMPOSER_CLASS (klass);
+ operation_class->process = operation_process;
point_composer_class->process = process;
operation_class->prepare = prepare;
- /* overriding the caching behavior that point-composers do
- * not have caches, this means that an opacity op can be
- * inserted where you want a cache to be in the graph
- */
- operation_class->no_cache = FALSE;
-
operation_class->name = "gegl:opacity";
operation_class->categories = "transparency";
operation_class->description =
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]