mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-10-06 17:52:42 +02:00
app: layer layer modes to use babl conversions directly.
This commit is contained in:
@@ -84,9 +84,8 @@ gimp_operation_hsl_color_legacy_process (GeglOperation *op,
|
|||||||
|
|
||||||
while (samples--)
|
while (samples--)
|
||||||
{
|
{
|
||||||
GimpHSL layer_hsl, out_hsl;
|
gfloat layer_hsl[3], out_hsl[3];
|
||||||
GimpRGB layer_rgb = {layer[0], layer[1], layer[2]};
|
gfloat out_rgb[3];
|
||||||
GimpRGB out_rgb = {in[0], in[1], in[2]};
|
|
||||||
gfloat comp_alpha, new_alpha;
|
gfloat comp_alpha, new_alpha;
|
||||||
|
|
||||||
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
|
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
|
||||||
@@ -98,24 +97,23 @@ gimp_operation_hsl_color_legacy_process (GeglOperation *op,
|
|||||||
if (comp_alpha && new_alpha)
|
if (comp_alpha && new_alpha)
|
||||||
{
|
{
|
||||||
gint b;
|
gint b;
|
||||||
gfloat out_tmp[3];
|
|
||||||
gfloat ratio = comp_alpha / new_alpha;
|
gfloat ratio = comp_alpha / new_alpha;
|
||||||
|
|
||||||
gimp_rgb_to_hsl (&layer_rgb, &layer_hsl);
|
/* TODO: shouldn't these conversions be processed in image space, or
|
||||||
gimp_rgb_to_hsl (&out_rgb, &out_hsl);
|
* doesn't it matter?
|
||||||
|
*/
|
||||||
|
babl_process (babl_fish (babl_format ("R'G'B' float"), babl_format ("HSL float")),
|
||||||
|
layer, layer_hsl, 1);
|
||||||
|
babl_process (babl_fish (babl_format ("R'G'B' float"), babl_format ("HSL float")),
|
||||||
|
in, out_hsl, 1);
|
||||||
|
|
||||||
out_hsl.h = layer_hsl.h;
|
out_hsl[0] = layer_hsl[0];
|
||||||
out_hsl.s = layer_hsl.s;
|
out_hsl[1] = layer_hsl[1];
|
||||||
gimp_hsl_to_rgb (&out_hsl, &out_rgb);
|
babl_process (babl_fish (babl_format ("HSL float"), babl_format ("R'G'B' float")),
|
||||||
|
out_hsl, out_rgb, 1);
|
||||||
out_tmp[0] = out_rgb.r;
|
|
||||||
out_tmp[1] = out_rgb.g;
|
|
||||||
out_tmp[2] = out_rgb.b;
|
|
||||||
|
|
||||||
for (b = RED; b < ALPHA; b++)
|
for (b = RED; b < ALPHA; b++)
|
||||||
{
|
out[b] = out_rgb[b] * ratio + in[b] * (1.0f - ratio);
|
||||||
out[b] = out_tmp[b] * ratio + in[b] * (1.0f - ratio);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -84,9 +84,8 @@ gimp_operation_hsv_hue_legacy_process (GeglOperation *op,
|
|||||||
|
|
||||||
while (samples--)
|
while (samples--)
|
||||||
{
|
{
|
||||||
GimpHSV layer_hsv, out_hsv;
|
gfloat layer_hsv[3], out_hsv[3];
|
||||||
GimpRGB layer_rgb = {layer[0], layer[1], layer[2]};
|
gfloat out_rgb[3];
|
||||||
GimpRGB out_rgb = {in[0], in[1], in[2]};
|
|
||||||
gfloat comp_alpha, new_alpha;
|
gfloat comp_alpha, new_alpha;
|
||||||
|
|
||||||
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
|
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
|
||||||
@@ -98,29 +97,23 @@ gimp_operation_hsv_hue_legacy_process (GeglOperation *op,
|
|||||||
if (comp_alpha && new_alpha)
|
if (comp_alpha && new_alpha)
|
||||||
{
|
{
|
||||||
gint b;
|
gint b;
|
||||||
gfloat out_tmp[3];
|
|
||||||
gfloat ratio = comp_alpha / new_alpha;
|
gfloat ratio = comp_alpha / new_alpha;
|
||||||
|
|
||||||
gimp_rgb_to_hsv (&layer_rgb, &layer_hsv);
|
babl_process (babl_fish (babl_format ("R'G'B' float"), babl_format ("HSV float")),
|
||||||
gimp_rgb_to_hsv (&out_rgb, &out_hsv);
|
layer, layer_hsv, 1);
|
||||||
|
babl_process (babl_fish (babl_format ("R'G'B' float"), babl_format ("HSV float")),
|
||||||
|
in, out_hsv, 1);
|
||||||
|
|
||||||
/* Composition should have no effect if saturation is zero.
|
/* Composition should have no effect if saturation is zero.
|
||||||
* otherwise, black would be painted red (see bug #123296).
|
* otherwise, black would be painted red (see bug #123296).
|
||||||
*/
|
*/
|
||||||
if (layer_hsv.s)
|
if (layer_hsv[1])
|
||||||
{
|
out_hsv[0] = layer_hsv[0];
|
||||||
out_hsv.h = layer_hsv.h;
|
babl_process (babl_fish (babl_format ("HSV float"), babl_format ("R'G'B' float")),
|
||||||
}
|
out_hsv, out_rgb, 1);
|
||||||
gimp_hsv_to_rgb (&out_hsv, &out_rgb);
|
|
||||||
|
|
||||||
out_tmp[0] = out_rgb.r;
|
|
||||||
out_tmp[1] = out_rgb.g;
|
|
||||||
out_tmp[2] = out_rgb.b;
|
|
||||||
|
|
||||||
for (b = RED; b < ALPHA; b++)
|
for (b = RED; b < ALPHA; b++)
|
||||||
{
|
out[b] = out_rgb[b] * ratio + in[b] * (1.0f - ratio);
|
||||||
out[b] = out_tmp[b] * ratio + in[b] * (1.0f - ratio);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -84,9 +84,8 @@ gimp_operation_hsv_saturation_legacy_process (GeglOperation *op,
|
|||||||
|
|
||||||
while (samples--)
|
while (samples--)
|
||||||
{
|
{
|
||||||
GimpHSV layer_hsv, out_hsv;
|
gfloat layer_hsv[3], out_hsv[3];
|
||||||
GimpRGB layer_rgb = {layer[0], layer[1], layer[2]};
|
gfloat out_rgb[3];
|
||||||
GimpRGB out_rgb = {in[0], in[1], in[2]};
|
|
||||||
gfloat comp_alpha, new_alpha;
|
gfloat comp_alpha, new_alpha;
|
||||||
|
|
||||||
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
|
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
|
||||||
@@ -98,23 +97,19 @@ gimp_operation_hsv_saturation_legacy_process (GeglOperation *op,
|
|||||||
if (comp_alpha && new_alpha)
|
if (comp_alpha && new_alpha)
|
||||||
{
|
{
|
||||||
gint b;
|
gint b;
|
||||||
gfloat out_tmp[3];
|
|
||||||
gfloat ratio = comp_alpha / new_alpha;
|
gfloat ratio = comp_alpha / new_alpha;
|
||||||
|
|
||||||
gimp_rgb_to_hsv (&layer_rgb, &layer_hsv);
|
babl_process (babl_fish (babl_format ("R'G'B' float"), babl_format ("HSV float")),
|
||||||
gimp_rgb_to_hsv (&out_rgb, &out_hsv);
|
layer, layer_hsv, 1);
|
||||||
|
babl_process (babl_fish (babl_format ("R'G'B' float"), babl_format ("HSV float")),
|
||||||
|
in, out_hsv, 1);
|
||||||
|
|
||||||
out_hsv.s = layer_hsv.s;
|
out_hsv[1] = layer_hsv[1];
|
||||||
gimp_hsv_to_rgb (&out_hsv, &out_rgb);
|
babl_process (babl_fish (babl_format ("HSV float"), babl_format ("R'G'B' float")),
|
||||||
|
out_hsv, out_rgb, 1);
|
||||||
out_tmp[0] = out_rgb.r;
|
|
||||||
out_tmp[1] = out_rgb.g;
|
|
||||||
out_tmp[2] = out_rgb.b;
|
|
||||||
|
|
||||||
for (b = RED; b < ALPHA; b++)
|
for (b = RED; b < ALPHA; b++)
|
||||||
{
|
out[b] = out_rgb[b] * ratio + in[b] * (1.0f - ratio);
|
||||||
out[b] = out_tmp[b] * ratio + in[b] * (1.0f - ratio);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -84,9 +84,8 @@ gimp_operation_hsv_value_legacy_process (GeglOperation *op,
|
|||||||
|
|
||||||
while (samples--)
|
while (samples--)
|
||||||
{
|
{
|
||||||
GimpHSV layer_hsv, out_hsv;
|
gfloat layer_hsv[3], out_hsv[3];
|
||||||
GimpRGB layer_rgb = {layer[0], layer[1], layer[2]};
|
gfloat out_rgb[3];
|
||||||
GimpRGB out_rgb = {in[0], in[1], in[2]};
|
|
||||||
gfloat comp_alpha, new_alpha;
|
gfloat comp_alpha, new_alpha;
|
||||||
|
|
||||||
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
|
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
|
||||||
@@ -98,23 +97,19 @@ gimp_operation_hsv_value_legacy_process (GeglOperation *op,
|
|||||||
if (comp_alpha && new_alpha)
|
if (comp_alpha && new_alpha)
|
||||||
{
|
{
|
||||||
gint b;
|
gint b;
|
||||||
gfloat out_tmp[3];
|
|
||||||
gfloat ratio = comp_alpha / new_alpha;
|
gfloat ratio = comp_alpha / new_alpha;
|
||||||
|
|
||||||
gimp_rgb_to_hsv (&layer_rgb, &layer_hsv);
|
babl_process (babl_fish (babl_format ("R'G'B' float"), babl_format ("HSV float")),
|
||||||
gimp_rgb_to_hsv (&out_rgb, &out_hsv);
|
layer, layer_hsv, 1);
|
||||||
|
babl_process (babl_fish (babl_format ("R'G'B' float"), babl_format ("HSV float")),
|
||||||
|
in, out_hsv, 1);
|
||||||
|
|
||||||
out_hsv.v = layer_hsv.v;
|
out_hsv[2] = layer_hsv[2];
|
||||||
gimp_hsv_to_rgb (&out_hsv, &out_rgb);
|
babl_process (babl_fish (babl_format ("HSV float"), babl_format ("R'G'B' float")),
|
||||||
|
out_hsv, out_rgb, 1);
|
||||||
out_tmp[0] = out_rgb.r;
|
|
||||||
out_tmp[1] = out_rgb.g;
|
|
||||||
out_tmp[2] = out_rgb.b;
|
|
||||||
|
|
||||||
for (b = RED; b < ALPHA; b++)
|
for (b = RED; b < ALPHA; b++)
|
||||||
{
|
out[b] = out_rgb[b] * ratio + in[b] * (1.0f - ratio);
|
||||||
out[b] = out_tmp[b] * ratio + in[b] * (1.0f - ratio);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user