app: remove "gboolean linear" from gimp_get_layer_mode_function()

and get rid of the two process_pixels() functions in the LCH modes,
they always take linear now.
This commit is contained in:
Michael Natterer
2017-01-19 18:43:31 +01:00
parent 417d9553b5
commit 349cff8c16
11 changed files with 88 additions and 396 deletions

View File

@ -78,8 +78,7 @@
GimpLayerModeFunc
gimp_get_layer_mode_function (GimpLayerMode paint_mode,
gboolean linear_mode)
gimp_get_layer_mode_function (GimpLayerMode paint_mode)
{
GimpLayerModeFunc func;
@ -267,27 +266,19 @@ gimp_get_layer_mode_function (GimpLayerMode paint_mode,
break;
case GIMP_LAYER_MODE_LCH_HUE:
func = linear_mode ?
gimp_operation_lch_hue_process_pixels_linear :
gimp_operation_lch_hue_process_pixels;
func = gimp_operation_lch_hue_process_pixels;
break;
case GIMP_LAYER_MODE_LCH_CHROMA:
func = linear_mode ?
gimp_operation_lch_chroma_process_pixels_linear :
gimp_operation_lch_chroma_process_pixels;
func = gimp_operation_lch_chroma_process_pixels;
break;
case GIMP_LAYER_MODE_LCH_COLOR:
func = linear_mode ?
gimp_operation_lch_color_process_pixels_linear :
gimp_operation_lch_color_process_pixels;
func = gimp_operation_lch_color_process_pixels;
break;
case GIMP_LAYER_MODE_LCH_LIGHTNESS:
func = linear_mode ?
gimp_operation_lch_lightness_process_pixels_linear :
gimp_operation_lch_lightness_process_pixels;
func = gimp_operation_lch_lightness_process_pixels;
break;
case GIMP_LAYER_MODE_ERASE:

View File

@ -22,8 +22,7 @@
#define __GIMP_LAYER_MODE_FUNCTIONS_H__
GimpLayerModeFunc gimp_get_layer_mode_function (GimpLayerMode paint_mode,
gboolean linear_mode);
GimpLayerModeFunc gimp_get_layer_mode_function (GimpLayerMode paint_mode);
#endif /* __GIMP_LAYER_MODE_FUNCTIONS_H__ */

View File

@ -81,58 +81,17 @@ gimp_operation_lch_chroma_process (GeglOperation *operation,
const GeglRectangle *roi,
gint level)
{
GimpOperationPointLayerMode *gimp_op = GIMP_OPERATION_POINT_LAYER_MODE (operation);
gfloat opacity = gimp_op->opacity;
gboolean linear = gimp_op->linear;
GimpOperationPointLayerMode *layer_mode = (gpointer) operation;
return (linear ? gimp_operation_lch_chroma_process_pixels_linear :
gimp_operation_lch_chroma_process_pixels)
(in_buf, aux_buf, aux2_buf,
out_buf,
opacity,
samples, roi, level,
gimp_op->blend_trc,
gimp_op->composite_trc,
gimp_op->composite_mode);
return gimp_operation_lch_chroma_process_pixels (in_buf, aux_buf, aux2_buf,
out_buf,
layer_mode->opacity,
samples, roi, level,
layer_mode->blend_trc,
layer_mode->composite_trc,
layer_mode->composite_mode);
}
static void
chroma_pre_process (const Babl *from_fish,
const Babl *to_fish,
const gfloat *in,
const gfloat *layer,
gfloat *out,
glong samples)
{
gfloat tmp[4 * samples], *layer_lab = tmp;
gint i;
babl_process (from_fish, in, out, samples);
babl_process (from_fish, layer, layer_lab, samples);
for (i = 0; i < samples; ++i)
{
gfloat A1 = out[4 * i + 1];
gfloat B1 = out[4 * i + 2];
gfloat c1 = hypotf (A1, B1);
if (c1 != 0)
{
gfloat A2 = layer_lab[4 * i + 1];
gfloat B2 = layer_lab[4 * i + 2];
gfloat c2 = hypotf (A2, B2);
gfloat A = c2 * A1 / c1;
gfloat B = c2 * B1 / c1;
out[4 * i + 1] = A;
out[4 * i + 2] = B;
}
}
babl_process (to_fish, out, out, samples);
}
/* XXX: this and pre_process should be removed */
gboolean
gimp_operation_lch_chroma_process_pixels (gfloat *in,
gfloat *layer,
@ -145,33 +104,6 @@ gimp_operation_lch_chroma_process_pixels (gfloat *in,
GimpLayerBlendTRC blend_trc,
GimpLayerBlendTRC composite_trc,
GimpLayerCompositeMode composite_mode)
{
static const Babl *from_fish = NULL;
static const Babl *to_fish = NULL;
if (!from_fish)
from_fish = babl_fish ("R'G'B'A float", "CIE Lab alpha float");
if (!to_fish)
to_fish = babl_fish ("CIE Lab alpha float", "R'G'B'A float");
chroma_pre_process (from_fish, to_fish, in, layer, out, samples);
compfun_src_atop (in, layer, mask, opacity, out, samples);
return TRUE;
}
gboolean
gimp_operation_lch_chroma_process_pixels_linear (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
gfloat opacity,
glong samples,
const GeglRectangle *roi,
gint level,
GimpLayerBlendTRC blend_trc,
GimpLayerBlendTRC composite_trc,
GimpLayerCompositeMode composite_mode)
{
gimp_composite_blend (in, layer, mask, out, opacity, samples,
blend_trc, composite_trc, composite_mode,

View File

@ -49,31 +49,19 @@ struct _GimpOperationLchChromaClass
};
GType gimp_operation_lch_chroma_get_type (void) G_GNUC_CONST;
GType gimp_operation_lch_chroma_get_type (void) G_GNUC_CONST;
gboolean gimp_operation_lch_chroma_process_pixels_linear (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
gfloat opacity,
glong samples,
const GeglRectangle *roi,
gint level,
GimpLayerBlendTRC blend_trc,
GimpLayerBlendTRC composite_trc,
GimpLayerCompositeMode composite_mode);
gboolean gimp_operation_lch_chroma_process_pixels (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
gfloat opacity,
glong samples,
const GeglRectangle *roi,
gint level,
GimpLayerBlendTRC blend_trc,
GimpLayerBlendTRC composite_trc,
GimpLayerCompositeMode composite_mode);
gboolean gimp_operation_lch_chroma_process_pixels (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
gfloat opacity,
glong samples,
const GeglRectangle *roi,
gint level,
GimpLayerBlendTRC blend_trc,
GimpLayerBlendTRC composite_trc,
GimpLayerCompositeMode composite_mode);
#endif /* __GIMP_OPERATION_LCH_CHROMA_H__ */

View File

@ -81,46 +81,17 @@ gimp_operation_lch_color_process (GeglOperation *operation,
const GeglRectangle *roi,
gint level)
{
GimpOperationPointLayerMode *gimp_op = GIMP_OPERATION_POINT_LAYER_MODE (operation);
GimpOperationPointLayerMode *layer_mode = (gpointer) operation;
return (gimp_op->linear ? gimp_operation_lch_color_process_pixels_linear :
gimp_operation_lch_color_process_pixels)
(in_buf, aux_buf, aux2_buf,
out_buf,
gimp_op->opacity,
samples, roi, level,
gimp_op->blend_trc,
gimp_op->composite_trc,
gimp_op->composite_mode);
return gimp_operation_lch_color_process_pixels (in_buf, aux_buf, aux2_buf,
out_buf,
layer_mode->opacity,
samples, roi, level,
layer_mode->blend_trc,
layer_mode->composite_trc,
layer_mode->composite_mode);
}
static void
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,
glong samples)
{
gfloat tmp[4 * samples], *layer_lab = tmp;
gint i;
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)
{
out[4 * i + 0] = out[2 * samples + 2 * i + 0];
out[4 * i + 1] = layer_lab[4 * i + 1];
out[4 * i + 2] = layer_lab[4 * i + 2];
out[4 * i + 3] = out[2 * samples + 2 * i + 1];
}
babl_process (to_fish, out, out, samples);
}
/* XXX: should be removed along with the pre_process fun */
gboolean
gimp_operation_lch_color_process_pixels (gfloat *in,
gfloat *layer,
@ -133,37 +104,6 @@ gimp_operation_lch_color_process_pixels (gfloat *in,
GimpLayerBlendTRC blend_trc,
GimpLayerBlendTRC composite_trc,
GimpLayerCompositeMode composite_mode)
{
static const Babl *from_fish_laba = NULL;
static const Babl *from_fish_la = NULL;
static const Babl *to_fish = NULL;
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 (from_fish_la, from_fish_laba, to_fish, in, layer, out, samples);
compfun_src_atop (in, layer, mask, opacity, out, samples);
return TRUE;
}
gboolean
gimp_operation_lch_color_process_pixels_linear (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
gfloat opacity,
glong samples,
const GeglRectangle *roi,
gint level,
GimpLayerBlendTRC blend_trc,
GimpLayerBlendTRC composite_trc,
GimpLayerCompositeMode composite_mode)
{
gimp_composite_blend (in, layer, mask, out, opacity, samples,
blend_trc, composite_trc, composite_mode,

View File

@ -49,31 +49,19 @@ struct _GimpOperationLchColorClass
};
GType gimp_operation_lch_color_get_type (void) G_GNUC_CONST;
GType gimp_operation_lch_color_get_type (void) G_GNUC_CONST;
gboolean gimp_operation_lch_color_process_pixels_linear (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
gfloat opacity,
glong samples,
const GeglRectangle *roi,
gint level,
GimpLayerBlendTRC blend_trc,
GimpLayerBlendTRC composite_trc,
GimpLayerCompositeMode composite_mode);
gboolean gimp_operation_lch_color_process_pixels (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
gfloat opacity,
glong samples,
const GeglRectangle *roi,
gint level,
GimpLayerBlendTRC blend_trc,
GimpLayerBlendTRC composite_trc,
GimpLayerCompositeMode composite_mode);
gboolean gimp_operation_lch_color_process_pixels (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
gfloat opacity,
glong samples,
const GeglRectangle *roi,
gint level,
GimpLayerBlendTRC blend_trc,
GimpLayerBlendTRC composite_trc,
GimpLayerCompositeMode composite_mode);
#endif /* __GIMP_OPERATION_LCH_COLOR_H__ */

View File

@ -81,56 +81,17 @@ gimp_operation_lch_hue_process (GeglOperation *operation,
const GeglRectangle *roi,
gint level)
{
GimpOperationPointLayerMode *layer_mode = (GimpOperationPointLayerMode*)operation;
GimpOperationPointLayerMode *layer_mode = (gpointer) operation;
return (layer_mode->linear ? gimp_operation_lch_hue_process_pixels_linear :
gimp_operation_lch_hue_process_pixels)
(in_buf, aux_buf, aux2_buf,
out_buf,
layer_mode->opacity,
samples, roi, level,
layer_mode->blend_trc,
layer_mode->composite_trc,
layer_mode->composite_mode);
return gimp_operation_lch_hue_process_pixels (in_buf, aux_buf, aux2_buf,
out_buf,
layer_mode->opacity,
samples, roi, level,
layer_mode->blend_trc,
layer_mode->composite_trc,
layer_mode->composite_mode);
}
static void
hue_pre_process (const Babl *from_fish,
const Babl *to_fish,
const gfloat *in,
const gfloat *layer,
gfloat *out,
glong samples)
{
gint i;
gfloat tmp[4 * samples], *layer_lab = tmp;
babl_process (from_fish, in, out, samples);
babl_process (from_fish, layer, layer_lab, samples);
for (i = 0; i < samples; ++i)
{
gfloat A2 = layer_lab[4 * i + 1];
gfloat B2 = layer_lab[4 * i + 2];
gfloat c2 = hypotf (A2, B2);
if (c2 > 0.1f)
{
gfloat A1 = out[4 * i + 1];
gfloat B1 = out[4 * i + 2];
gfloat c1 = hypotf (A1, B1);
gfloat A = c1 * A2 / c2;
gfloat B = c1 * B2 / c2;
out[4 * i + 1] = A;
out[4 * i + 2] = B;
}
}
babl_process (to_fish, out, out, samples);
}
/* XXX: this should be removed along with _pre_process */
gboolean
gimp_operation_lch_hue_process_pixels (gfloat *in,
gfloat *layer,
@ -143,34 +104,6 @@ gimp_operation_lch_hue_process_pixels (gfloat *in,
GimpLayerBlendTRC blend_trc,
GimpLayerBlendTRC composite_trc,
GimpLayerCompositeMode composite_mode)
{
static const Babl *from_fish = NULL;
static const Babl *to_fish = NULL;
if (!from_fish)
from_fish = babl_fish ("R'G'B'A float", "CIE Lab alpha float");
if (!to_fish)
to_fish = babl_fish ("CIE Lab alpha float", "R'G'B'A float");
hue_pre_process (from_fish, to_fish, in, layer, out, samples);
compfun_src_atop (in, layer, mask, opacity, out, samples);
return TRUE;
}
gboolean
gimp_operation_lch_hue_process_pixels_linear (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
gfloat opacity,
glong samples,
const GeglRectangle *roi,
gint level,
GimpLayerBlendTRC blend_trc,
GimpLayerBlendTRC composite_trc,
GimpLayerCompositeMode composite_mode)
{
gimp_composite_blend (in, layer, mask, out, opacity, samples,
blend_trc, composite_trc, composite_mode,

View File

@ -49,30 +49,18 @@ struct _GimpOperationLchHueClass
};
GType gimp_operation_lch_hue_get_type (void) G_GNUC_CONST;
GType gimp_operation_lch_hue_get_type (void) G_GNUC_CONST;
gboolean gimp_operation_lch_hue_process_pixels_linear (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
gfloat opacity,
glong samples,
const GeglRectangle *roi,
gint level,
GimpLayerBlendTRC blend_trc,
GimpLayerBlendTRC composite_trc,
GimpLayerCompositeMode composite_mode);
gboolean gimp_operation_lch_hue_process_pixels (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
gfloat opacity,
glong samples,
const GeglRectangle *roi,
gint level,
GimpLayerBlendTRC blend_trc,
GimpLayerBlendTRC composite_trc,
GimpLayerCompositeMode composite_mode);
gboolean gimp_operation_lch_hue_process_pixels (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
gfloat opacity,
glong samples,
const GeglRectangle *roi,
gint level,
GimpLayerBlendTRC blend_trc,
GimpLayerBlendTRC composite_trc,
GimpLayerCompositeMode composite_mode);
#endif /* __GIMP_OPERATION_LCH_HUE_H__ */

View File

@ -81,39 +81,17 @@ gimp_operation_lch_lightness_process (GeglOperation *operation,
const GeglRectangle *roi,
gint level)
{
GimpOperationPointLayerMode *layer_mode = (GimpOperationPointLayerMode*)operation;
return (layer_mode->linear ? gimp_operation_lch_lightness_process_pixels_linear : gimp_operation_lch_lightness_process_pixels)
(in_buf, aux_buf, aux2_buf,
out_buf,
layer_mode->opacity,
samples, roi, level,
layer_mode->blend_trc,
layer_mode->composite_trc,
layer_mode->composite_mode);
GimpOperationPointLayerMode *layer_mode = (gpointer) operation;
return gimp_operation_lch_lightness_process_pixels (in_buf, aux_buf, aux2_buf,
out_buf,
layer_mode->opacity,
samples, roi, level,
layer_mode->blend_trc,
layer_mode->composite_trc,
layer_mode->composite_mode);
}
static void
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,
glong samples)
{
gfloat lightness_alpha[samples * 2];
gint i;
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 (to_fish, out, out, samples);
}
/* XXX: this should be remove along with _pre_process */
gboolean
gimp_operation_lch_lightness_process_pixels (gfloat *in,
gfloat *layer,
@ -126,38 +104,6 @@ gimp_operation_lch_lightness_process_pixels (gfloat *in,
GimpLayerBlendTRC blend_trc,
GimpLayerBlendTRC composite_trc,
GimpLayerCompositeMode composite_mode)
{
static const Babl *from_fish_laba = NULL;
static const Babl *from_fish_la = NULL;
static const Babl *to_fish = NULL;
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 (from_fish_la, from_fish_laba, to_fish, in, layer, out, samples);
compfun_src_atop (in, layer, mask, opacity, out, samples);
return TRUE;
}
gboolean
gimp_operation_lch_lightness_process_pixels_linear (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
gfloat opacity,
glong samples,
const GeglRectangle *roi,
gint level,
GimpLayerBlendTRC blend_trc,
GimpLayerBlendTRC composite_trc,
GimpLayerCompositeMode composite_mode)
{
gimp_composite_blend (in, layer, mask, out, opacity, samples,
blend_trc, composite_trc, composite_mode,

View File

@ -49,31 +49,19 @@ struct _GimpOperationLchLightnessClass
};
GType gimp_operation_lch_lightness_get_type (void) G_GNUC_CONST;
GType gimp_operation_lch_lightness_get_type (void) G_GNUC_CONST;
gboolean gimp_operation_lch_lightness_process_pixels_linear (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
gfloat opacity,
glong samples,
const GeglRectangle *roi,
gint level,
GimpLayerBlendTRC blend_trc,
GimpLayerBlendTRC composite_trc,
GimpLayerCompositeMode composite_mode);
gboolean gimp_operation_lch_lightness_process_pixels (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
gfloat opacity,
glong samples,
const GeglRectangle *roi,
gint level,
GimpLayerBlendTRC blend_trc,
GimpLayerBlendTRC composite_trc,
GimpLayerCompositeMode composite_mode);
gboolean gimp_operation_lch_lightness_process_pixels (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
gfloat opacity,
glong samples,
const GeglRectangle *roi,
gint level,
GimpLayerBlendTRC blend_trc,
GimpLayerBlendTRC composite_trc,
GimpLayerCompositeMode composite_mode);
#endif /* __GIMP_OPERATION_LCH_LIGHTNESS_H__ */

View File

@ -308,8 +308,7 @@ do_layer_blend (GeglBuffer *src_buffer,
const guint paint_stride = gimp_temp_buf_get_width (paint_buf);
gfloat *paint_data = (gfloat *) gimp_temp_buf_get_data (paint_buf);
GimpLayerModeFunc apply_func = gimp_get_layer_mode_function (paint_mode,
linear_mode);
GimpLayerModeFunc apply_func = gimp_get_layer_mode_function (paint_mode);
if (linear_mode)
iterator_format = babl_format ("RGBA float");