Mesa (master): egl: Add macros to define typecast functions.

Chia-I Wu olv at kemper.freedesktop.org
Thu Feb 4 06:38:27 UTC 2010


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

Author: Chia-I Wu <olvaffe at gmail.com>
Date:   Thu Feb  4 12:52:15 2010 +0800

egl: Add macros to define typecast functions.

There are standard typecast functions that are common to most drivers.
They are used to typecast, for example, an _EGLSurface to a
driver-defined type.

This commits define _EGL_DRIVER_STANDARD_TYPECASTS and
_EGL_DRIVER_TYPECAST that should hopefully save some typings for driver
writers.

---

 src/egl/main/egldriver.h |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h
index 5149acd..c1e6fa2 100644
--- a/src/egl/main/egldriver.h
+++ b/src/egl/main/egldriver.h
@@ -6,6 +6,27 @@
 #include "eglapi.h"
 
 
+/**
+ * Define an inline driver typecast function.
+ */
+#define _EGL_DRIVER_TYPECAST(drvtype, egltype, code)           \
+   static INLINE struct drvtype *drvtype(const egltype *obj)   \
+   { return (struct drvtype *) code; }
+
+
+/**
+ * Define the driver typecast functions for _EGLDriver, _EGLDisplay,
+ * _EGLContext, _EGLSurface, and _EGLConfig.
+ */
+#define _EGL_DRIVER_STANDARD_TYPECASTS(drvname)                            \
+   _EGL_DRIVER_TYPECAST(drvname ## _driver, _EGLDriver, obj)               \
+   /* note that this is not a direct cast */                               \
+   _EGL_DRIVER_TYPECAST(drvname ## _display, _EGLDisplay, obj->DriverData) \
+   _EGL_DRIVER_TYPECAST(drvname ## _context, _EGLContext, obj)             \
+   _EGL_DRIVER_TYPECAST(drvname ## _surface, _EGLSurface, obj)             \
+   _EGL_DRIVER_TYPECAST(drvname ## _config, _EGLConfig, obj)
+
+
 typedef _EGLDriver *(*_EGLMain_t)(const char *args);
 
 




More information about the mesa-commit mailing list