]> Pileus Git - ~andy/gtk/commitdiff
Bug 513811 – Use cairo_format_stride_for_width()
authorMatthias Clasen <matthiasc@src.gnome.org>
Mon, 26 May 2008 04:25:25 +0000 (04:25 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 26 May 2008 04:25:25 +0000 (04:25 +0000)
        * 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
INSTALL.in
configure.in
gdk/gdkcairo.c
gtk/gtkhsv.c

index c7b3d698f1628dddfbc62b7e9b1a00055c4696d2..76345f194d34ce46787857ab392d4cc62f58cdd6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2008-05-26  Matthias Clasen  <mclasen@redhat.com>
+
+       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  <mclasen@redhat.com>
 
        * gtk/gtkshow.[hc]: Formatting fixes
index 742d782803d9f0860f4fb3bcfb4cd2d138fd05b9..a8c0be5c82bc07a5cc9a0e5d46a6b0c378594be0 100644 (file)
@@ -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
index 02064d62ee5d9e6cc17b1ae48dd501cf9dda682d..f1f9c173f5122529f616e6768d9032000e72e74b 100644 (file)
@@ -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],
index f887627e6534e104798500a9d7694c1851f1fd16..4c2d91ac0beee3ffaf97fd97c1e38c90491d335d 100644 (file)
@@ -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);
index 58c4494809d6ac2a8a7c97249d2b04f0f44ff652..f6a8133651ae3648e0d2c6d896e40a08197997c9 100644 (file)
@@ -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 */