Commit 0c305bdb authored by Ell's avatar Ell

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.
parent 96efde0f
......@@ -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,
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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,
......
......@@ -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",
......
......@@ -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__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment