[gtk+] gl: Clean up the required version accessors



commit 2d35053d9721a4159a776889dd908e6e972dfdfb
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Mon Feb 9 16:10:22 2015 +0000

    gl: Clean up the required version accessors
    
    We can simplify the code, since we only have core GL profiles in GDK.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=741946

 gdk/gdkglcontext.c |   45 +++++++++++++++++----------------------------
 1 files changed, 17 insertions(+), 28 deletions(-)
---
diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c
index aac9e42..a1b1088 100644
--- a/gdk/gdkglcontext.c
+++ b/gdk/gdkglcontext.c
@@ -526,10 +526,9 @@ gdk_gl_context_set_required_version (GdkGLContext *context,
 
   g_return_if_fail (GDK_IS_GL_CONTEXT (context));
   g_return_if_fail (!priv->realized);
-  g_return_if_fail (priv->profile == GDK_GL_PROFILE_3_2_CORE);
 
-  priv->major = major;
-  priv->minor = minor;
+  priv->major = MAX (major, 3);
+  priv->minor = MAX (minor, 2);
 }
 
 /**
@@ -549,34 +548,24 @@ gdk_gl_context_get_required_version (GdkGLContext *context,
                                      int          *minor)
 {
   GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
+  int maj, min;
 
-  if (major != NULL && priv->major > 0)
-    *major = priv->major;
+  g_return_if_fail (GDK_IS_GL_CONTEXT (context));
+
+  if (priv->major > 0)
+    maj = priv->major;
   else
-    {
-      switch (priv->profile)
-        {
-        case GDK_GL_PROFILE_DEFAULT:
-        case GDK_GL_PROFILE_3_2_CORE:
-          if (major != NULL)
-            *major = 3;
-          break;
-        }
-    }
+    maj = 3;
 
-  if (minor != NULL && priv->minor > 0)
-    *minor = priv->minor;
+  if (priv->minor > 0)
+    min = priv->minor;
   else
-    {
-      switch (priv->profile)
-        {
-        case GDK_GL_PROFILE_DEFAULT:
-        case GDK_GL_PROFILE_3_2_CORE:
-          if (minor != NULL)
-            *minor = 2;
-          break;
-        }
-    }
+    min = 2;
+
+  if (major != NULL)
+    *major = maj;
+  if (minor != NULL)
+    *minor = min;
 }
 
 /**
@@ -601,7 +590,7 @@ gdk_gl_context_realize (GdkGLContext  *context,
   g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), FALSE);
 
   if (priv->realized)
-    return priv->realized;
+    return TRUE;
 
   priv->realized = GDK_GL_CONTEXT_GET_CLASS (context)->realize (context, error);
 


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