Make luma_lighten/darken_only blend modes work in AnyRGB

This commit is contained in:
Elle Stone 2019-06-09 17:01:49 -04:00 committed by Øyvind Kolås
parent 4a20a75dc3
commit 65f85e7078
1 changed files with 31 additions and 10 deletions

View File

@ -815,6 +815,11 @@ gimp_operation_layer_mode_blend_luma_darken_only (GeglOperation *operation,
gfloat *comp,
gint samples)
{
const Babl *space = gegl_operation_get_source_space (operation, "input");
double red_luminance, green_luminance, blue_luminance;
babl_space_get_rgb_luminance (space,
&red_luminance, &green_luminance, &blue_luminance);
while (samples--)
{
if (in[ALPHA] != 0.0f && layer[ALPHA] != 0.0f)
@ -823,8 +828,13 @@ gimp_operation_layer_mode_blend_luma_darken_only (GeglOperation *operation,
gfloat src_luminance;
gint c;
dest_luminance = GIMP_RGB_LUMINANCE (in[0], in[1], in[2]);
src_luminance = GIMP_RGB_LUMINANCE (layer[0], layer[1], layer[2]);
dest_luminance = (in[0] * red_luminance) +
(in[1] * green_luminance) +
(in[2] * blue_luminance);
src_luminance = (layer[0] * red_luminance) +
(layer[1] * green_luminance) +
(layer[2] * blue_luminance);
if (dest_luminance <= src_luminance)
{
@ -853,6 +863,11 @@ gimp_operation_layer_mode_blend_luma_lighten_only (GeglOperation *operation,
gfloat *comp,
gint samples)
{
const Babl *space = gegl_operation_get_source_space (operation, "input");
double red_luminance, green_luminance, blue_luminance;
babl_space_get_rgb_luminance (space,
&red_luminance, &green_luminance, &blue_luminance);
while (samples--)
{
if (in[ALPHA] != 0.0f && layer[ALPHA] != 0.0f)
@ -861,8 +876,13 @@ gimp_operation_layer_mode_blend_luma_lighten_only (GeglOperation *operation,
gfloat src_luminance;
gint c;
dest_luminance = GIMP_RGB_LUMINANCE (in[0], in[1], in[2]);
src_luminance = GIMP_RGB_LUMINANCE (layer[0], layer[1], layer[2]);
dest_luminance = (in[0] * red_luminance) +
(in[1] * green_luminance) +
(in[2] * blue_luminance);
src_luminance = (layer[0] * red_luminance) +
(layer[1] * green_luminance) +
(layer[2] * blue_luminance);
if (dest_luminance >= src_luminance)
{
@ -891,10 +911,11 @@ gimp_operation_layer_mode_blend_luminance (GeglOperation *operation,
gfloat *comp,
gint samples)
{
const Babl *fish;
static const Babl *fish;
gfloat *scratch;
gfloat *in_Y;
gfloat *layer_Y;
const Babl *format = gegl_operation_get_source_format (operation, "input");
const Babl *space = gegl_operation_get_source_space (operation, "input");
fish = babl_fish (babl_format_with_space ("RGBA float", space),