From 8d175801d73612b1ca49e9fd47c3c0fed17c7552 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Correa=20G=C3=B3mez?= Date: Mon, 30 May 2022 20:14:53 +0200 Subject: [PATCH] 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,