[gimp/goat-invasion] app: turn GimpDrawable::apply_region() into ::apply_buffer()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion] app: turn GimpDrawable::apply_region() into ::apply_buffer()
- Date: Thu, 22 Mar 2012 22:47:14 +0000 (UTC)
commit 3c34e13ce3337405f69d1f5ddc6fdeecaf00fb32
Author: Michael Natterer <mitch gimp org>
Date: Thu Mar 22 23:45:11 2012 +0100
app: turn GimpDrawable::apply_region() into ::apply_buffer()
and GimpDrawableUndo.src2_tiles into applied_buffer.
app/actions/edit-actions.c | 2 +-
app/core/gimp-edit.c | 24 +++++--------
app/core/gimpchannel.c | 15 +++++---
app/core/gimpdrawable-combine.c | 68 ++++++++++++++++++++++++--------------
app/core/gimpdrawable-combine.h | 5 ++-
app/core/gimpdrawable.c | 51 +++--------------------------
app/core/gimpdrawable.h | 15 ++-------
app/core/gimpdrawableundo.c | 8 ++---
app/core/gimpdrawableundo.h | 2 +-
app/dialogs/fade-dialog.c | 2 +-
10 files changed, 78 insertions(+), 114 deletions(-)
---
diff --git a/app/actions/edit-actions.c b/app/actions/edit-actions.c
index a4b7fcb..627282c 100644
--- a/app/actions/edit-actions.c
+++ b/app/actions/edit-actions.c
@@ -315,7 +315,7 @@ edit_actions_update (GimpActionGroup *group,
undo = gimp_image_undo_get_fadeable (image);
if (GIMP_IS_DRAWABLE_UNDO (undo) &&
- GIMP_DRAWABLE_UNDO (undo)->src2_tiles)
+ GIMP_DRAWABLE_UNDO (undo)->applied_buffer)
{
fade_enabled = TRUE;
}
diff --git a/app/core/gimp-edit.c b/app/core/gimp-edit.c
index 106534b..2a347e8 100644
--- a/app/core/gimp-edit.c
+++ b/app/core/gimp-edit.c
@@ -27,9 +27,7 @@
#include "core-types.h"
-#include "base/pixel-region.h"
#include "base/temp-buf.h"
-#include "base/tile-manager.h"
#include "gegl/gimp-gegl-utils.h"
@@ -524,26 +522,22 @@ gimp_edit_fade (GimpImage *image,
undo = GIMP_DRAWABLE_UNDO (gimp_image_undo_get_fadeable (image));
- if (undo && undo->src2_tiles)
+ if (undo && undo->applied_buffer)
{
- GimpDrawable *drawable;
- TileManager *src2_tiles;
- PixelRegion src2PR;
+ GimpDrawable *drawable;
+ GeglBuffer *buffer;
drawable = GIMP_DRAWABLE (GIMP_ITEM_UNDO (undo)->item);
g_object_ref (undo);
- src2_tiles = tile_manager_ref (undo->src2_tiles);
+ buffer = g_object_ref (undo->applied_buffer);
gimp_image_undo (image);
- pixel_region_init (&src2PR, src2_tiles,
- 0, 0,
- gegl_buffer_get_width (undo->buffer),
- gegl_buffer_get_height (undo->buffer),
- FALSE);
-
- gimp_drawable_apply_region (drawable, &src2PR,
+ gimp_drawable_apply_buffer (drawable, buffer,
+ GIMP_GEGL_RECT (0, 0,
+ gegl_buffer_get_width (undo->buffer),
+ gegl_buffer_get_height (undo->buffer)),
TRUE,
gimp_object_get_name (undo),
gimp_context_get_opacity (context),
@@ -552,7 +546,7 @@ gimp_edit_fade (GimpImage *image,
undo->x,
undo->y);
- tile_manager_unref (src2_tiles);
+ g_object_unref (buffer);
g_object_unref (undo);
return TRUE;
diff --git a/app/core/gimpchannel.c b/app/core/gimpchannel.c
index 658d490..a7ef7a0 100644
--- a/app/core/gimpchannel.c
+++ b/app/core/gimpchannel.c
@@ -138,8 +138,9 @@ static void gimp_channel_invalidate_boundary (GimpDrawable *drawable);
static void gimp_channel_get_active_components (const GimpDrawable *drawable,
gboolean *active);
-static void gimp_channel_apply_region (GimpDrawable *drawable,
- PixelRegion *src2PR,
+static void gimp_channel_apply_buffer (GimpDrawable *drawable,
+ GeglBuffer *buffer,
+ const GeglRectangle *buffer_region,
gboolean push_undo,
const gchar *undo_desc,
gdouble opacity,
@@ -287,7 +288,7 @@ gimp_channel_class_init (GimpChannelClass *klass)
drawable_class->invalidate_boundary = gimp_channel_invalidate_boundary;
drawable_class->get_active_components = gimp_channel_get_active_components;
- drawable_class->apply_region = gimp_channel_apply_region;
+ drawable_class->apply_buffer = gimp_channel_apply_buffer;
drawable_class->replace_region = gimp_channel_replace_region;
drawable_class->project_region = gimp_channel_project_region;
drawable_class->set_buffer = gimp_channel_set_buffer;
@@ -804,8 +805,9 @@ gimp_channel_get_active_components (const GimpDrawable *drawable,
}
static void
-gimp_channel_apply_region (GimpDrawable *drawable,
- PixelRegion *src2PR,
+gimp_channel_apply_buffer (GimpDrawable *drawable,
+ GeglBuffer *buffer,
+ const GeglRectangle *buffer_region,
gboolean push_undo,
const gchar *undo_desc,
gdouble opacity,
@@ -817,7 +819,8 @@ gimp_channel_apply_region (GimpDrawable *drawable,
{
gimp_drawable_invalidate_boundary (drawable);
- GIMP_DRAWABLE_CLASS (parent_class)->apply_region (drawable, src2PR,
+ GIMP_DRAWABLE_CLASS (parent_class)->apply_buffer (drawable, buffer,
+ buffer_region,
push_undo, undo_desc,
opacity, mode,
src1_tiles, destPR,
diff --git a/app/core/gimpdrawable-combine.c b/app/core/gimpdrawable-combine.c
index 1e4f26c..af53343 100644
--- a/app/core/gimpdrawable-combine.c
+++ b/app/core/gimpdrawable-combine.c
@@ -26,6 +26,8 @@
#include "paint-funcs/paint-funcs.h"
+#include "gegl/gimp-gegl-utils.h"
+
#include "gimpchannel.h"
#include "gimpdrawable-combine.h"
#include "gimpdrawableundo.h"
@@ -34,8 +36,9 @@
void
-gimp_drawable_real_apply_region (GimpDrawable *drawable,
- PixelRegion *src2PR,
+gimp_drawable_real_apply_buffer (GimpDrawable *drawable,
+ GeglBuffer *buffer,
+ const GeglRectangle *buffer_region,
gboolean push_undo,
const gchar *undo_desc,
gdouble opacity,
@@ -48,12 +51,30 @@ gimp_drawable_real_apply_region (GimpDrawable *drawable,
GimpItem *item = GIMP_ITEM (drawable);
GimpImage *image = gimp_item_get_image (item);
GimpChannel *mask = gimp_image_get_mask (image);
+ TempBuf *temp_buf;
+ PixelRegion src2PR;
gint x1, y1, x2, y2;
gint offset_x, offset_y;
PixelRegion src1PR, my_destPR;
CombinationMode operation;
gboolean active_components[MAX_CHANNELS];
+ temp_buf = gimp_gegl_buffer_get_temp_buf (buffer);
+
+ if (temp_buf)
+ {
+ pixel_region_init_temp_buf (&src2PR, temp_buf,
+ buffer_region->x, buffer_region->y,
+ buffer_region->width, buffer_region->height);
+ }
+ else
+ {
+ pixel_region_init (&src2PR, gimp_gegl_buffer_get_tiles (buffer),
+ buffer_region->x, buffer_region->y,
+ buffer_region->width, buffer_region->height,
+ FALSE);
+ }
+
/* don't apply the mask to itself and don't apply an empty mask */
if (GIMP_DRAWABLE (mask) == drawable || gimp_channel_is_empty (mask))
mask = NULL;
@@ -65,7 +86,7 @@ gimp_drawable_real_apply_region (GimpDrawable *drawable,
* if it's actually legal...
*/
operation = gimp_image_get_combination_mode (gimp_drawable_type (drawable),
- src2PR->bytes);
+ src2PR.bytes);
if (operation == -1)
{
g_warning ("%s: illegal parameters.", G_STRFUNC);
@@ -76,10 +97,10 @@ gimp_drawable_real_apply_region (GimpDrawable *drawable,
gimp_item_get_offset (item, &offset_x, &offset_y);
/* make sure the image application coordinates are within drawable bounds */
- x1 = CLAMP (x, 0, gimp_item_get_width (item));
- y1 = CLAMP (y, 0, gimp_item_get_height (item));
- x2 = CLAMP (x + src2PR->w, 0, gimp_item_get_width (item));
- y2 = CLAMP (y + src2PR->h, 0, gimp_item_get_height (item));
+ x1 = CLAMP (x, 0, gimp_item_get_width (item));
+ y1 = CLAMP (y, 0, gimp_item_get_height (item));
+ x2 = CLAMP (x + src2PR.w, 0, gimp_item_get_width (item));
+ y2 = CLAMP (y + src2PR.h, 0, gimp_item_get_height (item));
if (mask)
{
@@ -109,23 +130,20 @@ gimp_drawable_real_apply_region (GimpDrawable *drawable,
if (undo)
{
- PixelRegion tmp_srcPR;
- PixelRegion tmp_destPR;
-
undo->paint_mode = mode;
undo->opacity = opacity;
- undo->src2_tiles = tile_manager_new (x2 - x1, y2 - y1,
- src2PR->bytes);
- tmp_srcPR = *src2PR;
- pixel_region_resize (&tmp_srcPR,
- src2PR->x + (x1 - x), src2PR->y + (y1 - y),
- x2 - x1, y2 - y1);
- pixel_region_init (&tmp_destPR, undo->src2_tiles,
- 0, 0,
- x2 - x1, y2 - y1, TRUE);
-
- copy_region (&tmp_srcPR, &tmp_destPR);
+ undo->applied_buffer =
+ gimp_gegl_buffer_new (GIMP_GEGL_RECT (0, 0, x2 - x1, y2 - y1),
+ gegl_buffer_get_format (buffer));
+
+ gegl_buffer_copy (buffer,
+ GIMP_GEGL_RECT (buffer_region->x + (x1 - x),
+ buffer_region->y + (y1 - y),
+ x2 - x1, y2 - y1),
+ undo->applied_buffer,
+ GIMP_GEGL_RECT (0, 0,
+ x2 - x1, y2 - y1));
}
}
@@ -158,8 +176,8 @@ gimp_drawable_real_apply_region (GimpDrawable *drawable,
destPR = &my_destPR;
}
- pixel_region_resize (src2PR,
- src2PR->x + (x1 - x), src2PR->y + (y1 - y),
+ pixel_region_resize (&src2PR,
+ src2PR.x + (x1 - x), src2PR.y + (y1 - y),
x2 - x1, y2 - y1);
if (mask)
@@ -173,7 +191,7 @@ gimp_drawable_real_apply_region (GimpDrawable *drawable,
x2 - x1, y2 - y1,
FALSE);
- combine_regions (&src1PR, src2PR, destPR, &maskPR, NULL,
+ combine_regions (&src1PR, &src2PR, destPR, &maskPR, NULL,
opacity * 255.999,
mode,
active_components,
@@ -181,7 +199,7 @@ gimp_drawable_real_apply_region (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 1b13e8a..5ff02bd 100644
--- a/app/core/gimpdrawable-combine.h
+++ b/app/core/gimpdrawable-combine.h
@@ -21,8 +21,9 @@
/* virtual functions of GimpDrawable, don't call directly */
-void gimp_drawable_real_apply_region (GimpDrawable *drawable,
- PixelRegion *src2PR,
+void gimp_drawable_real_apply_buffer (GimpDrawable *drawable,
+ GeglBuffer *buffer,
+ const GeglRectangle *buffer_region,
gboolean push_undo,
const gchar *undo_desc,
gdouble opacity,
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index 471a5cc..2ff55ce 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -239,7 +239,7 @@ gimp_drawable_class_init (GimpDrawableClass *klass)
klass->invalidate_boundary = NULL;
klass->get_active_components = NULL;
klass->convert_type = gimp_drawable_real_convert_type;
- klass->apply_region = gimp_drawable_real_apply_region;
+ klass->apply_buffer = gimp_drawable_real_apply_buffer;
klass->replace_region = gimp_drawable_real_replace_region;
klass->get_buffer = gimp_drawable_real_get_buffer;
klass->set_buffer = gimp_drawable_real_set_buffer;
@@ -1237,7 +1237,7 @@ gimp_drawable_convert_type (GimpDrawable *drawable,
void
gimp_drawable_apply_buffer (GimpDrawable *drawable,
GeglBuffer *buffer,
- const GeglRectangle *buffer_rect,
+ const GeglRectangle *buffer_region,
gboolean push_undo,
const gchar *undo_desc,
gdouble opacity,
@@ -1247,54 +1247,13 @@ gimp_drawable_apply_buffer (GimpDrawable *drawable,
gint x,
gint y)
{
- TempBuf *temp_buf;
- PixelRegion src2PR;
-
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_rect != NULL);
-
- temp_buf = gimp_gegl_buffer_get_temp_buf (buffer);
-
- if (temp_buf)
- {
- pixel_region_init_temp_buf (&src2PR, temp_buf,
- buffer_rect->x, buffer_rect->y,
- buffer_rect->width, buffer_rect->height);
- }
- else
- {
- pixel_region_init (&src2PR, gimp_gegl_buffer_get_tiles (buffer),
- buffer_rect->x, buffer_rect->y,
- buffer_rect->width, buffer_rect->height,
- FALSE);
- }
-
- GIMP_DRAWABLE_GET_CLASS (drawable)->apply_region (drawable, &src2PR,
- push_undo, undo_desc,
- opacity, mode,
- src1_tiles, destPR,
- x, y);
-}
-
-void
-gimp_drawable_apply_region (GimpDrawable *drawable,
- PixelRegion *src2PR,
- gboolean push_undo,
- const gchar *undo_desc,
- gdouble opacity,
- GimpLayerModeEffects mode,
- TileManager *src1_tiles,
- PixelRegion *destPR,
- gint x,
- gint y)
-{
- g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
- g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
- g_return_if_fail (src2PR != NULL);
+ g_return_if_fail (buffer_region != NULL);
- GIMP_DRAWABLE_GET_CLASS (drawable)->apply_region (drawable, src2PR,
+ GIMP_DRAWABLE_GET_CLASS (drawable)->apply_buffer (drawable, buffer,
+ buffer_region,
push_undo, undo_desc,
opacity, mode,
src1_tiles, destPR,
diff --git a/app/core/gimpdrawable.h b/app/core/gimpdrawable.h
index 5131612..9a8482c 100644
--- a/app/core/gimpdrawable.h
+++ b/app/core/gimpdrawable.h
@@ -63,8 +63,9 @@ struct _GimpDrawableClass
GimpImage *dest_image,
GimpImageBaseType new_base_type,
gboolean push_undo);
- void (* apply_region) (GimpDrawable *drawable,
- PixelRegion *src2PR,
+ void (* apply_buffer) (GimpDrawable *drawable,
+ GeglBuffer *buffer,
+ const GeglRectangle *buffer_region,
gboolean push_undo,
const gchar *undo_desc,
gdouble opacity,
@@ -151,16 +152,6 @@ void gimp_drawable_apply_buffer (GimpDrawable *drawable,
PixelRegion *destPR,
gint x,
gint y);
-void gimp_drawable_apply_region (GimpDrawable *drawable,
- PixelRegion *src2PR,
- gboolean push_undo,
- const gchar *undo_desc,
- gdouble opacity,
- GimpLayerModeEffects mode,
- TileManager *src1_tiles,
- PixelRegion *destPR,
- gint x,
- gint y);
void gimp_drawable_replace_region (GimpDrawable *drawable,
PixelRegion *src2PR,
gboolean push_undo,
diff --git a/app/core/gimpdrawableundo.c b/app/core/gimpdrawableundo.c
index d768d9e..0dbfd9b 100644
--- a/app/core/gimpdrawableundo.c
+++ b/app/core/gimpdrawableundo.c
@@ -23,8 +23,6 @@
#include "core-types.h"
-#include "base/tile-manager.h"
-
#include "gimp-utils.h"
#include "gimpimage.h"
#include "gimpdrawable.h"
@@ -209,10 +207,10 @@ gimp_drawable_undo_free (GimpUndo *undo,
drawable_undo->buffer = NULL;
}
- if (drawable_undo->src2_tiles)
+ if (drawable_undo->applied_buffer)
{
- tile_manager_unref (drawable_undo->src2_tiles);
- drawable_undo->src2_tiles = NULL;
+ g_object_unref (drawable_undo->applied_buffer);
+ drawable_undo->applied_buffer = NULL;
}
GIMP_UNDO_CLASS (parent_class)->free (undo, undo_mode);
diff --git a/app/core/gimpdrawableundo.h b/app/core/gimpdrawableundo.h
index aaf0717..d97a0d1 100644
--- a/app/core/gimpdrawableundo.h
+++ b/app/core/gimpdrawableundo.h
@@ -41,7 +41,7 @@ struct _GimpDrawableUndo
gint y;
/* stuff for "Fade" */
- TileManager *src2_tiles;
+ GeglBuffer *applied_buffer;
GimpLayerModeEffects paint_mode;
gdouble opacity;
};
diff --git a/app/dialogs/fade-dialog.c b/app/dialogs/fade-dialog.c
index de3111d..ffc0176 100644
--- a/app/dialogs/fade-dialog.c
+++ b/app/dialogs/fade-dialog.c
@@ -85,7 +85,7 @@ fade_dialog_new (GimpImage *image,
undo = GIMP_DRAWABLE_UNDO (gimp_image_undo_get_fadeable (image));
- if (! (undo && undo->src2_tiles))
+ if (! (undo && undo->applied_buffer))
return NULL;
item = GIMP_ITEM_UNDO (undo)->item;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]