egl: Add macros to define typecast functions.
[mesa.git] / src / egl / main / egldriver.h
1 #ifndef EGLDRIVER_INCLUDED
2 #define EGLDRIVER_INCLUDED
3
4
5 #include "egltypedefs.h"
6 #include "eglapi.h"
7
8
9 /**
10 * Define an inline driver typecast function.
11 */
12 #define _EGL_DRIVER_TYPECAST(drvtype, egltype, code) \
13 static INLINE struct drvtype *drvtype(const egltype *obj) \
14 { return (struct drvtype *) code; }
15
16
17 /**
18 * Define the driver typecast functions for _EGLDriver, _EGLDisplay,
19 * _EGLContext, _EGLSurface, and _EGLConfig.
20 */
21 #define _EGL_DRIVER_STANDARD_TYPECASTS(drvname) \
22 _EGL_DRIVER_TYPECAST(drvname ## _driver, _EGLDriver, obj) \
23 /* note that this is not a direct cast */ \
24 _EGL_DRIVER_TYPECAST(drvname ## _display, _EGLDisplay, obj->DriverData) \
25 _EGL_DRIVER_TYPECAST(drvname ## _context, _EGLContext, obj) \
26 _EGL_DRIVER_TYPECAST(drvname ## _surface, _EGLSurface, obj) \
27 _EGL_DRIVER_TYPECAST(drvname ## _config, _EGLConfig, obj)
28
29
30 typedef _EGLDriver *(*_EGLMain_t)(const char *args);
31
32
33 /**
34 * Base class for device drivers.
35 */
36 struct _egl_driver
37 {
38 void *LibHandle; /**< dlopen handle */
39 const char *Path; /**< path to this driver */
40 const char *Args; /**< args to load this driver */
41
42 const char *Name; /**< name of this driver */
43
44 /**
45 * Probe a display and return a score.
46 *
47 * Roughly,
48 * 50 means the driver supports the display;
49 * 90 means the driver can accelerate the display;
50 * 100 means a perfect match.
51 */
52 EGLint (*Probe)(_EGLDriver *drv, _EGLDisplay *dpy);
53
54 /**
55 * Release the driver resource.
56 *
57 * It is called before dlclose().
58 */
59 void (*Unload)(_EGLDriver *drv);
60
61 _EGLAPI API; /**< EGL API dispatch table */
62 };
63
64
65 PUBLIC _EGLDriver *
66 _eglMain(const char *args);
67
68
69 extern _EGLDriver *
70 _eglMatchDriver(_EGLDisplay *dpy);
71
72
73 extern EGLBoolean
74 _eglPreloadDrivers(void);
75
76
77 extern void
78 _eglUnloadDrivers(void);
79
80
81 PUBLIC void
82 _eglInitDriverFallbacks(_EGLDriver *drv);
83
84
85 PUBLIC void
86 _eglSetProbeCache(EGLint key, const void *val);
87
88
89 PUBLIC const void *
90 _eglGetProbeCache(EGLint key);
91
92
93 #endif /* EGLDRIVER_INCLUDED */