[gimp/goat-invasion: 250/418] app: remove thin_region(), turns out that gimp:shrink was not slow after all
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion: 250/418] app: remove thin_region(), turns out that gimp:shrink was not slow after all
- Date: Wed, 4 Apr 2012 10:46:48 +0000 (UTC)
commit 20feaf8148203a6fdda49dfb1fcb9ad0ceb102ce
Author: Michael Natterer <mitch gimp org>
Date: Sun Mar 25 23:20:03 2012 +0200
app: remove thin_region(), turns out that gimp:shrink was not slow after all
app/core/gimpchannel.c | 40 +++------
app/paint-funcs/paint-funcs.c | 180 -----------------------------------------
app/paint-funcs/paint-funcs.h | 5 -
3 files changed, 13 insertions(+), 212 deletions(-)
---
diff --git a/app/core/gimpchannel.c b/app/core/gimpchannel.c
index a3174b2..623e90c 100644
--- a/app/core/gimpchannel.c
+++ b/app/core/gimpchannel.c
@@ -1540,6 +1540,7 @@ gimp_channel_real_shrink (GimpChannel *channel,
gboolean edge_lock,
gboolean push_undo)
{
+ GeglNode *shrink;
gint x1, y1, x2, y2;
if (radius_x == 0 && radius_y == 0)
@@ -1575,35 +1576,20 @@ gimp_channel_real_shrink (GimpChannel *channel,
else
gimp_drawable_invalidate_boundary (GIMP_DRAWABLE (channel));
- if (gimp_use_gegl (gimp_item_get_image (GIMP_ITEM (channel))->gimp))
- {
- GeglNode *shrink;
-
- shrink = gegl_node_new_child (NULL,
- "operation", "gimp:shrink",
- "radius-x", radius_x,
- "radius-y", radius_y,
- "edge-lock", edge_lock,
- NULL);
-
- gimp_apply_operation (gimp_drawable_get_buffer (GIMP_DRAWABLE (channel)),
- NULL, NULL,
- shrink,
- gimp_drawable_get_buffer (GIMP_DRAWABLE (channel)),
- NULL);
-
- g_object_unref (shrink);
- }
- else
- {
- PixelRegion bPR;
+ shrink = gegl_node_new_child (NULL,
+ "operation", "gimp:shrink",
+ "radius-x", radius_x,
+ "radius-y", radius_y,
+ "edge-lock", edge_lock,
+ NULL);
- pixel_region_init (&bPR,
- gimp_drawable_get_tiles (GIMP_DRAWABLE (channel)),
- x1, y1, (x2 - x1), (y2 - y1), TRUE);
+ gimp_apply_operation (gimp_drawable_get_buffer (GIMP_DRAWABLE (channel)),
+ NULL, NULL,
+ shrink,
+ gimp_drawable_get_buffer (GIMP_DRAWABLE (channel)),
+ NULL);
- thin_region (&bPR, radius_x, radius_y, edge_lock);
- }
+ g_object_unref (shrink);
channel->bounds_known = FALSE;
diff --git a/app/paint-funcs/paint-funcs.c b/app/paint-funcs/paint-funcs.c
index c998226..97a605c 100644
--- a/app/paint-funcs/paint-funcs.c
+++ b/app/paint-funcs/paint-funcs.c
@@ -2240,186 +2240,6 @@ fatten_region (PixelRegion *region,
g_free (out);
}
-void
-thin_region (PixelRegion *region,
- gint16 xradius,
- gint16 yradius,
- gboolean edge_lock)
-{
- /*
- pretty much the same as fatten_region only different
- blame all bugs in this function on jaycox gimp org
- */
- /* If edge_lock is true we assume that pixels outside the region
- we are passed are identical to the edge pixels.
- If edge_lock is false, we assume that pixels outside the region are 0
- */
- register gint32 i, j, x, y;
- guchar **buf; /* caches the the region's pixels */
- guchar *out; /* holds the new scan line we are computing */
- guchar **max; /* caches the smallest values for each column */
- gint16 *circ; /* holds the y coords of the filter's mask */
- gint16 last_max, last_index;
-
- guchar *buffer;
- gint buffer_size;
-
- if (xradius <= 0 || yradius <= 0)
- return;
-
- max = g_new (guchar *, region->w + 2 * xradius);
- buf = g_new (guchar *, yradius + 1);
-
- for (i = 0; i < yradius + 1; i++)
- buf[i] = g_new (guchar, region->w);
-
- buffer_size = (region->w + 2 * xradius + 1) * (yradius + 1);
- buffer = g_new (guchar, buffer_size);
-
- if (edge_lock)
- memset(buffer, 255, buffer_size);
- else
- memset(buffer, 0, buffer_size);
-
- for (i = 0; i < region->w + 2 * xradius; i++)
- {
- if (i < xradius)
- {
- if (edge_lock)
- max[i] = buffer;
- else
- max[i] = &buffer[(yradius + 1) * (region->w + xradius)];
- }
- else if (i < region->w + xradius)
- {
- max[i] = &buffer[(yradius + 1) * (i - xradius)];
- }
- else
- {
- if (edge_lock)
- max[i] = &buffer[(yradius + 1) * (region->w + xradius - 1)];
- else
- max[i] = &buffer[(yradius + 1) * (region->w + xradius)];
- }
- }
-
- if (! edge_lock)
- for (j = 0 ; j < xradius + 1; j++)
- max[0][j] = 0;
-
- /* offset the max pointer by xradius so the range of the array
- is [-xradius] to [region->w + xradius] */
- max += xradius;
-
- out = g_new (guchar, region->w);
-
- circ = g_new (gint16, 2 * xradius + 1);
- compute_border (circ, xradius, yradius);
-
- /* offset the circ pointer by xradius so the range of the array
- is [-xradius] to [xradius] */
- circ += xradius;
-
- for (i = 0; i < yradius && i < region->h; i++) /* load top of image */
- pixel_region_get_row (region,
- region->x, region->y + i, region->w, buf[i + 1], 1);
- if (edge_lock)
- memcpy (buf[0], buf[1], region->w);
- else
- memset (buf[0], 0, region->w);
-
-
- for (x = 0; x < region->w; x++) /* set up max for top of image */
- {
- max[x][0] = buf[0][x];
-
- for (j = 1; j < yradius + 1; j++)
- max[x][j] = MIN(buf[j][x], max[x][j-1]);
- }
-
- for (y = 0; y < region->h; y++)
- {
- rotate_pointers (buf, yradius + 1);
-
- if (y < region->h - yradius)
- pixel_region_get_row (region,
- region->x, region->y + y + yradius, region->w,
- buf[yradius], 1);
- else if (edge_lock)
- memcpy (buf[yradius], buf[yradius - 1], region->w);
- else
- memset (buf[yradius], 0, region->w);
-
- for (x = 0 ; x < region->w; x++) /* update max array */
- {
- for (i = yradius; i > 0; i--)
- max[x][i] = MIN (MIN (max[x][i - 1], buf[i - 1][x]), buf[i][x]);
-
- max[x][0] = buf[0][x];
- }
-
- last_max = max[0][circ[-1]];
- last_index = 0;
-
- for (x = 0 ; x < region->w; x++) /* render scan line */
- {
- last_index--;
-
- if (last_index >= 0)
- {
- if (last_max == 0)
- {
- out[x] = 0;
- }
- else
- {
- last_max = 255;
-
- for (i = xradius; i >= 0; i--)
- if (last_max > max[x + i][circ[i]])
- {
- last_max = max[x + i][circ[i]];
- last_index = i;
- }
-
- out[x] = last_max;
- }
- }
- else
- {
- last_index = xradius;
- last_max = max[x + xradius][circ[xradius]];
-
- for (i = xradius - 1; i >= -xradius; i--)
- if (last_max > max[x + i][circ[i]])
- {
- last_max = max[x + i][circ[i]];
- last_index = i;
- }
-
- out[x] = last_max;
- }
- }
-
- pixel_region_set_row (region, region->x, region->y + y, region->w, out);
- }
-
- /* undo the offsets to the pointers so we can free the malloced memmory */
- circ -= xradius;
- max -= xradius;
-
- /* free the memmory */
- g_free (circ);
- g_free (buffer);
- g_free (max);
-
- for (i = 0; i < yradius + 1; i++)
- g_free (buf[i]);
-
- g_free (buf);
- g_free (out);
-}
-
/* Simple convolution filter to smooth a mask (1bpp). */
void
smooth_region (PixelRegion *region)
diff --git a/app/paint-funcs/paint-funcs.h b/app/paint-funcs/paint-funcs.h
index bc5c27d..74ebe79 100644
--- a/app/paint-funcs/paint-funcs.h
+++ b/app/paint-funcs/paint-funcs.h
@@ -296,11 +296,6 @@ gfloat shapeburst_region (PixelRegion *srcPR,
GimpProgressFunc progress_callback,
gpointer progress_data);
-void thin_region (PixelRegion *region,
- gint16 xradius,
- gint16 yradius,
- gboolean edge_lock);
-
void fatten_region (PixelRegion *region,
gint16 xradius,
gint16 yradius);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]