[gimp/goat-invasion: 331/401] app: replace GimpPaintCore->canvas_buf by a GeglBuffer
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion: 331/401] app: replace GimpPaintCore->canvas_buf by a GeglBuffer
- Date: Mon, 2 Apr 2012 12:15:57 +0000 (UTC)
commit 68420aec394720153884df9acbf9b8c6956a7de8
Author: Michael Natterer <mitch gimp org>
Date: Fri Mar 30 16:38:52 2012 +0200
app: replace GimpPaintCore->canvas_buf by a GeglBuffer
app/paint/gimpink.c | 14 +++----
app/paint/gimppaintcore.c | 83 ++++++++++++---------------------------------
app/paint/gimppaintcore.h | 8 +----
3 files changed, 29 insertions(+), 76 deletions(-)
---
diff --git a/app/paint/gimpink.c b/app/paint/gimpink.c
index 43f26dd..ecabda9 100644
--- a/app/paint/gimpink.c
+++ b/app/paint/gimpink.c
@@ -30,6 +30,8 @@
#include "paint-funcs/paint-funcs.h"
+#include "gegl/gimp-gegl-utils.h"
+
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimpimage-undo.h"
@@ -307,14 +309,9 @@ gimp_ink_motion (GimpPaintCore *paint_core,
color_pixels (temp_buf_get_data (paint_core->canvas_buf), col,
area->width * area->height, area->bytes);
- gimp_paint_core_validate_canvas_tiles (paint_core,
- paint_core->canvas_buf->x,
- paint_core->canvas_buf->y,
- paint_core->canvas_buf->width,
- paint_core->canvas_buf->height);
-
/* draw the blob directly to the canvas_tiles */
- pixel_region_init (&blob_maskPR, paint_core->canvas_tiles,
+ pixel_region_init (&blob_maskPR,
+ gimp_gegl_buffer_get_tiles (paint_core->canvas_buffer),
paint_core->canvas_buf->x,
paint_core->canvas_buf->y,
paint_core->canvas_buf->width,
@@ -324,7 +321,8 @@ gimp_ink_motion (GimpPaintCore *paint_core,
render_blob (blob_to_render, &blob_maskPR);
/* draw the canvas_buf using the just rendered canvas_tiles as mask */
- pixel_region_init (&blob_maskPR, paint_core->canvas_tiles,
+ pixel_region_init (&blob_maskPR,
+ gimp_gegl_buffer_get_tiles (paint_core->canvas_buffer),
paint_core->canvas_buf->x,
paint_core->canvas_buf->y,
paint_core->canvas_buf->width,
diff --git a/app/paint/gimppaintcore.c b/app/paint/gimppaintcore.c
index 9f35f3a..295b5ef 100644
--- a/app/paint/gimppaintcore.c
+++ b/app/paint/gimppaintcore.c
@@ -28,8 +28,6 @@
#include "base/pixel-region.h"
#include "base/temp-buf.h"
-#include "base/tile-manager.h"
-#include "base/tile.h"
#include "paint-funcs/paint-funcs.h"
@@ -385,12 +383,15 @@ gimp_paint_core_start (GimpPaintCore *core,
}
/* Allocate the canvas blocks structure */
- if (core->canvas_tiles)
- tile_manager_unref (core->canvas_tiles);
+ if (core->canvas_buffer)
+ g_object_unref (core->canvas_buffer);
- core->canvas_tiles = tile_manager_new (gimp_item_get_width (item),
- gimp_item_get_height (item),
- 1);
+ core->canvas_buffer =
+ gimp_gegl_buffer_new (GIMP_GEGL_RECT (0, 0,
+ gimp_item_get_width (item),
+ gimp_item_get_height (item)),
+ babl_format ("Y u8"));
+ gegl_buffer_clear (core->canvas_buffer, NULL);
/* Get the initial undo extents */
@@ -541,10 +542,10 @@ gimp_paint_core_cleanup (GimpPaintCore *core)
core->saved_proj_buffer = NULL;
}
- if (core->canvas_tiles)
+ if (core->canvas_buffer)
{
- tile_manager_unref (core->canvas_tiles);
- core->canvas_tiles = NULL;
+ g_object_unref (core->canvas_buffer);
+ core->canvas_buffer = NULL;
}
if (core->orig_buf)
@@ -812,15 +813,9 @@ gimp_paint_core_paste (GimpPaintCore *core,
/* Some tools (ink) paint the mask to paint_core->canvas_tiles
* directly. Don't need to copy it in this case.
*/
- if (paint_maskPR->tiles != core->canvas_tiles)
+ if (paint_maskPR->tiles !=
+ gimp_gegl_buffer_get_tiles (core->canvas_buffer))
{
- /* initialize any invalid canvas tiles */
- gimp_paint_core_validate_canvas_tiles (core,
- core->canvas_buf->x,
- core->canvas_buf->y,
- core->canvas_buf->width,
- core->canvas_buf->height);
-
paint_mask_to_canvas_tiles (core, paint_maskPR, paint_opacity);
}
@@ -900,23 +895,18 @@ gimp_paint_core_replace (GimpPaintCore *core,
if (mode == GIMP_PAINT_CONSTANT)
{
- /* Some tools (ink) paint the mask to paint_core->canvas_tiles
+ /* Some tools (ink) paint the mask to paint_core->canvas_buffer
* directly. Don't need to copy it in this case.
*/
- if (paint_maskPR->tiles != core->canvas_tiles)
+ if (paint_maskPR->tiles !=
+ gimp_gegl_buffer_get_tiles (core->canvas_buffer))
{
- /* initialize any invalid canvas tiles */
- gimp_paint_core_validate_canvas_tiles (core,
- core->canvas_buf->x,
- core->canvas_buf->y,
- core->canvas_buf->width,
- core->canvas_buf->height);
-
/* combine the paint mask and the canvas tiles */
paint_mask_to_canvas_tiles (core, paint_maskPR, paint_opacity);
/* initialize the maskPR from the canvas tiles */
- pixel_region_init (paint_maskPR, core->canvas_tiles,
+ pixel_region_init (paint_maskPR,
+ gimp_gegl_buffer_get_tiles (core->canvas_buffer),
core->canvas_buf->x,
core->canvas_buf->y,
core->canvas_buf->width,
@@ -1042,7 +1032,8 @@ canvas_tiles_to_canvas_buf (GimpPaintCore *core)
core->canvas_buf->width,
core->canvas_buf->height);
- pixel_region_init (&maskPR, core->canvas_tiles,
+ pixel_region_init (&maskPR,
+ gimp_gegl_buffer_get_tiles (core->canvas_buffer),
core->canvas_buf->x,
core->canvas_buf->y,
core->canvas_buf->width,
@@ -1061,7 +1052,8 @@ paint_mask_to_canvas_tiles (GimpPaintCore *core,
PixelRegion srcPR;
/* combine the paint mask and the canvas tiles */
- pixel_region_init (&srcPR, core->canvas_tiles,
+ pixel_region_init (&srcPR,
+ gimp_gegl_buffer_get_tiles (core->canvas_buffer),
core->canvas_buf->x,
core->canvas_buf->y,
core->canvas_buf->width,
@@ -1089,34 +1081,3 @@ paint_mask_to_canvas_buf (GimpPaintCore *core,
/* apply the mask */
apply_mask_to_region (&srcPR, paint_maskPR, paint_opacity * 255.999);
}
-
-void
-gimp_paint_core_validate_canvas_tiles (GimpPaintCore *core,
- gint x,
- gint y,
- gint w,
- gint h)
-{
- gint i, j;
-
- g_return_if_fail (GIMP_IS_PAINT_CORE (core));
- g_return_if_fail (core->canvas_tiles != NULL);
-
- for (i = y; i < (y + h); i += (TILE_HEIGHT - (i % TILE_HEIGHT)))
- {
- for (j = x; j < (x + w); j += (TILE_WIDTH - (j % TILE_WIDTH)))
- {
- Tile *tile = tile_manager_get_tile (core->canvas_tiles, j, i,
- FALSE, FALSE);
-
- if (! tile_is_valid (tile))
- {
- tile = tile_manager_get_tile (core->canvas_tiles, j, i,
- TRUE, TRUE);
- memset (tile_data_pointer (tile, 0, 0), 0, tile_size (tile));
- tile_release (tile, TRUE);
- }
- }
- }
-}
-
diff --git a/app/paint/gimppaintcore.h b/app/paint/gimppaintcore.h
index 3c3f782..cbdb2d1 100644
--- a/app/paint/gimppaintcore.h
+++ b/app/paint/gimppaintcore.h
@@ -57,7 +57,7 @@ struct _GimpPaintCore
GeglBuffer *undo_buffer; /* pixels which have been modified */
GeglBuffer *saved_proj_buffer; /* proj tiles which have been modified */
- TileManager *canvas_tiles; /* the buffer to paint the mask to */
+ GeglBuffer *canvas_buffer; /* the buffer to paint the mask to */
TempBuf *orig_buf; /* the unmodified drawable pixels */
TempBuf *orig_proj_buf; /* the unmodified projection pixels */
@@ -184,12 +184,6 @@ void gimp_paint_core_replace (GimpPaintCore *core,
gdouble image_opacity,
GimpPaintApplicationMode mode);
-void gimp_paint_core_validate_canvas_tiles (GimpPaintCore *core,
- gint x,
- gint y,
- gint w,
- gint h);
-
void gimp_paint_core_smooth_coords (GimpPaintCore *core,
GimpPaintOptions *paint_options,
GimpCoords *coords);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]