[waffle] [PATCH 5/8] egl: Optionally query for eglGetPlatformDisplay (v2)

Chad Versace chadversary at chromium.org
Mon Oct 24 21:58:00 UTC 2016


Not yet used.

v2: Use eglGetProcAddress, not dlsym, due the EGL 1.5 spec. (for emil)

Cc: Emil Velikov <emil.l.velikov at gmail.com>
---
 src/waffle/egl/wegl_imports.h  |  4 ++++
 src/waffle/egl/wegl_platform.c | 23 +++++++++++++++++++++++
 src/waffle/egl/wegl_platform.h |  4 ++++
 3 files changed, 31 insertions(+)

diff --git a/src/waffle/egl/wegl_imports.h b/src/waffle/egl/wegl_imports.h
index 99e79c8..3f39b9e 100644
--- a/src/waffle/egl/wegl_imports.h
+++ b/src/waffle/egl/wegl_imports.h
@@ -35,6 +35,10 @@
 #include <EGL/egl.h>
 #include <EGL/eglext.h>
 
+#ifndef EGL_VERSION_1_5
+typedef intptr_t EGLAttrib;
+#endif
+
 #ifndef EGL_KHR_create_context
 #define EGL_KHR_create_context 1
 #define EGL_CONTEXT_MAJOR_VERSION_KHR                       EGL_CONTEXT_CLIENT_VERSION
diff --git a/src/waffle/egl/wegl_platform.c b/src/waffle/egl/wegl_platform.c
index 524a9a8..f52bdfa 100644
--- a/src/waffle/egl/wegl_platform.c
+++ b/src/waffle/egl/wegl_platform.c
@@ -116,6 +116,25 @@ wegl_platform_init(struct wegl_platform *self, EGLenum egl_platform)
         goto error;                                                    \
     }
 
+    // Use eglGetProcAddress to get EGL 1.5 symbols, not dlsym, because the
+    // EGL 1.5 spec requires that implementors support eglGetProcAddress for
+    // all symbols.
+    //
+    // From the EGL 1.5 spec:
+    //
+    //   eglGetProcAddress may be queried for all EGL and client API functions
+    //   supported by the implementation (whether those functions are
+    //   extensions or not, and whether they are supported by the current
+    //   client API context or not).
+    //
+    //   For functions that are queryable with eglGetProcAddress,
+    //   implementations may choose to also export those functions statically
+    //   from the object libraries implementing those functions. However,
+    //   portable clients cannot rely on this behavior.
+    //
+#define RETRIEVE_EGL_SYMBOL_OPTIONAL(function) \
+    self->function = (void*) self->eglGetProcAddress(#function);
+
     RETRIEVE_EGL_SYMBOL(eglMakeCurrent);
     RETRIEVE_EGL_SYMBOL(eglGetProcAddress);
 
@@ -140,7 +159,11 @@ wegl_platform_init(struct wegl_platform *self, EGLenum egl_platform)
     RETRIEVE_EGL_SYMBOL(eglDestroySurface);
     RETRIEVE_EGL_SYMBOL(eglSwapBuffers);
 
+    // EGL 1.5
+    RETRIEVE_EGL_SYMBOL_OPTIONAL(eglGetPlatformDisplay);
+
 #undef RETRIEVE_EGL_SYMBOL
+#undef RETRIEVE_EGL_SYMBOL_OPTIONAL
 
     self->client_extensions =
         self->eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
diff --git a/src/waffle/egl/wegl_platform.h b/src/waffle/egl/wegl_platform.h
index 92db3b0..4573ec2 100644
--- a/src/waffle/egl/wegl_platform.h
+++ b/src/waffle/egl/wegl_platform.h
@@ -60,6 +60,10 @@ struct wegl_platform {
     __eglMustCastToProperFunctionPointerType
        (*eglGetProcAddress)(const char *procname);
 
+    // EGL 1.5
+    EGLDisplay (*eglGetPlatformDisplay)(EGLenum platform, void *native_display,
+                                        const EGLAttrib *attrib_list);
+
     // display
     EGLDisplay (*eglGetDisplay)(EGLNativeDisplayType display_id);
     EGLBoolean (*eglInitialize)(EGLDisplay dpy, EGLint *major, EGLint *minor);
-- 
2.10.1



More information about the waffle mailing list