[Mesa-dev] [PATCH 22/25] egl/main: Stop using EGLNative types internally

Chad Versace chad.versace at linux.intel.com
Sun Feb 9 13:37:58 PST 2014


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 <chad.versace at linux.intel.com>
---
 src/egl/drivers/dri2/egl_dri2.c                    | 12 ++++-----
 src/egl/drivers/dri2/egl_dri2.h                    |  6 ++---
 src/egl/drivers/dri2/egl_dri2_fallbacks.h          |  4 +--
 src/egl/drivers/dri2/platform_android.c            | 10 ++++---
 src/egl/drivers/dri2/platform_drm.c                |  9 ++++---
 src/egl/drivers/dri2/platform_wayland.c            |  9 ++++---
 src/egl/drivers/dri2/platform_x11.c                | 24 ++++++++++-------
 src/egl/main/eglapi.c                              | 31 ++++++++++++++++++----
 src/egl/main/eglapi.h                              |  6 ++---
 src/egl/main/egldisplay.c                          |  4 +--
 src/egl/main/egldisplay.h                          |  2 +-
 .../state_trackers/egl/common/egl_g3d_api.c        | 18 ++++++++++---
 12 files changed, 89 insertions(+), 46 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index fcf4acf..12b0dc2 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1025,21 +1025,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);
 }
 
@@ -1101,10 +1101,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 35115bc..aaa20e0 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -92,12 +92,12 @@ struct dri2_egl_display_vtbl {
 
    _EGLSurface*
    (*create_window_surface)(_EGLDriver *drv, _EGLDisplay *dpy,
-                            _EGLConfig *config, EGLNativeWindowType window,
+                            _EGLConfig *config, void *native_window,
                             const EGLint *attrib_list);
 
    _EGLSurface*
    (*create_pixmap_surface)(_EGLDriver *drv, _EGLDisplay *dpy,
-                            _EGLConfig *config, EGLNativePixmapType pixmap,
+                            _EGLConfig *config, void *native_pixmap,
                             const EGLint *attrib_list);
 
    _EGLSurface*
@@ -134,7 +134,7 @@ struct dri2_egl_display_vtbl {
 
    EGLBoolean
    (*copy_buffers)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
-                   EGLNativePixmapType target);
+                   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 80ed26d..a5cf344 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 3020af7..e117457 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 a05074d..2e6e725 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 1b5577a..9602d67 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 82f3ce9..7b585a2 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;
 
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 59e214c..8a64f8a 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);
 }
 
@@ -532,12 +539,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);
@@ -553,12 +565,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);
@@ -743,11 +760,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);
 }
diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h
index 091c09c..f20ce5b 100644
--- a/src/egl/main/eglapi.h
+++ b/src/egl/main/eglapi.h
@@ -58,8 +58,8 @@ typedef EGLBoolean (*MakeCurrent_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurfa
 typedef EGLBoolean (*QueryContext_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, EGLint attribute, EGLint *value);
 
 /* surface funcs */
-typedef _EGLSurface *(*CreateWindowSurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, EGLNativeWindowType window, const EGLint *attrib_list);
-typedef _EGLSurface *(*CreatePixmapSurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, EGLNativePixmapType pixmap, const EGLint *attrib_list);
+typedef _EGLSurface *(*CreateWindowSurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, void *native_window, const EGLint *attrib_list);
+typedef _EGLSurface *(*CreatePixmapSurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, void *native_pixmap, const EGLint *attrib_list);
 typedef _EGLSurface *(*CreatePbufferSurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, const EGLint *attrib_list);
 typedef EGLBoolean (*DestroySurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface);
 typedef EGLBoolean (*QuerySurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint attribute, EGLint *value);
@@ -68,7 +68,7 @@ typedef EGLBoolean (*BindTexImage_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurf
 typedef EGLBoolean (*ReleaseTexImage_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint buffer);
 typedef EGLBoolean (*SwapInterval_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint interval);
 typedef EGLBoolean (*SwapBuffers_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw);
-typedef EGLBoolean (*CopyBuffers_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLNativePixmapType target);
+typedef EGLBoolean (*CopyBuffers_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, void *native_pixmap_target);
 
 /* misc funcs */
 typedef const char *(*QueryString_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLint name);
diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c
index 97ad865..e5d126e 100644
--- a/src/egl/main/egldisplay.c
+++ b/src/egl/main/egldisplay.c
@@ -139,7 +139,7 @@ _eglPointerIsDereferencable(void *p)
  * Try detecting native platform with the help of native display characteristcs.
  */
 static _EGLPlatformType
-_eglNativePlatformDetectNativeDisplay(EGLNativeDisplayType nativeDisplay)
+_eglNativePlatformDetectNativeDisplay(void *nativeDisplay)
 {
 #ifdef HAVE_FBDEV_PLATFORM
    struct stat buf;
@@ -186,7 +186,7 @@ _eglNativePlatformDetectNativeDisplay(EGLNativeDisplayType nativeDisplay)
  * Return the native platform.  It is the platform of the EGL native types.
  */
 _EGLPlatformType
-_eglGetNativePlatform(EGLNativeDisplayType nativeDisplay)
+_eglGetNativePlatform(void *nativeDisplay)
 {
    static _EGLPlatformType native_platform = _EGL_INVALID_PLATFORM;
    char *detection_method = NULL;
diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
index 66aaff5..ef3524c 100644
--- a/src/egl/main/egldisplay.h
+++ b/src/egl/main/egldisplay.h
@@ -161,7 +161,7 @@ struct _egl_display
 
 
 extern _EGLPlatformType
-_eglGetNativePlatform(EGLNativeDisplayType nativeDisplay);
+_eglGetNativePlatform(void *nativeDisplay);
 
 
 extern void
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 46a3245..b19d899 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;
-- 
1.8.5.3



More information about the mesa-dev mailing list