mirror of https://github.com/GNOME/gimp.git
app: add a new gimp_gegl_combine_mask() which does what it says
which is combining two masks. Use it in gimp_drawable_real_replace_buffer() instead of gimp_gegl_apply_mask() which does the wrong thing.
This commit is contained in:
parent
5738c866a1
commit
dd9b132d8f
|
@ -331,9 +331,9 @@ gimp_drawable_real_replace_buffer (GimpDrawable *drawable,
|
|||
dest_buffer,
|
||||
GEGL_RECTANGLE (0, 0, 0, 0));
|
||||
|
||||
gimp_gegl_apply_mask (mask_buffer, mask_buffer_region,
|
||||
dest_buffer, GEGL_RECTANGLE (0, 0, width, height),
|
||||
1.0);
|
||||
gimp_gegl_combine_mask (mask_buffer, mask_buffer_region,
|
||||
dest_buffer, GEGL_RECTANGLE (0, 0, width, height),
|
||||
1.0);
|
||||
|
||||
gimp_gegl_replace (buffer,
|
||||
buffer_region,
|
||||
|
|
|
@ -424,6 +424,38 @@ gimp_gegl_apply_mask (GeglBuffer *mask_buffer,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_gegl_combine_mask (GeglBuffer *mask_buffer,
|
||||
const GeglRectangle *mask_rect,
|
||||
GeglBuffer *dest_buffer,
|
||||
const GeglRectangle *dest_rect,
|
||||
gdouble opacity)
|
||||
{
|
||||
GeglBufferIterator *iter;
|
||||
|
||||
iter = gegl_buffer_iterator_new (mask_buffer, mask_rect, 0,
|
||||
babl_format ("Y float"),
|
||||
GEGL_BUFFER_READ, GEGL_ABYSS_NONE);
|
||||
|
||||
gegl_buffer_iterator_add (iter, dest_buffer, dest_rect, 0,
|
||||
babl_format ("Y float"),
|
||||
GEGL_BUFFER_READWRITE, GEGL_ABYSS_NONE);
|
||||
|
||||
while (gegl_buffer_iterator_next (iter))
|
||||
{
|
||||
const gfloat *mask = iter->data[0];
|
||||
gfloat *dest = iter->data[1];
|
||||
|
||||
while (iter->length--)
|
||||
{
|
||||
*dest *= *mask * opacity;
|
||||
|
||||
mask += 1;
|
||||
dest += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_gegl_combine_mask_weird (GeglBuffer *mask_buffer,
|
||||
const GeglRectangle *mask_rect,
|
||||
|
|
|
@ -57,6 +57,12 @@ void gimp_gegl_apply_mask (GeglBuffer *mask_buffer,
|
|||
const GeglRectangle *dest_rect,
|
||||
gdouble opacity);
|
||||
|
||||
void gimp_gegl_combine_mask (GeglBuffer *mask_buffer,
|
||||
const GeglRectangle *mask_rect,
|
||||
GeglBuffer *dest_buffer,
|
||||
const GeglRectangle *dest_rect,
|
||||
gdouble opacity);
|
||||
|
||||
void gimp_gegl_combine_mask_weird (GeglBuffer *mask_buffer,
|
||||
const GeglRectangle *mask_rect,
|
||||
GeglBuffer *dest_buffer,
|
||||
|
|
Loading…
Reference in New Issue