[gimp] app: use the layer's composite space when flattening it
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: use the layer's composite space when flattening it
- Date: Sat, 21 Oct 2017 15:46:13 +0000 (UTC)
commit 0c305bdb0fd8f5642942ed660c52104fb8311a7f
Author: Ell <ell_se yahoo com>
Date: Sat Oct 21 11:21:10 2017 -0400
app: use the layer's composite space when flattening it
Add a composite_space parameter to gimp_gegl_create_flatten_node()
and gimp_gegl_apply_flatten(), which controld the color space --
linear or perceptual RGB -- used for the operation (instead of
hardcoding it to linear).
When removing a layer's alpha channel, use the layer's composite
space for the flattening. When flattening an image, use the bottom
layer's composite space. Keep using linear space when creating a
channel or a mask from a drawable with alpha.
app/core/gimpchannel.c | 3 ++-
app/core/gimpimage-merge.c | 3 ++-
app/gegl/gimp-gegl-apply-operation.c | 13 +++++++------
app/gegl/gimp-gegl-apply-operation.h | 3 ++-
app/gegl/gimp-gegl-nodes.c | 8 +++++++-
app/gegl/gimp-gegl-nodes.h | 31 ++++++++++++++++---------------
6 files changed, 36 insertions(+), 25 deletions(-)
---
diff --git a/app/core/gimpchannel.c b/app/core/gimpchannel.c
index 8725a23..4f3b063 100644
--- a/app/core/gimpchannel.c
+++ b/app/core/gimpchannel.c
@@ -596,7 +596,8 @@ gimp_channel_convert (GimpItem *item,
gimp_gegl_apply_flatten (gimp_drawable_get_buffer (drawable),
NULL, NULL,
- new_buffer, &background);
+ new_buffer, &background,
+ GIMP_LAYER_COLOR_SPACE_RGB_LINEAR);
gimp_drawable_set_buffer_full (drawable, FALSE, NULL,
new_buffer,
diff --git a/app/core/gimpimage-merge.c b/app/core/gimpimage-merge.c
index 893cf98..e4d0f94 100644
--- a/app/core/gimpimage-merge.c
+++ b/app/core/gimpimage-merge.c
@@ -541,7 +541,8 @@ gimp_image_merge_layers (GimpImage *image,
gimp_pickable_srgb_to_image_color (GIMP_PICKABLE (layer),
&bg, &bg);
- flatten_node = gimp_gegl_create_flatten_node (&bg);
+ flatten_node = gimp_gegl_create_flatten_node (
+ &bg, gimp_layer_get_real_composite_space (bottom_layer));
position = 0;
}
diff --git a/app/gegl/gimp-gegl-apply-operation.c b/app/gegl/gimp-gegl-apply-operation.c
index 16ca76f..6c524ab 100644
--- a/app/gegl/gimp-gegl-apply-operation.c
+++ b/app/gegl/gimp-gegl-apply-operation.c
@@ -301,11 +301,12 @@ gimp_gegl_apply_dither (GeglBuffer *src_buffer,
}
void
-gimp_gegl_apply_flatten (GeglBuffer *src_buffer,
- GimpProgress *progress,
- const gchar *undo_desc,
- GeglBuffer *dest_buffer,
- const GimpRGB *background)
+gimp_gegl_apply_flatten (GeglBuffer *src_buffer,
+ GimpProgress *progress,
+ const gchar *undo_desc,
+ GeglBuffer *dest_buffer,
+ const GimpRGB *background,
+ GimpLayerColorSpace composite_space)
{
GeglNode *node;
@@ -314,7 +315,7 @@ gimp_gegl_apply_flatten (GeglBuffer *src_buffer,
g_return_if_fail (GEGL_IS_BUFFER (dest_buffer));
g_return_if_fail (background != NULL);
- node = gimp_gegl_create_flatten_node (background);
+ node = gimp_gegl_create_flatten_node (background, composite_space);
gimp_gegl_apply_operation (src_buffer, progress, undo_desc,
node, dest_buffer, NULL);
diff --git a/app/gegl/gimp-gegl-apply-operation.h b/app/gegl/gimp-gegl-apply-operation.h
index cbe0b7d..c65fe59 100644
--- a/app/gegl/gimp-gegl-apply-operation.h
+++ b/app/gegl/gimp-gegl-apply-operation.h
@@ -58,7 +58,8 @@ void gimp_gegl_apply_flatten (GeglBuffer *src_buffer,
GimpProgress *progress,
const gchar *undo_desc,
GeglBuffer *dest_buffer,
- const GimpRGB *background);
+ const GimpRGB *background,
+ GimpLayerColorSpace composite_space);
void gimp_gegl_apply_feather (GeglBuffer *src_buffer,
GimpProgress *progress,
diff --git a/app/gegl/gimp-gegl-nodes.c b/app/gegl/gimp-gegl-nodes.c
index ed3e3c4..3b7ef69 100644
--- a/app/gegl/gimp-gegl-nodes.c
+++ b/app/gegl/gimp-gegl-nodes.c
@@ -31,7 +31,8 @@
GeglNode *
-gimp_gegl_create_flatten_node (const GimpRGB *background)
+gimp_gegl_create_flatten_node (const GimpRGB *background,
+ GimpLayerColorSpace composite_space)
{
GeglNode *node;
GeglNode *input;
@@ -41,6 +42,9 @@ gimp_gegl_create_flatten_node (const GimpRGB *background)
GeglColor *c;
g_return_val_if_fail (background != NULL, NULL);
+ g_return_val_if_fail (composite_space == GIMP_LAYER_COLOR_SPACE_RGB_LINEAR ||
+ composite_space == GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL,
+ NULL);
node = gegl_node_new ();
@@ -56,6 +60,8 @@ gimp_gegl_create_flatten_node (const GimpRGB *background)
over = gegl_node_new_child (node,
"operation", "gegl:over",
+ "srgb", composite_space ==
+ GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL,
NULL);
gegl_node_connect_to (input, "output",
diff --git a/app/gegl/gimp-gegl-nodes.h b/app/gegl/gimp-gegl-nodes.h
index 0963fec..2141dba 100644
--- a/app/gegl/gimp-gegl-nodes.h
+++ b/app/gegl/gimp-gegl-nodes.h
@@ -22,28 +22,29 @@
#define __GIMP_GEGL_NODES_H__
-GeglNode * gimp_gegl_create_flatten_node (const GimpRGB *background);
-GeglNode * gimp_gegl_create_apply_opacity_node (GeglBuffer *mask,
- gint mask_offset_x,
- gint mask_offset_y,
- gdouble opacity);
-GeglNode * gimp_gegl_add_buffer_source (GeglNode *parent,
- GeglBuffer *buffer,
- gint offset_x,
- gint offset_y);
+GeglNode * gimp_gegl_create_flatten_node (const GimpRGB *background,
+ GimpLayerColorSpace composite_space);
+GeglNode * gimp_gegl_create_apply_opacity_node (GeglBuffer *mask,
+ gint mask_offset_x,
+ gint mask_offset_y,
+ gdouble opacity);
+GeglNode * gimp_gegl_add_buffer_source (GeglNode *parent,
+ GeglBuffer *buffer,
+ gint offset_x,
+ gint offset_y);
void gimp_gegl_mode_node_set_mode (GeglNode *node,
GimpLayerMode mode,
GimpLayerColorSpace blend_space,
GimpLayerColorSpace composite_space,
GimpLayerCompositeMode composite_mode);
-void gimp_gegl_mode_node_set_opacity (GeglNode *node,
- gdouble opacity);
+void gimp_gegl_mode_node_set_opacity (GeglNode *node,
+ gdouble opacity);
-void gimp_gegl_node_set_matrix (GeglNode *node,
- const GimpMatrix3 *matrix);
-void gimp_gegl_node_set_color (GeglNode *node,
- const GimpRGB *color);
+void gimp_gegl_node_set_matrix (GeglNode *node,
+ const GimpMatrix3 *matrix);
+void gimp_gegl_node_set_color (GeglNode *node,
+ const GimpRGB *color);
#endif /* __GIMP_GEGL_NODES_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]