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



commit 52d5ebfc5ece419315750b08107106618bb14053
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, 8 insertions(+), 13 deletions(-)
---
diff --git a/demos/gtk-demo/drawingarea.c b/demos/gtk-demo/drawingarea.c
index 5e80449..b84004e 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;
 
-  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);
+  cr = gdk_cairo_create (widget->window);
+  
+  gdk_cairo_set_source_pixmap (cr, pixmap, 0, 0);
+  gdk_cairo_rectangle (cr, &event->area);
+  cairo_fill (cr);
+
+  cairo_destroy (cr);
 
   return FALSE;
 }
@@ -172,8 +169,6 @@ checkerboard_expose (GtkWidget      *da,
       ycount = xcount % 2; /* start with even/odd depending on row */
       while (j < da->allocation.height)
         {
-          GdkGC *gc;
-
           if (ycount % 2)
             cairo_set_source_rgb (cr, 0.45777, 0, 0.45777);
           else



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