Use macros to define the standard typecasts. This saves lots of typings.tags/7.8-rc1
int index; | int index; | ||||
}; | }; | ||||
/** cast wrapper */ | |||||
static struct GLX_egl_driver * | |||||
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; | |||||
} | |||||
/* standard typecasts */ | |||||
_EGL_DRIVER_STANDARD_TYPECASTS(GLX_egl) | |||||
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; | |||||
} | } | ||||
/** 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 */ | /** Get size of given window */ |
const struct native_mode **native_modes; | const struct native_mode **native_modes; | ||||
}; | }; | ||||
static INLINE struct egl_g3d_driver * | |||||
egl_g3d_driver(_EGLDriver *drv) | |||||
{ | |||||
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; | |||||
} | |||||
/* standard typecasts */ | |||||
_EGL_DRIVER_STANDARD_TYPECASTS(egl_g3d) | |||||
_EGL_DRIVER_TYPECAST(egl_g3d_screen, _EGLScreen, obj) | |||||
#endif /* _EGL_G3D_H_ */ | #endif /* _EGL_G3D_H_ */ |