[gimp/goat-invasion: 235/608] app: completely port GimpDrawable::apply_region()'s API to GeglBuffer
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion: 235/608] app: completely port GimpDrawable::apply_region()'s API to GeglBuffer
- Date: Fri, 27 Apr 2012 20:45:09 +0000 (UTC)
commit 334997762ff846f7c3569b3d1f9f96662bf31b41
Author: Michael Natterer <mitch gimp org>
Date: Sat Mar 24 00:57:11 2012 +0100
app: completely port GimpDrawable::apply_region()'s API to GeglBuffer
and pass lots of coords that were hidden inside PixelRegions
explicitly.
app/core/gimp-edit.c | 8 ++--
app/core/gimpchannel-project.c | 8 ++--
app/core/gimpchannel.c | 21 +++++++----
app/core/gimpdrawable-blend.c | 3 +-
app/core/gimpdrawable-bucket-fill.c | 3 +-
app/core/gimpdrawable-combine.c | 40 +++++++++++---------
app/core/gimpdrawable-combine.h | 8 +++--
app/core/gimpdrawable-shadow.c | 3 +-
app/core/gimpdrawable-stroke.c | 3 +-
app/core/gimpdrawable.c | 69 ++++++++++++++++-------------------
app/core/gimpdrawable.h | 18 ++++++----
app/core/gimpimagemap.c | 8 ++--
app/core/gimplayer-floating-sel.c | 5 ++-
app/core/gimplayer-project.c | 28 +++++++-------
app/paint/gimppaintcore.c | 2 +
15 files changed, 123 insertions(+), 104 deletions(-)
---
diff --git a/app/core/gimp-edit.c b/app/core/gimp-edit.c
index 2a347e8..6eb4107 100644
--- a/app/core/gimp-edit.c
+++ b/app/core/gimp-edit.c
@@ -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);
diff --git a/app/core/gimpchannel-project.c b/app/core/gimpchannel-project.c
index 98eea45..21a90ea 100644
--- a/app/core/gimpchannel-project.c
+++ b/app/core/gimpchannel-project.c
@@ -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);
}
diff --git a/app/core/gimpchannel.c b/app/core/gimpchannel.c
index fdee4cd..87e3ac2 100644
--- a/app/core/gimpchannel.c
+++ b/app/core/gimpchannel.c
@@ -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;
}
diff --git a/app/core/gimpdrawable-blend.c b/app/core/gimpdrawable-blend.c
index 022745c..6ce922b 100644
--- a/app/core/gimpdrawable-blend.c
+++ b/app/core/gimpdrawable-blend.c
@@ -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);
diff --git a/app/core/gimpdrawable-bucket-fill.c b/app/core/gimpdrawable-bucket-fill.c
index 7939a10..e1eb116 100644
--- a/app/core/gimpdrawable-bucket-fill.c
+++ b/app/core/gimpdrawable-bucket-fill.c
@@ -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);
diff --git a/app/core/gimpdrawable-combine.c b/app/core/gimpdrawable-combine.c
index 56512b9..3f4eb15 100644
--- a/app/core/gimpdrawable-combine.c
+++ b/app/core/gimpdrawable-combine.c
@@ -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,
diff --git a/app/core/gimpdrawable-combine.h b/app/core/gimpdrawable-combine.h
index 25e39a7..7541c18 100644
--- a/app/core/gimpdrawable-combine.h
+++ b/app/core/gimpdrawable-combine.h
@@ -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,
diff --git a/app/core/gimpdrawable-shadow.c b/app/core/gimpdrawable-shadow.c
index 78bcc72..bb89e3f 100644
--- a/app/core/gimpdrawable-shadow.c
+++ b/app/core/gimpdrawable-shadow.c
@@ -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);
}
diff --git a/app/core/gimpdrawable-stroke.c b/app/core/gimpdrawable-stroke.c
index 43bd3df..1e87092 100644
--- a/app/core/gimpdrawable-stroke.c
+++ b/app/core/gimpdrawable-stroke.c
@@ -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);
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index d5f6cbd..76d3cc0 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -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 *
diff --git a/app/core/gimpdrawable.h b/app/core/gimpdrawable.h
index f20b7a8..fe52a41 100644
--- a/app/core/gimpdrawable.h
+++ b/app/core/gimpdrawable.h
@@ -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,
diff --git a/app/core/gimpimagemap.c b/app/core/gimpimagemap.c
index 00fddf1..19296d0 100644
--- a/app/core/gimpimagemap.c
+++ b/app/core/gimpimagemap.c
@@ -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,
diff --git a/app/core/gimplayer-floating-sel.c b/app/core/gimplayer-floating-sel.c
index f09d33f..c883d1b 100644
--- a/app/core/gimplayer-floating-sel.c
+++ b/app/core/gimplayer-floating-sel.c
@@ -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);
diff --git a/app/core/gimplayer-project.c b/app/core/gimplayer-project.c
index 7b96a60..15397f0 100644
--- a/app/core/gimplayer-project.c
+++ b/app/core/gimplayer-project.c
@@ -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);
}
}
diff --git a/app/paint/gimppaintcore.c b/app/paint/gimppaintcore.c
index 99d3a08..948ea68 100644
--- a/app/paint/gimppaintcore.c
+++ b/app/paint/gimppaintcore.c
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]