diff options
Diffstat (limited to 'src/egl/main')
-rw-r--r-- | src/egl/main/eglconfig.c | 25 | ||||
-rw-r--r-- | src/egl/main/eglconfig.h | 21 | ||||
-rw-r--r-- | src/egl/main/eglcontext.h | 6 | ||||
-rw-r--r-- | src/egl/main/egldriver.h | 6 | ||||
-rw-r--r-- | src/egl/main/eglsurface.h | 6 |
5 files changed, 48 insertions, 16 deletions
diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c index 635ffee92b..1190f8cdd5 100644 --- a/src/egl/main/eglconfig.c +++ b/src/egl/main/eglconfig.c @@ -366,8 +366,11 @@ _eglValidateConfig(const _EGLConfig *conf, EGLBoolean for_matching) if (_eglValidationTable[i].criterion == ATTRIB_CRITERION_SPECIAL) valid = EGL_TRUE; } - if (!valid) + if (!valid) { + _eglLog(_EGL_DEBUG, + "attribute 0x%04x has an invalid value 0x%x", attr, val); break; + } } /* any invalid attribute value should have been catched */ @@ -390,10 +393,18 @@ _eglValidateConfig(const _EGLConfig *conf, EGLBoolean for_matching) valid = EGL_FALSE; break; } + if (!valid) { + _eglLog(_EGL_DEBUG, "conflicting color buffer type and channel sizes"); + return EGL_FALSE; + } val = GET_CONFIG_ATTRIB(conf, EGL_SAMPLE_BUFFERS); if (!val && GET_CONFIG_ATTRIB(conf, EGL_SAMPLES)) valid = EGL_FALSE; + if (!valid) { + _eglLog(_EGL_DEBUG, "conflicting samples and sample buffers"); + return EGL_FALSE; + } val = GET_CONFIG_ATTRIB(conf, EGL_SURFACE_TYPE); if (!(val & EGL_WINDOW_BIT)) { @@ -406,6 +417,10 @@ _eglValidateConfig(const _EGLConfig *conf, EGLBoolean for_matching) GET_CONFIG_ATTRIB(conf, EGL_BIND_TO_TEXTURE_RGBA)) valid = EGL_FALSE; } + if (!valid) { + _eglLog(_EGL_DEBUG, "conflicting surface type and native visual/texture binding"); + return EGL_FALSE; + } return valid; } @@ -457,8 +472,14 @@ _eglMatchConfig(const _EGLConfig *conf, const _EGLConfig *criteria) break; } - if (!matched) + if (!matched) { +#ifdef DEBUG + _eglLog(_EGL_DEBUG, + "the value (0x%x) of attribute 0x%04x did not meet the criteria (0x%x)", + val, attr, cmp); +#endif break; + } } return matched; diff --git a/src/egl/main/eglconfig.h b/src/egl/main/eglconfig.h index 09dc61f547..56ec95fe9a 100644 --- a/src/egl/main/eglconfig.h +++ b/src/egl/main/eglconfig.h @@ -21,6 +21,9 @@ struct _egl_config }; +/** + * Macros for source level compatibility. + */ #define SET_CONFIG_ATTRIB(CONF, ATTR, VAL) _eglSetConfigKey(CONF, ATTR, VAL) #define GET_CONFIG_ATTRIB(CONF, ATTR) _eglGetConfigKey(CONF, ATTR) @@ -55,6 +58,10 @@ _eglResetConfigKeys(_EGLConfig *conf, EGLint val) /** * Update a config for a given key. + * + * Note that a valid key is not necessarily a valid attribute. There are gaps + * in the attribute enums. The separation is to catch application errors. + * Drivers should never set a key that is an invalid attribute. */ static INLINE void _eglSetConfigKey(_EGLConfig *conf, EGLint key, EGLint val) @@ -77,20 +84,6 @@ _eglGetConfigKey(const _EGLConfig *conf, EGLint key) } -/** - * Set a given attribute. - * - * Because _eglGetConfigAttrib is already used as a fallback driver - * function, this function is not considered to have a good name. - * SET_CONFIG_ATTRIB is preferred over this function. - */ -static INLINE void -_eglSetConfigAttrib(_EGLConfig *conf, EGLint attr, EGLint val) -{ - SET_CONFIG_ATTRIB(conf, attr, val); -} - - PUBLIC void _eglInitConfig(_EGLConfig *config, _EGLDisplay *dpy, EGLint id); diff --git a/src/egl/main/eglcontext.h b/src/egl/main/eglcontext.h index 14fce02c11..cfe92dd9f5 100644 --- a/src/egl/main/eglcontext.h +++ b/src/egl/main/eglcontext.h @@ -60,6 +60,9 @@ _eglCopyContextMESA(_EGLDriver *drv, EGLDisplay dpy, EGLContext source, EGLConte /** * Return true if the context is bound to a thread. + * + * The binding is considered a reference to the context. Drivers should not + * destroy a context when it is bound. */ static INLINE EGLBoolean _eglIsContextBound(_EGLContext *ctx) @@ -119,6 +122,9 @@ _eglGetContextHandle(_EGLContext *ctx) /** * Return true if the context is linked to a display. + * + * The link is considered a reference to the context (the display is owning the + * context). Drivers should not destroy a context when it is linked. */ static INLINE EGLBoolean _eglIsContextLinked(_EGLContext *ctx) diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index c1e6fa2820..55686681dc 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -8,6 +8,9 @@ /** * Define an inline driver typecast function. + * + * Note that this macro defines a function and should not be ended with a + * semicolon when used. */ #define _EGL_DRIVER_TYPECAST(drvtype, egltype, code) \ static INLINE struct drvtype *drvtype(const egltype *obj) \ @@ -17,6 +20,9 @@ /** * Define the driver typecast functions for _EGLDriver, _EGLDisplay, * _EGLContext, _EGLSurface, and _EGLConfig. + * + * Note that this macro defines several functions and should not be ended with + * a semicolon when used. */ #define _EGL_DRIVER_STANDARD_TYPECASTS(drvname) \ _EGL_DRIVER_TYPECAST(drvname ## _driver, _EGLDriver, obj) \ diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h index feba30d4f8..0a00035730 100644 --- a/src/egl/main/eglsurface.h +++ b/src/egl/main/eglsurface.h @@ -107,6 +107,9 @@ _eglCreatePbufferFromClientBuffer(_EGLDriver *drv, _EGLDisplay *dpy, /** * Return true if there is a context bound to the surface. + * + * The binding is considered a reference to the surface. Drivers should not + * destroy a surface when it is bound. */ static INLINE EGLBoolean _eglIsSurfaceBound(_EGLSurface *surf) @@ -166,6 +169,9 @@ _eglGetSurfaceHandle(_EGLSurface *surf) /** * Return true if the surface is linked to a display. + * + * The link is considered a reference to the surface (the display is owning the + * surface). Drivers should not destroy a surface when it is linked. */ static INLINE EGLBoolean _eglIsSurfaceLinked(_EGLSurface *surf) |