summaryrefslogtreecommitdiffstats
path: root/src/egl/main/eglapi.c
diff options
context:
space:
mode:
authorChad Versace <[email protected]>2014-01-07 14:54:51 -0800
committerChad Versace <[email protected]>2014-03-17 15:39:23 -0700
commit6d1f83ec09164bd805c90785635bbcf861b403e5 (patch)
tree8b4ec7c4d8322e62ec78df551d91cb14d79149be /src/egl/main/eglapi.c
parentcefa06cd6967f2c2db2acfb54a4bf3be398a3ce8 (diff)
egl/main: Stop using EGLNative types internally
Internally, much of the EGL code uses EGLNativeDisplayType, EGLNativeWindowType, and EGLPixmapType. However, the EGLNative type often does not match the variable's actual type. The concept of EGLNative types are a bad match for Linux, as explained below. And the EGL platform extensions don't use EGLNative types at all. Those extensions attempt to solve cross-platform issues by moving the EGL API away from the EGLNative types. The core of the problem is that eglplatform.h can define each EGLNative type once only, but Linux supports multiple EGL platforms. To work around the problem, Mesa's eglplatform.h contains multiple definitions of each EGLNative type, selected by feature macros. Mesa expects EGL clients to set the feature macro approrpiately. But the feature macros don't work when a single codebase must be built with support for multiple EGL platforms, *such as Mesa itself*. When building libEGL, autotools chooses the EGLNative typedefs based on the first element of '--with-egl-platforms'. For example, '--with-egl-platforms=x11,drm,wayland' defines the following: typedef Display* EGLNativeDisplayType; typedef Window EGLNativeWindowType; typedef Pixmap EGLNativePixmapType; Clearly, this doesn't work well for Wayland and GBM. Mesa works around the problem by casting the EGLNative types to different things in different files. For sanity's sake, and to prepare for the EGL platform extensions, this patch removes from egl/main and egl/dri2 all internal use of the EGLNative types. It replaces them with 'void*' and checks each explicit cast with a static assertion. Also, the patch touches egl_gallium the minimal amount to keep it compatible with eglapi.h. Signed-off-by: Chad Versace <[email protected]>
Diffstat (limited to 'src/egl/main/eglapi.c')
-rw-r--r--src/egl/main/eglapi.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 950c447de9d..836714ce244 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -296,8 +296,15 @@ _eglUnlockDisplay(_EGLDisplay *dpy)
EGLDisplay EGLAPIENTRY
eglGetDisplay(EGLNativeDisplayType nativeDisplay)
{
- _EGLPlatformType plat = _eglGetNativePlatform(nativeDisplay);
- _EGLDisplay *dpy = _eglFindDisplay(plat, (void *) nativeDisplay);
+ _EGLPlatformType plat;
+ _EGLDisplay *dpy;
+ void *native_display_ptr;
+
+ STATIC_ASSERT(sizeof(void*) == sizeof(nativeDisplay));
+ native_display_ptr = (void*) nativeDisplay;
+
+ plat = _eglGetNativePlatform(native_display_ptr);
+ dpy = _eglFindDisplay(plat, native_display_ptr);
return _eglGetDisplayHandle(dpy);
}
@@ -529,12 +536,17 @@ eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,
_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, window, attrib_list);
+ surf = drv->API.CreateWindowSurface(drv, disp, conf, native_window_ptr,
+ attrib_list);
ret = (surf) ? _eglLinkSurface(surf) : EGL_NO_SURFACE;
RETURN_EGL_EVAL(disp, ret);
@@ -550,12 +562,17 @@ eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config,
_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, pixmap, attrib_list);
+ surf = drv->API.CreatePixmapSurface(drv, disp, conf, native_pixmap_ptr,
+ attrib_list);
ret = (surf) ? _eglLinkSurface(surf) : EGL_NO_SURFACE;
RETURN_EGL_EVAL(disp, ret);
@@ -740,11 +757,15 @@ eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target)
_EGLSurface *surf = _eglLookupSurface(surface, disp);
_EGLDriver *drv;
EGLBoolean ret;
+ void *native_pixmap_ptr;
+
+ STATIC_ASSERT(sizeof(void*) == sizeof(target));
+ native_pixmap_ptr = (void*) target;
_EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv);
if (disp->Platform != _eglGetNativePlatform(disp->PlatformDisplay))
RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_PIXMAP, EGL_FALSE);
- ret = drv->API.CopyBuffers(drv, disp, surf, target);
+ ret = drv->API.CopyBuffers(drv, disp, surf, native_pixmap_ptr);
RETURN_EGL_EVAL(disp, ret);
}