Mesa (master): egl: Convert drivers to use typecast macros.

Chia-I Wu olv at kemper.freedesktop.org
Wed Feb 3 22:38:27 PST 2010


Module: Mesa
Branch: master
Commit: 9a3de505dc5377a47a6ccb29fe60343feb2f5b14
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9a3de505dc5377a47a6ccb29fe60343feb2f5b14

Author: Chia-I Wu <olvaffe at gmail.com>
Date:   Thu Feb  4 13:16:24 2010 +0800

egl: Convert drivers to use typecast macros.

Use macros to define the standard typecasts.  This saves lots of
typings.

---

 src/egl/drivers/glx/egl_glx.c                   |   29 ++-------------
 src/egl/drivers/xdri/egl_xdri.c                 |   42 +++-------------------
 src/gallium/state_trackers/egl/common/egl_g3d.h |   39 ++-------------------
 3 files changed, 13 insertions(+), 97 deletions(-)

diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c
index 8e6b5b0..3cbfebe 100644
--- a/src/egl/drivers/glx/egl_glx.c
+++ b/src/egl/drivers/glx/egl_glx.c
@@ -116,35 +116,14 @@ struct GLX_egl_config
    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
 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;
 }
 
 
diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c
index 68e659e..555473c 100644
--- a/src/egl/drivers/xdri/egl_xdri.c
+++ b/src/egl/drivers/xdri/egl_xdri.c
@@ -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 */
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.h b/src/gallium/state_trackers/egl/common/egl_g3d.h
index 3dae8c4..5d2d9c4 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d.h
+++ b/src/gallium/state_trackers/egl/common/egl_g3d.h
@@ -87,41 +87,8 @@ struct egl_g3d_screen {
    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_ */



More information about the mesa-commit mailing list