app: cache fishes in lch blend modes
This commit is contained in:
@ -87,7 +87,9 @@ gimp_operation_lch_color_process (GeglOperation *operation,
|
||||
}
|
||||
|
||||
static void
|
||||
color_pre_process (const Babl *format,
|
||||
color_pre_process (const Babl *from_fish_la,
|
||||
const Babl *from_fish_laba,
|
||||
const Babl *to_fish,
|
||||
const gfloat *in,
|
||||
const gfloat *layer,
|
||||
gfloat *out,
|
||||
@ -96,8 +98,8 @@ color_pre_process (const Babl *format,
|
||||
gfloat tmp[4 * samples], *layer_lab = tmp;
|
||||
gint i;
|
||||
|
||||
babl_process (babl_fish (format, "CIE L alpha float"), in, &out[2 * samples], samples);
|
||||
babl_process (babl_fish (format, "CIE Lab alpha float"), layer, layer_lab, samples);
|
||||
babl_process (from_fish_la, in, &out[2 * samples], samples);
|
||||
babl_process (from_fish_laba, layer, layer_lab, samples);
|
||||
|
||||
for (i = 0; i < samples; ++i)
|
||||
{
|
||||
@ -107,7 +109,7 @@ color_pre_process (const Babl *format,
|
||||
out[4 * i + 3] = out[2 * samples + 2 * i + 1];
|
||||
}
|
||||
|
||||
babl_process (babl_fish ("CIE Lab alpha float", format), out, out, samples);
|
||||
babl_process (to_fish, out, out, samples);
|
||||
}
|
||||
|
||||
gboolean
|
||||
@ -120,15 +122,18 @@ gimp_operation_lch_color_process_pixels_linear (gfloat *in,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
static const Babl *from_fish;
|
||||
static const Babl *to_fish;
|
||||
static const Babl *from_fish_laba = NULL;
|
||||
static const Babl *from_fish_la = NULL;
|
||||
static const Babl *to_fish = NULL;
|
||||
|
||||
if (!from_fish)
|
||||
from_fish = babl_fish ("RGBA float", "CIE Lab alpha float");
|
||||
if (!from_fish_laba)
|
||||
from_fish_laba = babl_fish ("RGBA float", "CIE Lab alpha float");
|
||||
if (!from_fish_la)
|
||||
from_fish_la = babl_fish ("RGBA float", "CIE L alpha float");
|
||||
if (!to_fish)
|
||||
to_fish = babl_fish ("CIE Lab alpha float", "RGBA float");
|
||||
|
||||
color_pre_process (babl_format ("RGBA float"), in, layer, out, samples);
|
||||
color_pre_process (from_fish_la, from_fish_laba, to_fish, in, layer, out, samples);
|
||||
gimp_operation_layer_composite (in, layer, mask, out, opacity, samples);
|
||||
|
||||
return TRUE;
|
||||
@ -144,15 +149,18 @@ gimp_operation_lch_color_process_pixels (gfloat *in,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
static const Babl *from_fish = NULL;
|
||||
static const Babl *from_fish_laba = NULL;
|
||||
static const Babl *from_fish_la = NULL;
|
||||
static const Babl *to_fish = NULL;
|
||||
|
||||
if (!from_fish)
|
||||
from_fish = babl_fish ("R'G'B'A float", "CIE Lab alpha float");
|
||||
if (!from_fish_laba)
|
||||
from_fish_laba = babl_fish ("R'G'B'A float", "CIE Lab alpha float");
|
||||
if (!from_fish_la)
|
||||
from_fish_la = babl_fish ("R'G'B'A float", "CIE L alpha float");
|
||||
if (!to_fish)
|
||||
to_fish = babl_fish ("CIE Lab alpha float", "R'G'B'A float");
|
||||
|
||||
color_pre_process (babl_format ("R'G'B'A float"), in, layer, out, samples);
|
||||
color_pre_process (from_fish_la, from_fish_laba, to_fish, in, layer, out, samples);
|
||||
gimp_operation_layer_composite (in, layer, mask, out, opacity, samples);
|
||||
|
||||
return TRUE;
|
||||
|
@ -88,7 +88,8 @@ gimp_operation_lch_hue_process (GeglOperation *operation,
|
||||
}
|
||||
|
||||
static void
|
||||
hue_pre_process (const Babl *format,
|
||||
hue_pre_process (const Babl *from_fish,
|
||||
const Babl *to_fish,
|
||||
const gfloat *in,
|
||||
const gfloat *layer,
|
||||
gfloat *out,
|
||||
@ -97,8 +98,8 @@ hue_pre_process (const Babl *format,
|
||||
gint i;
|
||||
gfloat tmp[4 * samples], *layer_lab = tmp;
|
||||
|
||||
babl_process (babl_fish (format, "CIE Lab alpha float"), in, out, samples);
|
||||
babl_process (babl_fish (format, "CIE Lab alpha float"), layer, layer_lab, samples);
|
||||
babl_process (from_fish, in, out, samples);
|
||||
babl_process (from_fish, layer, layer_lab, samples);
|
||||
|
||||
for (i = 0; i < samples; ++i)
|
||||
{
|
||||
@ -119,7 +120,7 @@ hue_pre_process (const Babl *format,
|
||||
}
|
||||
}
|
||||
|
||||
babl_process (babl_fish ("CIE Lab alpha float", format), out, out, samples);
|
||||
babl_process (to_fish, out, out, samples);
|
||||
}
|
||||
|
||||
gboolean
|
||||
@ -140,7 +141,7 @@ gimp_operation_lch_hue_process_pixels_linear (gfloat *in,
|
||||
if (!to_fish)
|
||||
to_fish = babl_fish ("CIE Lab alpha float", "RGBA float");
|
||||
|
||||
hue_pre_process (babl_format ("RGBA float"), in, layer, out, samples);
|
||||
hue_pre_process (from_fish, to_fish, in, layer, out, samples);
|
||||
gimp_operation_layer_composite (in, layer, mask, out, opacity, samples);
|
||||
|
||||
return TRUE;
|
||||
@ -164,7 +165,7 @@ gimp_operation_lch_hue_process_pixels (gfloat *in,
|
||||
if (!to_fish)
|
||||
to_fish = babl_fish ("CIE Lab alpha float", "R'G'B'A float");
|
||||
|
||||
hue_pre_process (babl_format ("R'G'B'A float"), in, layer, out, samples);
|
||||
hue_pre_process (from_fish, to_fish, in, layer, out, samples);
|
||||
gimp_operation_layer_composite (in, layer, mask, out, opacity, samples);
|
||||
|
||||
return TRUE;
|
||||
|
@ -88,7 +88,9 @@ gimp_operation_lch_lightness_process (GeglOperation *operation,
|
||||
}
|
||||
|
||||
static void
|
||||
lightness_pre_process (const Babl *format,
|
||||
lightness_pre_process (const Babl *from_fish_la,
|
||||
const Babl *from_fish_laba,
|
||||
const Babl *to_fish,
|
||||
const gfloat *in,
|
||||
const gfloat *layer,
|
||||
gfloat *out,
|
||||
@ -97,13 +99,13 @@ lightness_pre_process (const Babl *format,
|
||||
gfloat lightness_alpha[samples * 2];
|
||||
gint i;
|
||||
|
||||
babl_process (babl_fish (format, "CIE Lab alpha float"), in, out, samples);
|
||||
babl_process (babl_fish (format, "CIE L alpha float"), layer, lightness_alpha, samples);
|
||||
babl_process (from_fish_laba, in, out, samples);
|
||||
babl_process (from_fish_la, layer, lightness_alpha, samples);
|
||||
|
||||
for (i = 0; i < samples; ++i)
|
||||
out[4 * i] = lightness_alpha[2 * i];
|
||||
|
||||
babl_process (babl_fish ("CIE Lab alpha float", format), out, out, samples);
|
||||
babl_process (to_fish, out, out, samples);
|
||||
}
|
||||
|
||||
gboolean
|
||||
@ -116,15 +118,18 @@ gimp_operation_lch_lightness_process_pixels_linear (gfloat *in,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
static const Babl *from_fish = NULL;
|
||||
static const Babl *from_fish_laba = NULL;
|
||||
static const Babl *from_fish_la = NULL;
|
||||
static const Babl *to_fish = NULL;
|
||||
|
||||
if (!from_fish)
|
||||
from_fish = babl_fish ("RGBA float", "CIE Lab alpha float");
|
||||
if (!from_fish_laba)
|
||||
from_fish_laba = babl_fish ("RGBA float", "CIE Lab alpha float");
|
||||
if (!from_fish_la)
|
||||
from_fish_la = babl_fish ("RGBA float", "CIE L alpha float");
|
||||
if (!to_fish)
|
||||
to_fish = babl_fish ("CIE Lab alpha float", "RGBA float");
|
||||
|
||||
lightness_pre_process (babl_format ("RGBA float"), in, layer, out, samples);
|
||||
lightness_pre_process (from_fish_la, from_fish_laba, to_fish, in, layer, out, samples);
|
||||
gimp_operation_layer_composite (in, layer, mask, out, opacity, samples);
|
||||
|
||||
return TRUE;
|
||||
@ -140,15 +145,19 @@ gimp_operation_lch_lightness_process_pixels (gfloat *in,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
static const Babl *from_fish = NULL;
|
||||
static const Babl *from_fish_laba = NULL;
|
||||
static const Babl *from_fish_la = NULL;
|
||||
static const Babl *to_fish = NULL;
|
||||
|
||||
if (!from_fish)
|
||||
from_fish = babl_fish ("R'G'B'A float", "CIE Lab alpha float");
|
||||
if (!from_fish_laba)
|
||||
from_fish_laba = babl_fish ("R'G'B'A float", "CIE Lab alpha float");
|
||||
if (!from_fish_la)
|
||||
from_fish_la = babl_fish ("R'G'B'A float", "CIE L alpha float");
|
||||
if (!to_fish)
|
||||
to_fish = babl_fish ("CIE Lab alpha float", "R'G'B'A float");
|
||||
|
||||
lightness_pre_process (babl_format ("R'G'B'A float"), in, layer, out, samples);
|
||||
|
||||
lightness_pre_process (from_fish_la, from_fish_laba, to_fish, in, layer, out, samples);
|
||||
gimp_operation_layer_composite (in, layer, mask, out, opacity, samples);
|
||||
|
||||
return TRUE;
|
||||
|
Reference in New Issue
Block a user