diff options
Diffstat (limited to 'src/egl')
-rw-r--r-- | src/egl/main/eglconfig.c | 194 | ||||
-rw-r--r-- | src/egl/main/eglcontext.c | 11 | ||||
-rw-r--r-- | src/egl/main/eglsurface.c | 14 |
3 files changed, 76 insertions, 143 deletions
diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c index d05eca86b8..4d313a9bb5 100644 --- a/src/egl/main/eglconfig.c +++ b/src/egl/main/eglconfig.c @@ -24,20 +24,18 @@ * IDs are from 1 to N respectively. */ void -_eglInitConfig(_EGLConfig *config, _EGLDisplay *dpy, EGLint id) +_eglInitConfig(_EGLConfig *conf, _EGLDisplay *dpy, EGLint id) { - memset(config, 0, sizeof(*config)); + memset(conf, 0, sizeof(*conf)); - config->Display = dpy; + conf->Display = dpy; /* some attributes take non-zero default values */ - SET_CONFIG_ATTRIB(config, EGL_CONFIG_ID, id); - SET_CONFIG_ATTRIB(config, EGL_CONFIG_CAVEAT, EGL_NONE); - SET_CONFIG_ATTRIB(config, EGL_TRANSPARENT_TYPE, EGL_NONE); - SET_CONFIG_ATTRIB(config, EGL_NATIVE_VISUAL_TYPE, EGL_NONE); -#ifdef EGL_VERSION_1_2 - SET_CONFIG_ATTRIB(config, EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER); -#endif /* EGL_VERSION_1_2 */ + conf->ConfigID = id; + conf->ConfigCaveat = EGL_NONE; + conf->TransparentType = EGL_NONE; + conf->NativeVisualType = EGL_NONE; + conf->ColorBufferType = EGL_RGB_BUFFER; } @@ -51,7 +49,7 @@ EGLConfig _eglAddConfig(_EGLDisplay *dpy, _EGLConfig *conf) { /* sanity check */ - assert(GET_CONFIG_ATTRIB(conf, EGL_CONFIG_ID) > 0); + assert(conf->ConfigID > 0); if (!dpy->Configs) { dpy->Configs = _eglCreateArray("Config", 16); @@ -224,15 +222,13 @@ _eglValidateConfig(const _EGLConfig *conf, EGLBoolean for_matching) { EGLint i, attr, val; EGLBoolean valid = EGL_TRUE; - EGLint red_size = 0, green_size = 0, blue_size = 0, luminance_size = 0; - EGLint alpha_size = 0, buffer_size = 0; /* check attributes by their types */ for (i = 0; i < ARRAY_SIZE(_eglValidationTable); i++) { EGLint mask; attr = _eglValidationTable[i].attr; - val = GET_CONFIG_ATTRIB(conf, attr); + val = _eglGetConfigKey(conf, attr); switch (_eglValidationTable[i].type) { case ATTRIB_TYPE_INTEGER: @@ -244,30 +240,14 @@ _eglValidateConfig(const _EGLConfig *conf, EGLBoolean for_matching) break; case EGL_SAMPLE_BUFFERS: /* there can be at most 1 sample buffer */ - if (val > 1) + if (val > 1 || val < 0) valid = EGL_FALSE; break; - case EGL_RED_SIZE: - red_size = val; - break; - case EGL_GREEN_SIZE: - green_size = val; - break; - case EGL_BLUE_SIZE: - blue_size = val; - break; - case EGL_LUMINANCE_SIZE: - luminance_size = val; - break; - case EGL_ALPHA_SIZE: - alpha_size = val; - break; - case EGL_BUFFER_SIZE: - buffer_size = val; + default: + if (val < 0) + valid = EGL_FALSE; break; } - if (val < 0) - valid = EGL_FALSE; break; case ATTRIB_TYPE_BOOLEAN: if (val != EGL_TRUE && val != EGL_FALSE) @@ -355,17 +335,18 @@ _eglValidateConfig(const _EGLConfig *conf, EGLBoolean for_matching) /* now check for conflicting attribute values */ - switch (GET_CONFIG_ATTRIB(conf, EGL_COLOR_BUFFER_TYPE)) { + switch (conf->ColorBufferType) { case EGL_RGB_BUFFER: - if (luminance_size) + if (conf->LuminanceSize) valid = EGL_FALSE; - if (red_size + green_size + blue_size + alpha_size != buffer_size) + if (conf->RedSize + conf->GreenSize + + conf->BlueSize + conf->AlphaSize != conf->BufferSize) valid = EGL_FALSE; break; case EGL_LUMINANCE_BUFFER: - if (red_size || green_size || blue_size) + if (conf->RedSize || conf->GreenSize || conf->BlueSize) valid = EGL_FALSE; - if (luminance_size + alpha_size != buffer_size) + if (conf->LuminanceSize + conf->AlphaSize != conf->BufferSize) valid = EGL_FALSE; break; } @@ -374,23 +355,19 @@ _eglValidateConfig(const _EGLConfig *conf, EGLBoolean for_matching) return EGL_FALSE; } - val = GET_CONFIG_ATTRIB(conf, EGL_SAMPLE_BUFFERS); - if (!val && GET_CONFIG_ATTRIB(conf, EGL_SAMPLES)) + if (!conf->SampleBuffers && conf->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)) { - if (GET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_ID) != 0 || - GET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_TYPE) != EGL_NONE) + if (!(conf->SurfaceType & EGL_WINDOW_BIT)) { + if (conf->NativeVisualID != 0 || conf->NativeVisualType != EGL_NONE) valid = EGL_FALSE; } - if (!(val & EGL_PBUFFER_BIT)) { - if (GET_CONFIG_ATTRIB(conf, EGL_BIND_TO_TEXTURE_RGB) || - GET_CONFIG_ATTRIB(conf, EGL_BIND_TO_TEXTURE_RGBA)) + if (!(conf->SurfaceType & EGL_PBUFFER_BIT)) { + if (conf->BindToTextureRGB || conf->BindToTextureRGBA) valid = EGL_FALSE; } if (!valid) { @@ -422,11 +399,11 @@ _eglMatchConfig(const _EGLConfig *conf, const _EGLConfig *criteria) continue; attr = _eglValidationTable[i].attr; - cmp = GET_CONFIG_ATTRIB(criteria, attr); + cmp = _eglGetConfigKey(criteria, attr); if (cmp == EGL_DONT_CARE) continue; - val = GET_CONFIG_ATTRIB(conf, attr); + val = _eglGetConfigKey(conf, attr); switch (_eglValidationTable[i].criterion) { case ATTRIB_CRITERION_EXACT: if (val != cmp) @@ -490,15 +467,12 @@ EGLBoolean _eglParseConfigAttribList(_EGLConfig *conf, const EGLint *attrib_list) { EGLint attr, val, i; - EGLint config_id = 0, level = 0; - EGLBoolean has_native_visual_type = EGL_FALSE; - EGLBoolean has_transparent_color = EGL_FALSE; /* reset to default values */ for (i = 0; i < ARRAY_SIZE(_eglValidationTable); i++) { attr = _eglValidationTable[i].attr; val = _eglValidationTable[i].default_value; - SET_CONFIG_ATTRIB(conf, attr, val); + _eglSetConfigKey(conf, attr, val); } /* parse the list */ @@ -508,35 +482,15 @@ _eglParseConfigAttribList(_EGLConfig *conf, const EGLint *attrib_list) if (!_eglIsConfigAttribValid(conf, attr)) return EGL_FALSE; - - SET_CONFIG_ATTRIB(conf, attr, val); - /* rememeber some attributes for post-processing */ - switch (attr) { - case EGL_CONFIG_ID: - config_id = val; - break; - case EGL_LEVEL: - level = val; - break; - case EGL_NATIVE_VISUAL_TYPE: - has_native_visual_type = EGL_TRUE; - break; - case EGL_TRANSPARENT_RED_VALUE: - case EGL_TRANSPARENT_GREEN_VALUE: - case EGL_TRANSPARENT_BLUE_VALUE: - has_transparent_color = EGL_TRUE; - break; - default: - break; - } + _eglSetConfigKey(conf, attr, val); } if (!_eglValidateConfig(conf, EGL_TRUE)) return EGL_FALSE; /* the spec says that EGL_LEVEL cannot be EGL_DONT_CARE */ - if (level == EGL_DONT_CARE) + if (conf->Level == EGL_DONT_CARE) return EGL_FALSE; /* ignore other attributes when EGL_CONFIG_ID is given */ @@ -544,26 +498,17 @@ _eglParseConfigAttribList(_EGLConfig *conf, const EGLint *attrib_list) for (i = 0; i < ARRAY_SIZE(_eglValidationTable); i++) { attr = _eglValidationTable[i].attr; if (attr != EGL_CONFIG_ID) - SET_CONFIG_ATTRIB(conf, attr, EGL_DONT_CARE); + _eglSetConfigKey(conf, attr, EGL_DONT_CARE); } } else { - if (has_native_visual_type) { - val = GET_CONFIG_ATTRIB(conf, EGL_SURFACE_TYPE); - if (!(val & EGL_WINDOW_BIT)) - SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_TYPE, EGL_DONT_CARE); - } + if (!(conf->SurfaceType & EGL_WINDOW_BIT)) + conf->NativeVisualType = EGL_DONT_CARE; - if (has_transparent_color) { - val = GET_CONFIG_ATTRIB(conf, EGL_TRANSPARENT_TYPE); - if (val == EGL_NONE) { - SET_CONFIG_ATTRIB(conf, EGL_TRANSPARENT_RED_VALUE, - EGL_DONT_CARE); - SET_CONFIG_ATTRIB(conf, EGL_TRANSPARENT_GREEN_VALUE, - EGL_DONT_CARE); - SET_CONFIG_ATTRIB(conf, EGL_TRANSPARENT_BLUE_VALUE, - EGL_DONT_CARE); - } + if (conf->TransparentType == EGL_NONE) { + conf->TransparentRedValue = EGL_DONT_CARE; + conf->TransparentGreenValue = EGL_DONT_CARE; + conf->TransparentBlueValue = EGL_DONT_CARE; } } @@ -597,7 +542,6 @@ _eglCompareConfigs(const _EGLConfig *conf1, const _EGLConfig *conf2, EGL_ALPHA_MASK_SIZE, }; EGLint val1, val2; - EGLBoolean rgb_buffer; EGLint i; if (conf1 == conf2) @@ -606,44 +550,41 @@ _eglCompareConfigs(const _EGLConfig *conf1, const _EGLConfig *conf2, /* the enum values have the desired ordering */ assert(EGL_NONE < EGL_SLOW_CONFIG); assert(EGL_SLOW_CONFIG < EGL_NON_CONFORMANT_CONFIG); - val1 = GET_CONFIG_ATTRIB(conf1, EGL_CONFIG_CAVEAT); - val2 = GET_CONFIG_ATTRIB(conf2, EGL_CONFIG_CAVEAT); - if (val1 != val2) - return (val1 - val2); + val1 = conf1->ConfigCaveat - conf2->ConfigCaveat; + if (val1) + return val1; /* the enum values have the desired ordering */ assert(EGL_RGB_BUFFER < EGL_LUMINANCE_BUFFER); - val1 = GET_CONFIG_ATTRIB(conf1, EGL_COLOR_BUFFER_TYPE); - val2 = GET_CONFIG_ATTRIB(conf2, EGL_COLOR_BUFFER_TYPE); - if (val1 != val2) - return (val1 - val2); - rgb_buffer = (val1 == EGL_RGB_BUFFER); + val1 = conf1->ColorBufferType - conf2->ColorBufferType; + if (val1) + return val1; if (criteria) { val1 = val2 = 0; - if (rgb_buffer) { - if (GET_CONFIG_ATTRIB(criteria, EGL_RED_SIZE) > 0) { - val1 += GET_CONFIG_ATTRIB(conf1, EGL_RED_SIZE); - val2 += GET_CONFIG_ATTRIB(conf2, EGL_RED_SIZE); + if (conf1->ColorBufferType == EGL_RGB_BUFFER) { + if (criteria->RedSize > 0) { + val1 += conf1->RedSize; + val2 += conf2->RedSize; } - if (GET_CONFIG_ATTRIB(criteria, EGL_GREEN_SIZE) > 0) { - val1 += GET_CONFIG_ATTRIB(conf1, EGL_GREEN_SIZE); - val2 += GET_CONFIG_ATTRIB(conf2, EGL_GREEN_SIZE); + if (criteria->GreenSize > 0) { + val1 += conf1->GreenSize; + val2 += conf2->GreenSize; } - if (GET_CONFIG_ATTRIB(criteria, EGL_BLUE_SIZE) > 0) { - val1 += GET_CONFIG_ATTRIB(conf1, EGL_BLUE_SIZE); - val2 += GET_CONFIG_ATTRIB(conf2, EGL_BLUE_SIZE); + if (criteria->BlueSize > 0) { + val1 += conf1->BlueSize; + val2 += conf2->BlueSize; } } else { - if (GET_CONFIG_ATTRIB(criteria, EGL_LUMINANCE_SIZE) > 0) { - val1 += GET_CONFIG_ATTRIB(conf1, EGL_LUMINANCE_SIZE); - val2 += GET_CONFIG_ATTRIB(conf2, EGL_LUMINANCE_SIZE); + if (criteria->LuminanceSize > 0) { + val1 += conf1->LuminanceSize; + val2 += conf2->LuminanceSize; } } - if (GET_CONFIG_ATTRIB(criteria, EGL_ALPHA_SIZE) > 0) { - val1 += GET_CONFIG_ATTRIB(conf1, EGL_ALPHA_SIZE); - val2 += GET_CONFIG_ATTRIB(conf2, EGL_ALPHA_SIZE); + if (criteria->AlphaSize > 0) { + val1 += conf1->AlphaSize; + val2 += conf2->AlphaSize; } } else { @@ -656,24 +597,15 @@ _eglCompareConfigs(const _EGLConfig *conf1, const _EGLConfig *conf2, return (val2 - val1); for (i = 0; i < ARRAY_SIZE(compare_attribs); i++) { - val1 = GET_CONFIG_ATTRIB(conf1, compare_attribs[i]); - val2 = GET_CONFIG_ATTRIB(conf2, compare_attribs[i]); + val1 = _eglGetConfigKey(conf1, compare_attribs[i]); + val2 = _eglGetConfigKey(conf2, compare_attribs[i]); if (val1 != val2) return (val1 - val2); } /* EGL_NATIVE_VISUAL_TYPE cannot be compared here */ - if (compare_id) { - val1 = GET_CONFIG_ATTRIB(conf1, EGL_CONFIG_ID); - val2 = GET_CONFIG_ATTRIB(conf2, EGL_CONFIG_ID); - assert(val1 != val2); - } - else { - val1 = val2 = 0; - } - - return (val1 - val2); + return (compare_id) ? (conf1->ConfigID - conf2->ConfigID) : 0; } @@ -789,7 +721,7 @@ _eglGetConfigAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, if (!value) return _eglError(EGL_BAD_PARAMETER, "eglGetConfigAttrib"); - *value = GET_CONFIG_ATTRIB(conf, attribute); + *value = _eglGetConfigKey(conf, attribute); return EGL_TRUE; } diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index bc22913d40..ec35be9d3a 100644 --- a/src/egl/main/eglcontext.c +++ b/src/egl/main/eglcontext.c @@ -113,13 +113,12 @@ _eglInitContext(_EGLContext *ctx, _EGLDisplay *dpy, _EGLConfig *conf, err = _eglParseContextAttribList(ctx, attrib_list); if (err == EGL_SUCCESS && ctx->Config) { - EGLint renderable_type, api_bit; + EGLint api_bit; - renderable_type = GET_CONFIG_ATTRIB(ctx->Config, EGL_RENDERABLE_TYPE); api_bit = _eglGetContextAPIBit(ctx); - if (!(renderable_type & api_bit)) { + if (!(ctx->Config->RenderableType & api_bit)) { _eglLog(_EGL_DEBUG, "context api is 0x%x while config supports 0x%x", - api_bit, renderable_type); + api_bit, ctx->Config->RenderableType); err = EGL_BAD_CONFIG; } } @@ -183,7 +182,9 @@ _eglQueryContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *c, switch (attribute) { case EGL_CONFIG_ID: - *value = GET_CONFIG_ATTRIB(c->Config, EGL_CONFIG_ID); + if (!c->Config) + return _eglError(EGL_BAD_ATTRIBUTE, "eglQueryContext"); + *value = c->Config->ConfigID; break; case EGL_CONTEXT_CLIENT_VERSION: *value = c->ClientVersion; diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 52f5c240c6..ec51dd6ba2 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -17,12 +17,12 @@ static void _eglClampSwapInterval(_EGLSurface *surf, EGLint interval) { - EGLint bound = GET_CONFIG_ATTRIB(surf->Config, EGL_MAX_SWAP_INTERVAL); + EGLint bound = surf->Config->MaxSwapInterval; if (interval >= bound) { interval = bound; } else { - bound = GET_CONFIG_ATTRIB(surf->Config, EGL_MIN_SWAP_INTERVAL); + bound = surf->Config->MinSwapInterval; if (interval < bound) interval = bound; } @@ -263,7 +263,7 @@ _eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type, return EGL_FALSE; } - if ((GET_CONFIG_ATTRIB(conf, EGL_SURFACE_TYPE) & type) == 0) { + if ((conf->SurfaceType & type) == 0) { /* The config can't be used to create a surface of this type */ _eglError(EGL_BAD_CONFIG, func); return EGL_FALSE; @@ -333,7 +333,7 @@ _eglQuerySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, *value = surface->Height; break; case EGL_CONFIG_ID: - *value = GET_CONFIG_ATTRIB(surface->Config, EGL_CONFIG_ID); + *value = surface->Config->ConfigID; break; case EGL_LARGEST_PBUFFER: *value = surface->LargestPbuffer; @@ -445,7 +445,7 @@ _eglSurfaceAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, switch (attribute) { case EGL_MIPMAP_LEVEL: - confval = GET_CONFIG_ATTRIB(surface->Config, EGL_RENDERABLE_TYPE); + confval = surface->Config->RenderableType; if (!(confval & (EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT))) { err = EGL_BAD_PARAMETER; break; @@ -457,7 +457,7 @@ _eglSurfaceAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, case EGL_MULTISAMPLE_RESOLVE_DEFAULT: break; case EGL_MULTISAMPLE_RESOLVE_BOX: - confval = GET_CONFIG_ATTRIB(surface->Config, EGL_SURFACE_TYPE); + confval = surface->Config->SurfaceType; if (!(confval & EGL_MULTISAMPLE_RESOLVE_BOX_BIT)) err = EGL_BAD_MATCH; break; @@ -474,7 +474,7 @@ _eglSurfaceAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, case EGL_BUFFER_DESTROYED: break; case EGL_BUFFER_PRESERVED: - confval = GET_CONFIG_ATTRIB(surface->Config, EGL_SURFACE_TYPE); + confval = surface->Config->SurfaceType; if (!(confval & EGL_SWAP_BEHAVIOR_PRESERVED_BIT)) err = EGL_BAD_MATCH; break; |