app: completely port GimpDrawable::apply_region()'s API to GeglBuffer

and pass lots of coords that were hidden inside PixelRegions
explicitly.
This commit is contained in:
Michael Natterer 2012-03-24 00:57:11 +01:00
parent bfd54a69b7
commit 7223af17a2
15 changed files with 123 additions and 104 deletions

View File

@ -502,7 +502,8 @@ gimp_edit_fill_full (GimpImage *image,
GIMP_GEGL_RECT (0, 0, width, height),
TRUE, undo_desc,
opacity, paint_mode,
NULL, NULL, x, y);
NULL, x, y,
NULL, x, y);
g_object_unref (dest_buffer);
@ -542,9 +543,8 @@ gimp_edit_fade (GimpImage *image,
gimp_object_get_name (undo),
gimp_context_get_opacity (context),
gimp_context_get_paint_mode (context),
NULL, NULL,
undo->x,
undo->y);
NULL, undo->x, undo->y,
NULL, undo->x, undo->y);
g_object_unref (buffer);
g_object_unref (undo);

View File

@ -46,7 +46,7 @@ gimp_channel_project_region (GimpDrawable *drawable,
{
GimpChannel *channel = GIMP_CHANNEL (drawable);
PixelRegion srcPR;
TileManager *temp_tiles;
GeglBuffer *temp_buffer;
guchar col[3];
guchar opacity;
@ -55,7 +55,7 @@ gimp_channel_project_region (GimpDrawable *drawable,
gimp_drawable_init_src_region (drawable, &srcPR,
x, y, width, height,
&temp_tiles);
&temp_buffer);
if (combine)
{
@ -78,6 +78,6 @@ gimp_channel_project_region (GimpDrawable *drawable,
INITIAL_CHANNEL_SELECTION));
}
if (temp_tiles)
tile_manager_unref (temp_tiles);
if (temp_buffer)
g_object_unref (temp_buffer);
}

View File

@ -146,9 +146,11 @@ static void gimp_channel_apply_buffer (GimpDrawable *drawable,
gdouble opacity,
GimpLayerModeEffects mode,
GeglBuffer *base_buffer,
PixelRegion *destPR,
gint x,
gint y);
gint base_x,
gint base_y,
GeglBuffer *dest_buffer,
gint dest_x,
gint dest_y);
static void gimp_channel_replace_buffer (GimpDrawable *drawable,
GeglBuffer *buffer,
const GeglRectangle *buffer_region,
@ -814,9 +816,11 @@ gimp_channel_apply_buffer (GimpDrawable *drawable,
gdouble opacity,
GimpLayerModeEffects mode,
GeglBuffer *base_buffer,
PixelRegion *destPR,
gint x,
gint y)
gint base_x,
gint base_y,
GeglBuffer *dest_buffer,
gint dest_x,
gint dest_y)
{
gimp_drawable_invalidate_boundary (drawable);
@ -825,8 +829,9 @@ gimp_channel_apply_buffer (GimpDrawable *drawable,
push_undo, undo_desc,
opacity, mode,
base_buffer,
destPR,
x, y);
base_x, base_y,
dest_buffer,
dest_x, dest_y);
GIMP_CHANNEL (drawable)->bounds_known = FALSE;
}

View File

@ -248,7 +248,8 @@ gimp_drawable_blend (GimpDrawable *drawable,
GIMP_GEGL_RECT (0, 0, width, height),
TRUE, C_("undo-type", "Blend"),
opacity, paint_mode,
NULL, NULL, x, y);
NULL, x, y,
NULL, x, y);
/* update the image */
gimp_drawable_update (drawable, x, y, width, height);

View File

@ -261,7 +261,8 @@ gimp_drawable_bucket_fill_internal (GimpDrawable *drawable,
GIMP_GEGL_RECT (0, 0, x2 - x1, y2 - y1),
TRUE, C_("undo-type", "Bucket Fill"),
opacity, paint_mode,
NULL, NULL, x1, y1);
NULL, x1, y2,
NULL, x1, y1);
g_object_unref (buffer);

View File

@ -46,7 +46,9 @@ gimp_drawable_real_apply_buffer (GimpDrawable *drawable,
gdouble opacity,
GimpLayerModeEffects mode,
GeglBuffer *base_buffer,
PixelRegion *destPR,
gint base_x,
gint base_y,
GeglBuffer *dest_buffer,
gint dest_x,
gint dest_y)
{
@ -54,10 +56,9 @@ gimp_drawable_real_apply_buffer (GimpDrawable *drawable,
GimpImage *image = gimp_item_get_image (item);
GimpChannel *mask = gimp_image_get_mask (image);
TempBuf *temp_buf;
PixelRegion src2PR;
PixelRegion src1PR, src2PR, destPR;
gint x, y, width, height;
gint offset_x, offset_y;
PixelRegion src1PR, my_destPR;
CombinationMode operation;
gboolean active_components[MAX_CHANNELS];
@ -102,7 +103,7 @@ gimp_drawable_real_apply_buffer (GimpDrawable *drawable,
gimp_item_get_offset (item, &offset_x, &offset_y);
/* make sure the image application coordinates are within drawable bounds */
gimp_rectangle_intersect (dest_x, dest_y, src2PR.w, src2PR.h,
gimp_rectangle_intersect (base_x, base_y, src2PR.w, src2PR.h,
0, 0,
gimp_item_get_width (item),
gimp_item_get_height (item),
@ -143,8 +144,8 @@ gimp_drawable_real_apply_buffer (GimpDrawable *drawable,
gegl_buffer_get_format (buffer));
gegl_buffer_copy (buffer,
GIMP_GEGL_RECT (buffer_region->x + (x - dest_x),
buffer_region->y + (y - dest_y),
GIMP_GEGL_RECT (buffer_region->x + (x - base_x),
buffer_region->y + (y - base_y),
width, height),
undo->applied_buffer,
GIMP_GEGL_RECT (0, 0, width, height));
@ -157,21 +158,24 @@ gimp_drawable_real_apply_buffer (GimpDrawable *drawable,
x, y, width, height,
FALSE);
/* check if an alternative to using the drawable's data as dest was
* provided...
*/
if (!destPR)
pixel_region_resize (&src2PR,
src2PR.x + (x - base_x), src2PR.y + (y - base_y),
width, height);
if (dest_buffer)
{
pixel_region_init (&my_destPR, gimp_drawable_get_tiles (drawable),
pixel_region_init (&destPR, gimp_gegl_buffer_get_tiles (dest_buffer),
dest_x, dest_y,
buffer_region->width, buffer_region->height,
TRUE);
}
else
{
pixel_region_init (&destPR, gimp_drawable_get_tiles (drawable),
x, y, width, height,
TRUE);
destPR = &my_destPR;
}
pixel_region_resize (&src2PR,
src2PR.x + (x - dest_x), src2PR.y + (y - dest_y),
width, height);
if (mask)
{
PixelRegion maskPR;
@ -183,7 +187,7 @@ gimp_drawable_real_apply_buffer (GimpDrawable *drawable,
width, height,
FALSE);
combine_regions (&src1PR, &src2PR, destPR, &maskPR, NULL,
combine_regions (&src1PR, &src2PR, &destPR, &maskPR, NULL,
opacity * 255.999,
mode,
active_components,
@ -191,7 +195,7 @@ gimp_drawable_real_apply_buffer (GimpDrawable *drawable,
}
else
{
combine_regions (&src1PR, &src2PR, destPR, NULL, NULL,
combine_regions (&src1PR, &src2PR, &destPR, NULL, NULL,
opacity * 255.999,
mode,
active_components,

View File

@ -29,9 +29,11 @@ void gimp_drawable_real_apply_buffer (GimpDrawable *drawable,
gdouble opacity,
GimpLayerModeEffects mode,
GeglBuffer *base_buffer,
PixelRegion *destPR,
gint x,
gint y);
gint base_x,
gint base_y,
GeglBuffer *dest_buffer,
gint dest_x,
gint dest_y);
void gimp_drawable_real_replace_buffer (GimpDrawable *drawable,
GeglBuffer *buffer,
const GeglRectangle *buffer_region,

View File

@ -103,7 +103,8 @@ gimp_drawable_merge_shadow_buffer (GimpDrawable *drawable,
GIMP_GEGL_RECT (x, y, width, height),
push_undo, undo_desc,
GIMP_OPACITY_OPAQUE, GIMP_REPLACE_MODE,
NULL, NULL, x, y);
NULL, x, y,
NULL, x, y);
g_object_unref (buffer);
}

View File

@ -397,7 +397,8 @@ gimp_drawable_stroke_scan_convert (GimpDrawable *drawable,
push_undo, C_("undo-type", "Render Stroke"),
gimp_context_get_opacity (context),
gimp_context_get_paint_mode (context),
NULL, NULL, x, y);
NULL, x, y,
NULL, x, y);
g_object_unref (base_buffer);

View File

@ -1243,23 +1243,27 @@ gimp_drawable_apply_buffer (GimpDrawable *drawable,
gdouble opacity,
GimpLayerModeEffects mode,
GeglBuffer *base_buffer,
PixelRegion *destPR,
gint x,
gint y)
gint base_x,
gint base_y,
GeglBuffer *dest_buffer,
gint dest_x,
gint dest_y)
{
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
g_return_if_fail (GEGL_IS_BUFFER (buffer));
g_return_if_fail (buffer_region != NULL);
g_return_if_fail (base_buffer == NULL || GEGL_IS_BUFFER (base_buffer));
g_return_if_fail (dest_buffer == NULL || GEGL_IS_BUFFER (dest_buffer));
GIMP_DRAWABLE_GET_CLASS (drawable)->apply_buffer (drawable, buffer,
buffer_region,
push_undo, undo_desc,
opacity, mode,
base_buffer,
destPR,
x, y);
base_x, base_y,
dest_buffer,
dest_x, dest_y);
}
void
@ -1310,14 +1314,14 @@ gimp_drawable_init_src_region (GimpDrawable *drawable,
gint y,
gint width,
gint height,
TileManager **temp_tiles)
GeglBuffer **temp_buffer)
{
GimpLayer *fs;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
g_return_if_fail (srcPR != NULL);
g_return_if_fail (temp_tiles != NULL);
g_return_if_fail (temp_buffer != NULL);
fs = gimp_drawable_get_floating_sel (drawable);
@ -1340,44 +1344,30 @@ gimp_drawable_init_src_region (GimpDrawable *drawable,
&combine_x, &combine_y,
&combine_width, &combine_height))
{
PixelRegion tempPR;
PixelRegion destPR;
gboolean lock_alpha = FALSE;
gboolean lock_alpha = FALSE;
/* a temporary buffer for the compisition of the drawable and
* its floating selection
*/
*temp_tiles = tile_manager_new (width, height,
gimp_drawable_bytes (drawable));
*temp_buffer = gimp_gegl_buffer_new (GIMP_GEGL_RECT (0, 0,
width, height),
gimp_drawable_get_format (drawable));
/* first, initialize the entire buffer with the drawable's
* contents
*/
pixel_region_init (&tempPR, gimp_drawable_get_tiles (drawable),
x, y, width, height,
FALSE);
pixel_region_init (&destPR, *temp_tiles,
0, 0, width, height,
TRUE);
copy_region (&tempPR, &destPR);
gegl_buffer_copy (gimp_drawable_get_buffer (drawable),
GIMP_GEGL_RECT (x, y, width, height),
*temp_buffer,
GIMP_GEGL_RECT (0, 0, 0, 0));
/* then, apply the floating selection onto the buffer just as
* we apply it onto the drawable when anchoring the floating
* selection
*/
pixel_region_init (&destPR, *temp_tiles,
combine_x - x - off_x,
combine_y - y - off_y,
combine_width, combine_height,
TRUE);
if (GIMP_IS_LAYER (drawable))
{
lock_alpha = gimp_layer_get_lock_alpha (GIMP_LAYER (drawable));
lock_alpha = (GIMP_IS_LAYER (drawable) &&
gimp_layer_get_lock_alpha (GIMP_LAYER (drawable)));
if (lock_alpha)
gimp_layer_set_lock_alpha (GIMP_LAYER (drawable), FALSE, FALSE);
}
if (lock_alpha)
gimp_layer_set_lock_alpha (GIMP_LAYER (drawable), FALSE, FALSE);
gimp_drawable_apply_buffer (drawable,
gimp_drawable_get_buffer (GIMP_DRAWABLE (fs)),
@ -1388,9 +1378,14 @@ gimp_drawable_init_src_region (GimpDrawable *drawable,
FALSE, NULL,
gimp_layer_get_opacity (fs),
gimp_layer_get_mode (fs),
NULL, &destPR,
NULL,
combine_x - off_x,
combine_y - off_y);
combine_y - off_y,
*temp_buffer,
combine_x - x - off_x,
combine_y - y - off_y);
gimp_gegl_buffer_refetch_tiles (*temp_buffer);
if (lock_alpha)
gimp_layer_set_lock_alpha (GIMP_LAYER (drawable), TRUE, FALSE);
@ -1398,7 +1393,7 @@ gimp_drawable_init_src_region (GimpDrawable *drawable,
/* finally, return a PixelRegion on the composited buffer instead
* of the drawable's tiles
*/
pixel_region_init (srcPR, *temp_tiles,
pixel_region_init (srcPR, gimp_gegl_buffer_get_tiles (*temp_buffer),
0, 0, width, height,
FALSE);
@ -1409,7 +1404,7 @@ gimp_drawable_init_src_region (GimpDrawable *drawable,
pixel_region_init (srcPR, gimp_drawable_get_tiles (drawable),
x, y, width, height,
FALSE);
*temp_tiles = NULL;
*temp_buffer = NULL;
}
GeglBuffer *

View File

@ -71,9 +71,11 @@ struct _GimpDrawableClass
gdouble opacity,
GimpLayerModeEffects mode,
GeglBuffer *base_buffer,
PixelRegion *destPR,
gint x,
gint y);
gint base_x,
gint base_y,
GeglBuffer *dest_buffer,
gint dest_x,
gint dest_y);
void (* replace_buffer) (GimpDrawable *drawable,
GeglBuffer *buffer,
const GeglRectangle *buffer_region,
@ -150,9 +152,11 @@ void gimp_drawable_apply_buffer (GimpDrawable *drawable,
gdouble opacity,
GimpLayerModeEffects mode,
GeglBuffer *base_buffer,
PixelRegion *destPR,
gint x,
gint y);
gint base_x,
gint base_y,
GeglBuffer *dest_buffer,
gint dest_x,
gint dest_y);
void gimp_drawable_replace_buffer (GimpDrawable *drawable,
GeglBuffer *buffer,
const GeglRectangle *buffer_region,
@ -175,7 +179,7 @@ void gimp_drawable_init_src_region (GimpDrawable *drawable,
gint y,
gint width,
gint height,
TileManager **temp_tiles);
GeglBuffer **temp_buffer);
GeglBuffer * gimp_drawable_get_buffer (GimpDrawable *drawable);
void gimp_drawable_set_buffer (GimpDrawable *drawable,

View File

@ -775,8 +775,8 @@ gimp_image_map_do (GimpImageMap *image_map)
GIMP_GEGL_RECT (x, y, w, h),
FALSE, NULL,
GIMP_OPACITY_OPAQUE, GIMP_REPLACE_MODE,
NULL, NULL,
x, y);
NULL, x, y,
NULL, x, y);
gimp_drawable_update (image_map->drawable, x, y, w, h);
@ -837,8 +837,8 @@ gimp_image_map_data_written (GObject *operation,
extent->width, extent->height),
FALSE, NULL,
GIMP_OPACITY_OPAQUE, GIMP_REPLACE_MODE,
NULL, NULL,
extent->x, extent->y);
NULL, extent->x, extent->y,
NULL, extent->x, extent->y);
gimp_drawable_update (image_map->drawable,
extent->x, extent->y,

View File

@ -336,7 +336,10 @@ floating_sel_composite (GimpLayer *layer)
TRUE, NULL,
gimp_layer_get_opacity (layer),
gimp_layer_get_mode (layer),
NULL, NULL,
NULL,
combine_x - dr_off_x,
combine_y - dr_off_y,
NULL,
combine_x - dr_off_x,
combine_y - dr_off_y);

View File

@ -51,16 +51,16 @@ gimp_layer_project_region (GimpDrawable *drawable,
/* If we're showing the layer mask instead of the layer... */
PixelRegion srcPR;
TileManager *temp_tiles;
GeglBuffer *temp_buffer;
gimp_drawable_init_src_region (GIMP_DRAWABLE (mask), &srcPR,
x, y, width, height,
&temp_tiles);
&temp_buffer);
copy_gray_to_region (&srcPR, projPR);
if (temp_tiles)
tile_manager_unref (temp_tiles);
if (temp_buffer)
g_object_unref (temp_buffer);
}
else
{
@ -69,23 +69,23 @@ gimp_layer_project_region (GimpDrawable *drawable,
GimpImage *image = gimp_item_get_image (GIMP_ITEM (layer));
PixelRegion srcPR;
PixelRegion maskPR;
PixelRegion *mask_pr = NULL;
const guchar *colormap = NULL;
TileManager *temp_mask_tiles = NULL;
TileManager *temp_layer_tiles = NULL;
PixelRegion *mask_pr = NULL;
const guchar *colormap = NULL;
GeglBuffer *temp_mask_buffer = NULL;
GeglBuffer *temp_layer_buffer = NULL;
InitialMode initial_mode;
CombinationMode combination_mode;
gboolean visible[MAX_CHANNELS];
gimp_drawable_init_src_region (drawable, &srcPR,
x, y, width, height,
&temp_layer_tiles);
&temp_layer_buffer);
if (mask && gimp_layer_get_apply_mask (layer))
{
gimp_drawable_init_src_region (GIMP_DRAWABLE (mask), &maskPR,
x, y, width, height,
&temp_mask_tiles);
&temp_mask_buffer);
mask_pr = &maskPR;
}
@ -144,10 +144,10 @@ gimp_layer_project_region (GimpDrawable *drawable,
initial_mode);
}
if (temp_layer_tiles)
tile_manager_unref (temp_layer_tiles);
if (temp_layer_buffer)
g_object_unref (temp_layer_buffer);
if (temp_mask_tiles)
tile_manager_unref (temp_mask_tiles);
if (temp_mask_buffer)
g_object_unref (temp_mask_buffer);
}
}

View File

@ -933,6 +933,8 @@ gimp_paint_core_paste (GimpPaintCore *core,
FALSE, NULL,
image_opacity, paint_mode,
base_buffer, /* specify an alternative src1 */
core->canvas_buf->x,
core->canvas_buf->y,
NULL,
core->canvas_buf->x,
core->canvas_buf->y);