[gimp/goat-invasion: 240/401] app: add gimp_gegl_node_set_layer_mode()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion: 240/401] app: add gimp_gegl_node_set_layer_mode()
- Date: Mon, 2 Apr 2012 12:08:17 +0000 (UTC)
commit 4d4a156a4513b852e53cbbd9f929f10ef808cda7
Author: Michael Natterer <mitch gimp org>
Date: Sat Mar 24 18:28:05 2012 +0100
app: add gimp_gegl_node_set_layer_mode()
and remove all other code that does layer_mode -> node.
app/core/gimplayer.c | 68 ++++++---------------------------
app/gegl/gimp-gegl-nodes.c | 90 ++++++++++++++++++++++++++++++++++++++++++--
app/gegl/gimp-gegl-nodes.h | 4 ++
app/gegl/gimp-gegl-utils.c | 38 ------------------
app/gegl/gimp-gegl-utils.h | 1 -
5 files changed, 102 insertions(+), 99 deletions(-)
---
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index 3518554..3ba9abf 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -177,8 +177,6 @@ static void gimp_layer_layer_mask_update (GimpDrawable *layer_mask,
gint height,
GimpLayer *layer);
-static void gimp_layer_sync_mode_node (GimpLayer *layer);
-
G_DEFINE_TYPE_WITH_CODE (GimpLayer, gimp_layer, GIMP_TYPE_DRAWABLE,
G_IMPLEMENT_INTERFACE (GIMP_TYPE_PICKABLE,
@@ -899,10 +897,12 @@ gimp_layer_get_node (GimpItem *item)
gegl_node_connect_to (layer->opacity_node, "output",
offset_node, "input");
- gimp_layer_sync_mode_node (layer);
-
mode_node = gimp_drawable_get_mode_node (drawable);
+ gimp_gegl_node_set_layer_mode (mode_node,
+ layer->mode,
+ TRUE);
+
gegl_node_connect_to (offset_node, "output",
mode_node, "aux");
@@ -1022,57 +1022,6 @@ gimp_layer_layer_mask_update (GimpDrawable *drawable,
}
}
-static void
-gimp_layer_sync_mode_node (GimpLayer *layer)
-{
- if (layer->opacity_node)
- {
- GeglNode *mode_node;
-
- mode_node = gimp_drawable_get_mode_node (GIMP_DRAWABLE (layer));
-
- switch (layer->mode)
- {
- case GIMP_BEHIND_MODE:
- case GIMP_MULTIPLY_MODE:
- case GIMP_SCREEN_MODE:
- case GIMP_OVERLAY_MODE:
- case GIMP_DIFFERENCE_MODE:
- case GIMP_ADDITION_MODE:
- case GIMP_SUBTRACT_MODE:
- case GIMP_DARKEN_ONLY_MODE:
- case GIMP_LIGHTEN_ONLY_MODE:
- case GIMP_HUE_MODE:
- case GIMP_SATURATION_MODE:
- case GIMP_COLOR_MODE:
- case GIMP_VALUE_MODE:
- case GIMP_DIVIDE_MODE:
- case GIMP_DODGE_MODE:
- case GIMP_BURN_MODE:
- case GIMP_HARDLIGHT_MODE:
- case GIMP_SOFTLIGHT_MODE:
- case GIMP_GRAIN_EXTRACT_MODE:
- case GIMP_GRAIN_MERGE_MODE:
- case GIMP_COLOR_ERASE_MODE:
- case GIMP_ERASE_MODE:
- case GIMP_REPLACE_MODE:
- case GIMP_ANTI_ERASE_MODE:
- gegl_node_set (mode_node,
- "operation", "gimp:point-layer-mode",
- "blend-mode", layer->mode,
- NULL);
- break;
-
- default:
- gegl_node_set (mode_node,
- "operation",
- gimp_layer_mode_to_gegl_operation (layer->mode),
- NULL);
- break;
- }
- }
-}
-
/* public functions */
@@ -1974,7 +1923,14 @@ gimp_layer_set_mode (GimpLayer *layer,
g_signal_emit (layer, layer_signals[MODE_CHANGED], 0);
g_object_notify (G_OBJECT (layer), "mode");
- gimp_layer_sync_mode_node (layer);
+ if (layer->opacity_node)
+ {
+ GeglNode *mode_node;
+
+ mode_node = gimp_drawable_get_mode_node (GIMP_DRAWABLE (layer));
+
+ gimp_gegl_node_set_layer_mode (mode_node, layer->mode, TRUE);
+ }
gimp_drawable_update (GIMP_DRAWABLE (layer),
0, 0,
diff --git a/app/gegl/gimp-gegl-nodes.c b/app/gegl/gimp-gegl-nodes.c
index 0e78384..a3b948f 100644
--- a/app/gegl/gimp-gegl-nodes.c
+++ b/app/gegl/gimp-gegl-nodes.c
@@ -189,10 +189,8 @@ gimp_gegl_create_apply_buffer_node (GeglBuffer *buffer,
gegl_node_connect_to (mask_source, "output",
opacity_node, "aux");
- mode_node = gegl_node_new_child (node,
- "operation",
- gimp_layer_mode_to_gegl_operation (mode),
- NULL);
+ mode_node = gegl_node_new_child (node, NULL);
+ gimp_gegl_node_set_layer_mode (node, mode, FALSE);
gegl_node_connect_to (opacity_node, "output",
mode_node, "aux");
@@ -237,3 +235,87 @@ gimp_gegl_add_buffer_source (GeglNode *parent,
return buffer_source;
}
+
+void
+gimp_gegl_node_set_layer_mode (GeglNode *node,
+ GimpLayerModeEffects mode,
+ gboolean premultiplied)
+{
+ const gchar *operation = "gimp:normal-mode";
+
+ g_return_if_fail (GEGL_IS_NODE (node));
+
+ switch (mode)
+ {
+ case GIMP_BEHIND_MODE:
+ case GIMP_MULTIPLY_MODE:
+ case GIMP_SCREEN_MODE:
+ case GIMP_OVERLAY_MODE:
+ case GIMP_DIFFERENCE_MODE:
+ case GIMP_ADDITION_MODE:
+ case GIMP_SUBTRACT_MODE:
+ case GIMP_DARKEN_ONLY_MODE:
+ case GIMP_LIGHTEN_ONLY_MODE:
+ case GIMP_HUE_MODE:
+ case GIMP_SATURATION_MODE:
+ case GIMP_COLOR_MODE:
+ case GIMP_VALUE_MODE:
+ case GIMP_DIVIDE_MODE:
+ case GIMP_DODGE_MODE:
+ case GIMP_BURN_MODE:
+ case GIMP_HARDLIGHT_MODE:
+ case GIMP_SOFTLIGHT_MODE:
+ case GIMP_GRAIN_EXTRACT_MODE:
+ case GIMP_GRAIN_MERGE_MODE:
+ case GIMP_COLOR_ERASE_MODE:
+ case GIMP_ERASE_MODE:
+ case GIMP_REPLACE_MODE:
+ case GIMP_ANTI_ERASE_MODE:
+ gegl_node_set (node,
+ "operation", "gimp:point-layer-mode",
+ "blend-mode", mode,
+ "premultiplied", premultiplied,
+ NULL);
+ return;
+
+ default:
+ break;
+ }
+
+ switch (mode)
+ {
+ case GIMP_NORMAL_MODE: operation = "gimp:normal-mode"; break;
+ case GIMP_DISSOLVE_MODE: operation = "gimp:dissolve-mode"; break;
+ case GIMP_BEHIND_MODE: operation = "gimp:behind-mode"; break;
+ case GIMP_MULTIPLY_MODE: operation = "gimp:multiply-mode"; break;
+ case GIMP_SCREEN_MODE: operation = "gimp:screen-mode"; break;
+ case GIMP_OVERLAY_MODE: operation = "gimp:overlay-mode"; break;
+ case GIMP_DIFFERENCE_MODE: operation = "gimp:difference-mode"; break;
+ case GIMP_ADDITION_MODE: operation = "gimp:addition-mode"; break;
+ case GIMP_SUBTRACT_MODE: operation = "gimp:subtract-mode"; break;
+ case GIMP_DARKEN_ONLY_MODE: operation = "gimp:darken-mode"; break;
+ case GIMP_LIGHTEN_ONLY_MODE: operation = "gimp:lighten-mode"; break;
+ case GIMP_HUE_MODE: operation = "gimp:hue-mode"; break;
+ case GIMP_SATURATION_MODE: operation = "gimp:saturation-mode"; break;
+ case GIMP_COLOR_MODE: operation = "gimp:color-mode"; break;
+ case GIMP_VALUE_MODE: operation = "gimp:value-mode"; break;
+ case GIMP_DIVIDE_MODE: operation = "gimp:divide-mode"; break;
+ case GIMP_DODGE_MODE: operation = "gimp:dodge-mode"; break;
+ case GIMP_BURN_MODE: operation = "gimp:burn-mode"; break;
+ case GIMP_HARDLIGHT_MODE: operation = "gimp:hardlight-mode"; break;
+ case GIMP_SOFTLIGHT_MODE: operation = "gimp:softlight-mode"; break;
+ case GIMP_GRAIN_EXTRACT_MODE: operation = "gimp:grain-extract-mode"; break;
+ case GIMP_GRAIN_MERGE_MODE: operation = "gimp:grain-merge-mode"; break;
+ case GIMP_COLOR_ERASE_MODE: operation = "gimp:color-erase-mode"; break;
+ case GIMP_ERASE_MODE: operation = "gimp:erase-mode"; break;
+ case GIMP_REPLACE_MODE: operation = "gimp:replace-mode"; break;
+ case GIMP_ANTI_ERASE_MODE: operation = "gimp:anti-erase-mode"; break;
+ default:
+ break;
+ }
+
+ gegl_node_set (node,
+ "operation", operation,
+ "premultiplied", premultiplied,
+ NULL);
+}
diff --git a/app/gegl/gimp-gegl-nodes.h b/app/gegl/gimp-gegl-nodes.h
index 17e8c99..dfca8da 100644
--- a/app/gegl/gimp-gegl-nodes.h
+++ b/app/gegl/gimp-gegl-nodes.h
@@ -45,5 +45,9 @@ GeglNode * gimp_gegl_add_buffer_source (GeglNode *parent,
gint offset_x,
gint offset_y);
+void gimp_gegl_node_set_layer_mode (GeglNode *node,
+ GimpLayerModeEffects mode,
+ gboolean premultiplied);
+
#endif /* __GIMP_GEGL_NODES_H__ */
diff --git a/app/gegl/gimp-gegl-utils.c b/app/gegl/gimp-gegl-utils.c
index 008bb86..52abde5 100644
--- a/app/gegl/gimp-gegl-utils.c
+++ b/app/gegl/gimp-gegl-utils.c
@@ -124,44 +124,6 @@ gimp_bpp_to_babl_format_with_alpha (guint bpp,
}
const gchar *
-gimp_layer_mode_to_gegl_operation (GimpLayerModeEffects mode)
-{
- switch (mode)
- {
- case GIMP_NORMAL_MODE: return "gegl:over";
- case GIMP_DISSOLVE_MODE: return "gimp:dissolve-mode";
- case GIMP_BEHIND_MODE: return "gimp:behind-mode";
- case GIMP_MULTIPLY_MODE: return "gimp:multiply-mode";
- case GIMP_SCREEN_MODE: return "gimp:screen-mode";
- case GIMP_OVERLAY_MODE: return "gimp:overlay-mode";
- case GIMP_DIFFERENCE_MODE: return "gimp:difference-mode";
- case GIMP_ADDITION_MODE: return "gimp:addition-mode";
- case GIMP_SUBTRACT_MODE: return "gimp:subtract-mode";
- case GIMP_DARKEN_ONLY_MODE: return "gimp:darken-mode";
- case GIMP_LIGHTEN_ONLY_MODE: return "gimp:lighten-mode";
- case GIMP_HUE_MODE: return "gimp:hue-mode";
- case GIMP_SATURATION_MODE: return "gimp:saturation-mode";
- case GIMP_COLOR_MODE: return "gimp:color-mode";
- case GIMP_VALUE_MODE: return "gimp:value-mode";
- case GIMP_DIVIDE_MODE: return "gimp:divide-mode";
- case GIMP_DODGE_MODE: return "gimp:dodge-mode";
- case GIMP_BURN_MODE: return "gimp:burn-mode";
- case GIMP_HARDLIGHT_MODE: return "gimp:hardlight-mode";
- case GIMP_SOFTLIGHT_MODE: return "gimp:softlight-mode";
- case GIMP_GRAIN_EXTRACT_MODE: return "gimp:grain-extract-mode";
- case GIMP_GRAIN_MERGE_MODE: return "gimp:grain-merge-mode";
- case GIMP_COLOR_ERASE_MODE: return "gimp:color-erase-mode";
- case GIMP_ERASE_MODE: return "gimp:erase-mode";
- case GIMP_REPLACE_MODE: return "gimp:replace-mode";
- case GIMP_ANTI_ERASE_MODE: return "gimp:anti-erase-mode";
- default:
- break;
- }
-
- return "gegl:over";
-}
-
-const gchar *
gimp_interpolation_to_gegl_filter (GimpInterpolationType interpolation)
{
switch (interpolation)
diff --git a/app/gegl/gimp-gegl-utils.h b/app/gegl/gimp-gegl-utils.h
index 7a4dfed..959db0b 100644
--- a/app/gegl/gimp-gegl-utils.h
+++ b/app/gegl/gimp-gegl-utils.h
@@ -30,7 +30,6 @@ const Babl * gimp_bpp_to_babl_format (guint bpp,
const Babl * gimp_bpp_to_babl_format_with_alpha (guint bpp,
gboolean linear) G_GNUC_CONST;
-const gchar * gimp_layer_mode_to_gegl_operation (GimpLayerModeEffects mode) G_GNUC_CONST;
const gchar * gimp_interpolation_to_gegl_filter (GimpInterpolationType interpolation) G_GNUC_CONST;
GeglBuffer * gimp_gegl_buffer_new (const GeglRectangle *rect,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]