[gegl] dropshadow, unsharp-mask: simplify code
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] dropshadow, unsharp-mask: simplify code
- Date: Wed, 7 Jul 2010 19:43:53 +0000 (UTC)
commit 4f29853cfaf252be19402925985243ef8375b2bb
Author: �yvind Kolås <pippin gimp org>
Date: Wed Jul 7 20:37:02 2010 +0100
dropshadow, unsharp-mask: simplify code
Removed quite a bit of unneeded logic and an allocation.
operations/common/dropshadow.c | 74 ++++++++++++-------------------------
operations/common/unsharp-mask.c | 67 +++++++++-------------------------
2 files changed, 41 insertions(+), 100 deletions(-)
---
diff --git a/operations/common/dropshadow.c b/operations/common/dropshadow.c
index c5953d0..aaad4ac 100644
--- a/operations/common/dropshadow.c
+++ b/operations/common/dropshadow.c
@@ -13,7 +13,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
*
- * Copyright 2006 �yvind Kolås <pippin gimp org>
+ * Copyright 2006, 2010 �yvind Kolås <pippin gimp org>
*/
#include "config.h"
@@ -37,60 +37,34 @@ gegl_chant_double (radius, _("Radius"), -G_MAXDOUBLE, G_MAXDOUBLE, 10.0,
#include "gegl-chant.h"
-typedef struct _Priv Priv;
-struct _Priv
-{
- GeglNode *self;
- GeglNode *input;
- GeglNode *output;
-
- GeglNode *over;
- GeglNode *translate;
- GeglNode *opacity;
- GeglNode *blur;
- GeglNode *darken;
- GeglNode *black;
-};
-
/* in attach we hook into graph adding the needed nodes */
static void attach (GeglOperation *operation)
{
- GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
- Priv *priv = (Priv*)o->chant_data;
- g_assert (priv == NULL);
-
- priv = g_malloc0 (sizeof (Priv));
- o->chant_data = (void*) priv;
-
- priv->self = operation->node;
-
- if (!priv->over)
- {
- GeglNode *gegl = priv->self;
- priv->input = gegl_node_get_input_proxy (gegl, "input");
- priv->output = gegl_node_get_output_proxy (gegl, "output");
- priv->over = gegl_node_new_child (gegl, "operation", "gegl:over", NULL);
- priv->translate = gegl_node_new_child (gegl, "operation", "gegl:translate", NULL);
- priv->opacity = gegl_node_new_child (gegl, "operation", "gegl:opacity", NULL);
- priv->blur = gegl_node_new_child (gegl, "operation", "gegl:gaussian-blur", NULL);
- priv->darken = gegl_node_new_child (gegl, "operation", "gegl:src-in", NULL);
- priv->black = gegl_node_new_child (gegl, "operation", "gegl:color",
- "value", gegl_color_new ("rgb(0.0,0.0,0.0)"),
- NULL);
-
- gegl_node_link_many (priv->input, priv->darken, priv->blur, priv->opacity, priv->translate, priv->over, priv->output, NULL);
- gegl_node_connect_from (priv->over, "aux", priv->input, "output");
- gegl_node_connect_from (priv->darken, "aux", priv->black, "output");
-
- gegl_operation_meta_redirect (operation, "opacity", priv->opacity, "value");
- gegl_operation_meta_redirect (operation, "radius", priv->blur, "std-dev-x");
- gegl_operation_meta_redirect (operation, "radius", priv->blur, "std-dev-y");
- gegl_operation_meta_redirect (operation, "x", priv->translate, "x");
- gegl_operation_meta_redirect (operation, "y", priv->translate, "y");
- }
+ GeglNode *gegl = operation->node;
+ GeglNode *input, *output, *over, *translate, *opacity, *blur, *darken, *black;
+
+ input = gegl_node_get_input_proxy (gegl, "input");
+ output = gegl_node_get_output_proxy (gegl, "output");
+ over = gegl_node_new_child (gegl, "operation", "gegl:over", NULL);
+ translate = gegl_node_new_child (gegl, "operation", "gegl:translate", NULL);
+ opacity = gegl_node_new_child (gegl, "operation", "gegl:opacity", NULL);
+ blur = gegl_node_new_child (gegl, "operation", "gegl:gaussian-blur", NULL);
+ darken = gegl_node_new_child (gegl, "operation", "gegl:src-in", NULL);
+ black = gegl_node_new_child (gegl, "operation", "gegl:color",
+ "value", gegl_color_new ("rgb(0.0,0.0,0.0)"),
+ NULL);
+
+ gegl_node_link_many (input, darken, blur, opacity, translate, over, output, NULL);
+ gegl_node_connect_from (over, "aux", input, "output");
+ gegl_node_connect_from (darken, "aux", black, "output");
+
+ gegl_operation_meta_redirect (operation, "opacity", opacity, "value");
+ gegl_operation_meta_redirect (operation, "radius", blur, "std-dev-x");
+ gegl_operation_meta_redirect (operation, "radius", blur, "std-dev-y");
+ gegl_operation_meta_redirect (operation, "x", translate, "x");
+ gegl_operation_meta_redirect (operation, "y", translate, "y");
}
-
static void
gegl_chant_class_init (GeglChantClass *klass)
{
diff --git a/operations/common/unsharp-mask.c b/operations/common/unsharp-mask.c
index df643d0..412df9e 100644
--- a/operations/common/unsharp-mask.c
+++ b/operations/common/unsharp-mask.c
@@ -13,13 +13,12 @@
* You should have received a copy of the GNU Lesser General Public
* License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
*
- * Copyright 2006 �yvind Kolås <pippin gimp org>
+ * Copyright 2006, 2010 �yvind Kolås <pippin gimp org>
*/
#include "config.h"
#include <glib/gi18n-lib.h>
-
#ifdef GEGL_CHANT_PROPERTIES
gegl_chant_double(std_dev, _("Std. Dev."), 0.0, 100.0, 1.0,
@@ -33,63 +32,31 @@ gegl_chant_double(scale, _("Scale"), 0.0, 100.0, 1.0, _("Scale, strength of eff
#include "gegl-chant.h"
-typedef struct _Priv Priv;
-struct _Priv
-{
- GeglNode *self;
- GeglNode *input;
- GeglNode *output;
-
- GeglNode *add;
- GeglNode *multiply;
- GeglNode *subtract;
- GeglNode *blur;
-};
-
static void attach (GeglOperation *operation)
{
- GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
- Priv *priv = g_malloc0 (sizeof (Priv));
-
- o->chant_data = (void*) priv;
+ GeglNode *gegl, *input, *output, *add, *multiply, *subtract, *blur;
- if (!priv->add)
- {
- GeglNode *gegl;
- gegl = operation->node;
+ gegl = operation->node;
- priv->input = gegl_node_get_input_proxy (gegl, "input");
- priv->output = gegl_node_get_output_proxy (gegl, "output");
- priv->add = gegl_node_new_child (gegl,
- "operation", "gegl:add",
- NULL);
+ input = gegl_node_get_input_proxy (gegl, "input");
+ output = gegl_node_get_output_proxy (gegl, "output");
+ add = gegl_node_new_child (gegl, "operation", "gegl:add", NULL);
+ multiply = gegl_node_new_child (gegl, "operation", "gegl:multiply", NULL);
+ subtract = gegl_node_new_child (gegl, "operation", "gegl:subtract", NULL);
+ blur = gegl_node_new_child (gegl, "operation", "gegl:gaussian-blur",NULL);
- priv->multiply = gegl_node_new_child (gegl,
- "operation", "gegl:multiply",
- NULL);
+ gegl_node_link_many (input, subtract, multiply, NULL);
+ gegl_node_link (input, blur);
+ gegl_node_link_many (multiply, add, output, NULL);
- priv->subtract = gegl_node_new_child (gegl,
- "operation", "gegl:subtract",
- NULL);
+ gegl_node_connect_from (subtract, "aux", blur, "output");
+ gegl_node_connect_from (add, "aux", input, "output");
- priv->blur = gegl_node_new_child (gegl,
- "operation", "gegl:gaussian-blur",
- NULL);
-
- gegl_node_link_many (priv->input, priv->subtract, priv->multiply, NULL);
- gegl_node_link (priv->input, priv->blur);
- gegl_node_link_many (priv->multiply, priv->add, priv->output, NULL);
-
- gegl_node_connect_from (priv->subtract, "aux", priv->blur, "output");
- gegl_node_connect_from (priv->add, "aux", priv->input, "output");
-
- gegl_operation_meta_redirect (operation, "scale", priv->multiply, "value");
- gegl_operation_meta_redirect (operation, "std-dev", priv->blur, "std-dev-x");
- gegl_operation_meta_redirect (operation, "std-dev", priv->blur, "std-dev-y");
- }
+ gegl_operation_meta_redirect (operation, "scale", multiply, "value");
+ gegl_operation_meta_redirect (operation, "std-dev", blur, "std-dev-x");
+ gegl_operation_meta_redirect (operation, "std-dev", blur, "std-dev-y");
}
-
static void
gegl_chant_class_init (GeglChantClass *klass)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]