gimp r25593 - in trunk: . app/core
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r25593 - in trunk: . app/core
- Date: Fri, 9 May 2008 09:05:02 +0100 (BST)
Author: neo
Date: Fri May 9 08:05:01 2008
New Revision: 25593
URL: http://svn.gnome.org/viewvc/gimp?rev=25593&view=rev
Log:
2008-05-09 Sven Neumann <sven gimp org>
* configure.in: check for a minimum required cairo version
(1.4.14).
* app/core/gimpscanconvert.c: copied some code from cairo until
we depend on cairo 1.6.
Modified:
trunk/ChangeLog
trunk/app/core/gimpscanconvert.c
trunk/configure.in
Modified: trunk/app/core/gimpscanconvert.c
==============================================================================
--- trunk/app/core/gimpscanconvert.c (original)
+++ trunk/app/core/gimpscanconvert.c Fri May 9 08:05:01 2008
@@ -77,6 +77,9 @@
gboolean antialias,
guchar value);
+static gint gimp_cairo_stride_for_width (gint width);
+
+
/* public functions */
/**
@@ -438,7 +441,6 @@
cairo_t *cr;
cairo_surface_t *surface;
cairo_path_t path;
- gint i;
x = 0;
y = 0;
@@ -469,32 +471,37 @@
pr = pixel_regions_process (pr))
{
guchar *tmp_buf = NULL;
- int tmp_rs = 0;
+ gint stride;
sc->buf = maskPR.data;
sc->rowstride = maskPR.rowstride;
sc->x0 = off_x + maskPR.x;
sc->x1 = off_x + maskPR.x + maskPR.w;
- if (maskPR.rowstride % 4 != 0)
+ stride = gimp_cairo_stride_for_width (maskPR.w);
+
+ g_assert (stride > 0);
+
+ if (maskPR.rowstride != stride)
{
- /* this is necessary to work around a cairo bug
- * for rowstride % 4 != 0 */
- tmp_rs = ((maskPR.rowstride + 3) / 4) * 4;
- tmp_buf = g_slice_alloc0 (tmp_rs * maskPR.h);
+ tmp_buf = g_alloca (stride * maskPR.h);
+ memset (tmp_buf, 0, stride * maskPR.h);
}
- surface = cairo_image_surface_create_for_data (tmp_buf ? tmp_buf : maskPR.data,
+ surface = cairo_image_surface_create_for_data (tmp_buf ?
+ tmp_buf : maskPR.data,
CAIRO_FORMAT_A8,
maskPR.w, maskPR.h,
- tmp_buf ? tmp_rs : maskPR.rowstride);
+ stride);
+
cairo_surface_set_device_offset (surface,
-off_x - maskPR.x,
-off_y - maskPR.y);
cr = cairo_create (surface);
cairo_set_source_rgb (cr, value / 255.0, value / 255.0, value / 255.0);
cairo_append_path (cr, &path);
- cairo_set_antialias (cr, sc->antialias ? CAIRO_ANTIALIAS_GRAY : CAIRO_ANTIALIAS_NONE);
+ cairo_set_antialias (cr,
+ sc->antialias ? CAIRO_ANTIALIAS_GRAY : CAIRO_ANTIALIAS_NONE);
if (sc->do_stroke)
{
cairo_set_line_cap (cr, sc->cap == GIMP_CAP_BUTT ? CAIRO_LINE_CAP_BUTT :
@@ -503,7 +510,11 @@
cairo_set_line_join (cr, sc->join == GIMP_JOIN_MITER ? CAIRO_LINE_JOIN_MITER :
sc->join == GIMP_JOIN_ROUND ? CAIRO_LINE_JOIN_ROUND :
CAIRO_LINE_JOIN_BEVEL);
+
+#ifdef __GNUC__
#warning cairo_set_dash() still missing!
+#endif
+
cairo_set_line_width (cr, sc->width);
cairo_scale (cr, 1.0, sc->ratio_xy);
cairo_stroke (cr);
@@ -513,22 +524,44 @@
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
cairo_fill (cr);
}
+
cairo_surface_flush (surface);
cairo_destroy (cr);
cairo_surface_destroy (surface);
if (tmp_buf)
{
+ guchar *dest = maskPR.data;
+ const guchar *src = tmp_buf;
+ gint i;
+
for (i = 0; i < maskPR.h; i++)
- memcpy (maskPR.data + i * maskPR.rowstride,
- tmp_buf + i * tmp_rs,
- maskPR.w);
+ {
+ memcpy (dest, src, maskPR.w);
- g_slice_free1 (tmp_rs * maskPR.h, tmp_buf);
+ src += stride;
+ dest += maskPR.rowstride;
+ }
}
}
}
+static gint
+gimp_cairo_stride_for_width (gint width)
+{
+#ifdef __GNUC__
+#warning use cairo_format_stride_for_width() as soon as we depend on cairo 1.6
+#endif
+#if 0
+ return cairo_format_stride_for_width (CAIRO_FORMAT_A8, width);
+#endif
+
+#define CAIRO_STRIDE_ALIGNMENT (sizeof (guint32))
+#define CAIRO_STRIDE_FOR_WIDTH_BPP(w,bpp) \
+ (((bpp)*(w)+7)/8 + CAIRO_STRIDE_ALIGNMENT-1) & ~(CAIRO_STRIDE_ALIGNMENT-1)
+
+ return CAIRO_STRIDE_FOR_WIDTH_BPP (width, 8);
+}
static inline void
compose (GimpChannelOps op,
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Fri May 9 08:05:01 2008
@@ -46,6 +46,7 @@
m4_define([gdk_pixbuf_required_version], [gtk_required_version])
m4_define([pangoft2_required_version], [1.18.0])
m4_define([fontconfig_required_version], [2.2.0])
+m4_define([cairo_required_version], [1.4.14])
m4_define([gtkdoc_required_version], [1.0])
m4_define([gtkhtml2_required_version], [2.0.0])
m4_define([alsa_required_version], [1.0.0])
@@ -480,7 +481,7 @@
AC_MSG_ERROR(Could not find gdk-pixbuf-csource in your PATH)
fi
-PKG_CHECK_MODULES(CAIRO, cairo)
+PKG_CHECK_MODULES(CAIRO, cairo >= cairo_required_version)
PKG_CHECK_MODULES(FONTCONFIG, fontconfig >= fontconfig_required_version)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]