egl: Convert drivers to use typecast macros.
[mesa.git] / src / egl / drivers / xdri / egl_xdri.c
index 2ca9ea8a5b07e397571189a9c1acb327e93e2090..555473c00a59e8d9e2c0ea5306879b3d7f93ab37 100644 (file)
@@ -52,7 +52,7 @@
 #include "eglcontext.h"
 #include "egldisplay.h"
 #include "egldriver.h"
-#include "eglglobals.h"
+#include "eglcurrent.h"
 #include "egllog.h"
 #include "eglsurface.h"
 
@@ -112,43 +112,13 @@ struct xdri_egl_config
 
 
 
-/** cast wrapper */
-static INLINE struct xdri_egl_driver *
-xdri_egl_driver(_EGLDriver *drv)
-{
-   return (struct xdri_egl_driver *) drv;
-}
-
+/* standard typecasts */
+_EGL_DRIVER_STANDARD_TYPECASTS(xdri_egl)
 
-static INLINE struct xdri_egl_display *
-lookup_display(_EGLDisplay *dpy)
-{
-   return (struct xdri_egl_display *) dpy->DriverData;
-}
-
-
-/** Map EGLSurface handle to xdri_egl_surface object */
-static INLINE struct xdri_egl_surface *
-lookup_surface(_EGLSurface *surface)
-{
-   return (struct xdri_egl_surface *) surface;
-}
-
-
-/** Map EGLContext handle to xdri_egl_context object */
-static INLINE struct xdri_egl_context *
-lookup_context(_EGLContext *context)
-{
-   return (struct xdri_egl_context *) context;
-}
-
-
-/** Map EGLConfig handle to xdri_egl_config object */
-static INLINE struct xdri_egl_config *
-lookup_config(_EGLConfig *conf)
-{
-   return (struct xdri_egl_config *) conf;
-}
+#define lookup_display(dpy) xdri_egl_display(dpy)
+#define lookup_context(ctx) xdri_egl_context(ctx)
+#define lookup_surface(surf) xdri_egl_surface(surf)
+#define lookup_config(conf) xdri_egl_config(conf)
 
 
 /** Get size of given window */
@@ -171,7 +141,6 @@ convert_config(_EGLConfig *conf, EGLint id, const __GLcontextModes *m)
 {
    EGLint val;
 
-   _eglInitConfig(conf, id);
    if (!_eglConfigFromContextModesRec(conf, m, EGL_OPENGL_BIT, EGL_OPENGL_BIT))
       return EGL_FALSE;
 
@@ -221,6 +190,7 @@ create_configs(_EGLDisplay *disp, const __GLcontextModes *m, EGLint first_id)
       _EGLConfig conf;
       EGLint rb;
 
+      _eglInitConfig(&conf, disp, id);
       if (!convert_config(&conf, id, m))
          continue;
       if (m->doubleBufferMode) {
@@ -391,7 +361,7 @@ xdri_eglCreateContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
       return NULL;
    }
 
-   if (!_eglInitContext(drv, &xdri_ctx->Base, &xdri_config->Base, attrib_list)) {
+   if (!_eglInitContext(&xdri_ctx->Base, dpy, &xdri_config->Base, attrib_list)) {
       free(xdri_ctx->dummy_gc);
       free(xdri_ctx);
       return NULL;
@@ -529,7 +499,7 @@ xdri_eglCreateWindowSurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
       return NULL;
    }
 
-   if (!_eglInitSurface(drv, &xdri_surf->Base, EGL_WINDOW_BIT,
+   if (!_eglInitSurface(&xdri_surf->Base, dpy, EGL_WINDOW_BIT,
                         &xdri_config->Base, attrib_list)) {
       free(xdri_surf);
       return NULL;
@@ -600,7 +570,7 @@ xdri_eglSwapBuffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw)
    struct xdri_egl_surface *xdri_surf = lookup_surface(draw);
 
    /* swapBuffers does not flush commands */
-   if (draw->Binding && xdri_driver->FlushCurrentContext)
+   if (draw->CurrentContext && xdri_driver->FlushCurrentContext)
       xdri_driver->FlushCurrentContext();
  
    xdri_dpy->psc->driScreen->swapBuffers(xdri_surf->driDrawable, 0, 0, 0);