[gimp] app: honor the exact region when drawing and invalidate overlay children



commit 1833a6eaa1ec085d6e0b1af3ce4d84666351c94d
Author: Michael Natterer <mitch gimp org>
Date:   Sat May 1 17:45:31 2010 +0200

    app: honor the exact region when drawing and invalidate overlay children
    
    gimp_overlay_child_expose(): clip drawing to event->region.
    
    gimp_overlay_child_damage(): transform and invalidate event->region's
    rectangles individually to avoid redundant invalidations.

 app/widgets/gimpoverlaychild.c |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/app/widgets/gimpoverlaychild.c b/app/widgets/gimpoverlaychild.c
index d51bbc0..7643d2e 100644
--- a/app/widgets/gimpoverlaychild.c
+++ b/app/widgets/gimpoverlaychild.c
@@ -334,6 +334,9 @@ gimp_overlay_child_expose (GimpOverlayBox   *box,
           GdkPixmap *pixmap = gdk_offscreen_window_get_pixmap (child->window);
           cairo_t   *cr     = gdk_cairo_create (gtk_widget_get_window (widget));
 
+          gdk_cairo_region (cr, event->region);
+          cairo_clip (cr);
+
           cairo_transform (cr, &child->matrix);
           gdk_cairo_set_source_pixmap (cr, pixmap, 0, 0);
           cairo_paint_with_alpha (cr, child->opacity);
@@ -373,12 +376,23 @@ gimp_overlay_child_damage (GimpOverlayBox   *box,
 
   if (event->window == child->window)
     {
-      GdkRectangle bounds;
+      GdkRectangle *rects;
+      gint          n_rects;
+      gint          i;
 
-      gimp_overlay_child_transform_bounds (child, &event->area, &bounds);
+      gdk_region_get_rectangles (event->region, &rects, &n_rects);
 
-      gdk_window_invalidate_rect (gtk_widget_get_window (widget),
-                                  &bounds, FALSE);
+      for (i = 0; i < n_rects; i++)
+        {
+          GdkRectangle bounds;
+
+          gimp_overlay_child_transform_bounds (child, &rects[i], &bounds);
+
+          gdk_window_invalidate_rect (gtk_widget_get_window (widget),
+                                      &bounds, FALSE);
+        }
+
+      g_free (rects);
 
       return TRUE;
     }



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