[gtk: 4/11] glcontext: Add internal get_clipped_version function




commit 8d175801d73612b1ca49e9fd47c3c0fed17c7552
Author: Pablo Correa Gómez <ablocorrea hotmail com>
Date:   Mon May 30 20:14:53 2022 +0200

    glcontext: Add internal get_clipped_version function
    
    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        | 18 ++++++++++++++++++
 gdk/gdkglcontextprivate.h |  5 +++++
 2 files changed, 23 insertions(+)
---
diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c
index 8f9fe25396..484dee3200 100644
--- a/gdk/gdkglcontext.c
+++ b/gdk/gdkglcontext.c
@@ -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)
diff --git a/gdk/gdkglcontextprivate.h b/gdk/gdkglcontextprivate.h
index 0a3739f090..b97d07f34f 100644
--- a/gdk/gdkglcontextprivate.h
+++ b/gdk/gdkglcontextprivate.h
@@ -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,


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