[gimp] app: remove GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA and friends
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: remove GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA and friends
- Date: Fri, 17 Feb 2017 23:21:55 +0000 (UTC)
commit 740212750507bc3d51ab7614c1e0705b44e2b9fb
Author: Ell <ell_se yahoo com>
Date: Fri Feb 17 10:20:04 2017 -0500
app: remove GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA and friends
Instead, add a gimp_layer_mode_get_format() function, which takes
the layer mode, composite space, and blend space, and returns the
I/O format.
Currently, we always use the composite space format as the I/O
format. This simplifies gimp_composite_blend(), and gives us
composite-space support for the "special" layer mode ops for free.
app/gegl/gimp-gegl-nodes.c | 1 -
app/operations/layer-modes/gimp-layer-modes.c | 141 ++++++--------
app/operations/layer-modes/gimp-layer-modes.h | 40 ++--
.../layer-modes/gimpoperationlayermode.c | 208 ++++++--------------
.../layer-modes/gimpoperationlayermode.h | 1 -
app/operations/operations-enums.h | 7 +-
app/paint/gimpbrushcore.c | 8 +-
app/paint/gimpink.c | 8 +-
app/paint/gimppaintcore-loops.c | 10 +-
9 files changed, 152 insertions(+), 272 deletions(-)
---
diff --git a/app/gegl/gimp-gegl-nodes.c b/app/gegl/gimp-gegl-nodes.c
index dbb811e..ed3e3c4 100644
--- a/app/gegl/gimp-gegl-nodes.c
+++ b/app/gegl/gimp-gegl-nodes.c
@@ -171,7 +171,6 @@ gimp_gegl_mode_node_set_mode (GeglNode *node,
"operation", gimp_layer_mode_get_operation (mode),
"layer-mode", mode,
"opacity", opacity,
- "linear", gimp_layer_mode_wants_linear_data (mode),
"blend-space", blend_space,
"composite-space", composite_space,
"composite-mode", composite_mode,
diff --git a/app/operations/layer-modes/gimp-layer-modes.c b/app/operations/layer-modes/gimp-layer-modes.c
index 405b80a..183c142 100644
--- a/app/operations/layer-modes/gimp-layer-modes.c
+++ b/app/operations/layer-modes/gimp-layer-modes.c
@@ -90,8 +90,7 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:dissolve",
.function = gimp_operation_dissolve_process,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA |
- GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE |
+ .flags = GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE |
GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
@@ -411,7 +410,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -423,8 +421,7 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA |
- GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
+ .flags = GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -436,8 +433,7 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA |
- GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
+ .flags = GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -449,8 +445,7 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA |
- GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
+ .flags = GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -462,8 +457,7 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA |
- GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
+ .flags = GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -475,8 +469,7 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:normal",
.function = gimp_operation_normal_process,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA |
- GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
+ .flags = GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
@@ -487,8 +480,7 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:behind",
.function = gimp_operation_behind_process,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA |
- GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
+ .flags = GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
.context = GIMP_LAYER_MODE_CONTEXT_PAINT |
GIMP_LAYER_MODE_CONTEXT_FADE,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
@@ -500,7 +492,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -512,7 +503,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -524,7 +514,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -536,7 +525,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -548,7 +536,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -560,7 +547,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -572,7 +558,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -584,7 +569,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -596,7 +580,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -608,7 +591,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -620,7 +602,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -632,8 +613,7 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA |
- GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
+ .flags = GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -644,8 +624,7 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA |
- GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
+ .flags = GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -656,8 +635,7 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA |
- GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
+ .flags = GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -669,8 +647,7 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA |
- GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
+ .flags = GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -682,8 +659,7 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA |
- GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
+ .flags = GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -695,8 +671,7 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA |
- GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
+ .flags = GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -708,7 +683,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -720,7 +694,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -732,7 +705,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -744,7 +716,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -756,7 +727,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -768,7 +738,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -780,7 +749,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -792,7 +760,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -804,7 +771,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -816,7 +782,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -828,7 +793,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -840,7 +804,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -852,7 +815,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -864,7 +826,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -876,7 +837,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -888,7 +848,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -900,7 +859,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -912,7 +870,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -924,7 +881,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -936,7 +892,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -948,7 +903,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -960,7 +914,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -972,7 +925,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -984,7 +936,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -996,7 +947,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -1008,7 +958,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -1020,7 +969,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -1032,7 +980,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -1044,7 +991,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -1056,7 +1002,6 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:layer-mode",
.function = gimp_operation_layer_mode_process_pixels,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA,
.context = GIMP_LAYER_MODE_CONTEXT_ALL,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -1068,8 +1013,7 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:erase",
.function = gimp_operation_erase_process,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA |
- GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
+ .flags = GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
.context = GIMP_LAYER_MODE_CONTEXT_FADE,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_ATOP,
@@ -1080,8 +1024,7 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:replace",
.function = gimp_operation_replace_process,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA |
- GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
+ .flags = GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
.context = GIMP_LAYER_MODE_CONTEXT_FADE,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
.composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
@@ -1092,8 +1035,7 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:anti-erase",
.function = gimp_operation_anti_erase_process,
- .flags = GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA |
- GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE |
+ .flags = GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE |
GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE,
.context = GIMP_LAYER_MODE_CONTEXT_FADE,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_SRC_OVER,
@@ -1544,15 +1486,6 @@ gimp_layer_mode_is_legacy (GimpLayerMode mode)
}
gboolean
-gimp_layer_mode_wants_linear_data (GimpLayerMode mode)
-{
- const GimpLayerModeInfo *info = gimp_layer_mode_info (mode);
- if (!info)
- return FALSE;
- return (info->flags & GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA) != 0;
-}
-
-gboolean
gimp_layer_mode_is_blend_space_mutable (GimpLayerMode mode)
{
const GimpLayerModeInfo *info = gimp_layer_mode_info (mode);
@@ -1738,3 +1671,45 @@ gimp_layer_mode_get_for_group (GimpLayerMode old_mode,
return FALSE;
}
+
+const Babl *
+gimp_layer_mode_get_format (GimpLayerMode mode,
+ GimpLayerColorSpace composite_space,
+ GimpLayerColorSpace blend_space,
+ const Babl *preferred_format)
+{
+ /* for now, all modes perform i/o in the composite space. */
+ (void) mode;
+ (void) blend_space;
+
+ if (composite_space == GIMP_LAYER_COLOR_SPACE_AUTO)
+ composite_space = gimp_layer_mode_get_composite_space (mode);
+
+ switch (composite_space)
+ {
+ case GIMP_LAYER_COLOR_SPACE_AUTO:
+ /* compositing is color-space agnostic. try to return the preferred
+ * format, and fall back to linear.
+ */
+ if (preferred_format == babl_format ("RGBA float") ||
+ preferred_format == babl_format ("R'G'B'A float"))
+ {
+ return preferred_format;
+ }
+ else
+ {
+ return babl_format ("RGBA float");
+ }
+
+ case GIMP_LAYER_COLOR_SPACE_RGB_LINEAR:
+ return babl_format ("RGBA float");
+
+ case GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL:
+ return babl_format ("R'G'B'A float");
+
+ case GIMP_LAYER_COLOR_SPACE_LAB:
+ return babl_format ("CIE Lab alpha float");
+ }
+
+ g_return_val_if_reached (babl_format ("RGBA float"));
+}
diff --git a/app/operations/layer-modes/gimp-layer-modes.h b/app/operations/layer-modes/gimp-layer-modes.h
index bd10031..699e390 100644
--- a/app/operations/layer-modes/gimp-layer-modes.h
+++ b/app/operations/layer-modes/gimp-layer-modes.h
@@ -25,33 +25,37 @@
void gimp_layer_modes_init (void);
-gboolean gimp_layer_mode_is_legacy (GimpLayerMode mode);
-gboolean gimp_layer_mode_wants_linear_data (GimpLayerMode mode);
+gboolean gimp_layer_mode_is_legacy (GimpLayerMode mode);
-gboolean gimp_layer_mode_is_blend_space_mutable (GimpLayerMode mode);
-gboolean gimp_layer_mode_is_composite_space_mutable (GimpLayerMode mode);
-gboolean gimp_layer_mode_is_composite_mode_mutable (GimpLayerMode mode);
+gboolean gimp_layer_mode_is_blend_space_mutable (GimpLayerMode mode);
+gboolean gimp_layer_mode_is_composite_space_mutable (GimpLayerMode mode);
+gboolean gimp_layer_mode_is_composite_mode_mutable (GimpLayerMode mode);
-GimpLayerColorSpace gimp_layer_mode_get_blend_space (GimpLayerMode mode);
-GimpLayerColorSpace gimp_layer_mode_get_composite_space (GimpLayerMode mode);
-GimpLayerCompositeMode gimp_layer_mode_get_composite_mode (GimpLayerMode mode);
+GimpLayerColorSpace gimp_layer_mode_get_blend_space (GimpLayerMode mode);
+GimpLayerColorSpace gimp_layer_mode_get_composite_space (GimpLayerMode mode);
+GimpLayerCompositeMode gimp_layer_mode_get_composite_mode (GimpLayerMode mode);
GimpLayerCompositeMode gimp_layer_mode_get_paint_composite_mode
- (GimpLayerMode mode);
+ (GimpLayerMode mode);
-const gchar * gimp_layer_mode_get_operation (GimpLayerMode mode);
+const gchar * gimp_layer_mode_get_operation (GimpLayerMode mode);
-GimpLayerModeFunc gimp_layer_mode_get_function (GimpLayerMode mode);
+GimpLayerModeFunc gimp_layer_mode_get_function (GimpLayerMode mode);
-GimpLayerModeContext gimp_layer_mode_get_context (GimpLayerMode mode);
+GimpLayerModeContext gimp_layer_mode_get_context (GimpLayerMode mode);
-GimpLayerModeGroup gimp_layer_mode_get_group (GimpLayerMode mode);
+GimpLayerModeGroup gimp_layer_mode_get_group (GimpLayerMode mode);
-const GimpLayerMode * gimp_layer_mode_get_group_array (GimpLayerModeGroup group,
- gint *n_modes);
+const GimpLayerMode * gimp_layer_mode_get_group_array (GimpLayerModeGroup group,
+ gint *n_modes);
-gboolean gimp_layer_mode_get_for_group (GimpLayerMode old_mode,
- GimpLayerModeGroup new_group,
- GimpLayerMode *new_mode);
+gboolean gimp_layer_mode_get_for_group (GimpLayerMode old_mode,
+ GimpLayerModeGroup new_group,
+ GimpLayerMode *new_mode);
+
+const Babl * gimp_layer_mode_get_format (GimpLayerMode mode,
+ GimpLayerColorSpace composite_space,
+ GimpLayerColorSpace blend_space,
+ const Babl *preferred_format);
#endif /* __GIMP_LAYER_MODES_H__ */
diff --git a/app/operations/layer-modes/gimpoperationlayermode.c
b/app/operations/layer-modes/gimpoperationlayermode.c
index 73e54b7..3eb54e4 100644
--- a/app/operations/layer-modes/gimpoperationlayermode.c
+++ b/app/operations/layer-modes/gimpoperationlayermode.c
@@ -31,6 +31,7 @@
#include "../operations-types.h"
+#include "gimp-layer-modes.h"
#include "gimpoperationlayermode.h"
@@ -38,7 +39,6 @@ enum
{
PROP_0,
PROP_LAYER_MODE,
- PROP_LINEAR,
PROP_OPACITY,
PROP_BLEND_SPACE,
PROP_COMPOSITE_SPACE,
@@ -119,12 +119,7 @@ G_DEFINE_TYPE (GimpOperationLayerMode, gimp_operation_layer_mode,
#define parent_class gimp_operation_layer_mode_parent_class
-static const Babl *_gimp_fish_rgba_to_perceptual = NULL;
-static const Babl *_gimp_fish_perceptual_to_rgba = NULL;
-static const Babl *_gimp_fish_perceptual_to_laba = NULL;
-static const Babl *_gimp_fish_rgba_to_laba = NULL;
-static const Babl *_gimp_fish_laba_to_rgba = NULL;
-static const Babl *_gimp_fish_laba_to_perceptual = NULL;
+static const Babl *gimp_layer_color_space_fish[3 /* from */][3 /* to */];
static CompositeFunc composite_func_src_atop = composite_func_src_atop_core;
static CompositeFunc composite_func_dst_atop = composite_func_dst_atop_core;
@@ -163,13 +158,6 @@ gimp_operation_layer_mode_class_init (GimpOperationLayerModeClass *klass)
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
- g_object_class_install_property (object_class, PROP_LINEAR,
- g_param_spec_boolean ("linear",
- NULL, NULL,
- FALSE,
- GIMP_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
g_object_class_install_property (object_class, PROP_OPACITY,
g_param_spec_double ("opacity",
NULL, NULL,
@@ -202,13 +190,32 @@ gimp_operation_layer_mode_class_init (GimpOperationLayerModeClass *klass)
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
- _gimp_fish_rgba_to_perceptual = babl_fish ("RGBA float", "R'G'B'A float");
- _gimp_fish_perceptual_to_rgba = babl_fish ("R'G'B'A float", "RGBA float");
- _gimp_fish_perceptual_to_laba = babl_fish ("R'G'B'A float", "CIE Lab alpha float");
-
- _gimp_fish_rgba_to_laba = babl_fish ("RGBA float", "CIE Lab alpha float");
- _gimp_fish_laba_to_rgba = babl_fish ("CIE Lab alpha float", "RGBA float");
- _gimp_fish_laba_to_perceptual = babl_fish ("CIE Lab alpha float", "R'G'B'A float");
+ gimp_layer_color_space_fish
+ /* from */ [GIMP_LAYER_COLOR_SPACE_RGB_LINEAR - 1]
+ /* to */ [GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL - 1] =
+ babl_fish ("RGBA float", "R'G'B'A float");
+ gimp_layer_color_space_fish
+ /* from */ [GIMP_LAYER_COLOR_SPACE_RGB_LINEAR - 1]
+ /* to */ [GIMP_LAYER_COLOR_SPACE_LAB - 1] =
+ babl_fish ("RGBA float", "CIE Lab alpha float");
+
+ gimp_layer_color_space_fish
+ /* from */ [GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL - 1]
+ /* to */ [GIMP_LAYER_COLOR_SPACE_RGB_LINEAR - 1] =
+ babl_fish ("R'G'B'A float", "RGBA float");
+ gimp_layer_color_space_fish
+ /* from */ [GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL - 1]
+ /* to */ [GIMP_LAYER_COLOR_SPACE_LAB - 1] =
+ babl_fish ("R'G'B'A float", "CIE Lab alpha float");
+
+ gimp_layer_color_space_fish
+ /* from */ [GIMP_LAYER_COLOR_SPACE_LAB - 1]
+ /* to */ [GIMP_LAYER_COLOR_SPACE_RGB_LINEAR - 1] =
+ babl_fish ("CIE Lab alpha float", "RGBA float");
+ gimp_layer_color_space_fish
+ /* from */ [GIMP_LAYER_COLOR_SPACE_LAB - 1]
+ /* to */ [GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL - 1] =
+ babl_fish ("CIE Lab alpha float", "R'G'B'A float");
#if COMPILE_SSE2_INTRINISICS
if (gimp_cpu_accel_get_support () & GIMP_CPU_ACCEL_X86_SSE2)
@@ -235,10 +242,6 @@ gimp_operation_layer_mode_set_property (GObject *object,
self->layer_mode = g_value_get_enum (value);
break;
- case PROP_LINEAR:
- self->linear = g_value_get_boolean (value);
- break;
-
case PROP_OPACITY:
self->opacity = g_value_get_double (value);
break;
@@ -275,10 +278,6 @@ gimp_operation_layer_mode_get_property (GObject *object,
g_value_set_enum (value, self->layer_mode);
break;
- case PROP_LINEAR:
- g_value_set_boolean (value, self->linear);
- break;
-
case PROP_OPACITY:
g_value_set_double (value, self->opacity);
break;
@@ -305,12 +304,15 @@ static void
gimp_operation_layer_mode_prepare (GeglOperation *operation)
{
GimpOperationLayerMode *self = GIMP_OPERATION_LAYER_MODE (operation);
+ const Babl *in_format;
const Babl *format;
- if (self->linear)
- format = babl_format ("RGBA float");
- else
- format = babl_format ("R'G'B'A float");
+ in_format = gegl_operation_get_source_format (operation, "input");
+
+ format = gimp_layer_mode_get_format (self->layer_mode,
+ self->composite_space,
+ self->blend_space,
+ in_format);
gegl_operation_set_format (operation, "input", format);
gegl_operation_set_format (operation, "output", format);
@@ -753,101 +755,41 @@ gimp_composite_blend (GimpOperationLayerMode *layer_mode,
glong samples,
GimpBlendFunc blend_func)
{
- gfloat opacity = layer_mode->opacity;
- GimpLayerColorSpace blend_space = layer_mode->blend_space;
- GimpLayerColorSpace composite_space= layer_mode->composite_space;
- GimpLayerCompositeMode composite_mode = layer_mode->composite_mode;
+ gfloat opacity = layer_mode->opacity;
+ GimpLayerColorSpace blend_space = layer_mode->blend_space;
+ GimpLayerColorSpace composite_space = layer_mode->composite_space;
+ GimpLayerCompositeMode composite_mode = layer_mode->composite_mode;
gfloat *blend_in = in;
gfloat *blend_layer = layer;
gfloat *blend_out = out;
- gfloat *composite_in = NULL;
- gfloat *composite_layer = NULL;
-
gboolean composite_needs_in_color =
composite_mode == GIMP_LAYER_COMPOSITE_SRC_OVER ||
composite_mode == GIMP_LAYER_COMPOSITE_SRC_ATOP;
- gboolean composite_needs_layer_color =
- composite_mode == GIMP_LAYER_COMPOSITE_SRC_OVER ||
- composite_mode == GIMP_LAYER_COMPOSITE_DST_ATOP;
- const Babl *fish_to_blend = NULL;
- const Babl *fish_to_composite = NULL;
- const Babl *fish_from_composite = NULL;
+ const Babl *composite_to_blend_fish = NULL;
+ const Babl *blend_to_composite_fish = NULL;
- switch (blend_space)
+ if (blend_space != GIMP_LAYER_COLOR_SPACE_AUTO)
{
- default:
- case GIMP_LAYER_COLOR_SPACE_RGB_LINEAR:
- fish_to_blend = NULL;
- switch (composite_space)
- {
- case GIMP_LAYER_COLOR_SPACE_LAB:
- fish_to_composite = _gimp_fish_rgba_to_laba;
- fish_from_composite = _gimp_fish_laba_to_rgba;
- break;
- default:
- case GIMP_LAYER_COLOR_SPACE_RGB_LINEAR:
- fish_to_composite = NULL;
- fish_from_composite = NULL;
- break;
- case GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL:
- fish_to_composite = _gimp_fish_rgba_to_perceptual;
- fish_from_composite = _gimp_fish_perceptual_to_rgba;
- break;
- }
- break;
+ g_assert (composite_space >= 1 && composite_space < 4);
+ g_assert (blend_space >= 1 && blend_space < 4);
- case GIMP_LAYER_COLOR_SPACE_LAB:
- fish_to_blend = _gimp_fish_rgba_to_laba;
- switch (composite_space)
- {
- case GIMP_LAYER_COLOR_SPACE_LAB:
- default:
- fish_to_composite = NULL;
- fish_from_composite = _gimp_fish_laba_to_rgba;
- break;
- case GIMP_LAYER_COLOR_SPACE_RGB_LINEAR:
- fish_to_composite = _gimp_fish_laba_to_rgba;
- fish_from_composite = NULL;
- break;
- case GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL:
- fish_to_composite = _gimp_fish_laba_to_perceptual;
- fish_from_composite = _gimp_fish_perceptual_to_rgba;
- break;
- }
- break;
+ composite_to_blend_fish = gimp_layer_color_space_fish [composite_space - 1]
+ [blend_space - 1];
- case GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL:
- fish_to_blend = _gimp_fish_rgba_to_perceptual;
- switch (composite_space)
- {
- case GIMP_LAYER_COLOR_SPACE_LAB:
- default:
- fish_to_composite = _gimp_fish_perceptual_to_laba;
- fish_from_composite = NULL;
- break;
- case GIMP_LAYER_COLOR_SPACE_RGB_LINEAR:
- fish_to_composite = _gimp_fish_perceptual_to_rgba;
- fish_from_composite = NULL;
- break;
- case GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL:
- fish_to_composite = NULL;
- fish_from_composite = _gimp_fish_perceptual_to_rgba;
- break;
- }
- break;
+ blend_to_composite_fish = gimp_layer_color_space_fish [blend_space - 1]
+ [composite_space - 1];
}
if (in == out) /* in-place detected, avoid clobbering since we need to
read it for the compositing stage */
blend_out = g_alloca (sizeof (gfloat) * 4 * samples);
- if (fish_to_blend)
+ if (composite_to_blend_fish)
{
- if (in != out || (composite_needs_in_color &&
- composite_space == GIMP_LAYER_COLOR_SPACE_RGB_LINEAR))
+ if (in != out || composite_needs_in_color)
{
/* don't convert input in-place if we're not doing in-place output,
* or if we're going to need the original input for compositing.
@@ -856,78 +798,44 @@ gimp_composite_blend (GimpOperationLayerMode *layer_mode,
}
blend_layer = g_alloca (sizeof (gfloat) * 4 * samples);
- babl_process (fish_to_blend, in, blend_in, samples);
- babl_process (fish_to_blend, layer, blend_layer, samples);
+ babl_process (composite_to_blend_fish, in, blend_in, samples);
+ babl_process (composite_to_blend_fish, layer, blend_layer, samples);
}
blend_func (blend_in, blend_layer, blend_out, samples);
- composite_in = blend_in;
- composite_layer = blend_layer;
-
- if (fish_to_composite)
+ if (blend_to_composite_fish)
{
- if (composite_space == GIMP_LAYER_COLOR_SPACE_RGB_LINEAR)
- {
- composite_in = in;
- composite_layer = layer;
- }
- else
- {
- if (composite_needs_in_color)
- {
- if (composite_in == in && in != out)
- composite_in = g_alloca (sizeof (gfloat) * 4 * samples);
-
- babl_process (fish_to_composite,
- blend_in, composite_in, samples);
- }
-
- if (composite_needs_layer_color)
- {
- if (composite_layer == layer)
- composite_layer = g_alloca (sizeof (gfloat) * 4 * samples);
-
- babl_process (fish_to_composite,
- blend_layer, composite_layer, samples);
- }
- }
-
- babl_process (fish_to_composite, blend_out, blend_out, samples);
+ babl_process (blend_to_composite_fish, blend_out, blend_out, samples);
}
switch (composite_mode)
{
case GIMP_LAYER_COMPOSITE_SRC_ATOP:
default:
- composite_func_src_atop (composite_in, blend_out, NULL,
+ composite_func_src_atop (in, blend_out, NULL,
mask, opacity,
out, samples);
break;
case GIMP_LAYER_COMPOSITE_SRC_OVER:
- composite_func_src_over (composite_in, composite_layer, blend_out,
+ composite_func_src_over (in, layer, blend_out,
mask, opacity,
out, samples);
break;
case GIMP_LAYER_COMPOSITE_DST_ATOP:
- composite_func_dst_atop (composite_in, composite_layer, blend_out,
+ composite_func_dst_atop (in, layer, blend_out,
mask, opacity,
out, samples);
break;
case GIMP_LAYER_COMPOSITE_SRC_IN:
- composite_func_src_in (composite_in, blend_out, NULL,
+ composite_func_src_in (in, blend_out, NULL,
mask, opacity,
out, samples);
break;
}
-
- if (fish_from_composite)
- {
- babl_process (fish_from_composite, out, out, samples);
- }
}
static inline void
diff --git a/app/operations/layer-modes/gimpoperationlayermode.h
b/app/operations/layer-modes/gimpoperationlayermode.h
index be6e684..c4383ca 100644
--- a/app/operations/layer-modes/gimpoperationlayermode.h
+++ b/app/operations/layer-modes/gimpoperationlayermode.h
@@ -54,7 +54,6 @@ struct _GimpOperationLayerMode
GeglOperationPointComposer3 parent_instance;
GimpLayerMode layer_mode;
- gboolean linear;
gdouble opacity;
GimpLayerColorSpace blend_space;
GimpLayerColorSpace composite_space;
diff --git a/app/operations/operations-enums.h b/app/operations/operations-enums.h
index 88016f6..f6a75d5 100644
--- a/app/operations/operations-enums.h
+++ b/app/operations/operations-enums.h
@@ -189,10 +189,9 @@ typedef enum /*< pdb-skip, skip >*/
typedef enum /*< pdb-skip, skip >*/
{
GIMP_LAYER_MODE_FLAG_LEGACY = 1 << 0,
- GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA = 1 << 1,
- GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE = 1 << 2,
- GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE = 1 << 3,
- GIMP_LAYER_MODE_FLAG_COMPOSITE_MODE_IMMUTABLE = 1 << 4,
+ GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE = 1 << 1,
+ GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE = 1 << 2,
+ GIMP_LAYER_MODE_FLAG_COMPOSITE_MODE_IMMUTABLE = 1 << 3,
} GimpLayerModeFlags;
diff --git a/app/paint/gimpbrushcore.c b/app/paint/gimpbrushcore.c
index d495bfa..970bfac 100644
--- a/app/paint/gimpbrushcore.c
+++ b/app/paint/gimpbrushcore.c
@@ -862,10 +862,10 @@ gimp_brush_core_get_paint_buffer (GimpPaintCore *paint_core,
GimpTempBuf *temp_buf;
const Babl *format;
- if (gimp_layer_mode_wants_linear_data (paint_mode))
- format = babl_format ("RGBA float");
- else
- format = babl_format ("R'G'B'A float");
+ format = gimp_layer_mode_get_format (paint_mode,
+ GIMP_LAYER_COLOR_SPACE_AUTO,
+ GIMP_LAYER_COLOR_SPACE_AUTO,
+ NULL);
if (paint_core->paint_buffer &&
gegl_buffer_get_width (paint_core->paint_buffer) == (x2 - x1) &&
diff --git a/app/paint/gimpink.c b/app/paint/gimpink.c
index 3ee478f..80bceea 100644
--- a/app/paint/gimpink.c
+++ b/app/paint/gimpink.c
@@ -259,10 +259,10 @@ gimp_ink_get_paint_buffer (GimpPaintCore *paint_core,
GimpTempBuf *temp_buf;
const Babl *format;
- if (gimp_layer_mode_wants_linear_data (paint_mode))
- format = babl_format ("RGBA float");
- else
- format = babl_format ("R'G'B'A float");
+ format = gimp_layer_mode_get_format (paint_mode,
+ GIMP_LAYER_COLOR_SPACE_AUTO,
+ GIMP_LAYER_COLOR_SPACE_AUTO,
+ NULL);
temp_buf = gimp_temp_buf_new ((x2 - x1), (y2 - y1),
format);
diff --git a/app/paint/gimppaintcore-loops.c b/app/paint/gimppaintcore-loops.c
index a1b7488..b8e2eb7 100644
--- a/app/paint/gimppaintcore-loops.c
+++ b/app/paint/gimppaintcore-loops.c
@@ -305,7 +305,6 @@ do_layer_blend (GeglBuffer *src_buffer,
GeglBufferIterator *iter;
guint paint_stride;
gfloat *paint_data;
- gboolean linear;
GimpLayerModeFunc apply_func;
GimpLayerColorSpace blend_space;
GimpLayerColorSpace composite_space;
@@ -314,16 +313,14 @@ do_layer_blend (GeglBuffer *src_buffer,
paint_stride = gimp_temp_buf_get_width (paint_buf);
paint_data = (gfloat *) gimp_temp_buf_get_data (paint_buf);
- linear = gimp_layer_mode_wants_linear_data (paint_mode);
apply_func = gimp_layer_mode_get_function (paint_mode);
blend_space = gimp_layer_mode_get_blend_space (paint_mode);
composite_space = gimp_layer_mode_get_composite_space (paint_mode);
composite_mode = gimp_layer_mode_get_paint_composite_mode (paint_mode);
- if (linear)
- iterator_format = babl_format ("RGBA float");
- else
- iterator_format = babl_format ("R'G'B'A float");
+ iterator_format = gimp_layer_mode_get_format (paint_mode,
+ composite_space, blend_space,
+ gegl_buffer_get_format (src_buffer));
roi.x = x_offset;
roi.y = y_offset;
@@ -364,7 +361,6 @@ do_layer_blend (GeglBuffer *src_buffer,
paint_pixel = paint_data + ((iter->roi[0].y - roi.y) * paint_stride + iter->roi[0].x - roi.x) * 4;
layer_data.layer_mode = paint_mode;
- layer_data.linear = linear;
layer_data.opacity = opacity;
layer_data.blend_space = blend_space;
layer_data.composite_space = composite_space;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]