1
1
mirror of https://gitlab.gnome.org/GNOME/gimp.git synced 2025-10-06 09:32:41 +02:00

app: layer layer modes to use babl conversions directly.

This commit is contained in:
Jehan
2023-12-24 00:38:52 +09:00
parent 95ac889f6c
commit 02546da780
4 changed files with 49 additions and 68 deletions

View File

@@ -84,10 +84,9 @@ gimp_operation_hsl_color_legacy_process (GeglOperation *op,
while (samples--)
{
GimpHSL layer_hsl, out_hsl;
GimpRGB layer_rgb = {layer[0], layer[1], layer[2]};
GimpRGB out_rgb = {in[0], in[1], in[2]};
gfloat comp_alpha, new_alpha;
gfloat layer_hsl[3], out_hsl[3];
gfloat out_rgb[3];
gfloat comp_alpha, new_alpha;
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
if (mask)
@@ -98,24 +97,23 @@ gimp_operation_hsl_color_legacy_process (GeglOperation *op,
if (comp_alpha && new_alpha)
{
gint b;
gfloat out_tmp[3];
gfloat ratio = comp_alpha / new_alpha;
gimp_rgb_to_hsl (&layer_rgb, &layer_hsl);
gimp_rgb_to_hsl (&out_rgb, &out_hsl);
/* TODO: shouldn't these conversions be processed in image space, or
* 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.s = layer_hsl.s;
gimp_hsl_to_rgb (&out_hsl, &out_rgb);
out_tmp[0] = out_rgb.r;
out_tmp[1] = out_rgb.g;
out_tmp[2] = out_rgb.b;
out_hsl[0] = layer_hsl[0];
out_hsl[1] = layer_hsl[1];
babl_process (babl_fish (babl_format ("HSL float"), babl_format ("R'G'B' float")),
out_hsl, out_rgb, 1);
for (b = RED; b < ALPHA; b++)
{
out[b] = out_tmp[b] * ratio + in[b] * (1.0f - ratio);
}
out[b] = out_rgb[b] * ratio + in[b] * (1.0f - ratio);
}
else
{

View File

@@ -84,10 +84,9 @@ gimp_operation_hsv_hue_legacy_process (GeglOperation *op,
while (samples--)
{
GimpHSV layer_hsv, out_hsv;
GimpRGB layer_rgb = {layer[0], layer[1], layer[2]};
GimpRGB out_rgb = {in[0], in[1], in[2]};
gfloat comp_alpha, new_alpha;
gfloat layer_hsv[3], out_hsv[3];
gfloat out_rgb[3];
gfloat comp_alpha, new_alpha;
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
if (mask)
@@ -98,29 +97,23 @@ gimp_operation_hsv_hue_legacy_process (GeglOperation *op,
if (comp_alpha && new_alpha)
{
gint b;
gfloat out_tmp[3];
gfloat ratio = comp_alpha / new_alpha;
gimp_rgb_to_hsv (&layer_rgb, &layer_hsv);
gimp_rgb_to_hsv (&out_rgb, &out_hsv);
babl_process (babl_fish (babl_format ("R'G'B' float"), babl_format ("HSV float")),
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.
* otherwise, black would be painted red (see bug #123296).
*/
if (layer_hsv.s)
{
out_hsv.h = layer_hsv.h;
}
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;
if (layer_hsv[1])
out_hsv[0] = layer_hsv[0];
babl_process (babl_fish (babl_format ("HSV float"), babl_format ("R'G'B' float")),
out_hsv, out_rgb, 1);
for (b = RED; b < ALPHA; b++)
{
out[b] = out_tmp[b] * ratio + in[b] * (1.0f - ratio);
}
out[b] = out_rgb[b] * ratio + in[b] * (1.0f - ratio);
}
else
{

View File

@@ -84,10 +84,9 @@ gimp_operation_hsv_saturation_legacy_process (GeglOperation *op,
while (samples--)
{
GimpHSV layer_hsv, out_hsv;
GimpRGB layer_rgb = {layer[0], layer[1], layer[2]};
GimpRGB out_rgb = {in[0], in[1], in[2]};
gfloat comp_alpha, new_alpha;
gfloat layer_hsv[3], out_hsv[3];
gfloat out_rgb[3];
gfloat comp_alpha, new_alpha;
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
if (mask)
@@ -98,23 +97,19 @@ gimp_operation_hsv_saturation_legacy_process (GeglOperation *op,
if (comp_alpha && new_alpha)
{
gint b;
gfloat out_tmp[3];
gfloat ratio = comp_alpha / new_alpha;
gimp_rgb_to_hsv (&layer_rgb, &layer_hsv);
gimp_rgb_to_hsv (&out_rgb, &out_hsv);
babl_process (babl_fish (babl_format ("R'G'B' float"), babl_format ("HSV float")),
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;
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;
out_hsv[1] = layer_hsv[1];
babl_process (babl_fish (babl_format ("HSV float"), babl_format ("R'G'B' float")),
out_hsv, out_rgb, 1);
for (b = RED; b < ALPHA; b++)
{
out[b] = out_tmp[b] * ratio + in[b] * (1.0f - ratio);
}
out[b] = out_rgb[b] * ratio + in[b] * (1.0f - ratio);
}
else
{

View File

@@ -84,10 +84,9 @@ gimp_operation_hsv_value_legacy_process (GeglOperation *op,
while (samples--)
{
GimpHSV layer_hsv, out_hsv;
GimpRGB layer_rgb = {layer[0], layer[1], layer[2]};
GimpRGB out_rgb = {in[0], in[1], in[2]};
gfloat comp_alpha, new_alpha;
gfloat layer_hsv[3], out_hsv[3];
gfloat out_rgb[3];
gfloat comp_alpha, new_alpha;
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
if (mask)
@@ -98,23 +97,19 @@ gimp_operation_hsv_value_legacy_process (GeglOperation *op,
if (comp_alpha && new_alpha)
{
gint b;
gfloat out_tmp[3];
gfloat ratio = comp_alpha / new_alpha;
gimp_rgb_to_hsv (&layer_rgb, &layer_hsv);
gimp_rgb_to_hsv (&out_rgb, &out_hsv);
babl_process (babl_fish (babl_format ("R'G'B' float"), babl_format ("HSV float")),
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;
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;
out_hsv[2] = layer_hsv[2];
babl_process (babl_fish (babl_format ("HSV float"), babl_format ("R'G'B' float")),
out_hsv, out_rgb, 1);
for (b = RED; b < ALPHA; b++)
{
out[b] = out_tmp[b] * ratio + in[b] * (1.0f - ratio);
}
out[b] = out_rgb[b] * ratio + in[b] * (1.0f - ratio);
}
else
{