[gtk+/wip/otte/vulkan: 30/42] gdk: Turn GdkGLContext into a GdkDrawContext



commit ad60d20a4913aba4c804a1b11399fdefe5437be8
Author: Benjamin Otte <otte redhat com>
Date:   Mon Nov 28 17:36:37 2016 +0100

    gdk: Turn GdkGLContext into a GdkDrawContext

 gdk/gdkglcontext.c                 |   88 ++---------------------------------
 gdk/gdkglcontextprivate.h          |    5 +-
 gdk/mir/gdkmirwindowimpl.c         |    1 -
 gdk/wayland/gdkglcontext-wayland.c |    1 -
 gdk/win32/gdkglcontext-win32.c     |    1 -
 gdk/x11/gdkglcontext-x11.c         |    1 -
 6 files changed, 8 insertions(+), 89 deletions(-)
---
diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c
index 2717f5d..aaf0736 100644
--- a/gdk/gdkglcontext.c
+++ b/gdk/gdkglcontext.c
@@ -115,8 +115,6 @@ typedef struct {
 enum {
   PROP_0,
 
-  PROP_DISPLAY,
-  PROP_WINDOW,
   PROP_SHARED_CONTEXT,
 
   LAST_PROP
@@ -126,7 +124,7 @@ static GParamSpec *obj_pspecs[LAST_PROP] = { NULL, };
 
 G_DEFINE_QUARK (gdk-gl-error-quark, gdk_gl_error)
 
-G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkGLContext, gdk_gl_context, G_TYPE_OBJECT)
+G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkGLContext, gdk_gl_context, GDK_TYPE_DRAW_CONTEXT)
 
 static GPrivate thread_current_context = G_PRIVATE_INIT (g_object_unref);
 
@@ -141,8 +139,6 @@ gdk_gl_context_dispose (GObject *gobject)
   if (current == context)
     g_private_replace (&thread_current_context, NULL);
 
-  g_clear_object (&priv->display);
-  g_clear_object (&priv->window);
   g_clear_object (&priv->shared_context);
 
   G_OBJECT_CLASS (gdk_gl_context_parent_class)->dispose (gobject);
@@ -168,34 +164,6 @@ gdk_gl_context_set_property (GObject      *gobject,
 
   switch (prop_id)
     {
-    case PROP_DISPLAY:
-      {
-        GdkDisplay *display = g_value_get_object (value);
-
-        if (display)
-          g_object_ref (display);
-
-        if (priv->display)
-          g_object_unref (priv->display);
-
-        priv->display = display;
-      }
-      break;
-
-    case PROP_WINDOW:
-      {
-        GdkWindow *window = g_value_get_object (value);
-
-        if (window)
-          g_object_ref (window);
-
-        if (priv->window)
-          g_object_unref (priv->window);
-
-        priv->window = window;
-      }
-      break;
-
     case PROP_SHARED_CONTEXT:
       {
         GdkGLContext *context = g_value_get_object (value);
@@ -220,14 +188,6 @@ gdk_gl_context_get_property (GObject    *gobject,
 
   switch (prop_id)
     {
-    case PROP_DISPLAY:
-      g_value_set_object (value, priv->display);
-      break;
-
-    case PROP_WINDOW:
-      g_value_set_object (value, priv->window);
-      break;
-
     case PROP_SHARED_CONTEXT:
       g_value_set_object (value, priv->shared_context);
       break;
@@ -306,38 +266,6 @@ gdk_gl_context_class_init (GdkGLContextClass *klass)
   klass->realize = gdk_gl_context_real_realize;
 
   /**
-   * GdkGLContext:display:
-   *
-   * The #GdkDisplay used to create the #GdkGLContext.
-   *
-   * Since: 3.16
-   */
-  obj_pspecs[PROP_DISPLAY] =
-    g_param_spec_object ("display",
-                         P_("Display"),
-                         P_("The GDK display used to create the GL context"),
-                         GDK_TYPE_DISPLAY,
-                         G_PARAM_READWRITE |
-                         G_PARAM_CONSTRUCT_ONLY |
-                         G_PARAM_STATIC_STRINGS);
-
-  /**
-   * GdkGLContext:window:
-   *
-   * The #GdkWindow the gl context is bound to.
-   *
-   * Since: 3.16
-   */
-  obj_pspecs[PROP_WINDOW] =
-    g_param_spec_object ("window",
-                         P_("Window"),
-                         P_("The GDK window bound to the GL context"),
-                         GDK_TYPE_WINDOW,
-                         G_PARAM_READWRITE |
-                         G_PARAM_CONSTRUCT_ONLY |
-                         G_PARAM_STATIC_STRINGS);
-
-  /**
    * GdkGLContext:shared-context:
    *
    * The #GdkGLContext that this context is sharing data with, or #NULL
@@ -964,7 +892,7 @@ gdk_gl_context_make_current (GdkGLContext *context)
         }
     }
 
-  if (gdk_display_make_gl_context_current (priv->display, context))
+  if (gdk_display_make_gl_context_current (gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context)), 
context))
     {
       g_private_replace (&thread_current_context, g_object_ref (context));
       gdk_gl_context_check_extensions (context);
@@ -984,11 +912,9 @@ gdk_gl_context_make_current (GdkGLContext *context)
 GdkDisplay *
 gdk_gl_context_get_display (GdkGLContext *context)
 {
-  GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
-
   g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), NULL);
 
-  return priv->display;
+  return gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
 }
 
 /**
@@ -1004,11 +930,9 @@ gdk_gl_context_get_display (GdkGLContext *context)
 GdkWindow *
 gdk_gl_context_get_window (GdkGLContext *context)
 {
-  GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
-
   g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), NULL);
 
-  return priv->window;
+  return gdk_draw_context_get_window (GDK_DRAW_CONTEXT (context));
 }
 
 /**
@@ -1077,9 +1001,7 @@ gdk_gl_context_clear_current (void)
   current = g_private_get (&thread_current_context);
   if (current != NULL)
     {
-      GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (current);
-
-      if (gdk_display_make_gl_context_current (priv->display, NULL))
+      if (gdk_display_make_gl_context_current (gdk_draw_context_get_display (GDK_DRAW_CONTEXT (current)), 
NULL))
         g_private_replace (&thread_current_context, NULL);
     }
 }
diff --git a/gdk/gdkglcontextprivate.h b/gdk/gdkglcontextprivate.h
index 3193e2d..2f1bb5e 100644
--- a/gdk/gdkglcontextprivate.h
+++ b/gdk/gdkglcontextprivate.h
@@ -22,6 +22,7 @@
 #define __GDK_GL_CONTEXT_PRIVATE_H__
 
 #include "gdkglcontext.h"
+#include "gdkdrawcontextprivate.h"
 
 G_BEGIN_DECLS
 
@@ -33,12 +34,12 @@ typedef struct _GdkGLContextClass       GdkGLContextClass;
 
 struct _GdkGLContext
 {
-  GObject parent_instance;
+  GdkDrawContext parent_instance;
 };
 
 struct _GdkGLContextClass
 {
-  GObjectClass parent_class;
+  GdkDrawContextClass parent_class;
 
   gboolean (* realize) (GdkGLContext *context,
                         GError **error);
diff --git a/gdk/mir/gdkmirwindowimpl.c b/gdk/mir/gdkmirwindowimpl.c
index 87c77e9..069a6b0 100644
--- a/gdk/mir/gdkmirwindowimpl.c
+++ b/gdk/mir/gdkmirwindowimpl.c
@@ -1584,7 +1584,6 @@ gdk_mir_window_impl_create_gl_context (GdkWindow     *window,
     return NULL;
 
   context = g_object_new (GDK_TYPE_MIR_GL_CONTEXT,
-                          "display", display,
                           "window", window,
                           "shared-context", share,
                           NULL);
diff --git a/gdk/wayland/gdkglcontext-wayland.c b/gdk/wayland/gdkglcontext-wayland.c
index 1763ec7..a57e1e4 100644
--- a/gdk/wayland/gdkglcontext-wayland.c
+++ b/gdk/wayland/gdkglcontext-wayland.c
@@ -408,7 +408,6 @@ gdk_wayland_window_create_gl_context (GdkWindow     *window,
     return NULL;
 
   context = g_object_new (GDK_TYPE_WAYLAND_GL_CONTEXT,
-                          "display", display,
                           "window", window,
                           "shared-context", share,
                           NULL);
diff --git a/gdk/win32/gdkglcontext-win32.c b/gdk/win32/gdkglcontext-win32.c
index 8da90a3..12adf73 100644
--- a/gdk/win32/gdkglcontext-win32.c
+++ b/gdk/win32/gdkglcontext-win32.c
@@ -749,7 +749,6 @@ _gdk_win32_window_create_gl_context (GdkWindow *window,
   display_win32->gl_hwnd = hwnd;
 
   context = g_object_new (GDK_TYPE_WIN32_GL_CONTEXT,
-                          "display", display,
                           "window", window,
                           "shared-context", share,
                           NULL);
diff --git a/gdk/x11/gdkglcontext-x11.c b/gdk/x11/gdkglcontext-x11.c
index 92aaaf1..6665189 100644
--- a/gdk/x11/gdkglcontext-x11.c
+++ b/gdk/x11/gdkglcontext-x11.c
@@ -1226,7 +1226,6 @@ gdk_x11_window_create_gl_context (GdkWindow    *window,
     return NULL;
 
   context = g_object_new (GDK_TYPE_X11_GL_CONTEXT,
-                          "display", display,
                           "window", window,
                           "shared-context", share,
                           NULL);


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