[gimp/gtk3-port: 323/391] libgimpwidgets: move all GimpPreviewArea members to private
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 323/391] libgimpwidgets: move all GimpPreviewArea members to private
- Date: Thu, 10 May 2018 16:17:48 +0000 (UTC)
commit 53d83147a5a5c14083113ccdaebc96d09d48088c
Author: Michael Natterer <mitch gimp org>
Date: Thu May 3 15:17:43 2018 +0200
libgimpwidgets: move all GimpPreviewArea members to private
libgimpwidgets/gimppreviewarea.c | 452 +++++++++++++++++++---------------
libgimpwidgets/gimppreviewarea.h | 16 +-
libgimpwidgets/gimpscrolledpreview.c | 16 +-
plug-ins/common/file-raw-data.c | 10 +-
4 files changed, 277 insertions(+), 217 deletions(-)
---
diff --git a/libgimpwidgets/gimppreviewarea.c b/libgimpwidgets/gimppreviewarea.c
index 9c17656..cff2148 100644
--- a/libgimpwidgets/gimppreviewarea.c
+++ b/libgimpwidgets/gimppreviewarea.c
@@ -56,13 +56,25 @@ enum
#define DEFAULT_CHECK_SIZE GIMP_CHECK_SIZE_MEDIUM_CHECKS
#define DEFAULT_CHECK_TYPE GIMP_CHECK_TYPE_GRAY_CHECKS
-#define CHECK_COLOR(area, row, col) \
- (((((area)->offset_y + (row)) & size) ^ \
- (((area)->offset_x + (col)) & size)) ? dark : light)
+#define CHECK_COLOR(priv, row, col) \
+ (((((priv)->offset_y + (row)) & size) ^ \
+ (((priv)->offset_x + (col)) & size)) ? dark : light)
struct _GimpPreviewAreaPrivate
{
+ GimpCheckSize check_size;
+ GimpCheckType check_type;
+ gint width;
+ gint height;
+ gint rowstride;
+ gint offset_x;
+ gint offset_y;
+ gint max_width;
+ gint max_height;
+ guchar *buf;
+ guchar *colormap;
+
GimpColorConfig *config;
GimpColorTransform *transform;
};
@@ -138,14 +150,18 @@ gimp_preview_area_class_init (GimpPreviewAreaClass *klass)
static void
gimp_preview_area_init (GimpPreviewArea *area)
{
+ GimpPreviewAreaPrivate *priv;
+
area->priv = G_TYPE_INSTANCE_GET_PRIVATE (area,
GIMP_TYPE_PREVIEW_AREA,
GimpPreviewAreaPrivate);
- area->check_size = DEFAULT_CHECK_SIZE;
- area->check_type = DEFAULT_CHECK_TYPE;
- area->max_width = -1;
- area->max_height = -1;
+ priv = area->priv;
+
+ priv->check_size = DEFAULT_CHECK_SIZE;
+ priv->check_type = DEFAULT_CHECK_TYPE;
+ priv->max_width = -1;
+ priv->max_height = -1;
gimp_widget_track_monitor (GTK_WIDGET (area),
G_CALLBACK (gimp_preview_area_destroy_transform),
@@ -165,10 +181,10 @@ gimp_preview_area_dispose (GObject *object)
static void
gimp_preview_area_finalize (GObject *object)
{
- GimpPreviewArea *area = GIMP_PREVIEW_AREA (object);
+ GimpPreviewAreaPrivate *priv = GET_PRIVATE (object);
- g_clear_pointer (&area->buf, g_free);
- g_clear_pointer (&area->colormap, g_free);
+ g_clear_pointer (&priv->buf, g_free);
+ g_clear_pointer (&priv->colormap, g_free);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -179,15 +195,15 @@ gimp_preview_area_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- GimpPreviewArea *area = GIMP_PREVIEW_AREA (object);
+ GimpPreviewAreaPrivate *priv = GET_PRIVATE (object);
switch (property_id)
{
case PROP_CHECK_SIZE:
- area->check_size = g_value_get_enum (value);
+ priv->check_size = g_value_get_enum (value);
break;
case PROP_CHECK_TYPE:
- area->check_type = g_value_get_enum (value);
+ priv->check_type = g_value_get_enum (value);
break;
default:
@@ -202,15 +218,15 @@ gimp_preview_area_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- GimpPreviewArea *area = GIMP_PREVIEW_AREA (object);
+ GimpPreviewAreaPrivate *priv = GET_PRIVATE (object);
switch (property_id)
{
case PROP_CHECK_SIZE:
- g_value_set_enum (value, area->check_size);
+ g_value_set_enum (value, priv->check_size);
break;
case PROP_CHECK_TYPE:
- g_value_set_enum (value, area->check_type);
+ g_value_set_enum (value, priv->check_type);
break;
default:
@@ -223,30 +239,30 @@ static void
gimp_preview_area_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
- GimpPreviewArea *area = GIMP_PREVIEW_AREA (widget);
- gint width;
- gint height;
+ GimpPreviewAreaPrivate *priv = GET_PRIVATE (widget);
+ gint width;
+ gint height;
if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
- width = (area->max_width > 0 ?
- MIN (allocation->width, area->max_width) : allocation->width);
- height = (area->max_height > 0 ?
- MIN (allocation->height, area->max_height) : allocation->height);
+ width = (priv->max_width > 0 ?
+ MIN (allocation->width, priv->max_width) : allocation->width);
+ height = (priv->max_height > 0 ?
+ MIN (allocation->height, priv->max_height) : allocation->height);
- if (width != area->width || height != area->height)
+ if (width != priv->width || height != priv->height)
{
- if (area->buf)
+ if (priv->buf)
{
- g_free (area->buf);
+ g_free (priv->buf);
- area->buf = NULL;
- area->rowstride = 0;
+ priv->buf = NULL;
+ priv->rowstride = 0;
}
- area->width = width;
- area->height = height;
+ priv->width = width;
+ priv->height = height;
}
}
@@ -260,15 +276,15 @@ gimp_preview_area_widget_draw (GtkWidget *widget,
GdkPixbuf *pixbuf;
GdkRectangle rect;
- if (! area->buf)
+ if (! priv->buf)
return FALSE;
gtk_widget_get_allocation (widget, &allocation);
- rect.x = (allocation.width - area->width) / 2;
- rect.y = (allocation.height - area->height) / 2;
- rect.width = area->width;
- rect.height = area->height;
+ rect.x = (allocation.width - priv->width) / 2;
+ rect.y = (allocation.height - priv->height) / 2;
+ rect.width = priv->width;
+ rect.height = priv->height;
if (! priv->transform)
gimp_preview_area_create_transform (area);
@@ -276,20 +292,20 @@ gimp_preview_area_widget_draw (GtkWidget *widget,
if (priv->transform)
{
const Babl *format = babl_format ("R'G'B' u8");
- gint rowstride = ((area->width * 3) + 3) & ~3;
- guchar *buf = g_new (guchar, rowstride * area->height);
- guchar *src = area->buf;
+ gint rowstride = ((priv->width * 3) + 3) & ~3;
+ guchar *buf = g_new (guchar, rowstride * priv->height);
+ guchar *src = priv->buf;
guchar *dest = buf;
gint i;
- for (i = 0; i < area->height; i++)
+ for (i = 0; i < priv->height; i++)
{
gimp_color_transform_process_pixels (priv->transform,
format, src,
format, dest,
- area->width);
+ priv->width);
- src += area->rowstride;
+ src += priv->rowstride;
dest += rowstride;
}
@@ -304,13 +320,13 @@ gimp_preview_area_widget_draw (GtkWidget *widget,
}
else
{
- pixbuf = gdk_pixbuf_new_from_data (area->buf,
+ pixbuf = gdk_pixbuf_new_from_data (priv->buf,
GDK_COLORSPACE_RGB,
FALSE,
8,
rect.width,
rect.height,
- area->rowstride,
+ priv->rowstride,
NULL, NULL);
}
@@ -329,13 +345,14 @@ gimp_preview_area_queue_draw (GimpPreviewArea *area,
gint width,
gint height)
{
- GtkWidget *widget = GTK_WIDGET (area);
- GtkAllocation allocation;
+ GimpPreviewAreaPrivate *priv = GET_PRIVATE (area);
+ GtkWidget *widget = GTK_WIDGET (area);
+ GtkAllocation allocation;
gtk_widget_get_allocation (widget, &allocation);
- x += (allocation.width - area->width) / 2;
- y += (allocation.height - area->height) / 2;
+ x += (allocation.width - priv->width) / 2;
+ y += (allocation.height - priv->height) / 2;
gtk_widget_queue_draw_area (widget, x, y, width, height);
}
@@ -442,27 +459,30 @@ gimp_preview_area_draw (GimpPreviewArea *area,
const guchar *buf,
gint rowstride)
{
- const guchar *src;
- guchar *dest;
- guint size;
- guchar light;
- guchar dark;
- gint row;
- gint col;
+ GimpPreviewAreaPrivate *priv;
+ const guchar *src;
+ guchar *dest;
+ guint size;
+ guchar light;
+ guchar dark;
+ gint row;
+ gint col;
g_return_if_fail (GIMP_IS_PREVIEW_AREA (area));
g_return_if_fail (width >= 0 && height >= 0);
+ priv = GET_PRIVATE (area);
+
if (width == 0 || height == 0)
return;
g_return_if_fail (buf != NULL);
g_return_if_fail (rowstride > 0);
- if (x + width < 0 || x >= area->width)
+ if (x + width < 0 || x >= priv->width)
return;
- if (y + height < 0 || y >= area->height)
+ if (y + height < 0 || y >= priv->height)
return;
if (x < 0)
@@ -475,8 +495,8 @@ gimp_preview_area_draw (GimpPreviewArea *area,
x = 0;
}
- if (x + width > area->width)
- width = area->width - x;
+ if (x + width > priv->width)
+ width = priv->width - x;
if (y < 0)
{
@@ -486,20 +506,20 @@ gimp_preview_area_draw (GimpPreviewArea *area,
y = 0;
}
- if (y + height > area->height)
- height = area->height - y;
+ if (y + height > priv->height)
+ height = priv->height - y;
- if (! area->buf)
+ if (! priv->buf)
{
- area->rowstride = ((area->width * 3) + 3) & ~3;
- area->buf = g_new (guchar, area->rowstride * area->height);
+ priv->rowstride = ((priv->width * 3) + 3) & ~3;
+ priv->buf = g_new (guchar, priv->rowstride * priv->height);
}
- size = 1 << (2 + area->check_size);
- gimp_checks_get_shades (area->check_type, &light, &dark);
+ size = 1 << (2 + priv->check_size);
+ gimp_checks_get_shades (priv->check_type, &light, &dark);
src = buf;
- dest = area->buf + x * 3 + y * area->rowstride;
+ dest = priv->buf + x * 3 + y * priv->rowstride;
switch (type)
{
@@ -509,7 +529,7 @@ gimp_preview_area_draw (GimpPreviewArea *area,
memcpy (dest, src, 3 * width);
src += rowstride;
- dest += area->rowstride;
+ dest += priv->rowstride;
}
break;
@@ -524,7 +544,7 @@ gimp_preview_area_draw (GimpPreviewArea *area,
switch (s[3])
{
case 0:
- d[0] = d[1] = d[2] = CHECK_COLOR (area, row, col);
+ d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col);
break;
case 255:
@@ -536,7 +556,7 @@ gimp_preview_area_draw (GimpPreviewArea *area,
default:
{
register guint alpha = s[3] + 1;
- register guint check = CHECK_COLOR (area, row, col);
+ register guint check = CHECK_COLOR (priv, row, col);
d[0] = ((check << 8) + (s[0] - check) * alpha) >> 8;
d[1] = ((check << 8) + (s[1] - check) * alpha) >> 8;
@@ -547,7 +567,7 @@ gimp_preview_area_draw (GimpPreviewArea *area,
}
src += rowstride;
- dest += area->rowstride;
+ dest += priv->rowstride;
}
break;
@@ -563,7 +583,7 @@ gimp_preview_area_draw (GimpPreviewArea *area,
}
src += rowstride;
- dest += area->rowstride;
+ dest += priv->rowstride;
}
break;
@@ -578,7 +598,7 @@ gimp_preview_area_draw (GimpPreviewArea *area,
switch (s[1])
{
case 0:
- d[0] = d[1] = d[2] = CHECK_COLOR (area, row, col);
+ d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col);
break;
case 255:
@@ -588,7 +608,7 @@ gimp_preview_area_draw (GimpPreviewArea *area,
default:
{
register guint alpha = s[1] + 1;
- register guint check = CHECK_COLOR (area, row, col);
+ register guint check = CHECK_COLOR (priv, row, col);
d[0] = d[1] = d[2] =
((check << 8) + (s[0] - check) * alpha) >> 8;
@@ -598,12 +618,12 @@ gimp_preview_area_draw (GimpPreviewArea *area,
}
src += rowstride;
- dest += area->rowstride;
+ dest += priv->rowstride;
}
break;
case GIMP_INDEXED_IMAGE:
- g_return_if_fail (area->colormap != NULL);
+ g_return_if_fail (priv->colormap != NULL);
for (row = 0; row < height; row++)
{
const guchar *s = src;
@@ -611,7 +631,7 @@ gimp_preview_area_draw (GimpPreviewArea *area,
for (col = 0; col < width; col++, s++, d += 3)
{
- const guchar *colormap = area->colormap + 3 * s[0];
+ const guchar *colormap = priv->colormap + 3 * s[0];
d[0] = colormap[0];
d[1] = colormap[1];
@@ -619,12 +639,12 @@ gimp_preview_area_draw (GimpPreviewArea *area,
}
src += rowstride;
- dest += area->rowstride;
+ dest += priv->rowstride;
}
break;
case GIMP_INDEXEDA_IMAGE:
- g_return_if_fail (area->colormap != NULL);
+ g_return_if_fail (priv->colormap != NULL);
for (row = y; row < y + height; row++)
{
const guchar *s = src;
@@ -632,12 +652,12 @@ gimp_preview_area_draw (GimpPreviewArea *area,
for (col = x; col < x + width; col++, s += 2, d += 3)
{
- const guchar *colormap = area->colormap + 3 * s[0];
+ const guchar *colormap = priv->colormap + 3 * s[0];
switch (s[1])
{
case 0:
- d[0] = d[1] = d[2] = CHECK_COLOR (area, row, col);
+ d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col);
break;
case 255:
@@ -649,7 +669,7 @@ gimp_preview_area_draw (GimpPreviewArea *area,
default:
{
register guint alpha = s[3] + 1;
- register guint check = CHECK_COLOR (area, row, col);
+ register guint check = CHECK_COLOR (priv, row, col);
d[0] = ((check << 8) + (colormap[0] - check) * alpha) >> 8;
d[1] = ((check << 8) + (colormap[1] - check) * alpha) >> 8;
@@ -660,7 +680,7 @@ gimp_preview_area_draw (GimpPreviewArea *area,
}
src += rowstride;
- dest += area->rowstride;
+ dest += priv->rowstride;
}
break;
}
@@ -702,19 +722,22 @@ gimp_preview_area_blend (GimpPreviewArea *area,
gint rowstride2,
guchar opacity)
{
- const guchar *src1;
- const guchar *src2;
- guchar *dest;
- guint size;
- guchar light;
- guchar dark;
- gint row;
- gint col;
- gint i;
+ GimpPreviewAreaPrivate *priv;
+ const guchar *src1;
+ const guchar *src2;
+ guchar *dest;
+ guint size;
+ guchar light;
+ guchar dark;
+ gint row;
+ gint col;
+ gint i;
g_return_if_fail (GIMP_IS_PREVIEW_AREA (area));
g_return_if_fail (width >= 0 && height >= 0);
+ priv = GET_PRIVATE (area);
+
if (width == 0 || height == 0)
return;
@@ -739,10 +762,10 @@ gimp_preview_area_blend (GimpPreviewArea *area,
break;
}
- if (x + width < 0 || x >= area->width)
+ if (x + width < 0 || x >= priv->width)
return;
- if (y + height < 0 || y >= area->height)
+ if (y + height < 0 || y >= priv->height)
return;
if (x < 0)
@@ -756,8 +779,8 @@ gimp_preview_area_blend (GimpPreviewArea *area,
x = 0;
}
- if (x + width > area->width)
- width = area->width - x;
+ if (x + width > priv->width)
+ width = priv->width - x;
if (y < 0)
{
@@ -768,21 +791,21 @@ gimp_preview_area_blend (GimpPreviewArea *area,
y = 0;
}
- if (y + height > area->height)
- height = area->height - y;
+ if (y + height > priv->height)
+ height = priv->height - y;
- if (! area->buf)
+ if (! priv->buf)
{
- area->rowstride = ((area->width * 3) + 3) & ~3;
- area->buf = g_new (guchar, area->rowstride * area->height);
+ priv->rowstride = ((priv->width * 3) + 3) & ~3;
+ priv->buf = g_new (guchar, priv->rowstride * priv->height);
}
- size = 1 << (2 + area->check_size);
- gimp_checks_get_shades (area->check_type, &light, &dark);
+ size = 1 << (2 + priv->check_size);
+ gimp_checks_get_shades (priv->check_type, &light, &dark);
src1 = buf1;
src2 = buf2;
- dest = area->buf + x * 3 + y * area->rowstride;
+ dest = priv->buf + x * 3 + y * priv->rowstride;
switch (type)
{
@@ -802,7 +825,7 @@ gimp_preview_area_blend (GimpPreviewArea *area,
src1 += rowstride1;
src2 += rowstride2;
- dest += area->rowstride;
+ dest += priv->rowstride;
}
break;
@@ -844,7 +867,7 @@ gimp_preview_area_blend (GimpPreviewArea *area,
switch (inter[3])
{
case 0:
- d[0] = d[1] = d[2] = CHECK_COLOR (area, row, col);
+ d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col);
break;
case 255:
@@ -856,7 +879,7 @@ gimp_preview_area_blend (GimpPreviewArea *area,
default:
{
register guint alpha = inter[3] + 1;
- register guint check = CHECK_COLOR (area, row, col);
+ register guint check = CHECK_COLOR (priv, row, col);
d[0] = ((check << 8) + (inter[0] - check) * alpha) >> 8;
d[1] = ((check << 8) + (inter[1] - check) * alpha) >> 8;
@@ -868,7 +891,7 @@ gimp_preview_area_blend (GimpPreviewArea *area,
src1 += rowstride1;
src2 += rowstride2;
- dest += area->rowstride;
+ dest += priv->rowstride;
}
break;
@@ -887,7 +910,7 @@ gimp_preview_area_blend (GimpPreviewArea *area,
src1 += rowstride1;
src2 += rowstride2;
- dest += area->rowstride;
+ dest += priv->rowstride;
}
break;
@@ -924,7 +947,7 @@ gimp_preview_area_blend (GimpPreviewArea *area,
switch (inter[1])
{
case 0:
- d[0] = d[1] = d[2] = CHECK_COLOR (area, row, col);
+ d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col);
break;
case 255:
@@ -934,7 +957,7 @@ gimp_preview_area_blend (GimpPreviewArea *area,
default:
{
register guint alpha = inter[1] + 1;
- register guint check = CHECK_COLOR (area, row, col);
+ register guint check = CHECK_COLOR (priv, row, col);
d[0] = d[1] = d[2] =
((check << 8) + (inter[0] - check) * alpha) >> 8;
@@ -945,12 +968,12 @@ gimp_preview_area_blend (GimpPreviewArea *area,
src1 += rowstride1;
src2 += rowstride2;
- dest += area->rowstride;
+ dest += priv->rowstride;
}
break;
case GIMP_INDEXED_IMAGE:
- g_return_if_fail (area->colormap != NULL);
+ g_return_if_fail (priv->colormap != NULL);
for (row = 0; row < height; row++)
{
const guchar *s1 = src1;
@@ -959,8 +982,8 @@ gimp_preview_area_blend (GimpPreviewArea *area,
for (col = 0; col < width; col++, s1++, s2++, d += 3)
{
- const guchar *cmap1 = area->colormap + 3 * s1[0];
- const guchar *cmap2 = area->colormap + 3 * s2[0];
+ const guchar *cmap1 = priv->colormap + 3 * s1[0];
+ const guchar *cmap2 = priv->colormap + 3 * s2[0];
d[0] = ((cmap1[0] << 8) + (cmap2[0] - cmap1[0]) * opacity) >> 8;
d[1] = ((cmap1[1] << 8) + (cmap2[1] - cmap1[1]) * opacity) >> 8;
@@ -969,12 +992,12 @@ gimp_preview_area_blend (GimpPreviewArea *area,
src1 += rowstride1;
src2 += rowstride2;
- dest += area->rowstride;
+ dest += priv->rowstride;
}
break;
case GIMP_INDEXEDA_IMAGE:
- g_return_if_fail (area->colormap != NULL);
+ g_return_if_fail (priv->colormap != NULL);
for (row = y; row < y + height; row++)
{
const guchar *s1 = src1;
@@ -983,8 +1006,8 @@ gimp_preview_area_blend (GimpPreviewArea *area,
for (col = x; col < x + width; col++, s1 += 2, s2 += 2, d += 3)
{
- const guchar *cmap1 = area->colormap + 3 * s1[0];
- const guchar *cmap2 = area->colormap + 3 * s2[0];
+ const guchar *cmap1 = priv->colormap + 3 * s1[0];
+ const guchar *cmap2 = priv->colormap + 3 * s2[0];
guchar inter[4];
if (s1[1] == s2[1])
@@ -1017,7 +1040,7 @@ gimp_preview_area_blend (GimpPreviewArea *area,
switch (inter[3])
{
case 0:
- d[0] = d[1] = d[2] = CHECK_COLOR (area, row, col);
+ d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col);
break;
case 255:
@@ -1029,7 +1052,7 @@ gimp_preview_area_blend (GimpPreviewArea *area,
default:
{
register guint alpha = inter[3] + 1;
- register guint check = CHECK_COLOR (area, row, col);
+ register guint check = CHECK_COLOR (priv, row, col);
d[0] = ((check << 8) + (inter[0] - check) * alpha) >> 8;
d[1] = ((check << 8) + (inter[1] - check) * alpha) >> 8;
@@ -1041,7 +1064,7 @@ gimp_preview_area_blend (GimpPreviewArea *area,
src1 += rowstride1;
src2 += rowstride2;
- dest += area->rowstride;
+ dest += priv->rowstride;
}
break;
}
@@ -1086,20 +1109,23 @@ gimp_preview_area_mask (GimpPreviewArea *area,
const guchar *mask,
gint rowstride_mask)
{
- const guchar *src1;
- const guchar *src2;
- const guchar *src_mask;
- guchar *dest;
- guint size;
- guchar light;
- guchar dark;
- gint row;
- gint col;
- gint i;
+ GimpPreviewAreaPrivate *priv;
+ const guchar *src1;
+ const guchar *src2;
+ const guchar *src_mask;
+ guchar *dest;
+ guint size;
+ guchar light;
+ guchar dark;
+ gint row;
+ gint col;
+ gint i;
g_return_if_fail (GIMP_IS_PREVIEW_AREA (area));
g_return_if_fail (width >= 0 && height >= 0);
+ priv = GET_PRIVATE (area);
+
if (width == 0 || height == 0)
return;
@@ -1110,10 +1136,10 @@ gimp_preview_area_mask (GimpPreviewArea *area,
g_return_if_fail (rowstride2 > 0);
g_return_if_fail (rowstride_mask > 0);
- if (x + width < 0 || x >= area->width)
+ if (x + width < 0 || x >= priv->width)
return;
- if (y + height < 0 || y >= area->height)
+ if (y + height < 0 || y >= priv->height)
return;
if (x < 0)
@@ -1128,8 +1154,8 @@ gimp_preview_area_mask (GimpPreviewArea *area,
x = 0;
}
- if (x + width > area->width)
- width = area->width - x;
+ if (x + width > priv->width)
+ width = priv->width - x;
if (y < 0)
{
@@ -1141,22 +1167,22 @@ gimp_preview_area_mask (GimpPreviewArea *area,
y = 0;
}
- if (y + height > area->height)
- height = area->height - y;
+ if (y + height > priv->height)
+ height = priv->height - y;
- if (! area->buf)
+ if (! priv->buf)
{
- area->rowstride = ((area->width * 3) + 3) & ~3;
- area->buf = g_new (guchar, area->rowstride * area->height);
+ priv->rowstride = ((priv->width * 3) + 3) & ~3;
+ priv->buf = g_new (guchar, priv->rowstride * priv->height);
}
- size = 1 << (2 + area->check_size);
- gimp_checks_get_shades (area->check_type, &light, &dark);
+ size = 1 << (2 + priv->check_size);
+ gimp_checks_get_shades (priv->check_type, &light, &dark);
src1 = buf1;
src2 = buf2;
src_mask = mask;
- dest = area->buf + x * 3 + y * area->rowstride;
+ dest = priv->buf + x * 3 + y * priv->rowstride;
switch (type)
{
@@ -1178,7 +1204,7 @@ gimp_preview_area_mask (GimpPreviewArea *area,
src1 += rowstride1;
src2 += rowstride2;
src_mask += rowstride_mask;
- dest += area->rowstride;
+ dest += priv->rowstride;
}
break;
@@ -1198,7 +1224,7 @@ gimp_preview_area_mask (GimpPreviewArea *area,
switch (s1[3])
{
case 0:
- d[0] = d[1] = d[2] = CHECK_COLOR (area, row, col);
+ d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col);
break;
case 255:
@@ -1210,7 +1236,7 @@ gimp_preview_area_mask (GimpPreviewArea *area,
default:
{
register guint alpha = s1[3] + 1;
- register guint check = CHECK_COLOR (area, row, col);
+ register guint check = CHECK_COLOR (priv, row, col);
d[0] = ((check << 8) + (s1[0] - check) * alpha) >> 8;
d[1] = ((check << 8) + (s1[1] - check) * alpha) >> 8;
@@ -1224,7 +1250,7 @@ gimp_preview_area_mask (GimpPreviewArea *area,
switch (s2[3])
{
case 0:
- d[0] = d[1] = d[2] = CHECK_COLOR (area, row, col);
+ d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col);
break;
case 255:
@@ -1236,7 +1262,7 @@ gimp_preview_area_mask (GimpPreviewArea *area,
default:
{
register guint alpha = s2[3] + 1;
- register guint check = CHECK_COLOR (area, row, col);
+ register guint check = CHECK_COLOR (priv, row, col);
d[0] = ((check << 8) + (s2[0] - check) * alpha) >> 8;
d[1] = ((check << 8) + (s2[1] - check) * alpha) >> 8;
@@ -1277,7 +1303,7 @@ gimp_preview_area_mask (GimpPreviewArea *area,
switch (inter[3])
{
case 0:
- d[0] = d[1] = d[2] = CHECK_COLOR (area, row, col);
+ d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col);
break;
case 255:
@@ -1289,7 +1315,7 @@ gimp_preview_area_mask (GimpPreviewArea *area,
default:
{
register guint alpha = inter[3] + 1;
- register guint check = CHECK_COLOR (area, row, col);
+ register guint check = CHECK_COLOR (priv, row, col);
d[0] = (((check << 8) +
(inter[0] - check) * alpha) >> 8);
@@ -1308,7 +1334,7 @@ gimp_preview_area_mask (GimpPreviewArea *area,
src1 += rowstride1;
src2 += rowstride2;
src_mask += rowstride_mask;
- dest += area->rowstride;
+ dest += priv->rowstride;
}
break;
@@ -1326,7 +1352,7 @@ gimp_preview_area_mask (GimpPreviewArea *area,
src1 += rowstride1;
src2 += rowstride2;
src_mask += rowstride_mask;
- dest += area->rowstride;
+ dest += priv->rowstride;
}
break;
@@ -1346,7 +1372,7 @@ gimp_preview_area_mask (GimpPreviewArea *area,
switch (s1[1])
{
case 0:
- d[0] = d[1] = d[2] = CHECK_COLOR (area, row, col);
+ d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col);
break;
case 255:
@@ -1356,7 +1382,7 @@ gimp_preview_area_mask (GimpPreviewArea *area,
default:
{
register guint alpha = s1[1] + 1;
- register guint check = CHECK_COLOR (area, row, col);
+ register guint check = CHECK_COLOR (priv, row, col);
d[0] = d[1] = d[2] =
((check << 8) + (s1[0] - check) * alpha) >> 8;
@@ -1369,7 +1395,7 @@ gimp_preview_area_mask (GimpPreviewArea *area,
switch (s2[1])
{
case 0:
- d[0] = d[1] = d[2] = CHECK_COLOR (area, row, col);
+ d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col);
break;
case 255:
@@ -1379,7 +1405,7 @@ gimp_preview_area_mask (GimpPreviewArea *area,
default:
{
register guint alpha = s2[1] + 1;
- register guint check = CHECK_COLOR (area, row, col);
+ register guint check = CHECK_COLOR (priv, row, col);
d[0] = d[1] = d[2] =
((check << 8) + (s2[0] - check) * alpha) >> 8;
@@ -1414,7 +1440,7 @@ gimp_preview_area_mask (GimpPreviewArea *area,
switch (inter[1])
{
case 0:
- d[0] = d[1] = d[2] = CHECK_COLOR (area, row, col);
+ d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col);
break;
case 255:
@@ -1424,7 +1450,7 @@ gimp_preview_area_mask (GimpPreviewArea *area,
default:
{
register guint alpha = inter[1] + 1;
- register guint check = CHECK_COLOR (area, row, col);
+ register guint check = CHECK_COLOR (priv, row, col);
d[0] = d[1] = d[2] =
((check << 8) + (inter[0] - check) * alpha) >> 8;
@@ -1439,12 +1465,12 @@ gimp_preview_area_mask (GimpPreviewArea *area,
src1 += rowstride1;
src2 += rowstride2;
src_mask += rowstride_mask;
- dest += area->rowstride;
+ dest += priv->rowstride;
}
break;
case GIMP_INDEXED_IMAGE:
- g_return_if_fail (area->colormap != NULL);
+ g_return_if_fail (priv->colormap != NULL);
for (row = 0; row < height; row++)
{
const guchar *s1 = src1;
@@ -1454,8 +1480,8 @@ gimp_preview_area_mask (GimpPreviewArea *area,
for (col = 0; col < width; col++, s1++, s2++, m++, d += 3)
{
- const guchar *cmap1 = area->colormap + 3 * s1[0];
- const guchar *cmap2 = area->colormap + 3 * s2[0];
+ const guchar *cmap1 = priv->colormap + 3 * s1[0];
+ const guchar *cmap2 = priv->colormap + 3 * s2[0];
d[0] = ((cmap1[0] << 8) + (cmap2[0] - cmap1[0]) * m[0]) >> 8;
d[1] = ((cmap1[1] << 8) + (cmap2[1] - cmap1[1]) * m[0]) >> 8;
@@ -1465,12 +1491,12 @@ gimp_preview_area_mask (GimpPreviewArea *area,
src1 += rowstride1;
src2 += rowstride2;
src_mask += rowstride_mask;
- dest += area->rowstride;
+ dest += priv->rowstride;
}
break;
case GIMP_INDEXEDA_IMAGE:
- g_return_if_fail (area->colormap != NULL);
+ g_return_if_fail (priv->colormap != NULL);
for (row = y; row < y + height; row++)
{
const guchar *s1 = src1;
@@ -1480,8 +1506,8 @@ gimp_preview_area_mask (GimpPreviewArea *area,
for (col = x; col < x + width; col++, s1 += 2, s2 += 2, m++, d += 3)
{
- const guchar *cmap1 = area->colormap + 3 * s1[0];
- const guchar *cmap2 = area->colormap + 3 * s2[0];
+ const guchar *cmap1 = priv->colormap + 3 * s1[0];
+ const guchar *cmap2 = priv->colormap + 3 * s2[0];
switch (m[0])
{
@@ -1489,7 +1515,7 @@ gimp_preview_area_mask (GimpPreviewArea *area,
switch (s1[1])
{
case 0:
- d[0] = d[1] = d[2] = CHECK_COLOR (area, row, col);
+ d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col);
break;
case 255:
@@ -1501,7 +1527,7 @@ gimp_preview_area_mask (GimpPreviewArea *area,
default:
{
register guint alpha = s1[1] + 1;
- register guint check = CHECK_COLOR (area, row, col);
+ register guint check = CHECK_COLOR (priv, row, col);
d[0] = ((check << 8) + (cmap1[0] - check) * alpha) >> 8;
d[1] = ((check << 8) + (cmap1[1] - check) * alpha) >> 8;
@@ -1515,7 +1541,7 @@ gimp_preview_area_mask (GimpPreviewArea *area,
switch (s2[1])
{
case 0:
- d[0] = d[1] = d[2] = CHECK_COLOR (area, row, col);
+ d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col);
break;
case 255:
@@ -1527,7 +1553,7 @@ gimp_preview_area_mask (GimpPreviewArea *area,
default:
{
register guint alpha = s2[1] + 1;
- register guint check = CHECK_COLOR (area, row, col);
+ register guint check = CHECK_COLOR (priv, row, col);
d[0] = ((check << 8) + (cmap2[0] - check) * alpha) >> 8;
d[1] = ((check << 8) + (cmap2[1] - check) * alpha) >> 8;
@@ -1571,7 +1597,7 @@ gimp_preview_area_mask (GimpPreviewArea *area,
switch (inter[3])
{
case 0:
- d[0] = d[1] = d[2] = CHECK_COLOR (area, row, col);
+ d[0] = d[1] = d[2] = CHECK_COLOR (priv, row, col);
break;
case 255:
@@ -1583,7 +1609,7 @@ gimp_preview_area_mask (GimpPreviewArea *area,
default:
{
register guint alpha = inter[3] + 1;
- register guint check = CHECK_COLOR (area, row, col);
+ register guint check = CHECK_COLOR (priv, row, col);
d[0] =
((check << 8) + (inter[0] - check) * alpha) >> 8;
@@ -1602,7 +1628,7 @@ gimp_preview_area_mask (GimpPreviewArea *area,
src1 += rowstride1;
src2 += rowstride2;
src_mask += rowstride_mask;
- dest += area->rowstride;
+ dest += priv->rowstride;
}
break;
}
@@ -1636,21 +1662,24 @@ gimp_preview_area_fill (GimpPreviewArea *area,
guchar green,
guchar blue)
{
- guchar *dest;
- guchar *d;
- gint row;
- gint col;
+ GimpPreviewAreaPrivate *priv;
+ guchar *dest;
+ guchar *d;
+ gint row;
+ gint col;
g_return_if_fail (GIMP_IS_PREVIEW_AREA (area));
g_return_if_fail (width >= 0 && height >= 0);
+ priv = GET_PRIVATE (area);
+
if (width == 0 || height == 0)
return;
- if (x + width < 0 || x >= area->width)
+ if (x + width < 0 || x >= priv->width)
return;
- if (y + height < 0 || y >= area->height)
+ if (y + height < 0 || y >= priv->height)
return;
if (x < 0)
@@ -1659,8 +1688,8 @@ gimp_preview_area_fill (GimpPreviewArea *area,
x = 0;
}
- if (x + width > area->width)
- width = area->width - x;
+ if (x + width > priv->width)
+ width = priv->width - x;
if (y < 0)
{
@@ -1668,16 +1697,16 @@ gimp_preview_area_fill (GimpPreviewArea *area,
y = 0;
}
- if (y + height > area->height)
- height = area->height - y;
+ if (y + height > priv->height)
+ height = priv->height - y;
- if (! area->buf)
+ if (! priv->buf)
{
- area->rowstride = ((area->width * 3) + 3) & ~3;
- area->buf = g_new (guchar, area->rowstride * area->height);
+ priv->rowstride = ((priv->width * 3) + 3) & ~3;
+ priv->buf = g_new (guchar, priv->rowstride * priv->height);
}
- dest = area->buf + x * 3 + y * area->rowstride;
+ dest = priv->buf + x * 3 + y * priv->rowstride;
/* colorize first row */
for (col = 0, d = dest; col < width; col++, d+= 3)
@@ -1690,7 +1719,7 @@ gimp_preview_area_fill (GimpPreviewArea *area,
/* copy first row to remaining rows */
for (row = 1, d = dest; row < height; row++)
{
- d += area->rowstride;
+ d += priv->rowstride;
memcpy (d, dest, width * 3);
}
@@ -1713,10 +1742,14 @@ gimp_preview_area_set_offsets (GimpPreviewArea *area,
gint x,
gint y)
{
+ GimpPreviewAreaPrivate *priv;
+
g_return_if_fail (GIMP_IS_PREVIEW_AREA (area));
- area->offset_x = x;
- area->offset_y = y;
+ priv = GET_PRIVATE (area);
+
+ priv->offset_x = x;
+ priv->offset_y = y;
}
/**
@@ -1736,23 +1769,27 @@ gimp_preview_area_set_colormap (GimpPreviewArea *area,
const guchar *colormap,
gint num_colors)
{
+ GimpPreviewAreaPrivate *priv;
+
g_return_if_fail (GIMP_IS_PREVIEW_AREA (area));
g_return_if_fail (colormap != NULL || num_colors == 0);
g_return_if_fail (num_colors >= 0 && num_colors <= 256);
+ priv = GET_PRIVATE (area);
+
if (num_colors > 0)
{
- if (area->colormap)
- memset (area->colormap, 0, 3 * 256);
+ if (priv->colormap)
+ memset (priv->colormap, 0, 3 * 256);
else
- area->colormap = g_new0 (guchar, 3 * 256);
+ priv->colormap = g_new0 (guchar, 3 * 256);
- memcpy (area->colormap, colormap, 3 * num_colors);
+ memcpy (priv->colormap, colormap, 3 * num_colors);
}
else
{
- g_free (area->colormap);
- area->colormap = NULL;
+ g_free (priv->colormap);
+ priv->colormap = NULL;
}
}
@@ -1801,6 +1838,21 @@ gimp_preview_area_set_color_config (GimpPreviewArea *area,
}
}
+void
+gimp_preview_area_get_size (GimpPreviewArea *area,
+ gint *width,
+ gint *height)
+{
+ GimpPreviewAreaPrivate *priv;
+
+ g_return_if_fail (GIMP_IS_PREVIEW_AREA (area));
+
+ priv = GET_PRIVATE (area);
+
+ if (width) *width = priv->width;
+ if (height) *height = priv->height;
+}
+
/**
* gimp_preview_area_set_max_size:
* @area: a #GimpPreviewArea widget
@@ -1819,10 +1871,14 @@ gimp_preview_area_set_max_size (GimpPreviewArea *area,
gint width,
gint height)
{
+ GimpPreviewAreaPrivate *priv;
+
g_return_if_fail (GIMP_IS_PREVIEW_AREA (area));
- area->max_width = width;
- area->max_height = height;
+ priv = GET_PRIVATE (area);
+
+ priv->max_width = width;
+ priv->max_height = height;
}
diff --git a/libgimpwidgets/gimppreviewarea.h b/libgimpwidgets/gimppreviewarea.h
index 9d7e471..11d5254 100644
--- a/libgimpwidgets/gimppreviewarea.h
+++ b/libgimpwidgets/gimppreviewarea.h
@@ -42,19 +42,6 @@ struct _GimpPreviewArea
GtkDrawingArea parent_instance;
GimpPreviewAreaPrivate *priv;
-
- /* FIXME MOVE TO PRIVATE */
- GimpCheckSize check_size;
- GimpCheckType check_type;
- gint width;
- gint height;
- gint rowstride;
- gint offset_x;
- gint offset_y;
- gint max_width;
- gint max_height;
- guchar *buf;
- guchar *colormap;
};
struct _GimpPreviewAreaClass
@@ -128,6 +115,9 @@ void gimp_preview_area_set_colormap (GimpPreviewArea *area,
void gimp_preview_area_set_color_config (GimpPreviewArea *area,
GimpColorConfig *config);
+void gimp_preview_area_get_size (GimpPreviewArea *area,
+ gint *width,
+ gint *height);
void gimp_preview_area_set_max_size (GimpPreviewArea *area,
gint width,
gint height);
diff --git a/libgimpwidgets/gimpscrolledpreview.c b/libgimpwidgets/gimpscrolledpreview.c
index b5d52ea..ff9b29b 100644
--- a/libgimpwidgets/gimpscrolledpreview.c
+++ b/libgimpwidgets/gimpscrolledpreview.c
@@ -566,6 +566,9 @@ gimp_scrolled_preview_nav_button_press (GtkWidget *widget,
GtkWidget *area;
GdkCursor *cursor;
GtkBorder border;
+ GimpCheckType check_type;
+ gint area_width;
+ gint area_height;
gint x, y;
gdouble h, v;
@@ -584,9 +587,13 @@ gimp_scrolled_preview_nav_button_press (GtkWidget *widget,
gtk_container_add (GTK_CONTAINER (outer), inner);
gtk_widget_show (inner);
+ g_object_get (gimp_preview->area,
+ "check-type", &check_type,
+ NULL);
+
area = g_object_new (GIMP_TYPE_PREVIEW_AREA,
"check-size", GIMP_CHECK_SIZE_SMALL_CHECKS,
- "check-type", GIMP_PREVIEW_AREA (gimp_preview->area)->check_type,
+ "check-type", check_type,
NULL);
gtk_container_add (GTK_CONTAINER (inner), area);
@@ -618,8 +625,11 @@ gimp_scrolled_preview_nav_button_press (GtkWidget *widget,
(gtk_adjustment_get_page_size (adj) /
gtk_adjustment_get_upper (adj)) / 2.0);
- x += event->x - h * (gdouble) GIMP_PREVIEW_AREA (area)->width;
- y += event->y - v * (gdouble) GIMP_PREVIEW_AREA (area)->height;
+ gimp_preview_area_get_size (GIMP_PREVIEW_AREA (area),
+ &area_width, &area_height);
+
+ x += event->x - h * (gdouble) area_width;
+ y += event->y - v * (gdouble) area_height;
gtk_style_context_get_border (context, 0, &border);
diff --git a/plug-ins/common/file-raw-data.c b/plug-ins/common/file-raw-data.c
index 0eecb42..a333d10 100644
--- a/plug-ins/common/file-raw-data.c
+++ b/plug-ins/common/file-raw-data.c
@@ -1463,17 +1463,21 @@ preview_update_size (GimpPreviewArea *preview)
static void
preview_update (GimpPreviewArea *preview)
{
+ gint preview_width;
+ gint preview_height;
gint width;
gint height;
gint32 pos;
gint x, y;
gint bitspp = 0;
- width = MIN (runtime->image_width, preview->width);
- height = MIN (runtime->image_height, preview->height);
+ gimp_preview_area_get_size (preview, &preview_width, &preview_height);
+
+ width = MIN (runtime->image_width, preview_width);
+ height = MIN (runtime->image_height, preview_height);
gimp_preview_area_fill (preview,
- 0, 0, preview->width, preview->height,
+ 0, 0, preview_width, preview_height,
255, 255, 255);
switch (runtime->image_type)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]