summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle Repinski <repinski23@gmail.com>2016-03-03 15:56:57 -0600
committerAndreas Blaesius <skate4life@gmx.de>2017-01-17 00:00:19 +0100
commit25959a7c94f1b6da7f75428d597b3f7bb9c0ea07 (patch)
tree22612e18b63139209c86e3f353a64cb62fc85c4c
parent41ee4ec65da1746184f25b591738589a260722fc (diff)
downloadhardware_ti_omap4-25959a7c94f1b6da7f75428d597b3f7bb9c0ea07.zip
hardware_ti_omap4-25959a7c94f1b6da7f75428d597b3f7bb9c0ea07.tar.gz
hardware_ti_omap4-25959a7c94f1b6da7f75428d597b3f7bb9c0ea07.tar.bz2
libEGL_POWERVR: Improve eglChooseConfig+recordable workaround code.
Change-Id: Ica4f022ebfd484d31d7848b68462e752e60ec520
-rw-r--r--libEGL_POWERVR/egl.c47
-rw-r--r--libEGL_POWERVR/egl.h26
2 files changed, 45 insertions, 28 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);
}
diff --git a/libEGL_POWERVR/egl.h b/libEGL_POWERVR/egl.h
index b8f5fd3..ec693c7 100644
--- a/libEGL_POWERVR/egl.h
+++ b/libEGL_POWERVR/egl.h
@@ -1,16 +1,31 @@
#ifndef __PVREGL_H__
#define __PVREGL_H__
+#include <string.h>
#include <stdint.h>
#include <stdbool.h>
+#include <cutils/compiler.h>
#ifdef __cplusplus
extern "C" {
#endif
+typedef int32_t EGLint;
+typedef unsigned int EGLBoolean;
+typedef unsigned int EGLenum;
+typedef void *EGLConfig;
+typedef void *EGLContext;
+typedef void *EGLDisplay;
+typedef void *EGLSurface;
+typedef void *EGLClientBuffer;
+typedef int EGLNativeDisplayType;
+typedef void *EGLNativeWindowType;
+typedef void *EGLNativePixmapType;
+
#define EGL_FALSE 0
#define EGL_TRUE 1
+#define EGL_DONT_CARE ((EGLint)-1)
#define EGL_SURFACE_TYPE 0x3033
#define EGL_NONE 0x3038
@@ -20,17 +35,6 @@ extern "C" {
#define EGL_PBUFFER_BIT 0x0001
#define EGL_OPENGL_ES2_BIT 0x0004
-typedef int32_t EGLint;
-typedef unsigned int EGLBoolean;
-typedef unsigned int EGLenum;
-typedef void *EGLConfig;
-typedef void *EGLContext;
-typedef void *EGLDisplay;
-typedef void *EGLSurface;
-typedef void *EGLClientBuffer;
-typedef int EGLNativeDisplayType;
-typedef void *EGLNativeWindowType;
-typedef void *EGLNativePixmapType;
EGLint IMGeglGetError(void);
EGLDisplay IMGeglGetDisplay(EGLNativeDisplayType display_id);