[gtk+] Fix transparency handling with non-double-buffered drawing



commit 251cffb638811b36779ea8364a63dd46b422dfbb
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Feb 9 21:09:44 2012 +0100

    Fix transparency handling with non-double-buffered drawing
    
    Sometimes we need to read back the window content into our double
    buffer due to rendering a window with alpha when there is
    no implicit paint or it has been flushed due to non-db drawing
    before.
    
    However, in this case we can't use gdk_cairo_set_source_window as
    it might trigger an implicit paint flush as we detect what we
    think is a direct non-double buffered window draw operation, which
    will flush the implicit paint operation that we're just setting up.
    
    To fix this we use the raw gdk_window_ref_impl_surface operation
    to get the source surface.

 gdk/gdkwindow.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 1642424..d2a0f4f 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -2971,9 +2971,14 @@ gdk_window_begin_paint_region (GdkWindow       *window,
        (implicit_paint && implicit_paint->flushed)))
     {
       cairo_t *cr = cairo_create (paint->surface);
-      gdk_cairo_set_source_window (cr, impl_window,
-                                   - (window->abs_x + clip_box.x),
-                                   - (window->abs_y + clip_box.y));
+      /* We can't use gdk_cairo_set_source_window here, as that might
+	 flush the implicit paint at an unfortunate time, since this
+	 would be detected as a draw during non-expose time */
+      cairo_surface_t *source_surface  = gdk_window_ref_impl_surface (impl_window);
+      cairo_set_source_surface (cr, source_surface,
+				- (window->abs_x + clip_box.x),
+				- (window->abs_y + clip_box.y));
+      cairo_surface_destroy (source_surface);
       cairo_paint (cr);
       cairo_destroy (cr);
     }



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