[gimp] Bug 155733 - need to check return values of gimp_drawable_mask_bounds()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 155733 - need to check return values of gimp_drawable_mask_bounds()
- Date: Mon, 18 Apr 2016 20:03:19 +0000 (UTC)
commit cfa9132c4db8c29a3eb76a1b1ab1ddbc86a8065a
Author: Andrew Worsley <amworsley gmail com>
Date: Mon Oct 26 21:54:39 2015 +1100
Bug 155733 - need to check return values of gimp_drawable_mask_bounds()
Remove calls to gimp_drawable_mask_bounds() from most plug-ins.
This just leaves a python gimp interface plug-in.
plug-ins/common/edge-dog.c | 46 +++++++++++--------------
plug-ins/common/sparkle.c | 28 ++++++++++------
plug-ins/common/sphere-designer.c | 34 +++++++++---------
plug-ins/common/unsharp-mask.c | 11 +++---
plug-ins/common/van-gogh-lic.c | 25 +++++++-------
plug-ins/fractal-explorer/fractal-explorer.c | 27 ++++++++-------
plug-ins/gfig/gfig.c | 14 ++++---
plug-ins/gimpressionist/brush.c | 24 ++++++++------
plug-ins/gradient-flare/gradient-flare.c | 26 +++++++-------
plug-ins/lighting/lighting-image.c | 13 ++++++-
plug-ins/lighting/lighting-main.c | 8 ++--
plug-ins/lighting/lighting-ui.c | 5 +--
plug-ins/map-object/map-object-image.c | 9 +++--
plug-ins/map-object/map-object-main.c | 8 ++--
plug-ins/map-object/map-object-preview.c | 3 ++
15 files changed, 151 insertions(+), 130 deletions(-)
---
diff --git a/plug-ins/common/edge-dog.c b/plug-ins/common/edge-dog.c
index ca19c1c..fd75cad 100644
--- a/plug-ins/common/edge-dog.c
+++ b/plug-ins/common/edge-dog.c
@@ -458,13 +458,11 @@ dog (gint32 image_ID,
gint32 layer1;
gint32 layer2;
gint width, height;
- gint x1, y1, x2, y2;
+ gint x1, y1;
guchar maxval = 255;
- gimp_drawable_mask_bounds (drawable_id, &x1, &y1, &x2, &y2);
-
- width = (x2 - x1);
- height = (y2 - y1);
+ if (! gimp_drawable_mask_intersect (drawable_id, &x1, &y1, &width, &height))
+ return;
gimp_drawable_flush (drawable);
@@ -522,17 +520,13 @@ compute_difference (GimpDrawable *drawable,
gint bpp;
gpointer pr;
gint x, y, k;
- gint x1, y1, x2, y2;
+ gint x1, y1;
gboolean has_alpha;
*maxval = 0;
- gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
-
- width = (x2 - x1);
- height = (y2 - y1);
-
- if (width < 1 || height < 1)
+ if (! gimp_drawable_mask_intersect (drawable->drawable_id,
+ &x1, &y1, &width, &height))
return;
bpp = drawable->bpp;
@@ -607,7 +601,8 @@ normalize_invert (GimpDrawable *drawable,
gint bpp;
gpointer pr;
gint x, y, k;
- gint x1, y1, x2, y2;
+ gint x1, y1;
+ gint width, height;
gboolean has_alpha;
gdouble factor;
@@ -617,7 +612,10 @@ normalize_invert (GimpDrawable *drawable,
else
factor = 1.0;
- gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
+ if (! gimp_drawable_mask_intersect (drawable->drawable_id,
+ &x1, &y1, &width, &height))
+ return;
+
bpp = drawable->bpp;
has_alpha = gimp_drawable_has_alpha(drawable->drawable_id);
@@ -690,7 +688,7 @@ gauss_rle (GimpDrawable *drawable,
gint *buf, *bb;
gint pixels;
gint total = 1;
- gint x1, y1, x2, y2;
+ gint x1, y1;
gint i, row, col, b;
gint start, end;
gdouble progress, max_progress;
@@ -704,12 +702,8 @@ gauss_rle (GimpDrawable *drawable,
if (radius <= 0.0)
return;
- gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
-
- width = (x2 - x1);
- height = (y2 - y1);
-
- if (width < 1 || height < 1)
+ if (! gimp_drawable_mask_intersect (drawable->drawable_id,
+ &x1, &y1, &width, &height))
return;
bytes = drawable->bpp;
@@ -748,7 +742,7 @@ gauss_rle (GimpDrawable *drawable,
for (col = 0; col < width; col++)
{
- gimp_pixel_rgn_get_col (&src_rgn, src, col + x1, y1, (y2 - y1));
+ gimp_pixel_rgn_get_col (&src_rgn, src, col + x1, y1, height);
if (has_alpha)
multiply_alpha (src, height, bytes);
@@ -800,7 +794,7 @@ gauss_rle (GimpDrawable *drawable,
if (has_alpha)
separate_alpha (dest, height, bytes);
- gimp_pixel_rgn_set_col (&dest_rgn, dest, col + x1, y1, (y2 - y1));
+ gimp_pixel_rgn_set_col (&dest_rgn, dest, col + x1, y1, height);
if (show_progress)
{
@@ -819,7 +813,7 @@ gauss_rle (GimpDrawable *drawable,
/* Now the horizontal pass */
for (row = 0; row < height; row++)
{
- gimp_pixel_rgn_get_row (&src_rgn, src, x1, row + y1, (x2 - x1));
+ gimp_pixel_rgn_get_row (&src_rgn, src, x1, row + y1, width);
if (has_alpha)
multiply_alpha (src, width, bytes);
@@ -869,7 +863,7 @@ gauss_rle (GimpDrawable *drawable,
if (has_alpha)
separate_alpha (dest, width, bytes);
- gimp_pixel_rgn_set_row (&dest_rgn, dest, x1, row + y1, (x2 - x1));
+ gimp_pixel_rgn_set_row (&dest_rgn, dest, x1, row + y1, width);
if (show_progress)
{
@@ -883,7 +877,7 @@ gauss_rle (GimpDrawable *drawable,
/* merge the shadow, update the drawable */
gimp_drawable_flush (drawable);
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
- gimp_drawable_update (drawable->drawable_id, x1, y1, (x2 - x1), (y2 - y1));
+ gimp_drawable_update (drawable->drawable_id, x1, y1, width, height);
/* free buffers */
g_free (buf);
diff --git a/plug-ins/common/sparkle.c b/plug-ins/common/sparkle.c
index 47ccb89..1ee3cf7 100644
--- a/plug-ins/common/sparkle.c
+++ b/plug-ins/common/sparkle.c
@@ -632,18 +632,21 @@ compute_lum_threshold (GimpDrawable *drawable,
gboolean gray;
gboolean has_alpha;
gint i;
- gint x1, y1, x2, y2;
+ gint x1, y1;
+ gint width, height;
/* zero out the luminosity values array */
memset (values, 0, sizeof (gint) * 256);
- gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
+ if (! gimp_drawable_mask_intersect (drawable->drawable_id,
+ &x1, &y1, &width, &height))
+ return 0;
gray = gimp_drawable_is_gray (drawable->drawable_id);
has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
gimp_pixel_rgn_init (&src_rgn, drawable,
- x1, y1, (x2 - x1), (y2 - y1), FALSE, FALSE);
+ x1, y1, width, height, FALSE, FALSE);
for (pr = gimp_pixel_rgns_register (1, &src_rgn);
pr != NULL;
@@ -668,7 +671,7 @@ compute_lum_threshold (GimpDrawable *drawable,
}
}
- total = (x2 - x1) * (y2 - y1);
+ total = width * height;
sum = 0;
for (i = 255; i >= 0; i--)
@@ -702,8 +705,6 @@ sparkle (GimpDrawable *drawable,
GRand *gr;
guchar *dest_buf = NULL;
- gr = g_rand_new ();
-
bytes = drawable->bpp;
if (preview)
@@ -717,12 +718,19 @@ sparkle (GimpDrawable *drawable,
}
else
{
- gimp_drawable_mask_bounds (drawable->drawable_id,
- &x1, &y1, &x2, &y2);
- width = x2 - x1;
- height = y2 - y1;
+ if (! gimp_drawable_mask_intersect (drawable->drawable_id,
+ &x1, &y1, &width, &height))
+ return;
+
+ x2 = x1 + width;
+ y2 = y1 + height;
}
+ if (width < 1 || height < 1)
+ return;
+
+ gr = g_rand_new ();
+
if (svals.border)
{
num_sparkles = 2 * (width + height);
diff --git a/plug-ins/common/sphere-designer.c b/plug-ins/common/sphere-designer.c
index b1ea411..c986f21 100644
--- a/plug-ins/common/sphere-designer.c
+++ b/plug-ins/common/sphere-designer.c
@@ -2948,8 +2948,8 @@ realrender (GimpDrawable *drawable)
gint x, y;
ray r;
GimpVector4 rcol;
- gint tx, ty;
- gint x1, y1, x2, y2;
+ gint width, height;
+ gint x1, y1;
guchar *dest;
gint bpp;
GimpPixelRgn pr, dpr;
@@ -2960,6 +2960,10 @@ realrender (GimpDrawable *drawable)
r.v1.z = -10.0;
r.v2.z = 0.0;
+ if (! gimp_drawable_mask_intersect (drawable->drawable_id,
+ &x1, &y1, &width, &height))
+ return;
+
gimp_pixel_rgn_init (&pr, drawable, 0, 0,
gimp_drawable_width (drawable->drawable_id),
gimp_drawable_height (drawable->drawable_id), FALSE,
@@ -2968,23 +2972,19 @@ realrender (GimpDrawable *drawable)
gimp_drawable_width (drawable->drawable_id),
gimp_drawable_height (drawable->drawable_id), TRUE,
TRUE);
- gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
bpp = gimp_drawable_bpp (drawable->drawable_id);
- buffer = g_malloc ((x2 - x1) * 4);
- ibuffer = g_malloc ((x2 - x1) * 4);
-
- tx = x2 - x1;
- ty = y2 - y1;
+ buffer = g_malloc (width * 4);
+ ibuffer = g_malloc (width * 4);
gimp_progress_init (_("Rendering sphere"));
- for (y = 0; y < ty; y++)
+ for (y = 0; y < height; y++)
{
dest = buffer;
- for (x = 0; x < tx; x++)
+ for (x = 0; x < width; x++)
{
- r.v1.x = r.v2.x = 8.1 * (x / (float) (tx - 1) - 0.5);
- r.v1.y = r.v2.y = 8.1 * (y / (float) (ty - 1) - 0.5);
+ r.v1.x = r.v2.x = 8.1 * (x / (float) (width - 1) - 0.5);
+ r.v1.y = r.v2.y = 8.1 * (y / (float) (height - 1) - 0.5);
traceray (&r, &rcol, 10, 1.0);
dest[0] = pixelval (255 * rcol.x);
@@ -2993,8 +2993,8 @@ realrender (GimpDrawable *drawable)
dest[3] = pixelval (255 * rcol.w);
dest += 4;
}
- gimp_pixel_rgn_get_row (&pr, ibuffer, x1, y1 + y, x2 - x1);
- for (x = 0; x < (x2 - x1); x++)
+ gimp_pixel_rgn_get_row (&pr, ibuffer, x1, y1 + y, width);
+ for (x = 0; x < width; x++)
{
gint k, dx = x * 4, sx = x * bpp;
gfloat a = buffer[dx + 3] / 255.0;
@@ -3005,15 +3005,15 @@ realrender (GimpDrawable *drawable)
buffer[dx + k] * a + ibuffer[sx + k] * (1.0 - a);
}
}
- gimp_pixel_rgn_set_row (&dpr, ibuffer, x1, y1 + y, x2 - x1);
- gimp_progress_update ((gdouble) y / (gdouble) ty);
+ gimp_pixel_rgn_set_row (&dpr, ibuffer, x1, y1 + y, width);
+ gimp_progress_update ((gdouble) y / (gdouble) height);
}
gimp_progress_update (1.0);
g_free (buffer);
g_free (ibuffer);
gimp_drawable_flush (drawable);
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
- gimp_drawable_update (drawable->drawable_id, x1, y1, x2 - x1, y2 - y1);
+ gimp_drawable_update (drawable->drawable_id, x1, y1, width, height);
}
static void
diff --git a/plug-ins/common/unsharp-mask.c b/plug-ins/common/unsharp-mask.c
index 9620735..e9ebd61 100644
--- a/plug-ins/common/unsharp-mask.c
+++ b/plug-ins/common/unsharp-mask.c
@@ -144,7 +144,6 @@ query (void)
GIMP_PLUGIN,
G_N_ELEMENTS (args), 0,
args, NULL);
-
}
static void
@@ -536,7 +535,7 @@ unsharp_mask (GimpDrawable *drawable,
gdouble amount)
{
GimpPixelRgn srcPR, destPR;
- gint x1, y1, x2, y2;
+ gint x1, y1, width, height;
/* initialize pixel regions */
gimp_pixel_rgn_init (&srcPR, drawable,
@@ -545,16 +544,18 @@ unsharp_mask (GimpDrawable *drawable,
0, 0, drawable->width, drawable->height, TRUE, TRUE);
/* Get the input */
- gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
+ if (! gimp_drawable_mask_intersect (drawable->drawable_id,
+ &x1, &y1, &width, &height))
+ return;
unsharp_region (&srcPR, &destPR, drawable->bpp,
radius, amount,
- x1, x2, y1, y2,
+ x1, x1 + width, y1, y1 + width,
TRUE);
gimp_drawable_flush (drawable);
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
- gimp_drawable_update (drawable->drawable_id, x1, y1, x2 - x1, y2 - y1);
+ gimp_drawable_update (drawable->drawable_id, x1, y1, width, height);
}
/* Perform an unsharp mask on the region, given a source region, dest.
diff --git a/plug-ins/common/van-gogh-lic.c b/plug-ins/common/van-gogh-lic.c
index c2f6cd7..64c31a2 100644
--- a/plug-ins/common/van-gogh-lic.c
+++ b/plug-ins/common/van-gogh-lic.c
@@ -93,7 +93,7 @@ static gdouble isteps = 20.0;
static gboolean source_drw_has_alpha = FALSE;
static gint effect_width, effect_height;
-static gint border_x1, border_y1, border_x2, border_y2;
+static gint border_x, border_y, border_w, border_h;
static GtkWidget *dialog;
@@ -444,8 +444,8 @@ rgb_to_hsl (GimpDrawable *drawable,
maxc = drawable->width * drawable->height;
- gimp_pixel_rgn_init (®ion, drawable, border_x1, border_y1,
- border_x2 - border_x1, border_y2 - border_y1, FALSE, FALSE);
+ gimp_pixel_rgn_init (®ion, drawable, border_x, border_y,
+ border_w, border_h, FALSE, FALSE);
themap = g_new (guchar, maxc);
@@ -496,14 +496,12 @@ compute_lic (GimpDrawable *drawable,
GimpPixelRgn src_rgn, dest_rgn;
gimp_pixel_rgn_init (&src_rgn, drawable,
- border_x1, border_y1,
- border_x2 - border_x1,
- border_y2 - border_y1, FALSE, FALSE);
+ border_x, border_y,
+ border_w, border_h, FALSE, FALSE);
gimp_pixel_rgn_init (&dest_rgn, drawable,
- border_x1, border_y1,
- border_x2 - border_x1,
- border_y2 - border_y1, TRUE, TRUE);
+ border_x, border_y,
+ border_w, border_h, TRUE, TRUE);
for (ycount = 0; ycount < src_rgn.h; ycount++)
{
@@ -563,8 +561,9 @@ compute_image (GimpDrawable *drawable)
/* Get some useful info on the input drawable */
/* ========================================== */
- gimp_drawable_mask_bounds (drawable->drawable_id,
- &border_x1, &border_y1, &border_x2, &border_y2);
+ if (! gimp_drawable_mask_intersect (drawable->drawable_id,
+ &border_x, &border_y, &border_w, &border_h))
+ return;
gimp_progress_init (_("Van Gogh (LIC)"));
@@ -609,8 +608,8 @@ compute_image (GimpDrawable *drawable)
gimp_drawable_flush (drawable);
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
- gimp_drawable_update (drawable->drawable_id, border_x1, border_y1,
- border_x2 - border_x1, border_y2 - border_y1);
+ gimp_drawable_update (drawable->drawable_id, border_x, border_y,
+ border_w, border_h);
gimp_displays_flush ();
}
diff --git a/plug-ins/fractal-explorer/fractal-explorer.c b/plug-ins/fractal-explorer/fractal-explorer.c
index 347123d..bf640a1 100644
--- a/plug-ins/fractal-explorer/fractal-explorer.c
+++ b/plug-ins/fractal-explorer/fractal-explorer.c
@@ -403,10 +403,10 @@ explorer (GimpDrawable * drawable)
gint height;
gint bpp;
gint row;
- gint x1;
- gint y1;
- gint x2;
- gint y2;
+ gint x;
+ gint y;
+ gint w;
+ gint h;
guchar *src_row;
guchar *dest_row;
@@ -416,7 +416,8 @@ explorer (GimpDrawable * drawable)
* need to be done for correct operation. (It simply makes it go
* faster, since fewer pixels need to be operated on).
*/
- gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
+ if (! gimp_drawable_mask_intersect (drawable->drawable_id, &x, &y, &w, &h))
+ return;
/* Get the size of the input image. (This will/must be the same
* as the size of the output image.
@@ -426,8 +427,8 @@ explorer (GimpDrawable * drawable)
bpp = drawable->bpp;
/* allocate row buffers */
- src_row = g_new (guchar, bpp * (x2 - x1));
- dest_row = g_new (guchar, bpp * (x2 - x1));
+ src_row = g_new (guchar, bpp * w);
+ dest_row = g_new (guchar, bpp * w);
/* initialize the pixel regions */
gimp_pixel_rgn_init (&srcPR, drawable, 0, 0, width, height, FALSE, FALSE);
@@ -448,28 +449,28 @@ explorer (GimpDrawable * drawable)
colormap[i].b);
}
- for (row = y1; row < y2; row++)
+ for (row = y; row < y + h; row++)
{
- gimp_pixel_rgn_get_row (&srcPR, src_row, x1, row, (x2 - x1));
+ gimp_pixel_rgn_get_row (&srcPR, src_row, x, row, w);
explorer_render_row (src_row,
dest_row,
row,
- (x2 - x1),
+ w,
bpp);
/* store the dest */
- gimp_pixel_rgn_set_row (&destPR, dest_row, x1, row, (x2 - x1));
+ gimp_pixel_rgn_set_row (&destPR, dest_row, x, row, w);
if ((row % 10) == 0)
- gimp_progress_update ((double) row / (double) (y2 - y1));
+ gimp_progress_update ((double) row / (double) h);
}
gimp_progress_update (1.0);
/* update the processed region */
gimp_drawable_flush (drawable);
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
- gimp_drawable_update (drawable->drawable_id, x1, y1, (x2 - x1), (y2 - y1));
+ gimp_drawable_update (drawable->drawable_id, x, y, w, h);
g_free (src_row);
g_free (dest_row);
diff --git a/plug-ins/gfig/gfig.c b/plug-ins/gfig/gfig.c
index f046652..f1a3d99 100644
--- a/plug-ins/gfig/gfig.c
+++ b/plug-ins/gfig/gfig.c
@@ -98,7 +98,7 @@ gdouble org_scale_x_factor, org_scale_y_factor;
/* Stuff for the preview bit */
-static gint sel_x1, sel_y1, sel_x2, sel_y2;
+static gint sel_x, sel_y;
static gint sel_width, sel_height;
gint preview_width, preview_height;
gdouble scale_x_factor, scale_y_factor;
@@ -178,12 +178,14 @@ run (const gchar *name,
if (! gimp_selection_is_empty (gfig_context->image_id))
gimp_selection_none (gfig_context->image_id);
- gimp_drawable_mask_bounds (drawable_id,
- &sel_x1, &sel_y1, &sel_x2, &sel_y2);
-
- sel_width = sel_x2 - sel_x1;
- sel_height = sel_y2 - sel_y1;
+ if (! gimp_drawable_mask_intersect (drawable_id, &sel_x, &sel_y,
+ &sel_width, &sel_height))
+ {
+ gimp_context_pop ();
+ gimp_image_undo_group_end (gfig_context->image_id);
+ return;
+ }
/* Calculate preview size */
diff --git a/plug-ins/gimpressionist/brush.c b/plug-ins/gimpressionist/brush.c
index 5cf0249..8bf6915 100644
--- a/plug-ins/gimpressionist/brush.c
+++ b/plug-ins/gimpressionist/brush.c
@@ -106,7 +106,7 @@ brushdmenuselect (GtkWidget *widget,
gint bpp;
gint x, y;
ppm_t *p;
- gint x1, y1, x2, y2;
+ gint x1, y1, w, h;
gint row;
GimpDrawable *drawable;
gint rowstride;
@@ -132,46 +132,50 @@ brushdmenuselect (GtkWidget *widget,
drawable = gimp_drawable_get (id);
- gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
+ if (! gimp_drawable_mask_intersect (drawable->drawable_id, &x1, &y1, &w, &h))
+ return;
bpp = gimp_drawable_bpp (drawable->drawable_id);
ppm_kill (&brushppm);
- ppm_new (&brushppm, x2 - x1, y2 - y1);
+ ppm_new (&brushppm, w, h);
p = &brushppm;
rowstride = p->width * 3;
- src_row = g_new (guchar, (x2 - x1) * bpp);
+ src_row = g_new (guchar, w * bpp);
gimp_pixel_rgn_init (&src_rgn, drawable,
- 0, 0, x2 - x1, y2 - y1,
- FALSE, FALSE);
+ 0, 0, w, h, FALSE, FALSE);
if (bpp == 3)
{ /* RGB */
- int bpr = (x2 - x1) * 3;
+ gint bpr = w * 3;
+ gint y2 = y1 + h;
for (row = 0, y = y1; y < y2; row++, y++)
{
- gimp_pixel_rgn_get_row (&src_rgn, src_row, x1, y, (x2 - x1));
+ gimp_pixel_rgn_get_row (&src_rgn, src_row, x1, y, w);
memcpy (p->col + row*rowstride, src_row, bpr);
}
}
else
{ /* RGBA (bpp > 3) GrayA (bpp == 2) or Gray */
gboolean is_gray = ((bpp > 3) ? TRUE : FALSE);
+ gint y2 = y1 + h;
for (row = 0, y = y1; y < y2; row++, y++)
{
guchar *tmprow = p->col + row * rowstride;
guchar *tmprow_ptr;
+ gint x2 = x1 + w;
+
- gimp_pixel_rgn_get_row (&src_rgn, src_row, x1, y, (x2 - x1));
+ gimp_pixel_rgn_get_row (&src_rgn, src_row, x1, y, w);
src = src_row;
tmprow_ptr = tmprow;
/* Possible micro-optimization here:
- * src_end = src + src_rgn.bpp * (x2-x1);
+ * src_end = src + src_rgn.bpp * w);
* for ( ; src < src_end ; src += src_rgn.bpp)
*/
for (x = x1; x < x2; x++)
diff --git a/plug-ins/gradient-flare/gradient-flare.c b/plug-ins/gradient-flare/gradient-flare.c
index 7caa6a1..3d7f4b4 100644
--- a/plug-ins/gradient-flare/gradient-flare.c
+++ b/plug-ins/gradient-flare/gradient-flare.c
@@ -282,7 +282,7 @@ typedef struct
{
gint is_color;
gint has_alpha;
- gint x1, y1, x2, y2; /* mask bounds */
+ gint x, y, w, h; /* mask bounds */
gint tile_width, tile_height;
/* these values don't belong to drawable, though. */
} DrawableInfo;
@@ -850,8 +850,11 @@ plugin_run (const gchar *name,
drawable = gimp_drawable_get (param[2].data.d_drawable);
dinfo.is_color = gimp_drawable_is_rgb (drawable->drawable_id);
dinfo.has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
- gimp_drawable_mask_bounds (drawable->drawable_id, &dinfo.x1, &dinfo.y1,
- &dinfo.x2, &dinfo.y2);
+
+ if (! gimp_drawable_mask_intersect (drawable->drawable_id,
+ &dinfo.x, &dinfo.y, &dinfo.w, &dinfo.h))
+ return;
+
dinfo.tile_width = gimp_tile_width ();
dinfo.tile_height = gimp_tile_height ();
@@ -1007,8 +1010,8 @@ plugin_do (void)
calc_deinit ();
gimp_drawable_flush (drawable);
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
- gimp_drawable_update (drawable->drawable_id, dinfo.x1, dinfo.y1,
- (dinfo.x2 - dinfo.x1), (dinfo.y2 - dinfo.y1));
+ gimp_drawable_update (drawable->drawable_id, dinfo.x, dinfo.y,
+ dinfo.w, dinfo.h);
}
/* these routines should be almost rewritten anyway */
@@ -1018,19 +1021,16 @@ plugin_do_non_asupsample (void)
{
GimpPixelRgn src_rgn, dest_rgn;
gpointer pr;
- gint width, height;
gint progress, max_progress;
- width = dinfo.x2 - dinfo.x1;
- height = dinfo.y2 - dinfo.y1;
progress = 0;
- max_progress = width * height;
+ max_progress = dinfo.w * dinfo.h;
gimp_pixel_rgn_init (&src_rgn, drawable,
- dinfo.x1, dinfo.y1, width, height, FALSE, FALSE);
+ dinfo.x, dinfo.y, dinfo.w, dinfo.h, FALSE, FALSE);
gimp_pixel_rgn_init (&dest_rgn, drawable,
- dinfo.x1, dinfo.y1, width, height, TRUE, TRUE);
+ dinfo.x, dinfo.y, dinfo.w, dinfo.h, TRUE, TRUE);
for (pr = gimp_pixel_rgns_register (2, &src_rgn, &dest_rgn);
pr != NULL; pr = gimp_pixel_rgns_process (pr))
@@ -1093,8 +1093,8 @@ plugin_do_asupsample (void)
tk_write = gimp_pixel_fetcher_new (drawable, TRUE);
- gimp_adaptive_supersample_area (dinfo.x1, dinfo.y1,
- dinfo.x2 - 1, dinfo.y2 - 1,
+ gimp_adaptive_supersample_area (dinfo.x, dinfo.y,
+ dinfo.x + dinfo.w - 1, dinfo.y + dinfo.h - 1,
pvals.asupsample_max_depth,
pvals.asupsample_threshold,
plugin_render_func,
diff --git a/plug-ins/lighting/lighting-image.c b/plug-ins/lighting/lighting-image.c
index 99b0b6f..5b3c939 100644
--- a/plug-ins/lighting/lighting-image.c
+++ b/plug-ins/lighting/lighting-image.c
@@ -347,6 +347,9 @@ gint
image_setup (GimpDrawable *drawable,
gint interactive)
{
+ gint w, h;
+ gboolean ret;
+
compute_maps ();
/* Get some useful info on the input drawable */
@@ -355,8 +358,14 @@ image_setup (GimpDrawable *drawable,
input_drawable = drawable;
output_drawable = drawable;
- gimp_drawable_mask_bounds (drawable->drawable_id,
- &border_x1, &border_y1, &border_x2, &border_y2);
+ ret = gimp_drawable_mask_intersect (drawable->drawable_id,
+ &border_x1, &border_y1, &w, &h);
+
+ border_x2 = border_x1 + w;
+ border_y2 = border_y1 + h;
+
+ if (! ret)
+ return FALSE;
width = input_drawable->width;
height = input_drawable->height;
diff --git a/plug-ins/lighting/lighting-main.c b/plug-ins/lighting/lighting-main.c
index c7b5446..0ca168b 100644
--- a/plug-ins/lighting/lighting-main.c
+++ b/plug-ins/lighting/lighting-main.c
@@ -270,8 +270,8 @@ run (const gchar *name,
break;
case GIMP_RUN_WITH_LAST_VALS:
- image_setup (drawable, FALSE);
- compute_image ();
+ if (image_setup (drawable, FALSE))
+ compute_image ();
gimp_displays_flush ();
break;
@@ -305,8 +305,8 @@ run (const gchar *name,
mapvals.transparent_background = (gint) param[23].data.d_int32;
check_drawables ();
- image_setup (drawable, FALSE);
- compute_image ();
+ if (image_setup (drawable, FALSE))
+ compute_image ();
}
default:
break;
diff --git a/plug-ins/lighting/lighting-ui.c b/plug-ins/lighting/lighting-ui.c
index 7044084..77b41b7 100644
--- a/plug-ins/lighting/lighting-ui.c
+++ b/plug-ins/lighting/lighting-ui.c
@@ -1118,9 +1118,8 @@ main_dialog (GimpDrawable *drawable)
gdk_cursor_unref (cursor);
}
- image_setup (drawable, TRUE);
-
- preview_compute ();
+ if (image_setup (drawable, TRUE))
+ preview_compute ();
if (gimp_dialog_run (GIMP_DIALOG (appwin)) == GTK_RESPONSE_OK)
run = TRUE;
diff --git a/plug-ins/map-object/map-object-image.c b/plug-ins/map-object/map-object-image.c
index 6c65277..7e0f4c7 100644
--- a/plug-ins/map-object/map-object-image.c
+++ b/plug-ins/map-object/map-object-image.c
@@ -41,7 +41,7 @@ gint imgtype,width,height,in_channels,out_channels,image_id;
GimpRGB background;
gdouble oldtreshold;
-gint border_x1, border_y1, border_x2, border_y2;
+gint border_x, border_y, border_w, border_h;
/******************/
/* Implementation */
@@ -153,7 +153,7 @@ gint
checkbounds (gint x,
gint y)
{
- if (x < border_x1 || y < border_y1 || x >= border_x2 || y >= border_y2)
+ if (x < border_x || y < border_y || x >= border_x + border_w || y >= border_y + border_h)
return FALSE;
else
return TRUE;
@@ -361,8 +361,9 @@ image_setup (GimpDrawable *drawable,
input_drawable = drawable;
output_drawable = drawable;
- gimp_drawable_mask_bounds (drawable->drawable_id,
- &border_x1, &border_y1, &border_x2, &border_y2);
+ if (! gimp_drawable_mask_intersect (drawable->drawable_id, &border_x, &border_y,
+ &border_w, &border_h))
+ return FALSE;
width = input_drawable->width;
height = input_drawable->height;
diff --git a/plug-ins/map-object/map-object-main.c b/plug-ins/map-object/map-object-main.c
index 1608078..b148f5c 100644
--- a/plug-ins/map-object/map-object-main.c
+++ b/plug-ins/map-object/map-object-main.c
@@ -251,8 +251,8 @@ run (const gchar *name,
case GIMP_RUN_WITH_LAST_VALS:
gimp_get_data (PLUG_IN_PROC, &mapvals);
check_drawables (drawable);
- image_setup (drawable, FALSE);
- compute_image ();
+ if (image_setup (drawable, FALSE))
+ compute_image ();
break;
case GIMP_RUN_NONINTERACTIVE:
@@ -309,8 +309,8 @@ run (const gchar *name,
mapvals.cylindermap_id[i] = param[47+i].data.d_drawable;
check_drawables (drawable);
- image_setup (drawable, FALSE);
- compute_image ();
+ if (image_setup (drawable, FALSE))
+ compute_image ();
}
break;
}
diff --git a/plug-ins/map-object/map-object-preview.c b/plug-ins/map-object/map-object-preview.c
index d3a0b33..afc29b4 100644
--- a/plug-ins/map-object/map-object-preview.c
+++ b/plug-ins/map-object/map-object-preview.c
@@ -96,6 +96,9 @@ compute_preview (gint x,
init_compute ();
+ if (! preview_surface)
+ return;
+
p1 = int_to_pos (x, y);
p2 = int_to_pos (x + w, y + h);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]