summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2023-04-25 21:45:31 +0200
committerBenjamin Otte <otte@redhat.com>2023-04-27 02:13:32 +0200
commit5f833f1d31c7a1699a997d73c1c5be6e2ad5b08d (patch)
tree0357a2d326972e1c4e6d7363a7ebeb66773f45ec /gdk
parentb8958419e657058ac705968c5e1a733013af5dcd (diff)
downloadgtk+-5f833f1d31c7a1699a997d73c1c5be6e2ad5b08d.tar.gz
glcontext: Compute matching version the simple way
Do it all in one function instead of requiring two different ones.
Diffstat (limited to 'gdk')
-rw-r--r--gdk/gdkglcontext.c40
-rw-r--r--gdk/gdkglcontextprivate.h6
-rw-r--r--gdk/macos/gdkmacosglcontext.c7
-rw-r--r--gdk/win32/gdkglcontext-win32-wgl.c8
-rw-r--r--gdk/x11/gdkglcontext-glx.c5
5 files changed, 26 insertions, 40 deletions
diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c
index 96eaac8d30..294e58e555 100644
--- a/gdk/gdkglcontext.c
+++ b/gdk/gdkglcontext.c
@@ -289,7 +289,7 @@ gdk_gl_context_create_egl_context (GdkGLContext *context,
EGLint context_attribs[N_EGL_ATTRS], i = 0, flags = 0;
gsize major_idx, minor_idx;
gboolean debug_bit, forward_bit;
- GdkGLVersion min, version;
+ GdkGLVersion version;
const GdkGLVersion* supported_versions;
gsize j;
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
@@ -299,8 +299,7 @@ gdk_gl_context_create_egl_context (GdkGLContext *context,
/* We will use the default version matching the context status
* unless the user requested a version which makes sense */
- gdk_gl_context_get_matching_version (api, legacy, &min);
- gdk_gl_context_get_clipped_version (context, &min, &version);
+ gdk_gl_context_get_matching_version (context, api, legacy, &version);
if (!eglBindAPI (gdk_api_to_egl_api (api)))
return 0;
@@ -996,21 +995,33 @@ gdk_gl_context_get_forward_compatible (GdkGLContext *context)
}
void
-gdk_gl_context_get_matching_version (GdkGLAPI api,
+gdk_gl_context_get_matching_version (GdkGLContext *context,
+ GdkGLAPI api,
gboolean legacy,
GdkGLVersion *out_version)
{
+ GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
+ GdkGLVersion min_version;
+
+ g_return_if_fail (GDK_IS_GL_CONTEXT (context));
+
if (api == GDK_GL_API_GL)
{
if (legacy)
- *out_version = GDK_GL_MIN_GL_LEGACY_VERSION;
+ min_version = GDK_GL_MIN_GL_LEGACY_VERSION;
else
- *out_version = GDK_GL_MIN_GL_VERSION;
+ min_version = GDK_GL_MIN_GL_VERSION;
}
else
{
- *out_version = GDK_GL_MIN_GLES_VERSION;
+ min_version = GDK_GL_MIN_GLES_VERSION;
}
+
+ if (gdk_gl_version_greater_equal (&priv->required, &min_version))
+ *out_version = priv->required;
+ else
+ *out_version = min_version;
+
}
/**
@@ -1096,21 +1107,6 @@ gdk_gl_context_get_required_version (GdkGLContext *context,
*minor = gdk_gl_version_get_minor (&priv->required);
}
-void
-gdk_gl_context_get_clipped_version (GdkGLContext *context,
- const GdkGLVersion *min_version,
- GdkGLVersion *out_clipped)
-{
- GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
-
- g_return_if_fail (GDK_IS_GL_CONTEXT (context));
-
- if (gdk_gl_version_greater_equal (&priv->required, min_version))
- *out_clipped = priv->required;
- else
- *out_clipped = *min_version;
-}
-
/**
* gdk_gl_context_is_legacy:
* @context: a `GdkGLContext`
diff --git a/gdk/gdkglcontextprivate.h b/gdk/gdkglcontextprivate.h
index 24809f88ef..2c23153992 100644
--- a/gdk/gdkglcontextprivate.h
+++ b/gdk/gdkglcontextprivate.h
@@ -120,10 +120,8 @@ gdk_gl_context_check_version (GdkGLContext *context,
gles_version ? &GDK_GL_VERSION_STRING (gles_version) : NULL);
}
-void gdk_gl_context_get_clipped_version (GdkGLContext *context,
- const GdkGLVersion *min_version,
- GdkGLVersion *out_clipped);
-void gdk_gl_context_get_matching_version (GdkGLAPI api,
+void gdk_gl_context_get_matching_version (GdkGLContext *context,
+ GdkGLAPI api,
gboolean legacy,
GdkGLVersion *out_version);
diff --git a/gdk/macos/gdkmacosglcontext.c b/gdk/macos/gdkmacosglcontext.c
index a74917d872..baa8eea9f0 100644
--- a/gdk/macos/gdkmacosglcontext.c
+++ b/gdk/macos/gdkmacosglcontext.c
@@ -377,9 +377,10 @@ gdk_macos_gl_context_real_realize (GdkGLContext *context,
existing = CGLGetCurrentContext ();
- gdk_gl_context_get_clipped_version (context,
- GDK_GL_MIN_GL_VERSION,
- &version);
+ gdk_gl_context_get_matching_version (context,
+ GDK_GL_API_GL,
+ FALSE,
+ &version);
display = gdk_gl_context_get_display (context);
shared = gdk_display_get_gl_context (display);
diff --git a/gdk/win32/gdkglcontext-win32-wgl.c b/gdk/win32/gdkglcontext-win32-wgl.c
index 683169418b..411bfd9756 100644
--- a/gdk/win32/gdkglcontext-win32-wgl.c
+++ b/gdk/win32/gdkglcontext-win32-wgl.c
@@ -551,14 +551,6 @@ gdk_win32_gl_context_wgl_realize (GdkGLContext *context,
else
hdc = display_win32->dummy_context_wgl.hdc;
- /*
- * A legacy context cannot be shared with core profile ones, so this means we
- * must stick to a legacy context if the shared context is a legacy context
- */
- legacy_bit = (gdk_display_get_debug_flags (display) & GDK_DEBUG_GL_LEGACY)
- ? TRUE
- : share != NULL && gdk_gl_context_is_legacy (share);
-
if (!set_wgl_pixformat_for_hdc (hdc,
&pixel_format,
display_win32))
diff --git a/gdk/x11/gdkglcontext-glx.c b/gdk/x11/gdkglcontext-glx.c
index 229373f1e9..f6cdedbd1f 100644
--- a/gdk/x11/gdkglcontext-glx.c
+++ b/gdk/x11/gdkglcontext-glx.c
@@ -478,7 +478,7 @@ gdk_x11_context_create_glx_context (GdkGLContext *context,
GLXContext ctx;
int context_attribs[N_GLX_ATTRS], i = 0, flags = 0;
gsize major_idx, minor_idx;
- GdkGLVersion min, version;
+ GdkGLVersion version;
const GdkGLVersion* supported_versions;
gboolean debug_bit, compat_bit;
gsize j;
@@ -491,8 +491,7 @@ gdk_x11_context_create_glx_context (GdkGLContext *context,
/* We will use the default version matching the context status
* unless the user requested a version which makes sense */
- gdk_gl_context_get_matching_version (api, legacy, &min);
- gdk_gl_context_get_clipped_version (context, &min, &version);
+ gdk_gl_context_get_matching_version (context, api, legacy, &version);
debug_bit = gdk_gl_context_get_debug_enabled (context);
compat_bit = gdk_gl_context_get_forward_compatible (context);