[gtk+] gdk: Allow querying if a GL context is in legacy mode
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gdk: Allow querying if a GL context is in legacy mode
- Date: Wed, 7 Oct 2015 15:22:33 +0000 (UTC)
commit 2dfca143bb6e09d900fa186ba8ecf9bcea6ac30d
Author: Emmanuele Bassi <ebassi gnome org>
Date: Tue Oct 6 18:54:58 2015 +0100
gdk: Allow querying if a GL context is in legacy mode
We want to have the ability to fall back to legacy GL contexts when
creating them. In order to do so, we need to store the legacy bit on the
GdkGLContext, as well as being able to query it.
Setting the legacy bit from outside GDK is not possible; we cannot
create GL contexts in 3.2 core profile *and* compatibility modes at the
same time, and if we allowed users to select the legacy mode themselves,
it would break the creation of the GdkWindow's paint GL context.
What we do allow is falling back to legacy GL context if the platform
does not support 3.2 core profiles — for instance, on older GPUs or
inside virtualized environments.
We are also going to use the legacy bit internally, to choose which GL
API we can use when drawing GL content.
https://bugzilla.gnome.org/show_bug.cgi?id=756142
gdk/gdkglcontext.c | 33 +++++++++++++++++++++++++++++++++
gdk/gdkglcontext.h | 2 ++
gdk/gdkglcontextprivate.h | 3 +++
3 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c
index 4d71353..874f1ad 100644
--- a/gdk/gdkglcontext.c
+++ b/gdk/gdkglcontext.c
@@ -103,6 +103,7 @@ typedef struct {
guint extensions_checked : 1;
guint debug_enabled : 1;
guint forward_compatible : 1;
+ guint is_legacy : 1;
GdkGLContextPaintData *paint_data;
} GdkGLContextPrivate;
@@ -555,6 +556,38 @@ gdk_gl_context_get_required_version (GdkGLContext *context,
}
/**
+ * gdk_gl_context_is_legacy:
+ * @context: a #GdkGLContext
+ *
+ * Whether the #GdkGLContext is in legacy mode or not.
+ *
+ * The #GdkGLContext must be realized.
+ *
+ * Returns: %TRUE if the GL context is in legacy mode
+ *
+ * Since: 3.20
+ */
+gboolean
+gdk_gl_context_is_legacy (GdkGLContext *context)
+{
+ GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
+
+ g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), FALSE);
+ g_return_val_if_fail (priv->realized, FALSE);
+
+ return priv->is_legacy;
+}
+
+void
+gdk_gl_context_set_is_legacy (GdkGLContext *context,
+ gboolean is_legacy)
+{
+ GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
+
+ priv->is_legacy = !!is_legacy;
+}
+
+/**
* gdk_gl_context_realize:
* @context: a #GdkGLContext
* @error: return location for a #GError
diff --git a/gdk/gdkglcontext.h b/gdk/gdkglcontext.h
index c9603ea..daacd1e 100644
--- a/gdk/gdkglcontext.h
+++ b/gdk/gdkglcontext.h
@@ -52,6 +52,8 @@ GDK_AVAILABLE_IN_3_16
void gdk_gl_context_get_version (GdkGLContext *context,
int *major,
int *minor);
+GDK_AVAILABLE_IN_3_20
+gboolean gdk_gl_context_is_legacy (GdkGLContext *context);
GDK_AVAILABLE_IN_3_16
void gdk_gl_context_set_required_version (GdkGLContext *context,
diff --git a/gdk/gdkglcontextprivate.h b/gdk/gdkglcontextprivate.h
index 668dd0e..a4f19d6 100644
--- a/gdk/gdkglcontextprivate.h
+++ b/gdk/gdkglcontextprivate.h
@@ -69,6 +69,9 @@ typedef struct {
GdkGLContextProgram *current_program;
} GdkGLContextPaintData;
+void gdk_gl_context_set_is_legacy (GdkGLContext *context,
+ gboolean is_legacy);
+
void gdk_gl_context_upload_texture (GdkGLContext *context,
cairo_surface_t *image_surface,
int width,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]