egl: Convert drivers to use typecast macros.

Use macros to define the standard typecasts.  This saves lots of
typings.
This commit is contained in:
Chia-I Wu 2010-02-04 13:16:24 +08:00
parent bdb9e202de
commit 9a3de505dc
3 changed files with 13 additions and 97 deletions

View File

@ -116,35 +116,14 @@ struct GLX_egl_config
int index; int index;
}; };
/** cast wrapper */ /* standard typecasts */
static struct GLX_egl_driver * _EGL_DRIVER_STANDARD_TYPECASTS(GLX_egl)
GLX_egl_driver(_EGLDriver *drv)
{
return (struct GLX_egl_driver *) drv;
}
static struct GLX_egl_display *
GLX_egl_display(_EGLDisplay *dpy)
{
return (struct GLX_egl_display *) dpy->DriverData;
}
static struct GLX_egl_context *
GLX_egl_context(_EGLContext *ctx)
{
return (struct GLX_egl_context *) ctx;
}
static struct GLX_egl_surface *
GLX_egl_surface(_EGLSurface *surf)
{
return (struct GLX_egl_surface *) surf;
}
static int static int
GLX_egl_config_index(_EGLConfig *conf) GLX_egl_config_index(_EGLConfig *conf)
{ {
return ((struct GLX_egl_config *) conf)->index; struct GLX_egl_config *GLX_conf = GLX_egl_config(conf);
return GLX_conf->index;
} }

View File

@ -112,43 +112,13 @@ struct xdri_egl_config
/** cast wrapper */ /* standard typecasts */
static INLINE struct xdri_egl_driver * _EGL_DRIVER_STANDARD_TYPECASTS(xdri_egl)
xdri_egl_driver(_EGLDriver *drv)
{
return (struct xdri_egl_driver *) drv;
}
#define lookup_display(dpy) xdri_egl_display(dpy)
static INLINE struct xdri_egl_display * #define lookup_context(ctx) xdri_egl_context(ctx)
lookup_display(_EGLDisplay *dpy) #define lookup_surface(surf) xdri_egl_surface(surf)
{ #define lookup_config(conf) xdri_egl_config(conf)
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;
}
/** Get size of given window */ /** Get size of given window */

View File

@ -87,41 +87,8 @@ struct egl_g3d_screen {
const struct native_mode **native_modes; const struct native_mode **native_modes;
}; };
static INLINE struct egl_g3d_driver * /* standard typecasts */
egl_g3d_driver(_EGLDriver *drv) _EGL_DRIVER_STANDARD_TYPECASTS(egl_g3d)
{ _EGL_DRIVER_TYPECAST(egl_g3d_screen, _EGLScreen, obj)
return (struct egl_g3d_driver *) drv;
}
static INLINE struct egl_g3d_display *
egl_g3d_display(_EGLDisplay *dpy)
{
/* note that it is not direct casting */
return (struct egl_g3d_display *) dpy->DriverData;
}
static INLINE struct egl_g3d_context *
egl_g3d_context(_EGLContext *ctx)
{
return (struct egl_g3d_context *) ctx;
}
static INLINE struct egl_g3d_surface *
egl_g3d_surface(_EGLSurface *surf)
{
return (struct egl_g3d_surface *) surf;
}
static INLINE struct egl_g3d_config *
egl_g3d_config(_EGLConfig *conf)
{
return (struct egl_g3d_config *) conf;
}
static INLINE struct egl_g3d_screen *
egl_g3d_screen(_EGLScreen *scr)
{
return (struct egl_g3d_screen *) scr;
}
#endif /* _EGL_G3D_H_ */ #endif /* _EGL_G3D_H_ */