glcontext: Add internal get_clipped_version function
authorPablo Correa Gómez <ablocorrea@hotmail.com>
Mon, 30 May 2022 18:14:53 +0000 (20:14 +0200)
committerPablo Correa Gómez <ablocorrea@hotmail.com>
Sat, 4 Jun 2022 18:48:40 +0000 (20:48 +0200)
It is useful for backends to get user set preferences while
ensuring the correctness of the result, which will be always
greater or equal than the minimum version provided

gdk/gdkglcontext.c
gdk/gdkglcontextprivate.h

index 8f9fe2539690603db729e81838b6fdbe8509c980..484dee32000540a59c7abfa239565120bd6a97ee 100644 (file)
@@ -1113,6 +1113,24 @@ gdk_gl_context_get_required_version (GdkGLContext *context,
   else
     min = default_minor;
 
+void
+gdk_gl_context_get_clipped_version (GdkGLContext *context,
+                                    int           min_major,
+                                    int           min_minor,
+                                    int          *major,
+                                    int          *minor)
+{
+  GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
+  int maj = min_major, min = min_minor;
+
+  g_return_if_fail (GDK_IS_GL_CONTEXT (context));
+
+  if (priv->major > maj || (priv->major == maj && priv->minor > min))
+    {
+      maj = priv->major;
+      min = priv->minor;
+    }
+
   if (major != NULL)
     *major = maj;
   if (minor != NULL)
index 0a3739f090fef8a4dba9a4da51acc958f5de2ad0..b97d07f34fb4313ec935023b6b8c43a74c760859 100644 (file)
@@ -117,6 +117,11 @@ gboolean                gdk_gl_context_check_version            (GdkGLContext
                                                                  int              required_gl_minor,
                                                                  int              required_gles_major,
                                                                  int              required_gles_minor);
+void                    gdk_gl_context_get_clipped_version      (GdkGLContext    *context,
+                                                                 int              min_major,
+                                                                 int              min_minor,
+                                                                 int             *major,
+                                                                 int             *minor);
 
 gboolean                gdk_gl_context_has_unpack_subimage      (GdkGLContext    *context);
 void                    gdk_gl_context_push_debug_group         (GdkGLContext    *context,