app: some more gegl_buffer_clear()/set_color() on mask objects

This commit is contained in:
Michael Natterer 2012-03-15 22:58:26 +01:00
parent d127e3ad35
commit 2a279f5e40
3 changed files with 24 additions and 19 deletions

View File

@ -43,8 +43,8 @@ gimp_channel_combine_rect (GimpChannel *mask,
gint w,
gint h)
{
PixelRegion maskPR;
guchar color;
GeglColor *color;
GeglRectangle rect;
g_return_if_fail (GIMP_IS_CHANNEL (mask));
@ -55,15 +55,19 @@ gimp_channel_combine_rect (GimpChannel *mask,
&x, &y, &w, &h))
return;
pixel_region_init (&maskPR, gimp_drawable_get_tiles (GIMP_DRAWABLE (mask)),
x, y, w, h, TRUE);
if (op == GIMP_CHANNEL_OP_ADD || op == GIMP_CHANNEL_OP_REPLACE)
color = OPAQUE_OPACITY;
color = gegl_color_new ("#fff");
else
color = TRANSPARENT_OPACITY;
color = gegl_color_new ("#000");
color_region (&maskPR, &color);
rect.x = x;
rect.y = y;
rect.width = w;
rect.height = h;
gegl_buffer_set_color (gimp_drawable_get_write_buffer (GIMP_DRAWABLE (mask)),
&rect, color);
g_object_unref (color);
/* Determine new boundary */
if (mask->bounds_known && (op == GIMP_CHANNEL_OP_ADD) && ! mask->empty)

View File

@ -1366,8 +1366,7 @@ static void
gimp_channel_real_all (GimpChannel *channel,
gboolean push_undo)
{
PixelRegion maskPR;
guchar bg = OPAQUE_OPACITY;
GeglColor *color;
if (push_undo)
gimp_channel_push_undo (channel,
@ -1376,12 +1375,10 @@ gimp_channel_real_all (GimpChannel *channel,
gimp_drawable_invalidate_boundary (GIMP_DRAWABLE (channel));
/* clear the channel */
pixel_region_init (&maskPR,
gimp_drawable_get_tiles (GIMP_DRAWABLE (channel)),
0, 0,
gimp_item_get_width (GIMP_ITEM (channel)),
gimp_item_get_height (GIMP_ITEM (channel)), TRUE);
color_region (&maskPR, &bg);
color = gegl_color_new ("#fff");
gegl_buffer_set_color (gimp_drawable_get_write_buffer (GIMP_DRAWABLE (channel)),
NULL, color);
g_object_unref (color);
/* we know the bounds */
channel->bounds_known = TRUE;

View File

@ -36,6 +36,8 @@
#include "paint-funcs/paint-funcs.h"
#include "gegl/gimp-gegl-utils.h"
#include "gimp.h"
#include "gimpbezierdesc.h"
#include "gimpchannel.h"
@ -290,7 +292,7 @@ gimp_drawable_stroke_scan_convert (GimpDrawable *drawable,
gint bytes;
gint off_x;
gint off_y;
guchar bg[1] = { 0, };
GeglBuffer *tmp_buffer;
PixelRegion maskPR;
PixelRegion basePR;
@ -343,8 +345,10 @@ gimp_drawable_stroke_scan_convert (GimpDrawable *drawable,
* of the stroke.
*/
mask = tile_manager_new (w, h, 1);
pixel_region_init (&maskPR, mask, 0, 0, w, h, TRUE);
color_region (&maskPR, bg);
tmp_buffer = gimp_tile_manager_create_buffer (mask, TRUE);
gegl_buffer_clear (tmp_buffer, NULL);
g_object_unref (tmp_buffer);
/* render the stroke into it */
gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);