gdk: Require EGL version 1.4 across the board
authorBenjamin Otte <otte@redhat.com>
Mon, 5 Jul 2021 01:04:08 +0000 (03:04 +0200)
committerBenjamin Otte <otte@redhat.com>
Thu, 22 Jul 2021 14:23:56 +0000 (16:23 +0200)
Mesa currently ships 1.5.

gdk/gdkglcontextprivate.h
gdk/wayland/gdkglcontext-wayland.c
gdk/x11/gdkglcontext-egl.c

index 07310eebfa8733a0493b2fe5e1275b02c03d0838..2f9fc23eed6f17f2be0ba56889cba7e7b94da6b0 100644 (file)
 
 G_BEGIN_DECLS
 
+/* Version requirements for EGL contexts.
+ *
+ * If you add support for EGL to your backend, please require this.
+ */
+#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))
index 23e0105802db5a7636187d6e610b137dd9792c51..6044a9a9073004ac3a0b859ab96bf505b733458b 100644 (file)
@@ -448,6 +448,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))
     {
index 271e77c2f293390347eba0f841bd551a95a1a0ee..1ce44b168bfea4423f78d9f4aa7765ca0b25c1c3 100644 (file)
@@ -626,6 +626,17 @@ 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);
+      self->egl_display = NULL;
+      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))
     {