summaryrefslogtreecommitdiffstats
path: root/libEGL_POWERVR/egl.c
diff options
context:
space:
mode:
Diffstat (limited to 'libEGL_POWERVR/egl.c')
-rw-r--r--libEGL_POWERVR/egl.c47
1 files changed, 30 insertions, 17 deletions
diff --git a/libEGL_POWERVR/egl.c b/libEGL_POWERVR/egl.c
index 78ee97d..878e4b1 100644
--- a/libEGL_POWERVR/egl.c
+++ b/libEGL_POWERVR/egl.c
@@ -46,40 +46,53 @@ EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig
* so in this shim we'll drop it on their behalf so they actually get an EGLConfig.
*/
bool renderable_type_es2 = false, surface_type_pbuffer = false;
- int i, j, attriblist_length = 0, recordable_attrib_pos = -1;
+ int attriblist_length = 0, recordable_attrib_val_pos = -1;
+ /* attrib_list is terminated by EGL_NONE key */
while( attrib_list[attriblist_length++] != EGL_NONE )
{
- if( attrib_list[attriblist_length-1] == EGL_SURFACE_TYPE && (attrib_list[attriblist_length] & EGL_PBUFFER_BIT) != 0 )
+ if( attrib_list[attriblist_length-1] == EGL_RENDERABLE_TYPE )
{
- surface_type_pbuffer = true;
+ /* if EGL_RENDERABLE_TYPE is specified, usually EGL_OPENGL_ES2_BIT is set. */
+ if( (attrib_list[attriblist_length] & EGL_OPENGL_ES2_BIT) != 0 )
+ renderable_type_es2 = true;
+ else
+ goto skip_override;
}
- else if( attrib_list[attriblist_length-1] == EGL_RENDERABLE_TYPE && (attrib_list[attriblist_length] & EGL_OPENGL_ES2_BIT) != 0 )
+ else if( attrib_list[attriblist_length-1] == EGL_SURFACE_TYPE )
{
- renderable_type_es2 = true;
+ /* EGL_PBUFFER_BIT is rarely used, so point the if to the skip here */
+ if( (attrib_list[attriblist_length] & EGL_PBUFFER_BIT) == 0 )
+ goto skip_override;
+ else
+ surface_type_pbuffer = true;
}
- else if( attrib_list[attriblist_length-1] == EGL_RECORDABLE_ANDROID && attrib_list[attriblist_length] == EGL_TRUE )
+ else if( attrib_list[attriblist_length-1] == EGL_RECORDABLE_ANDROID )
{
- recordable_attrib_pos = attriblist_length - 1;
+ /* It is generally useless to specify EGL_RECORDABLE_ANDROID
+ * as something other than EGL_TRUE; expect that to be the case */
+ if( CC_LIKELY( attrib_list[attriblist_length] == EGL_TRUE ) )
+ recordable_attrib_val_pos = attriblist_length;
+ else
+ goto skip_override;
}
+
+ /* the array is k/v pairs; for every key we can skip an iteration */
++attriblist_length;
}
- if( recordable_attrib_pos != -1 && surface_type_pbuffer && renderable_type_es2 )
+ if( recordable_attrib_val_pos != -1 && surface_type_pbuffer && renderable_type_es2 )
{
- EGLint override_attrib_list[attriblist_length-2];
-
- for( i = 0, j = 0; i < attriblist_length; ++i )
- {
- if( i != recordable_attrib_pos && i != recordable_attrib_pos + 1 )
- {
- override_attrib_list[j++] = attrib_list[i];
- }
- }
+ /* we've officially met all the conditions for an override of EGL_RECORDABLE_ANDROID.
+ * rather than remove it completely, we can just override its value to "EGL_DONT_CARE". */
+ EGLint override_attrib_list[attriblist_length];
+ memcpy(override_attrib_list, attrib_list, sizeof(EGLint) * attriblist_length);
+ override_attrib_list[recordable_attrib_val_pos] = EGL_DONT_CARE;
return IMGeglChooseConfig(dpy, override_attrib_list, configs, config_size, num_config);
}
+skip_override:
return IMGeglChooseConfig(dpy, attrib_list, configs, config_size, num_config);
}