egldriver.h revision cdc920a0
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 * Note that this macro defines a function and should not be ended with a 13 * semicolon when used. 14 */ 15#define _EGL_DRIVER_TYPECAST(drvtype, egltype, code) \ 16 static INLINE struct drvtype *drvtype(const egltype *obj) \ 17 { return (struct drvtype *) code; } 18 19 20/** 21 * Define the driver typecast functions for _EGLDriver, _EGLDisplay, 22 * _EGLContext, _EGLSurface, and _EGLConfig. 23 * 24 * Note that this macro defines several functions and should not be ended with 25 * a semicolon when used. 26 */ 27#define _EGL_DRIVER_STANDARD_TYPECASTS(drvname) \ 28 _EGL_DRIVER_TYPECAST(drvname ## _driver, _EGLDriver, obj) \ 29 /* note that this is not a direct cast */ \ 30 _EGL_DRIVER_TYPECAST(drvname ## _display, _EGLDisplay, obj->DriverData) \ 31 _EGL_DRIVER_TYPECAST(drvname ## _context, _EGLContext, obj) \ 32 _EGL_DRIVER_TYPECAST(drvname ## _surface, _EGLSurface, obj) \ 33 _EGL_DRIVER_TYPECAST(drvname ## _config, _EGLConfig, obj) 34 35 36typedef _EGLDriver *(*_EGLMain_t)(const char *args); 37 38 39/** 40 * Base class for device drivers. 41 */ 42struct _egl_driver 43{ 44 void *LibHandle; /**< dlopen handle */ 45 const char *Path; /**< path to this driver */ 46 const char *Args; /**< args to load this driver */ 47 48 const char *Name; /**< name of this driver */ 49 50 /** 51 * Probe a display and return a score. 52 * 53 * Roughly, 54 * 50 means the driver supports the display; 55 * 90 means the driver can accelerate the display; 56 * 100 means a perfect match. 57 */ 58 EGLint (*Probe)(_EGLDriver *drv, _EGLDisplay *dpy); 59 60 /** 61 * Release the driver resource. 62 * 63 * It is called before dlclose(). 64 */ 65 void (*Unload)(_EGLDriver *drv); 66 67 _EGLAPI API; /**< EGL API dispatch table */ 68}; 69 70 71PUBLIC _EGLDriver * 72_eglMain(const char *args); 73 74 75extern _EGLDriver * 76_eglMatchDriver(_EGLDisplay *dpy); 77 78 79extern EGLBoolean 80_eglPreloadDrivers(void); 81 82 83extern void 84_eglUnloadDrivers(void); 85 86 87PUBLIC void 88_eglInitDriverFallbacks(_EGLDriver *drv); 89 90 91PUBLIC void 92_eglSetProbeCache(EGLint key, const void *val); 93 94 95PUBLIC const void * 96_eglGetProbeCache(EGLint key); 97 98 99#endif /* EGLDRIVER_INCLUDED */ 100