[gtk+/wip/otte/vulkan: 6/36] drawingcontext: Store the GL paint context



commit 9913c29b185d553dd6e77a0fc84a666b62eefb02
Author: Benjamin Otte <otte redhat com>
Date:   Sun Nov 20 20:37:22 2016 +0100

    drawingcontext: Store the GL paint context

 gdk/gdkdrawingcontext.c |   31 +++++++++++++------------------
 1 files changed, 13 insertions(+), 18 deletions(-)
---
diff --git a/gdk/gdkdrawingcontext.c b/gdk/gdkdrawingcontext.c
index 81fb64d..cee0ea9 100644
--- a/gdk/gdkdrawingcontext.c
+++ b/gdk/gdkdrawingcontext.c
@@ -50,6 +50,7 @@ typedef struct _GdkDrawingContextPrivate GdkDrawingContextPrivate;
 
 struct _GdkDrawingContextPrivate {
   GdkWindow *window;
+  GdkGLContext *paint_context;
 
   cairo_region_t *clip;
   cairo_t *cr;
@@ -81,6 +82,7 @@ gdk_drawing_context_dispose (GObject *gobject)
     gdk_cairo_set_drawing_context (priv->cr, NULL);
 
   g_clear_object (&priv->window);
+  g_clear_object (&priv->paint_context);
   g_clear_pointer (&priv->clip, cairo_region_destroy);
   g_clear_pointer (&priv->cr, cairo_destroy);
 
@@ -100,6 +102,17 @@ gdk_drawing_context_set_property (GObject      *gobject,
     {
     case PROP_WINDOW:
       priv->window = g_value_dup_object (value);
+      if (priv->window == NULL)
+        {
+          g_critical ("The drawing context of type %s does not have a window "
+                      "associated to it. Drawing contexts can only be created "
+                      "using gdk_window_begin_draw_frame().",
+                      G_OBJECT_TYPE_NAME (gobject));
+          return;
+        }
+      priv->paint_context = priv->window->gl_paint_context;
+      if (priv->paint_context)
+        g_object_ref (priv->paint_context);
       break;
 
     case PROP_CLIP:
@@ -136,28 +149,10 @@ gdk_drawing_context_get_property (GObject    *gobject,
 }
 
 static void
-gdk_drawing_context_constructed (GObject *gobject)
-{
-  GdkDrawingContext *self = GDK_DRAWING_CONTEXT (gobject);
-  GdkDrawingContextPrivate *priv = gdk_drawing_context_get_instance_private (self);
-
-  if (priv->window == NULL)
-    {
-      g_critical ("The drawing context of type %s does not have a window "
-                  "associated to it. Drawing contexts can only be created "
-                  "using gdk_window_begin_draw_frame().",
-                  G_OBJECT_TYPE_NAME (gobject));
-    }
-
-  G_OBJECT_CLASS (gdk_drawing_context_parent_class)->constructed (gobject);
-}
-
-static void
 gdk_drawing_context_class_init (GdkDrawingContextClass *klass)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
 
-  gobject_class->constructed = gdk_drawing_context_constructed;
   gobject_class->set_property = gdk_drawing_context_set_property;
   gobject_class->get_property = gdk_drawing_context_get_property;
   gobject_class->dispose = gdk_drawing_context_dispose;


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