[gtk/wip/otte/gleanup: 6/10] gdk: Require EGL version 1.4 across the board




commit 662b246f84ec14e57429abed24f493626eeed9e3
Author: Benjamin Otte <otte redhat com>
Date:   Mon Jul 5 03:04:08 2021 +0200

    gdk: Require EGL version 1.4 across the board
    
    Mesa currently ships 1.5.

 gdk/gdkglcontextprivate.h          |  8 ++++++++
 gdk/wayland/gdkglcontext-wayland.c | 10 ++++++++++
 gdk/x11/gdkglcontext-egl.c         | 10 ++++++++++
 3 files changed, 28 insertions(+)
---
diff --git a/gdk/gdkglcontextprivate.h b/gdk/gdkglcontextprivate.h
index 07310eebfa..633d67ad1f 100644
--- a/gdk/gdkglcontextprivate.h
+++ b/gdk/gdkglcontextprivate.h
@@ -27,6 +27,14 @@
 
 G_BEGIN_DECLS
 
+/* Version requirements for EGL contexts.
+ *
+ * FIXME: Should this be in meson.build somewhere? It's a runtime check,
+ * so for now it lives here.
+ */
+#define GDK_EGL_MIN_VERSION_MAJOR (1)
+#define GDK_EGL_MIN_VERSION_MINOR (4)
+
 #define GDK_GL_CONTEXT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_GL_CONTEXT, 
GdkGLContextClass))
 #define GDK_IS_GL_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_GL_CONTEXT))
 #define GDK_GL_CONTEXT_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_GL_CONTEXT, 
GdkGLContextClass))
diff --git a/gdk/wayland/gdkglcontext-wayland.c b/gdk/wayland/gdkglcontext-wayland.c
index b33646f75d..60a6e20cdb 100644
--- a/gdk/wayland/gdkglcontext-wayland.c
+++ b/gdk/wayland/gdkglcontext-wayland.c
@@ -446,6 +446,16 @@ gdk_wayland_display_init_gl (GdkDisplay  *display,
                            _("Could not initialize EGL display"));
       return NULL;
     }
+  if (major < GDK_EGL_MIN_VERSION_MAJOR ||
+      (major == GDK_EGL_MIN_VERSION_MAJOR && minor < GDK_EGL_MIN_VERSION_MINOR))
+    {
+      eglTerminate (dpy);
+      g_set_error (error, GDK_GL_ERROR,
+                   GDK_GL_ERROR_NOT_AVAILABLE,
+                   _("EGL version %d.%d is too old. GTK requires %d.%d"),
+                   major, minor, GDK_EGL_MIN_VERSION_MAJOR, GDK_EGL_MIN_VERSION_MINOR);
+      return NULL;
+    }
 
   if (!eglBindAPI (EGL_OPENGL_API))
     {
diff --git a/gdk/x11/gdkglcontext-egl.c b/gdk/x11/gdkglcontext-egl.c
index 3ec383f3bd..ddf6c64aaa 100644
--- a/gdk/x11/gdkglcontext-egl.c
+++ b/gdk/x11/gdkglcontext-egl.c
@@ -626,6 +626,16 @@ gdk_x11_display_init_egl (GdkX11Display  *self,
                            _("Could not initialize EGL display"));
       return FALSE;
     }
+  if (major < GDK_EGL_MIN_VERSION_MAJOR ||
+      (major == GDK_EGL_MIN_VERSION_MAJOR && minor < GDK_EGL_MIN_VERSION_MINOR))
+    {
+      eglTerminate (dpy);
+      g_set_error (error, GDK_GL_ERROR,
+                   GDK_GL_ERROR_NOT_AVAILABLE,
+                   _("EGL version %d.%d is too old. GTK requires %d.%d"),
+                   major, minor, GDK_EGL_MIN_VERSION_MAJOR, GDK_EGL_MIN_VERSION_MINOR);
+      return FALSE;
+    }
 
   if (!gdk_x11_display_create_egl_config (self, force, out_visual, out_depth, error))
     {


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