[gnome-mag/cairo-port: 8/8] Draw the test image with Cairo



commit f629d491a571007cb54ca7b3770dfd4c8bab2d26
Author: Benjamin Otte <otte redhat com>
Date:   Fri Aug 13 04:27:44 2010 +0200

    Draw the test image with Cairo

 magnifier/zoom-region.c |   35 +++++++++++++++++------------------
 1 files changed, 17 insertions(+), 18 deletions(-)
---
diff --git a/magnifier/zoom-region.c b/magnifier/zoom-region.c
index 10cdb4b..3faece0 100644
--- a/magnifier/zoom-region.c
+++ b/magnifier/zoom-region.c
@@ -1644,28 +1644,27 @@ zoom_region_get_source_subwindow (ZoomRegion *zoom_region,
 	{
 		/* TESTING ONLY */
 		if (zoom_region->priv->test) {
-			GdkImage *test_image = NULL;
-
-			test_image = gdk_image_new (GDK_IMAGE_FASTEST,
-						    gdk_visual_get_system (),
-						    width,
-						    height);
-
-			for (i = 0; i < width; ++i)
-				for (j = 0; j < height; ++j)
-					gdk_image_put_pixel (test_image, i, j, i*j);
+                        cairo_surface_t *test_image = cairo_image_surface_create (CAIRO_FORMAT_RGB24, width, height);
+                        int stride = cairo_image_surface_get_stride (test_image) / sizeof (guint32);
+                        guint32 *pixels = (guint32 *) cairo_image_surface_get_data (test_image);
+                        cairo_t *cr;
+
+			for (j = 0; j < height; ++j) {
+			        for (i = 0; i < width; ++i) {
+                                        pixels[i] = i * j;
+                                }
+                                pixels += stride;
+                        }
+                        cairo_surface_mark_dirty (test_image);
 
 			zoom_region->priv->source_drawable = gdk_pixmap_new (gtk_widget_get_window (GTK_WIDGET (zoom_region)), width, height, -1);
 
-			if (zoom_region->priv->default_gc == NULL)
-				zoom_region->priv->default_gc = gdk_gc_new(gtk_widget_get_window (GTK_WIDGET (zoom_region)));
+                        cr = gdk_cairo_create (zoom_region->priv->source_drawable);
+                        cairo_set_source_surface (cr, test_image, 0, 0);
+                        cairo_paint (cr);
+                        cairo_destroy (cr);
 
-			gdk_draw_image (zoom_region->priv->source_drawable,
-					zoom_region->priv->default_gc,
-					test_image,
-					0, 0,
-					0, 0,
-					width, height);
+                        cairo_surface_destroy (test_image);
 		}
 		else
 		{



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