]> Pileus Git - ~andy/gtk/commitdiff
gdk: Refactor redirection code
authorBenjamin Otte <otte@redhat.com>
Tue, 20 Jul 2010 00:02:26 +0000 (02:02 +0200)
committerBenjamin Otte <otte@redhat.com>
Tue, 10 Aug 2010 19:02:28 +0000 (21:02 +0200)
This will make future patches easier

gdk/gdkwindow.c

index 51971aa02ec7e821b3ce53c83f26cf8d499c0fb0..3519f1fa48e73aee05fb609feb666bdc4e0cc705 100644 (file)
@@ -3027,9 +3027,8 @@ gdk_window_begin_paint_region (GdkWindow       *window,
 #endif /* USE_BACKING_STORE */
 }
 
-static void
+static cairo_region_t *
 setup_redirect_clip (GdkWindow      *window,
-                    GdkGC          *gc,
                     int            *x_offset_out,
                     int            *y_offset_out)
 {
@@ -3062,15 +3061,10 @@ setup_redirect_clip (GdkWindow      *window,
   x_offset += private->redirect->dest_x;
   y_offset += private->redirect->dest_y;
 
-  gdk_gc_set_clip_region (gc, visible_region); /* This resets clip origin! */
-
-  /* offset clip and tiles from window coords to pixmaps coords */
-  gdk_gc_offset (gc, -x_offset, -y_offset);
-
-  cairo_region_destroy (visible_region);
-
   *x_offset_out = x_offset;
   *y_offset_out = y_offset;
+
+  return visible_region;
 }
 
 /**
@@ -3148,15 +3142,23 @@ gdk_window_end_paint (GdkWindow *window)
   if (private->redirect)
     {
       int x_offset, y_offset;
+      cairo_region_t *region;
 
       /* TODO: Should also use paint->region for clipping */
-      setup_redirect_clip (window, tmp_gc, &x_offset, &y_offset);
+      region = setup_redirect_clip (window, &x_offset, &y_offset);
+
+      gdk_gc_set_clip_region (tmp_gc, region); /* This resets clip origin! */
+      /* offset clip and tiles from window coords to pixmaps coords */
+      gdk_gc_offset (tmp_gc, -x_offset, -y_offset);
+
       gdk_draw_drawable (private->redirect->pixmap, tmp_gc, paint->pixmap,
                         clip_box.x - paint->x_offset,
                         clip_box.y - paint->y_offset,
                         clip_box.x + x_offset,
                         clip_box.y + y_offset,
                         clip_box.width, clip_box.height);
+
+      cairo_region_destroy (region);
     }
 
   /* Reset clip region of the cached GdkGC */