gimp r26826 - in trunk: . app/base app/core app/paint-funcs
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26826 - in trunk: . app/base app/core app/paint-funcs
- Date: Mon, 1 Sep 2008 20:44:00 +0000 (UTC)
Author: neo
Date: Mon Sep 1 20:44:00 2008
New Revision: 26826
URL: http://svn.gnome.org/viewvc/gimp?rev=26826&view=rev
Log:
2008-09-01 Sven Neumann <sven gimp org>
* app/paint-funcs/paint-funcs.[ch]: added clear_region().
* app/base/tile-manager-crop.c
* app/core/gimpchannel.c
* app/core/gimpimage-merge.c
* app/core/gimpmaskundo.c
* app/core/gimpprojection-construct.c: use it instead of calling
color_region() with a zero color.
Modified:
trunk/ChangeLog
trunk/app/base/tile-manager-crop.c
trunk/app/core/gimpchannel.c
trunk/app/core/gimpimage-merge.c
trunk/app/core/gimpmaskundo.c
trunk/app/core/gimpprojection-construct.c
trunk/app/paint-funcs/paint-funcs.c
trunk/app/paint-funcs/paint-funcs.h
Modified: trunk/app/base/tile-manager-crop.c
==============================================================================
--- trunk/app/base/tile-manager-crop.c (original)
+++ trunk/app/base/tile-manager-crop.c Mon Sep 1 20:44:00 2008
@@ -35,14 +35,13 @@
tile_manager_crop (TileManager *tiles,
gint border)
{
- PixelRegion PR;
- TileManager *new_tiles;
- gint bytes, alpha;
- gint x1, y1, x2, y2;
- gboolean found;
- gboolean empty;
- gpointer pr;
- const guchar black[MAX_CHANNELS] = { 0, 0, 0, 0 };
+ PixelRegion region;
+ TileManager *new_tiles;
+ gint bytes, alpha;
+ gint x1, y1, x2, y2;
+ gboolean found;
+ gboolean empty;
+ gpointer pr;
g_return_val_if_fail (tiles != NULL, NULL);
@@ -55,22 +54,22 @@
x2 = 0;
y2 = 0;
- pixel_region_init (&PR, tiles, 0, 0, x1, y1, FALSE);
+ pixel_region_init (®ion, tiles, 0, 0, x1, y1, FALSE);
- for (pr = pixel_regions_register (1, &PR);
+ for (pr = pixel_regions_register (1, ®ion);
pr != NULL;
pr = pixel_regions_process (pr))
{
- const guchar *data = PR.data + alpha;
- gint ex = PR.x + PR.w;
- gint ey = PR.y + PR.h;
+ const guchar *data = region.data + alpha;
+ gint ex = region.x + region.w;
+ gint ey = region.y + region.h;
gint x, y;
- for (y = PR.y; y < ey; y++)
+ for (y = region.y; y < ey; y++)
{
found = FALSE;
- for (x = PR.x; x < ex; x++, data += bytes)
+ for (x = region.x; x < ex; x++, data += bytes)
if (*data)
{
if (x < x1)
@@ -129,22 +128,22 @@
pixel_region_init (&destPR, new_tiles,
0, 0, new_width, border,
TRUE);
- color_region (&destPR, black);
+ clear_region (&destPR);
pixel_region_init (&destPR, new_tiles,
0, border, border, (y2 - y1),
TRUE);
- color_region (&destPR, black);
+ clear_region (&destPR);
pixel_region_init (&destPR, new_tiles,
new_width - border, border, border, (y2 - y1),
TRUE);
- color_region (&destPR, black);
+ clear_region (&destPR);
pixel_region_init (&destPR, new_tiles,
0, new_height - border, new_width, border,
TRUE);
- color_region (&destPR, black);
+ clear_region (&destPR);
}
pixel_region_init (&srcPR, tiles,
Modified: trunk/app/core/gimpchannel.c
==============================================================================
--- trunk/app/core/gimpchannel.c (original)
+++ trunk/app/core/gimpchannel.c Mon Sep 1 20:44:00 2008
@@ -494,7 +494,6 @@
GimpChannel *tmp_mask = NULL;
gint width, height;
PixelRegion srcPR, destPR;
- guchar empty = TRANSPARENT_OPACITY;
gint x1, y1, x2, y2;
gimp_channel_bounds (channel, &x1, &y1, &x2, &y2);
@@ -539,7 +538,7 @@
0, 0,
gimp_item_width (GIMP_ITEM (channel)),
gimp_item_height (GIMP_ITEM (channel)), TRUE);
- color_region (&srcPR, &empty);
+ clear_region (&srcPR);
if (width != 0 && height != 0)
{
@@ -1195,7 +1194,6 @@
gboolean push_undo)
{
PixelRegion maskPR;
- guchar bg = TRANSPARENT_OPACITY;
if (push_undo)
{
@@ -1216,7 +1214,7 @@
channel->x1, channel->y1,
channel->x2 - channel->x1,
channel->y2 - channel->y1, TRUE);
- color_region (&maskPR, &bg);
+ clear_region (&maskPR);
}
else
{
@@ -1226,7 +1224,7 @@
0, 0,
gimp_item_width (GIMP_ITEM (channel)),
gimp_item_height (GIMP_ITEM (channel)), TRUE);
- color_region (&maskPR, &bg);
+ clear_region (&maskPR);
}
/* we know the bounds */
@@ -1247,7 +1245,6 @@
gboolean push_undo)
{
PixelRegion maskPR;
- guchar bg = OPAQUE_OPACITY;
if (push_undo)
gimp_channel_push_undo (channel,
@@ -1261,7 +1258,7 @@
0, 0,
gimp_item_width (GIMP_ITEM (channel)),
gimp_item_height (GIMP_ITEM (channel)), TRUE);
- color_region (&maskPR, &bg);
+ clear_region (&maskPR);
/* we know the bounds */
channel->bounds_known = TRUE;
Modified: trunk/app/core/gimpimage-merge.c
==============================================================================
--- trunk/app/core/gimpimage-merge.c (original)
+++ trunk/app/core/gimpimage-merge.c Mon Sep 1 20:44:00 2008
@@ -319,7 +319,6 @@
GimpLayer *merge_layer;
GimpLayer *layer;
GimpLayer *bottom_layer;
- guchar bg[4] = {0, 0, 0, 0};
GimpImageType type;
gint count;
gint x1, y1, x2, y2;
@@ -418,6 +417,8 @@
if (merge_type == GIMP_FLATTEN_IMAGE ||
gimp_drawable_type (GIMP_DRAWABLE (layer)) == GIMP_INDEXED_IMAGE)
{
+ guchar bg[4] = { 0, 0, 0, 0 };
+
type = GIMP_IMAGE_TYPE_FROM_BASE_TYPE (gimp_image_base_type (image));
merge_layer = gimp_layer_new (image, (x2 - x1), (y2 - y1),
@@ -471,15 +472,13 @@
GIMP_ITEM (merge_layer)->offset_x = x1;
GIMP_ITEM (merge_layer)->offset_y = y1;
- /* Set the layer to transparent */
+ /* clear the layer */
pixel_region_init (&src1PR,
gimp_drawable_get_tiles (GIMP_DRAWABLE (merge_layer)),
0, 0,
(x2 - x1), (y2 - y1),
TRUE);
-
- /* set the region to 0's */
- color_region (&src1PR, bg);
+ clear_region (&src1PR);
/* Find the index in the layer list of the bottom layer--we need this
* in order to add the final, merged layer to the layer list correctly
Modified: trunk/app/core/gimpmaskundo.c
==============================================================================
--- trunk/app/core/gimpmaskundo.c (original)
+++ trunk/app/core/gimpmaskundo.c Mon Sep 1 20:44:00 2008
@@ -139,8 +139,6 @@
if (gimp_channel_bounds (channel, &x1, &y1, &x2, &y2))
{
- guchar empty = 0;
-
new_tiles = tile_manager_new (x2 - x1, y2 - y1, 1);
pixel_region_init (&srcPR,
@@ -155,7 +153,7 @@
gimp_drawable_get_tiles (GIMP_DRAWABLE (channel)),
x1, y1, x2 - x1, y2 - y1, TRUE);
- color_region (&srcPR, &empty);
+ clear_region (&srcPR);
}
else
{
Modified: trunk/app/core/gimpprojection-construct.c
==============================================================================
--- trunk/app/core/gimpprojection-construct.c (original)
+++ trunk/app/core/gimpprojection-construct.c Mon Sep 1 20:44:00 2008
@@ -377,12 +377,11 @@
if (! coverage)
{
- PixelRegion PR;
- guchar clear[4] = { 0, 0, 0, 0 };
+ PixelRegion region;
- pixel_region_init (&PR, gimp_projection_get_tiles (proj),
- x, y, w, h, TRUE);
- color_region (&PR, clear);
+ pixel_region_init (®ion,
+ gimp_projection_get_tiles (proj), x, y, w, h, TRUE);
+ clear_region (®ion);
}
}
Modified: trunk/app/paint-funcs/paint-funcs.c
==============================================================================
--- trunk/app/paint-funcs/paint-funcs.c (original)
+++ trunk/app/paint-funcs/paint-funcs.c Mon Sep 1 20:44:00 2008
@@ -1886,6 +1886,35 @@
/**************************************************/
void
+clear_region (PixelRegion *dest)
+{
+ gpointer pr;
+
+ for (pr = pixel_regions_register (1, dest);
+ pr != NULL;
+ pr = pixel_regions_process (pr))
+ {
+ if (dest->w * dest->bytes == dest->rowstride)
+ {
+ memset (dest->data, 0, dest->w * dest->h * dest->bytes);
+ }
+ else
+ {
+ guchar *d = dest->data;
+ gint h = dest->h;
+
+ while (h--)
+ {
+ memset (d, 0, dest->w * dest->bytes);
+
+ d += dest->rowstride;
+ }
+ }
+ }
+}
+
+
+void
color_region (PixelRegion *dest,
const guchar *col)
{
Modified: trunk/app/paint-funcs/paint-funcs.h
==============================================================================
--- trunk/app/paint-funcs/paint-funcs.h (original)
+++ trunk/app/paint-funcs/paint-funcs.h Mon Sep 1 20:44:00 2008
@@ -339,6 +339,9 @@
/* Region functions */
+
+void clear_region (PixelRegion *dest);
+
void color_region (PixelRegion *dest,
const guchar *color);
void color_region_mask (PixelRegion *dest,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]