summaryrefslogtreecommitdiffstats
path: root/src/egl/main/eglapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/egl/main/eglapi.c')
-rw-r--r--src/egl/main/eglapi.c132
1 files changed, 110 insertions, 22 deletions
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 836714ce244..219d8e61715 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -308,6 +308,36 @@ eglGetDisplay(EGLNativeDisplayType nativeDisplay)
return _eglGetDisplayHandle(dpy);
}
+EGLDisplay EGLAPIENTRY
+eglGetPlatformDisplayEXT(EGLenum platform, void *native_display,
+ const EGLint *attrib_list)
+{
+ _EGLDisplay *dpy;
+
+ switch (platform) {
+#ifdef HAVE_X11_PLATFORM
+ case EGL_PLATFORM_X11_EXT:
+ dpy = _eglGetX11Display((Display*) native_display, attrib_list);
+ break;
+#endif
+#ifdef HAVE_DRM_PLATFORM
+ case EGL_PLATFORM_GBM_MESA:
+ dpy = _eglGetGbmDisplay((struct gbm_device*) native_display,
+ attrib_list);
+ break;
+#endif
+#ifdef HAVE_WAYLAND_PLATFORM
+ case EGL_PLATFORM_WAYLAND_EXT:
+ dpy = _eglGetWaylandDisplay((struct wl_display*) native_display,
+ attrib_list);
+ break;
+#endif
+ default:
+ RETURN_EGL_ERROR(NULL, EGL_BAD_PARAMETER, NULL);
+ }
+
+ return _eglGetDisplayHandle(dpy);
+}
/**
* This is typically the second EGL function that an application calls.
@@ -527,25 +557,17 @@ eglQueryContext(EGLDisplay dpy, EGLContext ctx,
}
-EGLSurface EGLAPIENTRY
-eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,
- EGLNativeWindowType window, const EGLint *attrib_list)
+static EGLSurface
+_eglCreateWindowSurfaceCommon(_EGLDisplay *disp, EGLConfig config,
+ void *native_window, const EGLint *attrib_list)
{
- _EGLDisplay *disp = _eglLockDisplay(dpy);
_EGLConfig *conf = _eglLookupConfig(config, disp);
_EGLDriver *drv;
_EGLSurface *surf;
EGLSurface ret;
- void *native_window_ptr;
-
- STATIC_ASSERT(sizeof(void*) == sizeof(window));
- native_window_ptr = (void*) window;
_EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv);
- if (disp->Platform != _eglGetNativePlatform(disp->PlatformDisplay))
- RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE);
-
- surf = drv->API.CreateWindowSurface(drv, disp, conf, native_window_ptr,
+ surf = drv->API.CreateWindowSurface(drv, disp, conf, native_window,
attrib_list);
ret = (surf) ? _eglLinkSurface(surf) : EGL_NO_SURFACE;
@@ -554,24 +576,52 @@ eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,
EGLSurface EGLAPIENTRY
-eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config,
- EGLNativePixmapType pixmap, const EGLint *attrib_list)
+eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,
+ EGLNativeWindowType window, const EGLint *attrib_list)
{
_EGLDisplay *disp = _eglLockDisplay(dpy);
+ STATIC_ASSERT(sizeof(void*) == sizeof(window));
+ return _eglCreateWindowSurfaceCommon(disp, config, (void*) window,
+ attrib_list);
+}
+
+
+EGLSurface EGLAPIENTRY
+eglCreatePlatformWindowSurfaceEXT(EGLDisplay dpy, EGLConfig config,
+ void *native_window,
+ const EGLint *attrib_list)
+{
+ _EGLDisplay *disp = _eglLockDisplay(dpy);
+
+#ifdef HAVE_X11_PLATFORM
+ if (disp->Platform == _EGL_PLATFORM_X11 && native_window != NULL) {
+ /* The `native_window` parameter for the X11 platform differs between
+ * eglCreateWindowSurface() and eglCreatePlatformPixmapSurfaceEXT(). In
+ * eglCreateWindowSurface(), the type of `native_window` is an Xlib
+ * `Window`. In eglCreatePlatformWindowSurfaceEXT(), the type is
+ * `Window*`. Convert `Window*` to `Window` because that's what
+ * dri2_x11_create_window_surface() expects.
+ */
+ native_window = (void*) (* (Window*) native_window);
+ }
+#endif
+
+ return _eglCreateWindowSurfaceCommon(disp, config, native_window,
+ attrib_list);
+}
+
+
+static EGLSurface
+_eglCreatePixmapSurfaceCommon(_EGLDisplay *disp, EGLConfig config,
+ void *native_pixmap, const EGLint *attrib_list)
+{
_EGLConfig *conf = _eglLookupConfig(config, disp);
_EGLDriver *drv;
_EGLSurface *surf;
EGLSurface ret;
- void *native_pixmap_ptr;
-
- STATIC_ASSERT(sizeof(void*) == sizeof(pixmap));
- native_pixmap_ptr = (void*) pixmap;
_EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv);
- if (disp->Platform != _eglGetNativePlatform(disp->PlatformDisplay))
- RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_PIXMAP, EGL_NO_SURFACE);
-
- surf = drv->API.CreatePixmapSurface(drv, disp, conf, native_pixmap_ptr,
+ surf = drv->API.CreatePixmapSurface(drv, disp, conf, native_pixmap,
attrib_list);
ret = (surf) ? _eglLinkSurface(surf) : EGL_NO_SURFACE;
@@ -580,6 +630,41 @@ eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config,
EGLSurface EGLAPIENTRY
+eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config,
+ EGLNativePixmapType pixmap, const EGLint *attrib_list)
+{
+ _EGLDisplay *disp = _eglLockDisplay(dpy);
+ STATIC_ASSERT(sizeof(void*) == sizeof(pixmap));
+ return _eglCreatePixmapSurfaceCommon(disp, config, (void*) pixmap,
+ attrib_list);
+}
+
+EGLSurface EGLAPIENTRY
+eglCreatePlatformPixmapSurfaceEXT(EGLDisplay dpy, EGLConfig config,
+ void *native_pixmap,
+ const EGLint *attrib_list)
+{
+ _EGLDisplay *disp = _eglLockDisplay(dpy);
+
+#ifdef HAVE_X11_PLATFORM
+ /* The `native_pixmap` parameter for the X11 platform differs between
+ * eglCreatePixmapSurface() and eglCreatePlatformPixmapSurfaceEXT(). In
+ * eglCreatePixmapSurface(), the type of `native_pixmap` is an Xlib
+ * `Pixmap`. In eglCreatePlatformPixmapSurfaceEXT(), the type is
+ * `Pixmap*`. Convert `Pixmap*` to `Pixmap` because that's what
+ * dri2_x11_create_pixmap_surface() expects.
+ */
+ if (disp->Platform == _EGL_PLATFORM_X11 && native_pixmap != NULL) {
+ native_pixmap = (void*) (* (Pixmap*) native_pixmap);
+ }
+#endif
+
+ return _eglCreatePixmapSurfaceCommon(disp, config, native_pixmap,
+ attrib_list);
+}
+
+
+EGLSurface EGLAPIENTRY
eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config,
const EGLint *attrib_list)
{
@@ -998,6 +1083,9 @@ eglGetProcAddress(const char *procname)
#ifdef EGL_EXT_swap_buffers_with_damage
{ "eglSwapBuffersWithDamageEXT", (_EGLProc) eglSwapBuffersWithDamageEXT },
#endif
+ { "eglGetPlatformDisplayEXT", (_EGLProc) eglGetPlatformDisplayEXT },
+ { "eglCreatePlatformWindowSurfaceEXT", (_EGLProc) eglCreatePlatformWindowSurfaceEXT },
+ { "eglCreatePlatformPixmapSurfaceEXT", (_EGLProc) eglCreatePlatformPixmapSurfaceEXT },
{ NULL, NULL }
};
EGLint i;