[gtk+/rendering-cleanup] gtk-demo: Blit backing pixmap using Cairo



commit 9fa179d4ec944898743a75e856ee7234fe23167d
Author: Benjamin Otte <otte redhat com>
Date:   Mon Jul 19 12:15:58 2010 +0200

    gtk-demo: Blit backing pixmap using Cairo

 demos/gtk-demo/drawingarea.c |   21 +++++++++------------
 1 files changed, 9 insertions(+), 12 deletions(-)
---
diff --git a/demos/gtk-demo/drawingarea.c b/demos/gtk-demo/drawingarea.c
index 5e80449..40549ec 100644
--- a/demos/gtk-demo/drawingarea.c
+++ b/demos/gtk-demo/drawingarea.c
@@ -53,18 +53,15 @@ scribble_expose_event (GtkWidget      *widget,
                        GdkEventExpose *event,
                        gpointer        data)
 {
-  /* We use the "foreground GC" for the widget since it already exists,
-   * but honestly any GC would work. The only thing to worry about
-   * is whether the GC has an inappropriate clip region set.
-   */
+  cairo_t *cr;
+
+  cr = gdk_cairo_create (widget->window);
+  
+  gdk_cairo_set_source_pixmap (cr, pixmap, 0, 0);
+  gdk_cairo_rectangle (cr, &event->area);
+  cairo_fill (cr);
 
-  gdk_draw_drawable (widget->window,
-                     widget->style->fg_gc[gtk_widget_get_state (widget)],
-                     pixmap,
-                     /* Only copy the area that was exposed. */
-                     event->area.x, event->area.y,
-                     event->area.x, event->area.y,
-                     event->area.width, event->area.height);
+  cairo_destroy (cr);
 
   return FALSE;
 }



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