From a860bbbe46f287f35e09d8728c8c499fdfc6c3a8 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sun, 20 Nov 2016 20:37:22 +0100 Subject: [PATCH] drawingcontext: Store the GL paint context --- gdk/gdkdrawingcontext.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/gdk/gdkdrawingcontext.c b/gdk/gdkdrawingcontext.c index 81fb64d970..cee0ea9cda 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: @@ -135,29 +148,11 @@ 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;