[gtk+] gdk: Try harder at tracking drawing contexts



commit 222bcf1a71dbd879fe39bfb9239c093b1da6bb4d
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Fri Jun 10 17:00:29 2016 +0100

    gdk: Try harder at tracking drawing contexts
    
    If gdk_cairo_create() is called within a frame draw operation, we can
    still associate the Cairo context with a GdkDrawingContext.

 gdk/gdkdrawingcontext.c |    2 +-
 gdk/gdkinternals.h      |    2 ++
 gdk/gdkwindow.c         |   17 +++++++----------
 3 files changed, 10 insertions(+), 11 deletions(-)
---
diff --git a/gdk/gdkdrawingcontext.c b/gdk/gdkdrawingcontext.c
index 89d9b50..c082a15 100644
--- a/gdk/gdkdrawingcontext.c
+++ b/gdk/gdkdrawingcontext.c
@@ -180,7 +180,7 @@ gdk_drawing_context_init (GdkDrawingContext *self)
 
 static const cairo_user_data_key_t draw_context_key;
 
-static void
+void
 gdk_cairo_set_drawing_context (cairo_t           *cr,
                                GdkDrawingContext *context)
 {
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index 255557f..33aca33 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -451,6 +451,8 @@ void            gdk_cairo_surface_mark_as_direct (cairo_surface_t *surface,
                                                   GdkWindow       *window);
 cairo_region_t *gdk_cairo_region_from_clip       (cairo_t         *cr);
 
+void            gdk_cairo_set_drawing_context    (cairo_t           *cr,
+                                                  GdkDrawingContext *context);
 
 /*************************************
  * Interfaces used by windowing code *
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 8abcddf..b9c5843 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -3553,20 +3553,17 @@ gdk_cairo_create (GdkWindow *window)
 
   cr = cairo_create (surface);
 
-  if (window->impl_window->current_paint.region != NULL)
-    {
-      region = cairo_region_copy (window->impl_window->current_paint.region);
-      cairo_region_translate (region, -window->abs_x, -window->abs_y);
-    }
-  else
-    {
-      region = cairo_region_copy (window->clip_region);
-    }
-
+  region = gdk_window_get_current_paint_region (window);
   gdk_cairo_region (cr, region);
   cairo_region_destroy (region);
   cairo_clip (cr);
 
+  /* Assign a drawing context, if one is set; if gdk_cairo_create()
+   * is called outside of a frame drawing then this is going to be
+   * NULL.
+   */
+  gdk_cairo_set_drawing_context (cr, window->drawing_context);
+
   cairo_surface_destroy (surface);
 
   return cr;


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