From 9ec6a65901aa1e4a494c09341f5a6ffbed8a8415 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 26 May 2008 04:25:25 +0000 Subject: [PATCH] =?UTF-8?q?=20=20=20=20=20=20=20=20Bug=20513811=20?= =?UTF-8?q?=E2=80=93=20Use=20cairo=5Fformat=5Fstride=5Ffor=5Fwidth()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * gtk/gtkhsv.c (paint_ring, paint_triangle): * gdk/gdkcairo.c (gdk_cairo_set_source_pixbuf): Use cairo_format_stride_for_width, proposed by Behdad Esfahbod. * configure.in: Bump cairo requirement to 1.6.0 * INSTALL.in: Update required versions svn path=/trunk/; revision=20170 --- ChangeLog | 12 ++++++++++++ INSTALL.in | 4 ++-- configure.in | 2 +- gdk/gdkcairo.c | 11 +++++++---- gtk/gtkhsv.c | 14 +++++++++----- 5 files changed, 31 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index c7b3d698f1..76345f194d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2008-05-26 Matthias Clasen + + Bug 513811 – Use cairo_format_stride_for_width() + + * gtk/gtkhsv.c (paint_ring, paint_triangle): + * gdk/gdkcairo.c (gdk_cairo_set_source_pixbuf): Use + cairo_format_stride_for_width, proposed by Behdad Esfahbod. + + * configure.in: Bump cairo requirement to 1.6.0 + + * INSTALL.in: Update required versions + 2008-05-26 Matthias Clasen * gtk/gtkshow.[hc]: Formatting fixes diff --git a/INSTALL.in b/INSTALL.in index 742d782803..a8c0be5c82 100644 --- a/INSTALL.in +++ b/INSTALL.in @@ -4,8 +4,8 @@ Prerequisites GTK+ requires the following packages: - The GLib, Pango, ATK and cairo libraries, available at the same - location as GTK+. GTK+ @GTK_VERSION@ requires at least GLib 2.12, - Pango 1.13, ATK 1.9 and cairo 1.2. + location as GTK+. GTK+ @GTK_VERSION@ requires at least GLib 2.15.0, + Pango 1.19.3, ATK 1.13.0 and cairo 1.6.0. - The TIFF, PNG, and JPEG image loading libraries. You most likely have these installed on your system already. If not diff --git a/configure.in b/configure.in index 02064d62ee..f1f9c173f5 100644 --- a/configure.in +++ b/configure.in @@ -34,7 +34,7 @@ m4_define([gtk_binary_version], [2.10.0]) m4_define([glib_required_version], [2.15.0]) m4_define([pango_required_version], [1.19.3]) m4_define([atk_required_version], [1.13.0]) -m4_define([cairo_required_version], [1.5.2]) +m4_define([cairo_required_version], [1.6]) AC_INIT([gtk+], [gtk_version], diff --git a/gdk/gdkcairo.c b/gdk/gdkcairo.c index f887627e65..4c2d91ac0b 100644 --- a/gdk/gdkcairo.c +++ b/gdk/gdkcairo.c @@ -146,6 +146,7 @@ gdk_cairo_set_source_pixbuf (cairo_t *cr, guchar *gdk_pixels = gdk_pixbuf_get_pixels (pixbuf); int gdk_rowstride = gdk_pixbuf_get_rowstride (pixbuf); int n_channels = gdk_pixbuf_get_n_channels (pixbuf); + int cairo_stride; guchar *cairo_pixels; cairo_format_t format; cairo_surface_t *surface; @@ -157,10 +158,12 @@ gdk_cairo_set_source_pixbuf (cairo_t *cr, else format = CAIRO_FORMAT_ARGB32; - cairo_pixels = g_malloc (4 * width * height); + cairo_stride = cairo_format_stride_for_width (format, width); + cairo_pixels = g_malloc (height * cairo_stride); surface = cairo_image_surface_create_for_data ((unsigned char *)cairo_pixels, - format, - width, height, 4 * width); + format, + width, height, cairo_stride); + cairo_surface_set_user_data (surface, &key, cairo_pixels, (cairo_destroy_func_t)g_free); @@ -217,7 +220,7 @@ gdk_cairo_set_source_pixbuf (cairo_t *cr, } gdk_pixels += gdk_rowstride; - cairo_pixels += 4 * width; + cairo_pixels += cairo_stride; } cairo_set_source_surface (cr, surface, pixbuf_x, pixbuf_y); diff --git a/gtk/gtkhsv.c b/gtk/gtkhsv.c index 58c4494809..f6a8133651 100644 --- a/gtk/gtkhsv.c +++ b/gtk/gtkhsv.c @@ -897,6 +897,7 @@ paint_ring (GtkHSV *hsv, gdouble r, g, b; cairo_surface_t *source; cairo_t *source_cr; + gint stride; gint focus_width; gint focus_pad; @@ -914,7 +915,8 @@ paint_ring (GtkHSV *hsv, /* Create an image initialized with the ring colors */ - buf = g_new (guint32, width * height); + stride = cairo_format_stride_for_width (CAIRO_FORMAT_RGB24, width); + buf = g_new (guint32, height * stride / 4); for (yy = 0; yy < height; yy++) { @@ -952,7 +954,7 @@ paint_ring (GtkHSV *hsv, source = cairo_image_surface_create_for_data ((char *)buf, CAIRO_FORMAT_RGB24, - width, height, 4 * width); + width, height, stride); /* Now draw the value marker onto the source image, so that it * will get properly clipped at the edges of the ring @@ -1047,6 +1049,7 @@ paint_triangle (GtkHSV *hsv, cairo_surface_t *source; gdouble r, g, b; gchar *detail; + gint stride; priv = hsv->priv; @@ -1094,8 +1097,9 @@ paint_triangle (GtkHSV *hsv, } /* Shade the triangle */ - - buf = g_new (guint32, width * height); + + stride = cairo_format_stride_for_width (CAIRO_FORMAT_RGB24, width); + buf = g_new (guint32, height * stride / 4); for (yy = 0; yy < height; yy++) { @@ -1162,7 +1166,7 @@ paint_triangle (GtkHSV *hsv, source = cairo_image_surface_create_for_data ((char *)buf, CAIRO_FORMAT_RGB24, - width, height, 4 * width); + width, height, stride); /* Draw a triangle with the image as a source */