[gimp/goat-invasion: 553/608] app: make the GimpTempBuf struct private and add accessors
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion: 553/608] app: make the GimpTempBuf struct private and add accessors
- Date: Fri, 27 Apr 2012 21:11:51 +0000 (UTC)
commit 4704e3a3c46874c75533db3083642ea4872a2440
Author: Michael Natterer <mitch gimp org>
Date: Mon Apr 23 09:40:56 2012 +0200
app: make the GimpTempBuf struct private and add accessors
app/base/pixel-region.c | 4 +-
app/core/gimp-edit.c | 2 +-
app/core/gimpbrush-transform.c | 53 ++++++++-------
app/core/gimpbrush.c | 20 +++---
app/core/gimpbrushgenerated.c | 9 ++-
app/core/gimpimage-preview.c | 16 +++--
app/core/gimppattern.c | 18 +++---
app/core/gimppreviewcache.c | 25 ++++---
app/core/gimptempbuf.c | 47 +++++++++++--
app/core/gimptempbuf.h | 18 ++---
app/core/gimpundo.c | 15 ++--
app/core/gimpviewable.c | 10 ++--
app/paint/gimpbrushcore.c | 131 ++++++++++++++++++++---------------
app/paint/gimpconvolve.c | 8 +-
app/pdb/brush-cmds.c | 22 +++---
app/pdb/brushes-cmds.c | 8 +-
app/pdb/context-cmds.c | 5 +-
app/pdb/drawable-cmds.c | 12 ++--
app/pdb/image-cmds.c | 6 +-
app/pdb/pattern-cmds.c | 12 ++--
app/pdb/patterns-cmds.c | 10 ++--
app/tools/gimpiscissorstool.c | 16 ++--
app/tools/gimppaintoptions-gui.c | 5 +-
app/widgets/gimpbrushselect.c | 4 +-
app/widgets/gimppatternselect.c | 6 +-
app/widgets/gimpviewrenderer.c | 38 +++++++----
app/widgets/gimpviewrendererbrush.c | 26 +++++--
tools/pdbgen/pdb/brush.pdb | 22 +++---
tools/pdbgen/pdb/brushes.pdb | 8 +-
tools/pdbgen/pdb/context.pdb | 5 +-
tools/pdbgen/pdb/drawable.pdb | 12 ++--
tools/pdbgen/pdb/image.pdb | 6 +-
tools/pdbgen/pdb/pattern.pdb | 12 ++--
tools/pdbgen/pdb/patterns.pdb | 10 ++--
34 files changed, 359 insertions(+), 262 deletions(-)
---
diff --git a/app/base/pixel-region.c b/app/base/pixel-region.c
index 14bc20a..86e6472 100644
--- a/app/base/pixel-region.c
+++ b/app/base/pixel-region.c
@@ -96,8 +96,8 @@ pixel_region_init_temp_buf (PixelRegion *PR,
PR->curtile = NULL;
PR->offx = 0;
PR->offy = 0;
- PR->bytes = babl_format_get_bytes_per_pixel (temp_buf->format);
- PR->rowstride = temp_buf->width * PR->bytes;
+ PR->bytes = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (temp_buf));
+ PR->rowstride = gimp_temp_buf_get_width (temp_buf) * PR->bytes;
PR->x = x;
PR->y = y;
PR->w = w;
diff --git a/app/core/gimp-edit.c b/app/core/gimp-edit.c
index ea6b5c9..a33d67c 100644
--- a/app/core/gimp-edit.c
+++ b/app/core/gimp-edit.c
@@ -468,7 +468,7 @@ gimp_edit_fill_full (GimpImage *image,
return TRUE; /* nothing to do, but the fill succeded */
if (pattern &&
- babl_format_has_alpha (pattern->mask->format) &&
+ babl_format_has_alpha (gimp_temp_buf_get_format (pattern->mask)) &&
! gimp_drawable_has_alpha (drawable))
{
format = gimp_drawable_get_format_with_alpha (drawable);
diff --git a/app/core/gimpbrush-transform.c b/app/core/gimpbrush-transform.c
index bfbe97d..3835370 100644
--- a/app/core/gimpbrush-transform.c
+++ b/app/core/gimpbrush-transform.c
@@ -67,7 +67,8 @@ gimp_brush_real_transform_size (GimpBrush *brush,
GimpMatrix3 matrix;
gint x, y;
- gimp_brush_transform_matrix (brush->mask->width, brush->mask->height,
+ gimp_brush_transform_matrix (gimp_temp_buf_get_width (brush->mask),
+ gimp_temp_buf_get_height (brush->mask),
scale, aspect_ratio, angle, &matrix);
gimp_brush_transform_bounding_box (brush->mask, &matrix, &x, &y, width, height);
@@ -173,14 +174,15 @@ gimp_brush_real_transform_mask (GimpBrush *brush,
source = brush->mask;
- gimp_brush_transform_matrix (source->height, source->width,
+ src_width = gimp_temp_buf_get_width (source);
+ src_height = gimp_temp_buf_get_height (source);
+
+ gimp_brush_transform_matrix (src_width, src_height,
scale, aspect_ratio, angle, &matrix);
if (gimp_matrix3_is_identity (&matrix))
return gimp_temp_buf_copy (source);
- src_width = source->width;
- src_height = source->height;
src_width_minus_one = src_width - 1;
src_height_minus_one = src_height - 1;
@@ -190,7 +192,7 @@ gimp_brush_real_transform_mask (GimpBrush *brush,
gimp_matrix3_invert (&matrix);
result = gimp_temp_buf_new (dest_width, dest_height,
- brush->mask->format);
+ gimp_temp_buf_get_format (brush->mask));
dest = gimp_temp_buf_get_data (result);
src = gimp_temp_buf_get_data (source);
@@ -332,9 +334,9 @@ gimp_brush_real_transform_mask (GimpBrush *brush,
GeglBuffer *src_buffer;
GeglBuffer *dest_buffer;
gint kernel_size =
- gimp_brush_transform_blur_kernel_size (result->height,
- result->width,
- hardness);
+ gimp_brush_transform_blur_kernel_size (gimp_temp_buf_get_height (result),
+ gimp_temp_buf_get_width (result),
+ hardness);
gint kernel_len = kernel_size * kernel_size;
gfloat blur_kernel[kernel_len];
@@ -349,12 +351,12 @@ gimp_brush_real_transform_mask (GimpBrush *brush,
gimp_gegl_convolve (src_buffer,
GEGL_RECTANGLE (0, 0,
- blur_src->width,
- blur_src->height),
+ gimp_temp_buf_get_width (blur_src),
+ gimp_temp_buf_get_height (blur_src)),
dest_buffer,
GEGL_RECTANGLE (0, 0,
- result->width,
- result->height),
+ gimp_temp_buf_get_width (result),
+ gimp_temp_buf_get_height (result)),
blur_kernel, kernel_size,
gimp_brush_transform_array_sum (blur_kernel,
kernel_len),
@@ -471,14 +473,15 @@ gimp_brush_real_transform_pixmap (GimpBrush *brush,
source = brush->pixmap;
- gimp_brush_transform_matrix (source->height, source->width,
+ src_width = gimp_temp_buf_get_width (source);
+ src_height = gimp_temp_buf_get_height (source);
+
+ gimp_brush_transform_matrix (src_width, src_height,
scale, aspect_ratio, angle, &matrix);
if (gimp_matrix3_is_identity (&matrix))
return gimp_temp_buf_copy (source);
- src_width = source->width;
- src_height = source->height;
src_width_minus_one = src_width - 1;
src_height_minus_one = src_height - 1;
@@ -488,7 +491,7 @@ gimp_brush_real_transform_pixmap (GimpBrush *brush,
gimp_matrix3_invert (&matrix);
result = gimp_temp_buf_new (dest_width, dest_height,
- brush->pixmap->format);
+ gimp_temp_buf_get_format (brush->pixmap));
dest = gimp_temp_buf_get_data (result);
src = gimp_temp_buf_get_data (source);
@@ -635,9 +638,9 @@ gimp_brush_real_transform_pixmap (GimpBrush *brush,
GeglBuffer *src_buffer;
GeglBuffer *dest_buffer;
gint kernel_size =
- gimp_brush_transform_blur_kernel_size (result->height,
- result->width,
- hardness);
+ gimp_brush_transform_blur_kernel_size (gimp_temp_buf_get_height (result),
+ gimp_temp_buf_get_width (result),
+ hardness);
gint kernel_len = kernel_size * kernel_size;
gfloat blur_kernel[kernel_len];
@@ -652,12 +655,12 @@ gimp_brush_real_transform_pixmap (GimpBrush *brush,
gimp_gegl_convolve (src_buffer,
GEGL_RECTANGLE (0, 0,
- blur_src->width,
- blur_src->height),
+ gimp_temp_buf_get_width (blur_src),
+ gimp_temp_buf_get_height (blur_src)),
dest_buffer,
GEGL_RECTANGLE (0, 0,
- result->width,
- result->height),
+ gimp_temp_buf_get_width (result),
+ gimp_temp_buf_get_height (result)),
blur_kernel, kernel_size,
gimp_brush_transform_array_sum (blur_kernel,
kernel_len),
@@ -712,8 +715,8 @@ gimp_brush_transform_bounding_box (GimpTempBuf *brush,
gint *width,
gint *height)
{
- const gdouble w = brush->width;
- const gdouble h = brush->height;
+ const gdouble w = gimp_temp_buf_get_width (brush);
+ const gdouble h = gimp_temp_buf_get_height (brush);
gdouble x1, x2, x3, x4;
gdouble y1, y2, y3, y4;
gdouble temp_x;
diff --git a/app/core/gimpbrush.c b/app/core/gimpbrush.c
index 8d038d0..5de80ca 100644
--- a/app/core/gimpbrush.c
+++ b/app/core/gimpbrush.c
@@ -268,8 +268,8 @@ gimp_brush_get_size (GimpViewable *viewable,
{
GimpBrush *brush = GIMP_BRUSH (viewable);
- *width = brush->mask->width;
- *height = brush->mask->height;
+ *width = gimp_temp_buf_get_width (brush->mask);
+ *height = gimp_temp_buf_get_height (brush->mask);
return TRUE;
}
@@ -294,8 +294,8 @@ gimp_brush_get_new_preview (GimpViewable *viewable,
mask_buf = brush->mask;
pixmap_buf = brush->pixmap;
- mask_width = mask_buf->width;
- mask_height = mask_buf->height;
+ mask_width = gimp_temp_buf_get_width (mask_buf);
+ mask_height = gimp_temp_buf_get_height (mask_buf);
if (mask_width > width || mask_height > height)
{
@@ -324,8 +324,8 @@ gimp_brush_get_new_preview (GimpViewable *viewable,
pixmap_buf = gimp_brush_transform_pixmap (brush, scale,
0.0, 0.0, 1.0);
- mask_width = mask_buf->width;
- mask_height = mask_buf->height;
+ mask_width = gimp_temp_buf_get_width (mask_buf);
+ mask_height = gimp_temp_buf_get_height (mask_buf);
scaled = TRUE;
}
@@ -385,8 +385,8 @@ gimp_brush_get_description (GimpViewable *viewable,
return g_strdup_printf ("%s (%d à %d)",
gimp_object_get_name (brush),
- brush->mask->width,
- brush->mask->height);
+ gimp_temp_buf_get_width (brush->mask),
+ gimp_temp_buf_get_height (brush->mask));
}
static void
@@ -581,8 +581,8 @@ gimp_brush_transform_size (GimpBrush *brush,
aspect_ratio == 0.0 &&
((angle == 0.0) || (angle == 0.5) || (angle == 1.0)))
{
- *width = brush->mask->width;
- *height = brush->mask->height;
+ *width = gimp_temp_buf_get_width (brush->mask);
+ *height = gimp_temp_buf_get_height (brush->mask);;
return;
}
diff --git a/app/core/gimpbrushgenerated.c b/app/core/gimpbrushgenerated.c
index 00176aa..b45b390 100644
--- a/app/core/gimpbrushgenerated.c
+++ b/app/core/gimpbrushgenerated.c
@@ -470,6 +470,7 @@ gimp_brush_generated_calc (GimpBrushGenerated *brush,
GimpVector2 x_axis;
GimpVector2 y_axis;
GimpTempBuf *mask;
+ gint mask_width;
gimp_brush_generated_get_half_size (brush,
shape,
@@ -485,8 +486,10 @@ gimp_brush_generated_calc (GimpBrushGenerated *brush,
half_height * 2 + 1,
babl_format ("Y u8"));
+ mask_width = gimp_temp_buf_get_width (mask);
+
centerp = gimp_temp_buf_get_data (mask) +
- half_height * mask->width + half_width;
+ half_height * mask_width + half_width;
lookup = gimp_brush_generated_calc_lut (radius, hardness);
@@ -538,10 +541,10 @@ gimp_brush_generated_calc (GimpBrushGenerated *brush,
else
a = 0;
- centerp[y * mask->width + x] = a;
+ centerp[y * mask_width + x] = a;
if (spikes % 2 == 0)
- centerp[-1 * y * mask->width - x] = a;
+ centerp[-1 * y * mask_width - x] = a;
}
}
diff --git a/app/core/gimpimage-preview.c b/app/core/gimpimage-preview.c
index b91d0c3..a48309c 100644
--- a/app/core/gimpimage-preview.c
+++ b/app/core/gimpimage-preview.c
@@ -101,9 +101,9 @@ gimp_image_get_preview (GimpViewable *viewable,
{
GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (viewable);
- if (private->preview &&
- private->preview->width == width &&
- private->preview->height == height)
+ if (private->preview &&
+ gimp_temp_buf_get_width (private->preview) == width &&
+ gimp_temp_buf_get_height (private->preview) == height)
{
/* The easy way */
return private->preview;
@@ -148,13 +148,15 @@ gimp_image_get_new_preview (GimpViewable *viewable,
if (is_premult)
{
- if (buf->format == babl_format ("Y'A u8"))
+ const Babl *format = gimp_temp_buf_get_format (buf);
+
+ if (format == babl_format ("Y'A u8"))
{
- buf->format = babl_format ("Y'aA u8");
+ gimp_temp_buf_set_format (buf, babl_format ("Y'aA u8"));
}
- else if (buf->format == babl_format ("R'G'B'A u8"))
+ else if (format == babl_format ("R'G'B'A u8"))
{
- buf->format = babl_format ("R'aG'aB'aA u8");
+ gimp_temp_buf_set_format (buf, babl_format ("R'aG'aB'aA u8"));
}
else
{
diff --git a/app/core/gimppattern.c b/app/core/gimppattern.c
index 1ea205c..fc77ea2 100644
--- a/app/core/gimppattern.c
+++ b/app/core/gimppattern.c
@@ -131,8 +131,8 @@ gimp_pattern_get_size (GimpViewable *viewable,
{
GimpPattern *pattern = GIMP_PATTERN (viewable);
- *width = pattern->mask->width;
- *height = pattern->mask->height;
+ *width = gimp_temp_buf_get_width (pattern->mask);
+ *height = gimp_temp_buf_get_height (pattern->mask);
return TRUE;
}
@@ -150,11 +150,11 @@ gimp_pattern_get_new_preview (GimpViewable *viewable,
gint copy_width;
gint copy_height;
- copy_width = MIN (width, pattern->mask->width);
- copy_height = MIN (height, pattern->mask->height);
+ copy_width = MIN (width, gimp_temp_buf_get_width (pattern->mask));
+ copy_height = MIN (height, gimp_temp_buf_get_height (pattern->mask));
temp_buf = gimp_temp_buf_new (copy_width, copy_height,
- pattern->mask->format);
+ gimp_temp_buf_get_format (pattern->mask));
src_buffer = gimp_temp_buf_create_buffer (pattern->mask);
dest_buffer = gimp_temp_buf_create_buffer (temp_buf);
@@ -176,8 +176,8 @@ gimp_pattern_get_description (GimpViewable *viewable,
return g_strdup_printf ("%s (%d à %d)",
gimp_object_get_name (pattern),
- pattern->mask->width,
- pattern->mask->height);
+ gimp_temp_buf_get_width (pattern->mask),
+ gimp_temp_buf_get_height (pattern->mask));
}
static const gchar *
@@ -236,8 +236,8 @@ gimp_pattern_new (GimpContext *context,
data = gimp_temp_buf_get_data (pattern->mask);
- for (row = 0; row < pattern->mask->height; row++)
- for (col = 0; col < pattern->mask->width; col++)
+ for (row = 0; row < gimp_temp_buf_get_height (pattern->mask); row++)
+ for (col = 0; col < gimp_temp_buf_get_width (pattern->mask); col++)
{
memset (data, (col % 2) && (row % 2) ? 255 : 0, 3);
data += 3;
diff --git a/app/core/gimppreviewcache.c b/app/core/gimppreviewcache.c
index bb38446..211d77e 100644
--- a/app/core/gimppreviewcache.c
+++ b/app/core/gimppreviewcache.c
@@ -43,7 +43,8 @@ preview_cache_compare (gconstpointer a,
const GimpTempBuf *buf1 = a;
const GimpTempBuf *buf2 = b;
- if (buf1->width > buf2->width && buf1->height > buf2->height)
+ if (gimp_temp_buf_get_width (buf1) > gimp_temp_buf_get_width (buf2) &&
+ gimp_temp_buf_get_height (buf1) > gimp_temp_buf_get_height (buf2))
return -1;
return 1;
@@ -59,7 +60,8 @@ preview_cache_find_exact (gpointer data,
if (nearest->buf)
return;
- if (buf->width == nearest->width && buf->height == nearest->height)
+ if (gimp_temp_buf_get_width (buf) == nearest->width &&
+ gimp_temp_buf_get_height (buf) == nearest->height)
{
nearest->buf = buf;
return;
@@ -73,15 +75,16 @@ preview_cache_find_biggest (gpointer data,
GimpTempBuf *buf = data;
PreviewNearest *nearest = udata;
- if (buf->width >= nearest->width && buf->height >= nearest->height)
+ if (gimp_temp_buf_get_width (buf) >= nearest->width &&
+ gimp_temp_buf_get_height (buf) >= nearest->height)
{
/* Ok we could make the preview out of this one...
* If we already have it are these bigger dimensions?
*/
if (nearest->buf)
{
- if (nearest->buf->width > buf->width &&
- nearest->buf->height > buf->height)
+ if (gimp_temp_buf_get_width (nearest->buf) > gimp_temp_buf_get_width (buf) &&
+ gimp_temp_buf_get_height (nearest->buf) > gimp_temp_buf_get_height (buf))
return;
}
@@ -109,7 +112,8 @@ preview_cache_remove_smallest (GSList **plist)
{
GimpTempBuf *this = list->data;
- if (smallest->height * smallest->width > this->height * this->width)
+ if (gimp_temp_buf_get_width (smallest) * gimp_temp_buf_get_height (smallest) >
+ gimp_temp_buf_get_width (this) * gimp_temp_buf_get_height (this))
{
smallest = this;
}
@@ -224,11 +228,12 @@ gimp_preview_cache_get (GSList **plist,
#endif
/* Make up new preview from the large one... */
- pwidth = pn.buf->width;
- pheight = pn.buf->height;
+ pwidth = gimp_temp_buf_get_width (pn.buf);
+ pheight = gimp_temp_buf_get_height (pn.buf);
/* Now get the real one and add to cache */
- preview = gimp_temp_buf_new (width, height, pn.buf->format);
+ preview = gimp_temp_buf_new (width, height,
+ gimp_temp_buf_get_format (pn.buf));
/* preview from nearest bigger one */
if (width)
@@ -244,7 +249,7 @@ gimp_preview_cache_get (GSList **plist,
src_data = gimp_temp_buf_get_data (pn.buf);
dest_data = gimp_temp_buf_get_data (preview);
- bytes = babl_format_get_bytes_per_pixel (preview->format);
+ bytes = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (preview));
for (loop1 = 0 ; loop1 < height ; loop1++)
for (loop2 = 0 ; loop2 < width ; loop2++)
diff --git a/app/core/gimptempbuf.c b/app/core/gimptempbuf.c
index 91a00de..e5fb95a 100644
--- a/app/core/gimptempbuf.c
+++ b/app/core/gimptempbuf.c
@@ -28,6 +28,16 @@
#include "gimptempbuf.h"
+struct _GimpTempBuf
+{
+ gint ref_count;
+ gint width;
+ gint height;
+ const Babl *format;
+ guchar *data;
+};
+
+
GimpTempBuf *
gimp_temp_buf_new (gint width,
gint height,
@@ -41,13 +51,12 @@ gimp_temp_buf_new (gint width,
temp = g_slice_new (GimpTempBuf);
temp->ref_count = 1;
- temp->format = format;
temp->width = width;
temp->height = height;
-
- temp->data = g_new (guchar,
- width * height *
- babl_format_get_bytes_per_pixel (format));
+ temp->format = format;
+ temp->data = g_new (guchar,
+ width * height *
+ babl_format_get_bytes_per_pixel (format));
return temp;
}
@@ -150,6 +159,34 @@ gimp_temp_buf_scale (const GimpTempBuf *src,
return dest;
}
+gint
+gimp_temp_buf_get_width (const GimpTempBuf *buf)
+{
+ return buf->width;
+}
+
+gint
+gimp_temp_buf_get_height (const GimpTempBuf *buf)
+{
+ return buf->height;
+}
+
+const Babl *
+gimp_temp_buf_get_format (const GimpTempBuf *buf)
+{
+ return buf->format;
+}
+
+void
+gimp_temp_buf_set_format (GimpTempBuf *buf,
+ const Babl *format)
+{
+ g_return_if_fail (babl_format_get_bytes_per_pixel (buf->format) ==
+ babl_format_get_bytes_per_pixel (format));
+
+ buf->format = format;
+}
+
guchar *
gimp_temp_buf_get_data (const GimpTempBuf *buf)
{
diff --git a/app/core/gimptempbuf.h b/app/core/gimptempbuf.h
index f05cb09..2a6033a 100644
--- a/app/core/gimptempbuf.h
+++ b/app/core/gimptempbuf.h
@@ -19,16 +19,6 @@
#define __GIMP_TEMP_BUF_H__
-struct _GimpTempBuf
-{
- gint ref_count;
- const Babl *format;
- gint width;
- gint height;
- guchar *data;
-};
-
-
GimpTempBuf * gimp_temp_buf_new (gint width,
gint height,
const Babl *fomat) G_GNUC_WARN_UNUSED_RESULT;
@@ -41,8 +31,16 @@ GimpTempBuf * gimp_temp_buf_scale (const GimpTempBuf *buf,
gint width,
gint height) G_GNUC_WARN_UNUSED_RESULT;
+gint gimp_temp_buf_get_width (const GimpTempBuf *buf);
+gint gimp_temp_buf_get_height (const GimpTempBuf *buf);
+
+const Babl * gimp_temp_buf_get_format (const GimpTempBuf *buf);
+void gimp_temp_buf_set_format (GimpTempBuf *buf,
+ const Babl *format);
+
guchar * gimp_temp_buf_get_data (const GimpTempBuf *buf);
gsize gimp_temp_buf_get_data_size (const GimpTempBuf *buf);
+
guchar * gimp_temp_buf_data_clear (GimpTempBuf *buf);
gsize gimp_temp_buf_get_memsize (const GimpTempBuf *buf);
diff --git a/app/core/gimpundo.c b/app/core/gimpundo.c
index 5cd766b..5fd0e26 100644
--- a/app/core/gimpundo.c
+++ b/app/core/gimpundo.c
@@ -288,10 +288,11 @@ gimp_undo_get_popup_size (GimpViewable *viewable,
GimpUndo *undo = GIMP_UNDO (viewable);
if (undo->preview &&
- (undo->preview->width > width || undo->preview->height > height))
+ (gimp_temp_buf_get_width (undo->preview) > width ||
+ gimp_temp_buf_get_height (undo->preview) > height))
{
- *popup_width = undo->preview->width;
- *popup_height = undo->preview->height;
+ *popup_width = gimp_temp_buf_get_width (undo->preview);
+ *popup_height = gimp_temp_buf_get_height (undo->preview);
return TRUE;
}
@@ -312,8 +313,8 @@ gimp_undo_get_new_preview (GimpViewable *viewable,
gint preview_width;
gint preview_height;
- gimp_viewable_calc_preview_size (undo->preview->width,
- undo->preview->height,
+ gimp_viewable_calc_preview_size (gimp_temp_buf_get_width (undo->preview),
+ gimp_temp_buf_get_height (undo->preview),
width,
height,
TRUE, 1.0, 1.0,
@@ -321,8 +322,8 @@ gimp_undo_get_new_preview (GimpViewable *viewable,
&preview_height,
NULL);
- if (preview_width < undo->preview->width &&
- preview_height < undo->preview->height)
+ if (preview_width < gimp_temp_buf_get_width (undo->preview) &&
+ preview_height < gimp_temp_buf_get_height (undo->preview))
{
return gimp_temp_buf_scale (undo->preview,
preview_width, preview_height);
diff --git a/app/core/gimpviewable.c b/app/core/gimpviewable.c
index dfeaba7..b87f187 100644
--- a/app/core/gimpviewable.c
+++ b/app/core/gimpviewable.c
@@ -358,10 +358,10 @@ gimp_viewable_real_get_new_pixbuf (GimpViewable *viewable,
GeglBuffer *dest_buffer;
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
- babl_format_has_alpha (temp_buf->format),
+ babl_format_has_alpha (gimp_temp_buf_get_format (temp_buf)),
8,
- temp_buf->width,
- temp_buf->height);
+ gimp_temp_buf_get_width (temp_buf),
+ gimp_temp_buf_get_height (temp_buf));
src_buffer = gimp_temp_buf_create_buffer (temp_buf);
dest_buffer = gimp_pixbuf_create_buffer (pixbuf);
@@ -709,8 +709,8 @@ gimp_viewable_get_preview (GimpViewable *viewable,
if (private->preview_temp_buf)
{
- if (private->preview_temp_buf->width == width &&
- private->preview_temp_buf->height == height)
+ if (gimp_temp_buf_get_width (private->preview_temp_buf) == width &&
+ gimp_temp_buf_get_height (private->preview_temp_buf) == height)
{
return private->preview_temp_buf;
}
diff --git a/app/paint/gimpbrushcore.c b/app/paint/gimpbrushcore.c
index e5c9c79..e11189b 100644
--- a/app/paint/gimpbrushcore.c
+++ b/app/paint/gimpbrushcore.c
@@ -332,8 +332,8 @@ gimp_brush_core_pre_paint (GimpPaintCore *paint_core,
paint_core->pixel_dist);
scale = paint_options->brush_size /
- MAX (core->main_brush->mask->width,
- core->main_brush->mask->height) *
+ MAX (gimp_temp_buf_get_width (core->main_brush->mask),
+ gimp_temp_buf_get_height (core->main_brush->mask)) *
gimp_dynamics_output_get_linear_value (size_output,
¤t_coords,
paint_options,
@@ -942,8 +942,8 @@ gimp_brush_core_paste_canvas (GimpBrushCore *core,
gint off_x;
gint off_y;
- x = (gint) floor (coords->x) - (brush_mask->width >> 1);
- y = (gint) floor (coords->y) - (brush_mask->height >> 1);
+ x = (gint) floor (coords->x) - (gimp_temp_buf_get_width (brush_mask) >> 1);
+ y = (gint) floor (coords->y) - (gimp_temp_buf_get_height (brush_mask) >> 1);
off_x = (x < 0) ? -x : 0;
off_y = (y < 0) ? -y : 0;
@@ -992,8 +992,8 @@ gimp_brush_core_replace_canvas (GimpBrushCore *core,
gint off_x;
gint off_y;
- x = (gint) floor (coords->x) - (brush_mask->width >> 1);
- y = (gint) floor (coords->y) - (brush_mask->height >> 1);
+ x = (gint) floor (coords->x) - (gimp_temp_buf_get_width (brush_mask) >> 1);
+ y = (gint) floor (coords->y) - (gimp_temp_buf_get_height (brush_mask) >> 1);
off_x = (x < 0) ? -x : 0;
off_y = (y < 0) ? -y : 0;
@@ -1066,21 +1066,25 @@ gimp_brush_core_subsample_mask (GimpBrushCore *core,
gint r, s;
gulong *accum[KERNEL_HEIGHT];
gint offs;
+ gint mask_width = gimp_temp_buf_get_width (mask);
+ gint mask_height = gimp_temp_buf_get_height (mask);
+ gint dest_width;
+ gint dest_height;
while (x < 0)
- x += mask->width;
+ x += mask_width;
left = x - floor (x);
index1 = (gint) (left * (gdouble) (KERNEL_SUBSAMPLE + 1));
while (y < 0)
- y += mask->height;
+ y += mask_height;
left = y - floor (y);
index2 = (gint) (left * (gdouble) (KERNEL_SUBSAMPLE + 1));
- if ((mask->width % 2) == 0)
+ if ((mask_width % 2) == 0)
{
index1 += KERNEL_SUBSAMPLE >> 1;
@@ -1091,7 +1095,7 @@ gimp_brush_core_subsample_mask (GimpBrushCore *core,
}
}
- if ((mask->height % 2) == 0)
+ if ((mask_height % 2) == 0)
{
index2 += KERNEL_SUBSAMPLE >> 1;
@@ -1125,21 +1129,24 @@ gimp_brush_core_subsample_mask (GimpBrushCore *core,
core->subsample_cache_invalid = FALSE;
}
- dest = gimp_temp_buf_new (mask->width + 2,
- mask->height + 2,
- mask->format);
+ dest = gimp_temp_buf_new (mask_width + 2,
+ mask_height + 2,
+ gimp_temp_buf_get_format (mask));
gimp_temp_buf_data_clear (dest);
+ dest_width = gimp_temp_buf_get_width (dest);
+ dest_height = gimp_temp_buf_get_height (dest);
+
/* Allocate and initialize the accum buffer */
for (i = 0; i < KERNEL_HEIGHT ; i++)
- accum[i] = g_new0 (gulong, dest->width + 1);
+ accum[i] = g_new0 (gulong, dest_width + 1);
core->subsample_brushes[index2][index1] = dest;
m = gimp_temp_buf_get_data (mask);
- for (i = 0; i < mask->height; i++)
+ for (i = 0; i < mask_height; i++)
{
- for (j = 0; j < mask->width; j++)
+ for (j = 0; j < mask_width; j++)
{
k = kernel;
for (r = 0; r < KERNEL_HEIGHT; r++)
@@ -1153,20 +1160,20 @@ gimp_brush_core_subsample_mask (GimpBrushCore *core,
}
/* store the accum buffer into the destination mask */
- d = gimp_temp_buf_get_data (dest) + (i + dest_offset_y) * dest->width;
- for (j = 0; j < dest->width; j++)
+ d = gimp_temp_buf_get_data (dest) + (i + dest_offset_y) * dest_width;
+ for (j = 0; j < dest_width; j++)
*d++ = (accum[0][j] + 127) / KERNEL_SUM;
rotate_pointers (accum, KERNEL_HEIGHT);
- memset (accum[KERNEL_HEIGHT - 1], 0, sizeof (gulong) * dest->width);
+ memset (accum[KERNEL_HEIGHT - 1], 0, sizeof (gulong) * dest_width);
}
/* store the rest of the accum buffer into the dest mask */
- while (i + dest_offset_y < dest->height)
+ while (i + dest_offset_y < dest_height)
{
- d = gimp_temp_buf_get_data (dest) + (i + dest_offset_y) * dest->width;
- for (j = 0; j < dest->width; j++)
+ d = gimp_temp_buf_get_data (dest) + (i + dest_offset_y) * dest_width;
+ for (j = 0; j < dest_width; j++)
*d++ = (accum[0][j] + (KERNEL_SUM / 2)) / KERNEL_SUM;
rotate_pointers (accum, KERNEL_HEIGHT);
@@ -1206,9 +1213,10 @@ gimp_brush_core_pressurize_mask (GimpBrushCore *core,
if (core->pressure_brush)
gimp_temp_buf_unref (core->pressure_brush);
- core->pressure_brush = gimp_temp_buf_new (brush_mask->width + 2,
- brush_mask->height + 2,
- brush_mask->format);
+ core->pressure_brush =
+ gimp_temp_buf_new (gimp_temp_buf_get_width (brush_mask) + 2,
+ gimp_temp_buf_get_height (brush_mask) + 2,
+ gimp_temp_buf_get_format (brush_mask));
gimp_temp_buf_data_clear (core->pressure_brush);
#ifdef FANCY_PRESSURE
@@ -1289,7 +1297,9 @@ gimp_brush_core_pressurize_mask (GimpBrushCore *core,
source = gimp_temp_buf_get_data (subsample_mask);
dest = gimp_temp_buf_get_data (core->pressure_brush);
- i = subsample_mask->width * subsample_mask->height;
+ i = gimp_temp_buf_get_width (subsample_mask) *
+ gimp_temp_buf_get_height (subsample_mask);
+
while (i--)
*dest++ = mapi[(*source++)];
@@ -1305,23 +1315,26 @@ gimp_brush_core_solidify_mask (GimpBrushCore *core,
GimpTempBuf *dest;
const guchar *m;
guchar *d;
- gint dest_offset_x = 0;
- gint dest_offset_y = 0;
+ gint dest_offset_x = 0;
+ gint dest_offset_y = 0;
+ gint brush_mask_width = gimp_temp_buf_get_width (brush_mask);
+ gint brush_mask_height = gimp_temp_buf_get_height (brush_mask);
+
gint i, j;
- if ((brush_mask->width % 2) == 0)
+ if ((brush_mask_width % 2) == 0)
{
while (x < 0)
- x += brush_mask->width;
+ x += brush_mask_width;
if ((x - floor (x)) >= 0.5)
dest_offset_x++;
}
- if ((brush_mask->height % 2) == 0)
+ if ((brush_mask_height % 2) == 0)
{
while (y < 0)
- y += brush_mask->height;
+ y += brush_mask_height;
if ((y - floor (y)) >= 0.5)
dest_offset_y++;
@@ -1347,21 +1360,21 @@ gimp_brush_core_solidify_mask (GimpBrushCore *core,
core->solid_cache_invalid = FALSE;
}
- dest = gimp_temp_buf_new (brush_mask->width + 2,
- brush_mask->height + 2,
- brush_mask->format);
+ dest = gimp_temp_buf_new (brush_mask_width + 2,
+ brush_mask_height + 2,
+ gimp_temp_buf_get_format (brush_mask));
gimp_temp_buf_data_clear (dest);
core->solid_brushes[dest_offset_y][dest_offset_x] = dest;
m = gimp_temp_buf_get_data (brush_mask);
d = (gimp_temp_buf_get_data (dest) +
- (dest_offset_y + 1) * dest->width +
+ (dest_offset_y + 1) * gimp_temp_buf_get_width (dest) +
(dest_offset_x + 1));
- for (i = 0; i < brush_mask->height; i++)
+ for (i = 0; i < brush_mask_height; i++)
{
- for (j = 0; j < brush_mask->width; j++)
+ for (j = 0; j < brush_mask_width; j++)
*d++ = (*m++) ? OPAQUE_OPACITY : TRANSPARENT_OPACITY;
d += 2;
@@ -1465,8 +1478,8 @@ gimp_brush_core_eval_transform_dynamics (GimpBrushCore *core,
{
if (core->main_brush)
core->scale = paint_options->brush_size /
- MAX (core->main_brush->mask->width,
- core->main_brush->mask->height);
+ MAX (gimp_temp_buf_get_width (core->main_brush->mask),
+ gimp_temp_buf_get_height (core->main_brush->mask));
else
core->scale = -1;
@@ -1574,15 +1587,15 @@ gimp_brush_core_color_area_with_pixmap (GimpBrushCore *core,
/* Calculate upper left corner of brush as in
* gimp_paint_core_get_paint_area. Ugly to have to do this here, too.
*/
- ulx = (gint) floor (coords->x) - (pixmap_mask->width >> 1);
- uly = (gint) floor (coords->y) - (pixmap_mask->height >> 1);
+ ulx = (gint) floor (coords->x) - (gimp_temp_buf_get_width (pixmap_mask) >> 1);
+ uly = (gint) floor (coords->y) - (gimp_temp_buf_get_height (pixmap_mask) >> 1);
/* Not sure why this is necessary, but empirically the code does
* not work without it for even-sided brushes. See bug #166622.
*/
- if (pixmap_mask->width % 2 == 0)
+ if (gimp_temp_buf_get_width (pixmap_mask) % 2 == 0)
ulx += ROUND (coords->x) - floor (coords->x);
- if (pixmap_mask->height % 2 == 0)
+ if (gimp_temp_buf_get_height (pixmap_mask) % 2 == 0)
uly += ROUND (coords->y) - floor (coords->y);
offsetx = area_x - ulx;
@@ -1620,30 +1633,36 @@ gimp_brush_core_paint_line_pixmap_mask (GimpDrawable *drawable,
gint width,
GimpBrushApplicationMode mode)
{
+ const Babl *pixmap_format;
GimpImageBaseType pixmap_base_type;
GimpPrecision pixmap_precision;
gint pixmap_bytes;
+ gint pixmap_width;
+ gint pixmap_height;
guchar *b;
+ pixmap_width = gimp_temp_buf_get_width (pixmap_mask);
+ pixmap_height = gimp_temp_buf_get_height (pixmap_mask);
+
/* Make sure x, y are positive */
- while (x < 0)
- x += pixmap_mask->width;
- while (y < 0)
- y += pixmap_mask->height;
+ while (x < 0) x += pixmap_width;
+ while (y < 0) y += pixmap_height;
- pixmap_base_type = gimp_babl_format_get_base_type (pixmap_mask->format);
- pixmap_precision = gimp_babl_format_get_precision (pixmap_mask->format);
- pixmap_bytes = babl_format_get_bytes_per_pixel (pixmap_mask->format);
+ pixmap_format = gimp_temp_buf_get_format (pixmap_mask);
+ pixmap_base_type = gimp_babl_format_get_base_type (pixmap_format);
+ pixmap_precision = gimp_babl_format_get_precision (pixmap_format);
+ pixmap_bytes = babl_format_get_bytes_per_pixel (pixmap_format);
/* Point to the approriate scanline */
b = (gimp_temp_buf_get_data (pixmap_mask) +
- (y % pixmap_mask->height) * pixmap_mask->width * pixmap_bytes);
+ (y % pixmap_height) * pixmap_width * pixmap_bytes);
if (mode == GIMP_BRUSH_SOFT && brush_mask)
{
const Babl *fish;
const guchar *mask = (gimp_temp_buf_get_data (brush_mask) +
- (y % brush_mask->height) * brush_mask->width);
+ (y % gimp_temp_buf_get_height (brush_mask)) *
+ gimp_temp_buf_get_width (brush_mask));
guchar *line_buf = g_alloca (width * (pixmap_bytes + 1));
guchar *l = line_buf;
gint i;
@@ -1658,7 +1677,7 @@ gimp_brush_core_paint_line_pixmap_mask (GimpDrawable *drawable,
*/
for (i = 0; i < width; i++)
{
- gint x_index = ((i + x) % pixmap_mask->width);
+ gint x_index = ((i + x) % pixmap_width);
gint p_bytes = pixmap_bytes;
guchar *p = b + x_index * p_bytes;
@@ -1677,7 +1696,7 @@ gimp_brush_core_paint_line_pixmap_mask (GimpDrawable *drawable,
guchar *l = line_buf;
gint i;
- fish = babl_fish (pixmap_mask->format,
+ fish = babl_fish (pixmap_format,
gimp_drawable_get_format_with_alpha (drawable));
/* put the source pixmap's pixels, into one line, so we can use
@@ -1685,7 +1704,7 @@ gimp_brush_core_paint_line_pixmap_mask (GimpDrawable *drawable,
*/
for (i = 0; i < width; i++)
{
- gint x_index = ((i + x) % pixmap_mask->width);
+ gint x_index = ((i + x) % pixmap_width);
gint p_bytes = pixmap_bytes;
guchar *p = b + x_index * p_bytes;
diff --git a/app/paint/gimpconvolve.c b/app/paint/gimpconvolve.c
index a750e6f..bbdd450 100644
--- a/app/paint/gimpconvolve.c
+++ b/app/paint/gimpconvolve.c
@@ -173,8 +173,8 @@ gimp_convolve_motion (GimpPaintCore *paint_core,
fade_point));
gimp_convolve_calculate_matrix (convolve, options->type,
- brush_core->brush->mask->width / 2,
- brush_core->brush->mask->height / 2,
+ gimp_temp_buf_get_width (brush_core->brush->mask) / 2,
+ gimp_temp_buf_get_height (brush_core->brush->mask) / 2,
rate);
convolve_temp = gimp_temp_buf_new (gegl_buffer_get_width (paint_buffer),
@@ -193,8 +193,8 @@ gimp_convolve_motion (GimpPaintCore *paint_core,
gimp_gegl_convolve (convolve_buffer,
GEGL_RECTANGLE (0, 0,
- convolve_temp->width,
- convolve_temp->height),
+ gimp_temp_buf_get_width (convolve_temp),
+ gimp_temp_buf_get_height (convolve_temp)),
paint_buffer,
GEGL_RECTANGLE (0, 0,
gegl_buffer_get_width (paint_buffer),
diff --git a/app/pdb/brush-cmds.c b/app/pdb/brush-cmds.c
index 7fff407..bde634b 100644
--- a/app/pdb/brush-cmds.c
+++ b/app/pdb/brush-cmds.c
@@ -277,10 +277,10 @@ brush_get_info_invoker (GimpProcedure *procedure,
if (brush)
{
- width = brush->mask->width;
- height = brush->mask->height;
- mask_bpp = babl_format_get_bytes_per_pixel (brush->mask->format);
- color_bpp = brush->pixmap ? babl_format_get_bytes_per_pixel (brush->pixmap->format) : 0;
+ width = gimp_temp_buf_get_width (brush->mask);
+ height = gimp_temp_buf_get_height (brush->mask);
+ mask_bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (brush->mask));
+ color_bpp = brush->pixmap ? babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (brush->pixmap)) : 0;
}
else
success = FALSE;
@@ -328,17 +328,19 @@ brush_get_pixels_invoker (GimpProcedure *procedure,
if (brush)
{
- width = brush->mask->width;
- height = brush->mask->height;
- mask_bpp = babl_format_get_bytes_per_pixel (brush->mask->format);
- num_mask_bytes = brush->mask->height * brush->mask->width * mask_bpp;
+ width = gimp_temp_buf_get_width (brush->mask);
+ height = gimp_temp_buf_get_height (brush->mask);
+ mask_bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (brush->mask));
+ num_mask_bytes = gimp_temp_buf_get_height (brush->mask) *
+ gimp_temp_buf_get_width (brush->mask) * mask_bpp;
mask_bytes = g_memdup (gimp_temp_buf_get_data (brush->mask),
num_mask_bytes);
if (brush->pixmap)
{
- color_bpp = babl_format_get_bytes_per_pixel (brush->pixmap->format);
- num_color_bytes = brush->pixmap->height * brush->pixmap->width *
+ color_bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (brush->pixmap));
+ num_color_bytes = gimp_temp_buf_get_height (brush->pixmap) *
+ gimp_temp_buf_get_width (brush->pixmap) *
color_bpp;
color_bytes = g_memdup (gimp_temp_buf_get_data (brush->pixmap),
num_color_bytes);
diff --git a/app/pdb/brushes-cmds.c b/app/pdb/brushes-cmds.c
index ee95936..3cfc452 100644
--- a/app/pdb/brushes-cmds.c
+++ b/app/pdb/brushes-cmds.c
@@ -106,8 +106,8 @@ brushes_get_brush_invoker (GimpProcedure *procedure,
if (brush)
{
name = g_strdup (gimp_object_get_name (brush));
- width = brush->mask->width;
- height = brush->mask->height;
+ width = gimp_temp_buf_get_width (brush->mask);
+ height = gimp_temp_buf_get_height (brush->mask);
spacing = gimp_brush_get_spacing (brush);
}
else
@@ -214,8 +214,8 @@ brushes_get_brush_data_invoker (GimpProcedure *procedure,
opacity = 1.0;
spacing = gimp_brush_get_spacing (brush);
paint_mode = 0;
- width = brush->mask->width;
- height = brush->mask->height;
+ width = gimp_temp_buf_get_width (brush->mask);
+ height = gimp_temp_buf_get_height (brush->mask);
length = gimp_temp_buf_get_data_size (brush->mask);
mask_data = g_memdup (gimp_temp_buf_get_data (brush->mask), length);
}
diff --git a/app/pdb/context-cmds.c b/app/pdb/context-cmds.c
index e6347b6..9ebe48b 100644
--- a/app/pdb/context-cmds.c
+++ b/app/pdb/context-cmds.c
@@ -509,8 +509,9 @@ context_set_brush_default_size_invoker (GimpProcedure *procedure,
for (list = options; list; list = g_list_next (list))
g_object_set (list->data,
- "brush-size", (gdouble) MAX (brush->mask->width,
- brush->mask->height),
+ "brush-size",
+ (gdouble) MAX (gimp_temp_buf_get_width (brush->mask),
+ gimp_temp_buf_get_height (brush->mask)),
NULL);
g_list_free (options);
diff --git a/app/pdb/drawable-cmds.c b/app/pdb/drawable-cmds.c
index 0252f45..035f518 100644
--- a/app/pdb/drawable-cmds.c
+++ b/app/pdb/drawable-cmds.c
@@ -744,9 +744,9 @@ drawable_thumbnail_invoker (GimpProcedure *procedure,
if (buf)
{
- actual_width = buf->width;
- actual_height = buf->height;
- bpp = babl_format_get_bytes_per_pixel (buf->format);
+ actual_width = gimp_temp_buf_get_width (buf);
+ actual_height = gimp_temp_buf_get_height (buf);
+ bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (buf));
thumbnail_data_count = gimp_temp_buf_get_data_size (buf);
thumbnail_data = g_memdup (gimp_temp_buf_get_data (buf),
thumbnail_data_count);
@@ -823,9 +823,9 @@ drawable_sub_thumbnail_invoker (GimpProcedure *procedure,
if (buf)
{
- width = buf->width;
- height = buf->height;
- bpp = babl_format_get_bytes_per_pixel (buf->format);
+ width = gimp_temp_buf_get_width (buf);
+ height = gimp_temp_buf_get_height (buf);
+ bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (buf));
thumbnail_data_count = gimp_temp_buf_get_data_size (buf);
thumbnail_data = g_memdup (gimp_temp_buf_get_data (buf),
thumbnail_data_count);
diff --git a/app/pdb/image-cmds.c b/app/pdb/image-cmds.c
index d684e39..a5eb078 100644
--- a/app/pdb/image-cmds.c
+++ b/app/pdb/image-cmds.c
@@ -1713,9 +1713,9 @@ image_thumbnail_invoker (GimpProcedure *procedure,
if (buf)
{
- actual_width = buf->width;
- actual_height = buf->height;
- bpp = babl_format_get_bytes_per_pixel (buf->format);
+ actual_width = gimp_temp_buf_get_width (buf);
+ actual_height = gimp_temp_buf_get_height (buf);
+ bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (buf));
thumbnail_data_count = gimp_temp_buf_get_data_size (buf);
thumbnail_data = g_memdup (gimp_temp_buf_get_data (buf),
thumbnail_data_count);
diff --git a/app/pdb/pattern-cmds.c b/app/pdb/pattern-cmds.c
index f37c1ac..4f822b7 100644
--- a/app/pdb/pattern-cmds.c
+++ b/app/pdb/pattern-cmds.c
@@ -60,9 +60,9 @@ pattern_get_info_invoker (GimpProcedure *procedure,
if (pattern)
{
- width = pattern->mask->width;
- height = pattern->mask->height;
- bpp = babl_format_get_bytes_per_pixel (pattern->mask->format);
+ width = gimp_temp_buf_get_width (pattern->mask);
+ height = gimp_temp_buf_get_height (pattern->mask);
+ bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (pattern->mask));
}
else
success = FALSE;
@@ -106,9 +106,9 @@ pattern_get_pixels_invoker (GimpProcedure *procedure,
if (pattern)
{
- width = pattern->mask->width;
- height = pattern->mask->height;
- bpp = babl_format_get_bytes_per_pixel (pattern->mask->format);
+ width = gimp_temp_buf_get_width (pattern->mask);
+ height = gimp_temp_buf_get_height (pattern->mask);
+ bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (pattern->mask));
num_color_bytes = gimp_temp_buf_get_data_size (pattern->mask);
color_bytes = g_memdup (gimp_temp_buf_get_data (pattern->mask),
num_color_bytes);
diff --git a/app/pdb/patterns-cmds.c b/app/pdb/patterns-cmds.c
index 1f3f8dc..a3ff2f9 100644
--- a/app/pdb/patterns-cmds.c
+++ b/app/pdb/patterns-cmds.c
@@ -105,8 +105,8 @@ patterns_get_pattern_invoker (GimpProcedure *procedure,
if (pattern)
{
name = g_strdup (gimp_object_get_name (pattern));
- width = pattern->mask->width;
- height = pattern->mask->height;
+ width = gimp_temp_buf_get_width (pattern->mask);
+ height = gimp_temp_buf_get_height (pattern->mask);
}
else
success = FALSE;
@@ -156,9 +156,9 @@ patterns_get_pattern_data_invoker (GimpProcedure *procedure,
if (pattern)
{
actual_name = g_strdup (gimp_object_get_name (pattern));
- width = pattern->mask->width;
- height = pattern->mask->height;
- mask_bpp = babl_format_get_bytes_per_pixel (pattern->mask->format);
+ width = gimp_temp_buf_get_width (pattern->mask);
+ height = gimp_temp_buf_get_height (pattern->mask);
+ mask_bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (pattern->mask));
length = gimp_temp_buf_get_data_size (pattern->mask);
mask_data = g_memdup (gimp_temp_buf_get_data (pattern->mask), length);
}
diff --git a/app/tools/gimpiscissorstool.c b/app/tools/gimpiscissorstool.c
index f6c5f00..68dffcd 100644
--- a/app/tools/gimpiscissorstool.c
+++ b/app/tools/gimpiscissorstool.c
@@ -1470,12 +1470,10 @@ plot_pixels (GimpIscissorsTool *iscissors,
gint x, y;
guint32 coords;
gint link;
- gint width;
+ gint width = gimp_temp_buf_get_width (dp_buf);
guint *data;
GPtrArray *list;
- width = dp_buf->width;
-
/* Start the data pointer at the correct location */
data = (guint *) gimp_temp_buf_get_data (dp_buf) + (ye - y1) * width + (xe - x1);
@@ -1505,7 +1503,7 @@ plot_pixels (GimpIscissorsTool *iscissors,
#define PACK(x, y) ((((y) & 0xff) << 8) | ((x) & 0xff))
#define OFFSET(pixel) ((gint8)((pixel) & 0xff) + \
- ((gint8)(((pixel) & 0xff00) >> 8)) * dp_buf->width)
+ ((gint8)(((pixel) & 0xff00) >> 8)) * gimp_temp_buf_get_width (dp_buf))
static void
@@ -1532,6 +1530,8 @@ find_optimal_path (TileManager *gradient_map,
guint32 pixel[8];
guint32 *data;
guint32 *d;
+ gint dp_buf_width = gimp_temp_buf_get_width (dp_buf);
+ gint dp_buf_height = gimp_temp_buf_get_height (dp_buf);
/* initialize the dynamic programming buffer */
data = (guint32 *) gimp_temp_buf_data_clear (dp_buf);
@@ -1543,13 +1543,13 @@ find_optimal_path (TileManager *gradient_map,
y = ys;
- for (i = 0; i < dp_buf->height; i++)
+ for (i = 0; i < dp_buf_height; i++)
{
x = xs;
- d = data + (y-y1) * dp_buf->width + (x-x1);
+ d = data + (y-y1) * dp_buf_width + (x-x1);
- for (j = 0; j < dp_buf->width; j++)
+ for (j = 0; j < dp_buf_width; j++)
{
min_cost = G_MAXINT;
@@ -1575,7 +1575,7 @@ find_optimal_path (TileManager *gradient_map,
pixel[((diry == 1) ? (link + 4) : link)] = PACK(-dirx, -diry);
link = (linkdir == 1) ? 2 : 3;
- if (j != dp_buf->width - 1)
+ if (j != dp_buf_width - 1)
pixel[((diry == 1) ? (link + 4) : link)] = PACK (dirx, -diry);
}
diff --git a/app/tools/gimppaintoptions-gui.c b/app/tools/gimppaintoptions-gui.c
index 7ad5d41..d11b0e1 100644
--- a/app/tools/gimppaintoptions-gui.c
+++ b/app/tools/gimppaintoptions-gui.c
@@ -414,8 +414,9 @@ gimp_paint_options_gui_reset_size (GtkWidget *button,
if (brush)
{
g_object_set (paint_options,
- "brush-size", (gdouble) MAX (brush->mask->width,
- brush->mask->height),
+ "brush-size",
+ (gdouble) MAX (gimp_temp_buf_get_width (brush->mask),
+ gimp_temp_buf_get_height (brush->mask)),
NULL);
}
}
diff --git a/app/widgets/gimpbrushselect.c b/app/widgets/gimpbrushselect.c
index dc45767..c526211 100644
--- a/app/widgets/gimpbrushselect.c
+++ b/app/widgets/gimpbrushselect.c
@@ -275,8 +275,8 @@ gimp_brush_select_run_callback (GimpPdbDialog *dialog,
G_TYPE_DOUBLE, gimp_context_get_opacity (dialog->context) * 100.0,
GIMP_TYPE_INT32, GIMP_BRUSH_SELECT (dialog)->spacing,
GIMP_TYPE_INT32, gimp_context_get_paint_mode (dialog->context),
- GIMP_TYPE_INT32, brush->mask->width,
- GIMP_TYPE_INT32, brush->mask->height,
+ GIMP_TYPE_INT32, gimp_temp_buf_get_width (brush->mask),
+ GIMP_TYPE_INT32, gimp_temp_buf_get_height (brush->mask),
GIMP_TYPE_INT32, array->length,
GIMP_TYPE_INT8_ARRAY, array,
GIMP_TYPE_INT32, closing,
diff --git a/app/widgets/gimppatternselect.c b/app/widgets/gimppatternselect.c
index 81ad1a4..3dba0ab 100644
--- a/app/widgets/gimppatternselect.c
+++ b/app/widgets/gimppatternselect.c
@@ -116,9 +116,9 @@ gimp_pattern_select_run_callback (GimpPdbDialog *dialog,
NULL, error,
dialog->callback_name,
G_TYPE_STRING, gimp_object_get_name (object),
- GIMP_TYPE_INT32, pattern->mask->width,
- GIMP_TYPE_INT32, pattern->mask->height,
- GIMP_TYPE_INT32, babl_format_get_bytes_per_pixel (pattern->mask->format),
+ GIMP_TYPE_INT32, gimp_temp_buf_get_width (pattern->mask),
+ GIMP_TYPE_INT32, gimp_temp_buf_get_height (pattern->mask),
+ GIMP_TYPE_INT32, babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (pattern->mask)),
GIMP_TYPE_INT32, array->length,
GIMP_TYPE_INT8_ARRAY, array,
GIMP_TYPE_INT32, closing,
diff --git a/app/widgets/gimpviewrenderer.c b/app/widgets/gimpviewrenderer.c
index 92a2dda..5dccdf7 100644
--- a/app/widgets/gimpviewrenderer.c
+++ b/app/widgets/gimpviewrenderer.c
@@ -798,15 +798,20 @@ gimp_view_renderer_render_temp_buf_simple (GimpViewRenderer *renderer,
{
gint temp_buf_x = 0;
gint temp_buf_y = 0;
+ gint temp_buf_width;
+ gint temp_buf_height;
g_return_if_fail (GIMP_IS_VIEW_RENDERER (renderer));
g_return_if_fail (temp_buf != NULL);
- if (temp_buf->width < renderer->width)
- temp_buf_x = (renderer->width - temp_buf->width) / 2;
+ temp_buf_width = gimp_temp_buf_get_width (temp_buf);
+ temp_buf_height = gimp_temp_buf_get_height (temp_buf);
- if (temp_buf->height < renderer->height)
- temp_buf_y = (renderer->height - temp_buf->height) / 2;
+ if (temp_buf_width < renderer->width)
+ temp_buf_x = (renderer->width - temp_buf_width) / 2;
+
+ if (temp_buf_height < renderer->height)
+ temp_buf_y = (renderer->height - temp_buf_height) / 2;
gimp_view_renderer_render_temp_buf (renderer, temp_buf,
temp_buf_x, temp_buf_y,
@@ -941,13 +946,20 @@ gimp_view_render_temp_buf_to_surface (GimpViewRenderer *renderer,
gint surface_width,
gint surface_height)
{
- cairo_t *cr;
- gint x, y;
- gint width, height;
+ cairo_t *cr;
+ gint x, y;
+ gint width, height;
+ const Babl *temp_buf_format;
+ gint temp_buf_width;
+ gint temp_buf_height;
g_return_if_fail (temp_buf != NULL);
g_return_if_fail (surface != NULL);
+ temp_buf_format = gimp_temp_buf_get_format (temp_buf);
+ temp_buf_width = gimp_temp_buf_get_width (temp_buf);
+ temp_buf_height = gimp_temp_buf_get_height (temp_buf);
+
/* Here are the different cases this functions handles correctly:
* 1) Offset temp_buf which does not necessarily cover full image area
* 2) Color conversion of temp_buf if it is gray and image is color
@@ -988,7 +1000,7 @@ gimp_view_render_temp_buf_to_surface (GimpViewRenderer *renderer,
if (! gimp_rectangle_intersect (0, 0,
surface_width, surface_height,
temp_buf_x, temp_buf_y,
- temp_buf->width, temp_buf->height,
+ temp_buf_width, temp_buf_height,
&x, &y,
&width, &height))
{
@@ -997,7 +1009,7 @@ gimp_view_render_temp_buf_to_surface (GimpViewRenderer *renderer,
}
if (inside_bg != outside_bg &&
- babl_format_has_alpha (temp_buf->format) && channel == -1)
+ babl_format_has_alpha (temp_buf_format) && channel == -1)
{
cairo_rectangle (cr, x, y, width, height);
@@ -1015,7 +1027,7 @@ gimp_view_render_temp_buf_to_surface (GimpViewRenderer *renderer,
cairo_fill (cr);
}
- if (babl_format_has_alpha (temp_buf->format) && channel == -1)
+ if (babl_format_has_alpha (temp_buf_format) && channel == -1)
{
GeglBuffer *src_buffer;
GeglBuffer *dest_buffer;
@@ -1080,8 +1092,8 @@ gimp_view_render_temp_buf_to_surface (GimpViewRenderer *renderer,
cairo_surface_flush (surface);
- bytes = babl_format_get_bytes_per_pixel (temp_buf->format);
- rowstride = temp_buf->width * bytes;
+ bytes = babl_format_get_bytes_per_pixel (temp_buf_format);
+ rowstride = temp_buf_width * bytes;
src = gimp_temp_buf_get_data (temp_buf) + ((y - temp_buf_y) * rowstride +
(x - temp_buf_x) * bytes);
@@ -1091,7 +1103,7 @@ gimp_view_render_temp_buf_to_surface (GimpViewRenderer *renderer,
dest += y * dest_stride + x * 4;
- fish = babl_fish (temp_buf->format,
+ fish = babl_fish (temp_buf_format,
babl_format ("cairo-RGB24"));
for (i = y; i < (y + height); i++)
diff --git a/app/widgets/gimpviewrendererbrush.c b/app/widgets/gimpviewrendererbrush.c
index 36f8046..317cb35 100644
--- a/app/widgets/gimpviewrendererbrush.c
+++ b/app/widgets/gimpviewrendererbrush.c
@@ -91,6 +91,8 @@ gimp_view_renderer_brush_render (GimpViewRenderer *renderer,
GimpTempBuf *temp_buf;
gint temp_buf_x = 0;
gint temp_buf_y = 0;
+ gint temp_buf_width;
+ gint temp_buf_height;
if (renderbrush->pipe_timeout_id)
{
@@ -103,11 +105,14 @@ gimp_view_renderer_brush_render (GimpViewRenderer *renderer,
renderer->width,
renderer->height);
- if (temp_buf->width < renderer->width)
- temp_buf_x = (renderer->width - temp_buf->width) / 2;
+ temp_buf_width = gimp_temp_buf_get_width (temp_buf);
+ temp_buf_height = gimp_temp_buf_get_height (temp_buf);
- if (temp_buf->height < renderer->height)
- temp_buf_y = (renderer->height - temp_buf->height) / 2;
+ if (temp_buf_width < renderer->width)
+ temp_buf_x = (renderer->width - temp_buf_width) / 2;
+
+ if (temp_buf_height < renderer->height)
+ temp_buf_y = (renderer->height - temp_buf_height) / 2;
if (renderer->is_popup)
{
@@ -149,6 +154,8 @@ gimp_view_renderer_brush_render_timeout (gpointer data)
GimpTempBuf *temp_buf;
gint temp_buf_x = 0;
gint temp_buf_y = 0;
+ gint temp_buf_width;
+ gint temp_buf_height;
if (! renderer->viewable)
{
@@ -173,11 +180,14 @@ gimp_view_renderer_brush_render_timeout (gpointer data)
renderer->width,
renderer->height);
- if (temp_buf->width < renderer->width)
- temp_buf_x = (renderer->width - temp_buf->width) / 2;
+ temp_buf_width = gimp_temp_buf_get_width (temp_buf);
+ temp_buf_height = gimp_temp_buf_get_height (temp_buf);
+
+ if (temp_buf_width < renderer->width)
+ temp_buf_x = (renderer->width - temp_buf_width) / 2;
- if (temp_buf->height < renderer->height)
- temp_buf_y = (renderer->height - temp_buf->height) / 2;
+ if (temp_buf_height < renderer->height)
+ temp_buf_y = (renderer->height - temp_buf_height) / 2;
gimp_view_renderer_render_temp_buf (renderer, temp_buf,
temp_buf_x, temp_buf_y,
diff --git a/tools/pdbgen/pdb/brush.pdb b/tools/pdbgen/pdb/brush.pdb
index a80468d..d209f4c 100644
--- a/tools/pdbgen/pdb/brush.pdb
+++ b/tools/pdbgen/pdb/brush.pdb
@@ -241,10 +241,10 @@ HELP
if (brush)
{
- width = brush->mask->width;
- height = brush->mask->height;
- mask_bpp = babl_format_get_bytes_per_pixel (brush->mask->format);
- color_bpp = brush->pixmap ? babl_format_get_bytes_per_pixel (brush->pixmap->format) : 0;
+ width = gimp_temp_buf_get_width (brush->mask);
+ height = gimp_temp_buf_get_height (brush->mask);
+ mask_bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (brush->mask));
+ color_bpp = brush->pixmap ? babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (brush->pixmap)) : 0;
}
else
success = FALSE;
@@ -292,17 +292,19 @@ HELP
if (brush)
{
- width = brush->mask->width;
- height = brush->mask->height;
- mask_bpp = babl_format_get_bytes_per_pixel (brush->mask->format);
- num_mask_bytes = brush->mask->height * brush->mask->width * mask_bpp;
+ width = gimp_temp_buf_get_width (brush->mask);
+ height = gimp_temp_buf_get_height (brush->mask);
+ mask_bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (brush->mask));
+ num_mask_bytes = gimp_temp_buf_get_height (brush->mask) *
+ gimp_temp_buf_get_width (brush->mask) * mask_bpp;
mask_bytes = g_memdup (gimp_temp_buf_get_data (brush->mask),
num_mask_bytes);
if (brush->pixmap)
{
- color_bpp = babl_format_get_bytes_per_pixel (brush->pixmap->format);
- num_color_bytes = brush->pixmap->height * brush->pixmap->width *
+ color_bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (brush->pixmap));
+ num_color_bytes = gimp_temp_buf_get_height (brush->pixmap) *
+ gimp_temp_buf_get_width (brush->pixmap) *
color_bpp;
color_bytes = g_memdup (gimp_temp_buf_get_data (brush->pixmap),
num_color_bytes);
diff --git a/tools/pdbgen/pdb/brushes.pdb b/tools/pdbgen/pdb/brushes.pdb
index 97f795f..66c2bb7 100644
--- a/tools/pdbgen/pdb/brushes.pdb
+++ b/tools/pdbgen/pdb/brushes.pdb
@@ -91,8 +91,8 @@ sub brushes_get_brush {
if (brush)
{
name = g_strdup (gimp_object_get_name (brush));
- width = brush->mask->width;
- height = brush->mask->height;
+ width = gimp_temp_buf_get_width (brush->mask);
+ height = gimp_temp_buf_get_height (brush->mask);
spacing = gimp_brush_get_spacing (brush);
}
else
@@ -184,8 +184,8 @@ sub brushes_get_brush_data {
opacity = 1.0;
spacing = gimp_brush_get_spacing (brush);
paint_mode = 0;
- width = brush->mask->width;
- height = brush->mask->height;
+ width = gimp_temp_buf_get_width (brush->mask);
+ height = gimp_temp_buf_get_height (brush->mask);
length = gimp_temp_buf_get_data_size (brush->mask);
mask_data = g_memdup (gimp_temp_buf_get_data (brush->mask), length);
}
diff --git a/tools/pdbgen/pdb/context.pdb b/tools/pdbgen/pdb/context.pdb
index 884aa1b..a314190 100644
--- a/tools/pdbgen/pdb/context.pdb
+++ b/tools/pdbgen/pdb/context.pdb
@@ -570,8 +570,9 @@ HELP
for (list = options; list; list = g_list_next (list))
g_object_set (list->data,
- "brush-size", (gdouble) MAX (brush->mask->width,
- brush->mask->height),
+ "brush-size",
+ (gdouble) MAX (gimp_temp_buf_get_width (brush->mask),
+ gimp_temp_buf_get_height (brush->mask)),
NULL);
g_list_free (options);
diff --git a/tools/pdbgen/pdb/drawable.pdb b/tools/pdbgen/pdb/drawable.pdb
index cc20f42..14eeb08 100644
--- a/tools/pdbgen/pdb/drawable.pdb
+++ b/tools/pdbgen/pdb/drawable.pdb
@@ -728,9 +728,9 @@ HELP
if (buf)
{
- actual_width = buf->width;
- actual_height = buf->height;
- bpp = babl_format_get_bytes_per_pixel (buf->format);
+ actual_width = gimp_temp_buf_get_width (buf);
+ actual_height = gimp_temp_buf_get_height (buf);
+ bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (buf));
thumbnail_data_count = gimp_temp_buf_get_data_size (buf);
thumbnail_data = g_memdup (gimp_temp_buf_get_data (buf),
thumbnail_data_count);
@@ -808,9 +808,9 @@ HELP
if (buf)
{
- width = buf->width;
- height = buf->height;
- bpp = babl_format_get_bytes_per_pixel (buf->format);
+ width = gimp_temp_buf_get_width (buf);
+ height = gimp_temp_buf_get_height (buf);
+ bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (buf));
thumbnail_data_count = gimp_temp_buf_get_data_size (buf);
thumbnail_data = g_memdup (gimp_temp_buf_get_data (buf),
thumbnail_data_count);
diff --git a/tools/pdbgen/pdb/image.pdb b/tools/pdbgen/pdb/image.pdb
index 88c9877..84140bd 100644
--- a/tools/pdbgen/pdb/image.pdb
+++ b/tools/pdbgen/pdb/image.pdb
@@ -2861,9 +2861,9 @@ HELP
if (buf)
{
- actual_width = buf->width;
- actual_height = buf->height;
- bpp = babl_format_get_bytes_per_pixel (buf->format);
+ actual_width = gimp_temp_buf_get_width (buf);
+ actual_height = gimp_temp_buf_get_height (buf);
+ bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (buf));
thumbnail_data_count = gimp_temp_buf_get_data_size (buf);
thumbnail_data = g_memdup (gimp_temp_buf_get_data (buf),
thumbnail_data_count);
diff --git a/tools/pdbgen/pdb/pattern.pdb b/tools/pdbgen/pdb/pattern.pdb
index 28ed202..221d395 100644
--- a/tools/pdbgen/pdb/pattern.pdb
+++ b/tools/pdbgen/pdb/pattern.pdb
@@ -47,9 +47,9 @@ HELP
if (pattern)
{
- width = pattern->mask->width;
- height = pattern->mask->height;
- bpp = babl_format_get_bytes_per_pixel (pattern->mask->format);
+ width = gimp_temp_buf_get_width (pattern->mask);
+ height = gimp_temp_buf_get_height (pattern->mask);
+ bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (pattern->mask));
}
else
success = FALSE;
@@ -95,9 +95,9 @@ HELP
if (pattern)
{
- width = pattern->mask->width;
- height = pattern->mask->height;
- bpp = babl_format_get_bytes_per_pixel (pattern->mask->format);
+ width = gimp_temp_buf_get_width (pattern->mask);
+ height = gimp_temp_buf_get_height (pattern->mask);
+ bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (pattern->mask));
num_color_bytes = gimp_temp_buf_get_data_size (pattern->mask);
color_bytes = g_memdup (gimp_temp_buf_get_data (pattern->mask),
num_color_bytes);
diff --git a/tools/pdbgen/pdb/patterns.pdb b/tools/pdbgen/pdb/patterns.pdb
index 90b7c26..747f275 100644
--- a/tools/pdbgen/pdb/patterns.pdb
+++ b/tools/pdbgen/pdb/patterns.pdb
@@ -88,8 +88,8 @@ sub patterns_get_pattern {
if (pattern)
{
name = g_strdup (gimp_object_get_name (pattern));
- width = pattern->mask->width;
- height = pattern->mask->height;
+ width = gimp_temp_buf_get_width (pattern->mask);
+ height = gimp_temp_buf_get_height (pattern->mask);
}
else
success = FALSE;
@@ -134,9 +134,9 @@ sub patterns_get_pattern_data {
if (pattern)
{
actual_name = g_strdup (gimp_object_get_name (pattern));
- width = pattern->mask->width;
- height = pattern->mask->height;
- mask_bpp = babl_format_get_bytes_per_pixel (pattern->mask->format);
+ width = gimp_temp_buf_get_width (pattern->mask);
+ height = gimp_temp_buf_get_height (pattern->mask);
+ mask_bpp = babl_format_get_bytes_per_pixel (gimp_temp_buf_get_format (pattern->mask));
length = gimp_temp_buf_get_data_size (pattern->mask);
mask_data = g_memdup (gimp_temp_buf_get_data (pattern->mask), length);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]