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/egl/drivers | |
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/egl/drivers')
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2.c | 12 | ||||
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2.h | 6 | ||||
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2_fallbacks.h | 4 | ||||
-rw-r--r-- | src/egl/drivers/dri2/platform_android.c | 10 | ||||
-rw-r--r-- | src/egl/drivers/dri2/platform_drm.c | 9 | ||||
-rw-r--r-- | src/egl/drivers/dri2/platform_wayland.c | 9 | ||||
-rw-r--r-- | src/egl/drivers/dri2/platform_x11.c | 24 |
7 files changed, 42 insertions, 32 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 76dc7734d9e..8abe8acdd34 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -1026,21 +1026,21 @@ dri2_get_proc_address(_EGLDriver *drv, const char *procname) static _EGLSurface* dri2_create_window_surface(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLConfig *conf, EGLNativeWindowType window, + _EGLConfig *conf, void *native_window, const EGLint *attrib_list) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy); - return dri2_dpy->vtbl->create_window_surface(drv, dpy, conf, window, + return dri2_dpy->vtbl->create_window_surface(drv, dpy, conf, native_window, attrib_list); } static _EGLSurface* dri2_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLConfig *conf, EGLNativePixmapType pixmap, + _EGLConfig *conf, void *native_pixmap, const EGLint *attrib_list) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy); - return dri2_dpy->vtbl->create_pixmap_surface(drv, dpy, conf, pixmap, + return dri2_dpy->vtbl->create_pixmap_surface(drv, dpy, conf, native_pixmap, attrib_list); } @@ -1102,10 +1102,10 @@ dri2_post_sub_buffer(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, static EGLBoolean dri2_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, - EGLNativePixmapType target) + void *native_pixmap_target) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy); - return dri2_dpy->vtbl->copy_buffers(drv, dpy, surf, target); + return dri2_dpy->vtbl->copy_buffers(drv, dpy, surf, native_pixmap_target); } static EGLint diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h index ad74015f733..e62e265b25e 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h @@ -91,12 +91,12 @@ struct dri2_egl_display_vtbl { _EGLSurface* (*create_window_surface)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, - EGLNativeWindowType window, + void *native_window, const EGLint *attrib_list); _EGLSurface* (*create_pixmap_surface)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, - EGLNativePixmapType pixmap, + void *native_pixmap, const EGLint *attrib_list); _EGLSurface* (*create_pbuffer_surface)(_EGLDriver *drv, _EGLDisplay *dpy, @@ -131,7 +131,7 @@ struct dri2_egl_display_vtbl { EGLint width, EGLint height); EGLBoolean (*copy_buffers)(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLSurface *surf, EGLNativePixmapType target); + _EGLSurface *surf, void *native_pixmap_target); EGLint (*query_buffer_age)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf); diff --git a/src/egl/drivers/dri2/egl_dri2_fallbacks.h b/src/egl/drivers/dri2/egl_dri2_fallbacks.h index 80ed26d2fe5..a5cf344f5e8 100644 --- a/src/egl/drivers/dri2/egl_dri2_fallbacks.h +++ b/src/egl/drivers/dri2/egl_dri2_fallbacks.h @@ -31,7 +31,7 @@ struct wl_buffer; static inline _EGLSurface * dri2_fallback_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf, - EGLNativePixmapType pixmap, + void *native_pixmap, const EGLint *attrib_list) { return NULL; @@ -79,7 +79,7 @@ dri2_fallback_post_sub_buffer(_EGLDriver *drv, _EGLDisplay *dpy, static inline EGLBoolean dri2_fallback_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, - EGLNativePixmapType target) + void *native_pixmap_target) { return EGL_FALSE; } diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c index db9edfaee57..7b1db7677ce 100644 --- a/src/egl/drivers/dri2/platform_android.c +++ b/src/egl/drivers/dri2/platform_android.c @@ -194,12 +194,14 @@ droid_free_local_buffers(struct dri2_egl_surface *dri2_surf) static _EGLSurface * droid_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, - _EGLConfig *conf, EGLNativeWindowType window, + _EGLConfig *conf, void *native_window, const EGLint *attrib_list) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_config *dri2_conf = dri2_egl_config(conf); struct dri2_egl_surface *dri2_surf; + struct ANativeWindow *window = native_window; + dri2_surf = calloc(1, sizeof *dri2_surf); if (!dri2_surf) { _eglError(EGL_BAD_ALLOC, "droid_create_surface"); @@ -254,11 +256,11 @@ cleanup_surface: static _EGLSurface * droid_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *conf, EGLNativeWindowType window, - const EGLint *attrib_list) + _EGLConfig *conf, void *native_window, + const EGLint *attrib_list) { return droid_create_surface(drv, disp, EGL_WINDOW_BIT, conf, - window, attrib_list); + native_window, attrib_list); } static _EGLSurface * diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c index 8f9149d98aa..785139e0eb3 100644 --- a/src/egl/drivers/dri2/platform_drm.c +++ b/src/egl/drivers/dri2/platform_drm.c @@ -88,12 +88,13 @@ has_free_buffers(struct gbm_surface *_surf) static _EGLSurface * dri2_drm_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, - _EGLConfig *conf, EGLNativeWindowType window, + _EGLConfig *conf, void *native_window, const EGLint *attrib_list) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_config *dri2_conf = dri2_egl_config(conf); struct dri2_egl_surface *dri2_surf; + struct gbm_surface *window = native_window; struct gbm_dri_surface *surf; (void) drv; @@ -111,7 +112,7 @@ dri2_drm_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, case EGL_WINDOW_BIT: if (!window) return NULL; - surf = gbm_dri_surface((struct gbm_surface *) window); + surf = gbm_dri_surface(window); dri2_surf->gbm_surf = surf; dri2_surf->base.Width = surf->base.width; dri2_surf->base.Height = surf->base.height; @@ -141,11 +142,11 @@ dri2_drm_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, static _EGLSurface * dri2_drm_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *conf, EGLNativeWindowType window, + _EGLConfig *conf, void *native_window, const EGLint *attrib_list) { return dri2_drm_create_surface(drv, disp, EGL_WINDOW_BIT, conf, - window, attrib_list); + native_window, attrib_list); } static EGLBoolean diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c index 02d70390fd2..85564661e92 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c @@ -120,11 +120,12 @@ resize_callback(struct wl_egl_window *wl_win, void *data) */ static _EGLSurface * dri2_wl_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, - _EGLConfig *conf, EGLNativeWindowType window, + _EGLConfig *conf, void *native_window, const EGLint *attrib_list) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_config *dri2_conf = dri2_egl_config(conf); + struct wl_egl_window *window = native_window; struct dri2_egl_surface *dri2_surf; (void) drv; @@ -148,7 +149,7 @@ dri2_wl_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, switch (type) { case EGL_WINDOW_BIT: - dri2_surf->wl_win = (struct wl_egl_window *) window; + dri2_surf->wl_win = window; dri2_surf->wl_win->private = dri2_surf; dri2_surf->wl_win->resize_callback = resize_callback; @@ -186,14 +187,14 @@ dri2_wl_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, */ static _EGLSurface * dri2_wl_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *conf, EGLNativeWindowType window, + _EGLConfig *conf, void *native_window, const EGLint *attrib_list) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); _EGLSurface *surf; surf = dri2_wl_create_surface(drv, disp, EGL_WINDOW_BIT, conf, - window, attrib_list); + native_window, attrib_list); if (surf != NULL) dri2_wl_swap_interval(drv, disp, surf, dri2_dpy->default_swap_interval); diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c index 82f3ce9fdc0..7b585a21971 100644 --- a/src/egl/drivers/dri2/platform_x11.c +++ b/src/egl/drivers/dri2/platform_x11.c @@ -183,7 +183,7 @@ swrastGetImage(__DRIdrawable * read, */ static _EGLSurface * dri2_x11_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, - _EGLConfig *conf, EGLNativeWindowType native_window, + _EGLConfig *conf, void *native_surface, const EGLint *attrib_list) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); @@ -193,7 +193,10 @@ dri2_x11_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, xcb_get_geometry_reply_t *reply; xcb_screen_iterator_t s; xcb_generic_error_t *error; - xcb_drawable_t window = (uintptr_t )native_window; + xcb_drawable_t drawable; + + STATIC_ASSERT(sizeof(uintptr_t) == sizeof(native_surface)); + drawable = (uintptr_t) native_surface; (void) drv; @@ -214,7 +217,7 @@ dri2_x11_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, dri2_surf->drawable, s.data->root, dri2_surf->base.Width, dri2_surf->base.Height); } else { - dri2_surf->drawable = window; + dri2_surf->drawable = drawable; } if (dri2_dpy->dri2) { @@ -278,14 +281,14 @@ dri2_x11_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, */ static _EGLSurface * dri2_x11_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *conf, EGLNativeWindowType window, + _EGLConfig *conf, void *native_window, const EGLint *attrib_list) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); _EGLSurface *surf; surf = dri2_x11_create_surface(drv, disp, EGL_WINDOW_BIT, conf, - window, attrib_list); + native_window, attrib_list); if (surf != NULL) { /* When we first create the DRI2 drawable, its swap interval on the * server side is 1. @@ -301,11 +304,11 @@ dri2_x11_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp, static _EGLSurface * dri2_x11_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *disp, - _EGLConfig *conf, EGLNativePixmapType pixmap, + _EGLConfig *conf, void *native_pixmap, const EGLint *attrib_list) { return dri2_x11_create_surface(drv, disp, EGL_PIXMAP_BIT, conf, - pixmap, attrib_list); + native_pixmap, attrib_list); } static _EGLSurface * @@ -862,12 +865,15 @@ dri2_x11_swap_interval(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, static EGLBoolean dri2_x11_copy_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, - EGLNativePixmapType native_target) + void *native_pixmap_target) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf); xcb_gcontext_t gc; - xcb_pixmap_t target = (uintptr_t )native_target; + xcb_pixmap_t target; + + STATIC_ASSERT(sizeof(uintptr_t) == sizeof(native_pixmap_target)); + target = (uintptr_t) native_pixmap_target; (void) drv; |