[gimp/pippin/linear-is-the-new-black: 2/17] app: gimp_composite_blend do fish computation before processing
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/pippin/linear-is-the-new-black: 2/17] app: gimp_composite_blend do fish computation before processing
- Date: Wed, 18 Jan 2017 23:11:12 +0000 (UTC)
commit 6f1673b86035690c2612cb32b89b013332bf47e8
Author: Øyvind Kolås <pippin gimp org>
Date: Tue Jan 17 14:28:05 2017 +0100
app: gimp_composite_blend do fish computation before processing
Thus making the code easier to read and more generic.
.../layer-modes/gimpoperationpointlayermode.c | 4 +
.../layer-modes/gimpoperationpointlayermode.h | 143 +++++++++----------
2 files changed, 72 insertions(+), 75 deletions(-)
---
diff --git a/app/operations/layer-modes/gimpoperationpointlayermode.c
b/app/operations/layer-modes/gimpoperationpointlayermode.c
index aca474c..8e47edf 100644
--- a/app/operations/layer-modes/gimpoperationpointlayermode.c
+++ b/app/operations/layer-modes/gimpoperationpointlayermode.c
@@ -68,8 +68,10 @@ G_DEFINE_TYPE (GimpOperationPointLayerMode, gimp_operation_point_layer_mode,
const Babl *_gimp_fish_rgba_to_perceptual = NULL;
const Babl *_gimp_fish_perceptual_to_rgba = NULL;
+const Babl *_gimp_fish_perceptual_to_laba = NULL;
const Babl *_gimp_fish_rgba_to_laba = NULL;
const Babl *_gimp_fish_laba_to_rgba = NULL;
+const Babl *_gimp_fish_laba_to_perceptual = NULL;
static void
gimp_operation_point_layer_mode_class_init (GimpOperationPointLayerModeClass *klass)
@@ -126,8 +128,10 @@ gimp_operation_point_layer_mode_class_init (GimpOperationPointLayerModeClass *kl
{
_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");
}
}
diff --git a/app/operations/layer-modes/gimpoperationpointlayermode.h
b/app/operations/layer-modes/gimpoperationpointlayermode.h
index 66539cb..80600a5 100644
--- a/app/operations/layer-modes/gimpoperationpointlayermode.h
+++ b/app/operations/layer-modes/gimpoperationpointlayermode.h
@@ -61,8 +61,10 @@ GType gimp_operation_point_layer_mode_get_type (void) G_GNUC_CONST;
extern const Babl *_gimp_fish_rgba_to_perceptual;
extern const Babl *_gimp_fish_perceptual_to_rgba;
+extern const Babl *_gimp_fish_perceptual_to_laba;
extern const Babl *_gimp_fish_rgba_to_laba;
extern const Babl *_gimp_fish_laba_to_rgba;
+extern const Babl *_gimp_fish_laba_to_perceptual;
static inline void
gimp_operation_layer_composite (const gfloat *in,
@@ -116,95 +118,93 @@ gimp_composite_blend (gfloat *in,
float *out,
int samples))
{
+ int samples_backup = samples;
gfloat *blend_in = in;
gfloat *blend_layer = layer;
gfloat *blend_out = out;
+ const Babl *fish_to_blend = NULL;
+ const Babl *fish_to_composite = NULL;
+ const Babl *fish_from_composite = NULL;
+ switch (blend_trc)
+ {
+ case GIMP_LAYER_BLEND_RGB_LINEAR:
+ switch (composite_trc)
+ {
+ default:
+ case GIMP_LAYER_BLEND_RGB_LINEAR:
+ break;
+ case GIMP_LAYER_BLEND_RGB_PERCEPTUAL:
+ fish_to_composite = _gimp_fish_rgba_to_perceptual;
+ fish_from_composite = _gimp_fish_perceptual_to_rgba;
+ break;
+ }
+ break;
+ case GIMP_LAYER_BLEND_LAB:
+ fish_to_blend = _gimp_fish_rgba_to_laba;
+ switch (composite_trc)
+ {
+ default:
+ case GIMP_LAYER_BLEND_RGB_LINEAR:
+ fish_to_composite = _gimp_fish_laba_to_rgba;
+ break;
+ case GIMP_LAYER_BLEND_RGB_PERCEPTUAL:
+ fish_to_composite = _gimp_fish_laba_to_perceptual;
+ fish_from_composite = _gimp_fish_perceptual_to_rgba;
+ break;
+ }
+ break;
+ case GIMP_LAYER_BLEND_RGB_PERCEPTUAL:
+ fish_to_blend = _gimp_fish_rgba_to_perceptual;
+ switch (composite_trc)
+ {
+ default:
+ case GIMP_LAYER_BLEND_RGB_LINEAR:
+ fish_to_composite = _gimp_fish_perceptual_to_rgba;
+ break;
+ case GIMP_LAYER_BLEND_RGB_PERCEPTUAL:
+ fish_from_composite = _gimp_fish_perceptual_to_rgba;
+ break;
+ }
+ break;
+ }
+
if (blendfun == NULL)
{
- switch (composite_trc)
- {
- case GIMP_LAYER_BLEND_RGB_LINEAR:
+ if (fish_to_blend == NULL)
+ {
blend_out = layer;
- break;
- case GIMP_LAYER_BLEND_LAB:
+ }
+ else
+ {
blend_out = alloca (sizeof (gfloat) * 4 * samples);
- babl_process (_gimp_fish_rgba_to_laba, layer, blend_out, samples);
- break;
- case GIMP_LAYER_BLEND_RGB_PERCEPTUAL:
- blend_out = alloca (sizeof (gfloat) * 4 * samples);
- babl_process (_gimp_fish_rgba_to_perceptual, layer, blend_out, samples);
- break;
- }
+ babl_process (fish_to_blend, layer, blend_out, samples);
+ }
}
- else if (blend_trc == GIMP_LAYER_BLEND_RGB_LINEAR)
+ else if (fish_to_blend == NULL)
{
if (in == out)
blend_out = alloca (sizeof (gfloat) * 4 * samples);
blendfun (blend_in, blend_layer, blend_out, samples);
-
- switch (composite_trc)
+ if (fish_to_composite)
{
- case GIMP_LAYER_BLEND_RGB_LINEAR:
- break;
- case GIMP_LAYER_BLEND_LAB:
- babl_process (_gimp_fish_rgba_to_laba, blend_out, blend_out, samples);
- break;
- case GIMP_LAYER_BLEND_RGB_PERCEPTUAL:
- babl_process (_gimp_fish_rgba_to_perceptual, blend_out, blend_out, samples);
- break;
+ babl_process (fish_to_composite, blend_out, blend_out, samples);
}
}
- else if (blend_trc == GIMP_LAYER_BLEND_RGB_PERCEPTUAL)
- {
+ else {
blend_in = alloca (sizeof (gfloat) * 4 * samples);
blend_layer = alloca (sizeof (gfloat) * 4 * samples);
if (in == out)
blend_out = alloca (sizeof (gfloat) * 4 * samples);
-
- babl_process (_gimp_fish_rgba_to_perceptual, in, blend_in, samples);
- babl_process (_gimp_fish_rgba_to_perceptual, layer, blend_layer, samples);
-
- blendfun (blend_in, blend_layer, blend_out, samples);
-
- switch (composite_trc)
- {
- case GIMP_LAYER_BLEND_RGB_LINEAR:
- babl_process (_gimp_fish_perceptual_to_rgba, blend_out, blend_out, samples);
- break;
- case GIMP_LAYER_BLEND_LAB:
- babl_process (_gimp_fish_perceptual_to_rgba, blend_out, blend_out, samples);
- // XXX : double conversion - could be avoided with custom fish
- babl_process (_gimp_fish_rgba_to_laba, blend_out, blend_out, samples);
- break;
- case GIMP_LAYER_BLEND_RGB_PERCEPTUAL:
- break;
- }
- }
- else if (blend_trc == GIMP_LAYER_BLEND_LAB)
- {
- blend_in = alloca (sizeof (gfloat) * 4 * samples);
- blend_layer = alloca (sizeof (gfloat) * 4 * samples);
- babl_process (_gimp_fish_rgba_to_laba, in, blend_in, samples);
- babl_process (_gimp_fish_rgba_to_laba, layer, blend_layer, samples);
- if (in == out)
- blend_out = alloca (sizeof (gfloat) * 4 * samples);
-
+ babl_process (fish_to_blend, in, blend_in, samples);
+ babl_process (fish_to_blend, layer, blend_layer, samples);
blendfun (blend_in, blend_layer, blend_out, samples);
- switch (composite_trc)
+ if (fish_to_composite)
{
- case GIMP_LAYER_BLEND_RGB_LINEAR:
- babl_process (_gimp_fish_laba_to_rgba, blend_out, blend_out, samples);
- break;
- case GIMP_LAYER_BLEND_LAB:
- break;
- case GIMP_LAYER_BLEND_RGB_PERCEPTUAL:
- babl_process (_gimp_fish_laba_to_rgba, blend_out, blend_out, samples);
- babl_process (_gimp_fish_perceptual_to_rgba, blend_out, blend_out, samples);
- break;
+ babl_process (fish_to_composite, blend_out, blend_out, samples);
}
}
@@ -338,18 +338,11 @@ gimp_composite_blend (gfloat *in,
break;
}
- switch (composite_trc)
+ if (fish_from_composite)
{
- case GIMP_LAYER_BLEND_RGB_LINEAR:
- break;
- case GIMP_LAYER_BLEND_LAB:
- out -= 4 * samples;
- babl_process (_gimp_fish_laba_to_rgba, out, out, samples);
- break;
- case GIMP_LAYER_BLEND_RGB_PERCEPTUAL:
- out -= 4 * samples;
- babl_process (_gimp_fish_perceptual_to_rgba, out, out, samples);
- break;
+ samples = samples_backup;
+ out -= 4 * samples;
+ babl_process (fish_from_composite, out, out, samples);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]