gtk+ r20170 - in trunk: . gdk gtk



Author: matthiasc
Date: Mon May 26 04:25:25 2008
New Revision: 20170
URL: http://svn.gnome.org/viewvc/gtk+?rev=20170&view=rev

Log:
        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



Modified:
   trunk/ChangeLog
   trunk/INSTALL.in
   trunk/configure.in
   trunk/gdk/gdkcairo.c
   trunk/gtk/gtkhsv.c

Modified: trunk/INSTALL.in
==============================================================================
--- trunk/INSTALL.in	(original)
+++ trunk/INSTALL.in	Mon May 26 04:25:25 2008
@@ -4,8 +4,8 @@
 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

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Mon May 26 04:25:25 2008
@@ -34,7 +34,7 @@
 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],

Modified: trunk/gdk/gdkcairo.c
==============================================================================
--- trunk/gdk/gdkcairo.c	(original)
+++ trunk/gdk/gdkcairo.c	Mon May 26 04:25:25 2008
@@ -146,6 +146,7 @@
   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 @@
   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_pixels += gdk_rowstride;
-      cairo_pixels += 4 * width;
+      cairo_pixels += cairo_stride;
     }
 
   cairo_set_source_surface (cr, surface, pixbuf_x, pixbuf_y);

Modified: trunk/gtk/gtkhsv.c
==============================================================================
--- trunk/gtk/gtkhsv.c	(original)
+++ trunk/gtk/gtkhsv.c	Mon May 26 04:25:25 2008
@@ -897,6 +897,7 @@
   gdouble r, g, b;
   cairo_surface_t *source;
   cairo_t *source_cr;
+  gint stride;
   gint focus_width;
   gint focus_pad;
 
@@ -914,7 +915,8 @@
   
   /* 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 @@
 
   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 @@
   cairo_surface_t *source;
   gdouble r, g, b;
   gchar *detail;
+  gint stride;
   
   priv = hsv->priv;
   
@@ -1094,8 +1097,9 @@
     }
   
   /* 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 @@
 
   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 */
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]