[gimp/pippin/linear-is-the-new-black] app: initialize blend-space fishes once at startup
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/pippin/linear-is-the-new-black] app: initialize blend-space fishes once at startup
- Date: Tue, 17 Jan 2017 00:39:07 +0000 (UTC)
commit 9f7ce332fdddc2cf1f61b6b4dad4485cce014f17
Author: Øyvind Kolås <pippin gimp org>
Date: Tue Jan 17 00:39:54 2017 +0100
app: initialize blend-space fishes once at startup
.../layer-modes/gimpoperationpointlayermode.c | 13 ++++
.../layer-modes/gimpoperationpointlayermode.h | 61 +++++++------------
2 files changed, 36 insertions(+), 38 deletions(-)
---
diff --git a/app/operations/layer-modes/gimpoperationpointlayermode.c
b/app/operations/layer-modes/gimpoperationpointlayermode.c
index 94c0e1b..194cbf1 100644
--- a/app/operations/layer-modes/gimpoperationpointlayermode.c
+++ b/app/operations/layer-modes/gimpoperationpointlayermode.c
@@ -63,6 +63,11 @@ G_DEFINE_TYPE (GimpOperationPointLayerMode, gimp_operation_point_layer_mode,
#define parent_class gimp_operation_point_layer_mode_parent_class
+const Babl *_gimp_fish_rgba_to_perceptual = NULL;
+const Babl *_gimp_fish_perceptual_to_rgba = NULL;
+const Babl *_gimp_fish_rgba_to_laba = NULL;
+const Babl *_gimp_fish_laba_to_rgba = NULL;
+
static void
gimp_operation_point_layer_mode_class_init (GimpOperationPointLayerModeClass *klass)
{
@@ -88,6 +93,14 @@ gimp_operation_point_layer_mode_class_init (GimpOperationPointLayerModeClass *kl
0.0, 1.0, 1.0,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
+
+ if (_gimp_fish_rgba_to_perceptual == NULL)
+ {
+ _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_rgba_to_laba = babl_fish ("RGBA float", "CIE Lab alpha float");
+ _gimp_fish_laba_to_rgba = babl_fish ("CIE Lab alpha float", "RGBA float");
+ }
}
static void
diff --git a/app/operations/layer-modes/gimpoperationpointlayermode.h
b/app/operations/layer-modes/gimpoperationpointlayermode.h
index 6c59549..1b6bd25 100644
--- a/app/operations/layer-modes/gimpoperationpointlayermode.h
+++ b/app/operations/layer-modes/gimpoperationpointlayermode.h
@@ -26,7 +26,8 @@
#include <math.h>
#include <cairo.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
-
+#include "../operations-enums.h"
+#include "../operations-types.h"
#include "libgimpcolor/gimpcolor.h"
#define GIMP_TYPE_OPERATION_POINT_LAYER_MODE (gimp_operation_point_layer_mode_get_type ())
@@ -54,6 +55,11 @@ struct _GimpOperationPointLayerMode
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_rgba_to_laba;
+extern const Babl *_gimp_fish_laba_to_rgba;
+
static inline void
gimp_operation_layer_composite (const gfloat *in,
const gfloat *layer,
@@ -90,18 +96,6 @@ gimp_operation_layer_composite (const gfloat *in,
}
}
-typedef enum {
- GIMP_LAYER_BLEND_RGB_LINEAR,
- GIMP_LAYER_BLEND_RGB_PERCEPTUAL,
- GIMP_LAYER_BLEND_LAB,
-} GimpBlendTRC;
-
-typedef enum {
- GIMP_LAYER_COMPOSITE_SRC_ATOP,
- GIMP_LAYER_COMPOSITE_SRC_OVER,
- GIMP_LAYER_COMPOSITE_SRC_IN,
- GIMP_LAYER_COMPOSITE_DST_ATOP
-} GimpLayerComposite;
static inline void
gimp_composite_blend (gfloat *in,
@@ -110,7 +104,7 @@ gimp_composite_blend (gfloat *in,
gfloat *out,
gfloat opacity,
glong samples,
- GimpBlendTRC blend_trc,
+ GimpBlendBlend blend_trc,
GimpLayerComposite composite_mode,
void (*blendfun) (const float *dst,
const float *src,
@@ -127,47 +121,38 @@ gimp_composite_blend (gfloat *in,
}
else if (blend_trc == GIMP_LAYER_BLEND_RGB_LINEAR)
{
- if (in == out)
- blend_out = alloca (sizeof (gfloat) * 4 * samples);
- blendfun (blend_in, blend_layer, blend_out, samples);
+ if (in == out)
+ blend_out = alloca (sizeof (gfloat) * 4 * samples);
+
+ blendfun (blend_in, blend_layer, blend_out, samples);
}
else if (blend_trc == GIMP_LAYER_BLEND_RGB_PERCEPTUAL)
{
- static const Babl *fish_to_perceptual = NULL;
- static const Babl *fish_to_linear = NULL;
- if (!fish_to_perceptual)
- fish_to_perceptual = babl_fish("RGBA float", "R'G'B'A float");
- if (!fish_to_linear)
- fish_to_linear = babl_fish("R'G'B'A float", "RGBA float");
-
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 (fish_to_perceptual, in, blend_in, samples);
- babl_process (fish_to_perceptual, layer, blend_layer, 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);
- babl_process (fish_to_linear, blend_out, blend_out, samples);
+ babl_process (_gimp_fish_perceptual_to_rgba, blend_out, blend_out, samples);
}
else if (blend_trc == GIMP_LAYER_BLEND_LAB)
{
- static const Babl *fish_to_lab = NULL;
- static const Babl *fish_to_rgb = NULL;
- if (!fish_to_lab)
- fish_to_lab = babl_fish("RGBA float", "CIE Lab alpha float");
- if (!fish_to_rgb)
- fish_to_rgb = babl_fish("CIE Lab alpha float", "RGBA float");
-
blend_in = alloca (sizeof (gfloat) * 4 * samples);
- babl_process (fish_to_lab, in, blend_in, samples);
blend_layer = alloca (sizeof (gfloat) * 4 * samples);
- babl_process (fish_to_lab, layer, blend_layer, 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);
- blendfun (blend_in, blend_layer, out, samples);
+ blendfun (blend_in, blend_layer, blend_out, samples);
- babl_process (fish_to_rgb, out, out, samples);
+ babl_process (_gimp_fish_laba_to_rgba, blend_out, blend_out, samples);
}
switch (composite_mode)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]