diff options
author | Chad Versace <[email protected]> | 2014-01-07 14:54:51 -0800 |
---|---|---|
committer | Chad Versace <[email protected]> | 2014-03-17 15:39:23 -0700 |
commit | 6d1f83ec09164bd805c90785635bbcf861b403e5 (patch) | |
tree | 8b4ec7c4d8322e62ec78df551d91cb14d79149be /src/gallium/state_trackers/egl | |
parent | cefa06cd6967f2c2db2acfb54a4bf3be398a3ce8 (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/gallium/state_trackers/egl')
-rw-r--r-- | src/gallium/state_trackers/egl/common/egl_g3d_api.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_api.c b/src/gallium/state_trackers/egl/common/egl_g3d_api.c index 46a3245246f..b19d8998dbd 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d_api.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d_api.c @@ -315,11 +315,15 @@ egl_g3d_create_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, static _EGLSurface * egl_g3d_create_window_surface(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLConfig *conf, EGLNativeWindowType win, + _EGLConfig *conf, void *native_window, const EGLint *attribs) { + EGLNativeWindowType win; struct egl_g3d_create_surface_arg arg; + STATIC_ASSERT(sizeof(EGLNativeWindowType) == sizeof(native_window)); + win = (EGLNativeWindowType) native_window; + memset(&arg, 0, sizeof(arg)); arg.type = EGL_WINDOW_BIT; arg.u.win = win; @@ -329,11 +333,15 @@ egl_g3d_create_window_surface(_EGLDriver *drv, _EGLDisplay *dpy, static _EGLSurface * egl_g3d_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLConfig *conf, EGLNativePixmapType pix, + _EGLConfig *conf, void *native_pixmap, const EGLint *attribs) { + EGLNativePixmapType pix; struct egl_g3d_create_surface_arg arg; + STATIC_ASSERT(sizeof(EGLNativePixmapType) == sizeof(native_pixmap)); + pix = (EGLNativePixmapType) native_pixmap; + memset(&arg, 0, sizeof(arg)); arg.type = EGL_PIXMAP_BIT; arg.u.pix = pix; @@ -634,11 +642,15 @@ egl_g3d_post_sub_buffer(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, static EGLBoolean egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, - EGLNativePixmapType target) + void *native_pixmap_target) { struct egl_g3d_display *gdpy = egl_g3d_display(dpy); struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); _EGLContext *ctx = _eglGetCurrentContext(); + EGLNativePixmapType target; + + STATIC_ASSERT(sizeof(EGLNativePixmapType) == sizeof(native_pixmap_target)); + target = (EGLNativePixmapType) native_pixmap_target; if (!gsurf->render_texture) return EGL_TRUE; |