[gtk+/wip/ebassi/frame-marker: 3/4] gdk: Explicitly create a cairo context inside GdkDrawingContext



commit 1bec964d260f66f37c03e150ed762442cc75f34c
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Tue Jun 7 16:52:50 2016 +0100

    gdk: Explicitly create a cairo context inside GdkDrawingContext
    
    Instead of using gdk_cairo_create(), which we'll soon deprecate.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=766675

 gdk/gdkdrawingcontext.c |   13 +++++++++++--
 gdk/gdkinternals.h      |    2 ++
 gdk/gdkwindow.c         |   26 ++++++++++++++++++++++++++
 3 files changed, 39 insertions(+), 2 deletions(-)
---
diff --git a/gdk/gdkdrawingcontext.c b/gdk/gdkdrawingcontext.c
index 6216bab..89d9b50 100644
--- a/gdk/gdkdrawingcontext.c
+++ b/gdk/gdkdrawingcontext.c
@@ -231,12 +231,21 @@ gdk_drawing_context_get_cairo_context (GdkDrawingContext *context)
 
   if (context->cr == NULL)
     {
-      context->cr = gdk_cairo_create (context->window);
+      cairo_region_t *region;
+      cairo_surface_t *surface;
+
+      surface = _gdk_window_ref_cairo_surface (context->window);
+      context->cr = cairo_create (surface);
 
       gdk_cairo_set_drawing_context (context->cr, context);
 
-      gdk_cairo_region (context->cr, context->clip);
+      region = gdk_window_get_current_paint_region (context->window);
+      cairo_region_union (region, context->clip);
+      gdk_cairo_region (context->cr, region);
       cairo_clip (context->cr);
+
+      cairo_region_destroy (region);
+      cairo_surface_destroy (surface);
     }
 
   return context->cr;
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index 1e7bcb0..255557f 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -472,6 +472,8 @@ void gdk_window_get_unscaled_size (GdkWindow *window,
 
 GdkDrawingContext *gdk_window_get_drawing_context (GdkWindow *window);
 
+cairo_region_t *gdk_window_get_current_paint_region (GdkWindow *window);
+
 void       _gdk_window_process_updates_recurse (GdkWindow *window,
                                                 cairo_region_t *expose_region);
 
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index c9f043d..f5503e8 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -3236,6 +3236,32 @@ gdk_window_end_draw_frame (GdkWindow         *window,
 }
 
 /*< private >
+ * gdk_window_get_current_paint_region:
+ * @window: a #GdkWindow
+ *
+ * Retrieves a copy of the current paint region.
+ *
+ * Returns: (transfer full): a Cairo region
+ */
+cairo_region_t *
+gdk_window_get_current_paint_region (GdkWindow *window)
+{
+  cairo_region_t *region;
+
+  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);
+    }
+
+  return region;
+}
+
+/*< private >
  * gdk_window_get_drawing_context:
  * @window: a #GdkWindow
  *


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