summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Hall <jessehall@google.com>2013-07-09 10:54:20 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-07-09 10:54:20 -0700
commit5477d0e4e858df1ea9cb1b6965a160fb5fe23b57 (patch)
treef5a82eb5a999fe6c138fbe6bf1a34ad1f2af2afb
parent8b9319162d4f574fc45f88e6f9e28e62a4b5da78 (diff)
parentc07b52060acd627c8510c1a9151e0753fce76330 (diff)
downloadnative-5477d0e4e858df1ea9cb1b6965a160fb5fe23b57.tar.gz
am c07b5206: Find non-extension GLES wrappers in eglGetProcAddress
* commit 'c07b52060acd627c8510c1a9151e0753fce76330': Find non-extension GLES wrappers in eglGetProcAddress
-rw-r--r--opengl/libs/EGL/Loader.cpp13
-rw-r--r--opengl/libs/EGL/eglApi.cpp17
-rw-r--r--opengl/libs/EGL/egldefs.h3
3 files changed, 32 insertions, 1 deletions
diff --git a/opengl/libs/EGL/Loader.cpp b/opengl/libs/EGL/Loader.cpp
index 00bfa5a3b0..56550b3fa2 100644
--- a/opengl/libs/EGL/Loader.cpp
+++ b/opengl/libs/EGL/Loader.cpp
@@ -175,6 +175,12 @@ Loader::~Loader()
GLTrace_stop();
}
+static void* load_wrapper(const char* path) {
+ void* so = dlopen(path, RTLD_NOW | RTLD_LOCAL);
+ ALOGE_IF(!so, "dlopen(\"%s\") failed: %s", path, dlerror());
+ return so;
+}
+
void* Loader::open(egl_connection_t* cnx)
{
void* dso;
@@ -200,7 +206,12 @@ void* Loader::open(egl_connection_t* cnx)
LOG_FATAL_IF(!index && !hnd,
"couldn't find the default OpenGL ES implementation "
"for default display");
-
+
+ cnx->libGles2 = load_wrapper("system/lib/libGLESv2.so");
+ cnx->libGles1 = load_wrapper("system/lib/libGLESv1_CM.so");
+ LOG_ALWAYS_FATAL_IF(!cnx->libGles2 || !cnx->libGles1,
+ "couldn't load system OpenGL ES wrapper libraries");
+
return (void*)hnd;
}
diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp
index 93eedff95d..ec07490d4d 100644
--- a/opengl/libs/EGL/eglApi.cpp
+++ b/opengl/libs/EGL/eglApi.cpp
@@ -16,6 +16,7 @@
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+#include <dlfcn.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
@@ -777,6 +778,20 @@ EGLint eglGetError(void)
return err;
}
+static __eglMustCastToProperFunctionPointerType findBuiltinGLWrapper(
+ const char* procname) {
+ const egl_connection_t* cnx = &gEGLImpl;
+ void* proc = NULL;
+
+ proc = dlsym(cnx->libGles2, procname);
+ if (proc) return (__eglMustCastToProperFunctionPointerType)proc;
+
+ proc = dlsym(cnx->libGles1, procname);
+ if (proc) return (__eglMustCastToProperFunctionPointerType)proc;
+
+ return NULL;
+}
+
__eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname)
{
// eglGetProcAddress() could be the very first function called
@@ -798,6 +813,8 @@ __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname)
addr = findProcAddress(procname, sExtensionMap, NELEM(sExtensionMap));
if (addr) return addr;
+ addr = findBuiltinGLWrapper(procname);
+ if (addr) return addr;
// this protects accesses to sGLExtentionMap and sGLExtentionSlot
pthread_mutex_lock(&sExtensionMapMutex);
diff --git a/opengl/libs/EGL/egldefs.h b/opengl/libs/EGL/egldefs.h
index 1cfe56147a..b905ea079a 100644
--- a/opengl/libs/EGL/egldefs.h
+++ b/opengl/libs/EGL/egldefs.h
@@ -43,6 +43,9 @@ struct egl_connection_t {
EGLint major;
EGLint minor;
egl_t egl;
+
+ void* libGles1;
+ void* libGles2;
};
// ----------------------------------------------------------------------------