diff --git a/opengl/libs/EGL/Loader.cpp b/opengl/libs/EGL/Loader.cpp index c02a85ffe..beaa560fb 100644 --- a/opengl/libs/EGL/Loader.cpp +++ b/opengl/libs/EGL/Loader.cpp @@ -1,16 +1,16 @@ -/* +/* ** Copyright 2007, The Android Open Source Project ** - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at + ** Licensed under the Apache License, Version 2.0 (the "License"); + ** you may not use this file except in compliance with the License. + ** You may obtain a copy of the License at ** - ** http://www.apache.org/licenses/LICENSE-2.0 + ** http://www.apache.org/licenses/LICENSE-2.0 ** - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ** See the License for the specific language governing permissions and + ** Unless required by applicable law or agreed to in writing, software + ** distributed under the License is distributed on an "AS IS" BASIS, + ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ** See the License for the specific language governing permissions and ** limitations under the License. */ @@ -56,9 +56,9 @@ namespace android { * * For backward compatibility and to facilitate the transition to * this new naming scheme, the loader will additionally look for: - * + * * /{vendor|system}/lib/egl/lib{GLES | [EGL|GLESv1_CM|GLESv2]}_*.so - * + * */ ANDROID_SINGLETON_STATIC_INSTANCE( Loader ) @@ -116,14 +116,14 @@ static char const * getProcessCmdline() { // ---------------------------------------------------------------------------- -Loader::driver_t::driver_t(void* gles) +Loader::driver_t::driver_t(void* gles) { dso[0] = gles; for (size_t i=1 ; ilibGles2 = 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; } @@ -191,16 +202,16 @@ status_t Loader::close(void* driver) return NO_ERROR; } -void Loader::init_api(void* dso, - char const * const * api, - __eglMustCastToProperFunctionPointerType* curr, - getProcAddressType getProcAddress) +void Loader::init_api(void* dso, + char const * const * api, + __eglMustCastToProperFunctionPointerType* curr, + getProcAddressType getProcAddress) { const ssize_t SIZE = 256; char scrap[SIZE]; while (*api) { char const * name = *api; - __eglMustCastToProperFunctionPointerType f = + __eglMustCastToProperFunctionPointerType f = (__eglMustCastToProperFunctionPointerType)dlsym(dso, name); if (f == NULL) { // couldn't find the entry-point, use eglGetProcAddress() @@ -360,7 +371,7 @@ void *Loader::load_driver(const char* kind, if (mask & EGL) { getProcAddress = (getProcAddressType)dlsym(dso, "eglGetProcAddress"); - ALOGE_IF(!getProcAddress, + ALOGE_IF(!getProcAddress, "can't find eglGetProcAddress() in %s", driver_absolute_path); #ifdef SYSTEMUI_PBSIZE_HACK @@ -398,7 +409,7 @@ void *Loader::load_driver(const char* kind, char const * const * api = egl_names; while (*api) { char const * name = *api; - __eglMustCastToProperFunctionPointerType f = + __eglMustCastToProperFunctionPointerType f = (__eglMustCastToProperFunctionPointerType)dlsym(dso, name); if (f == NULL) { // couldn't find the entry-point, use eglGetProcAddress() @@ -411,7 +422,7 @@ void *Loader::load_driver(const char* kind, api++; } } - + if (mask & GLESv1_CM) { init_api(dso, gl_names, (__eglMustCastToProperFunctionPointerType*) @@ -425,7 +436,7 @@ void *Loader::load_driver(const char* kind, &cnx->hooks[egl_connection_t::GLESv2_INDEX]->gl, getProcAddress); } - + return dso; } diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp index 0358fcc8d..015740aba 100644 --- a/opengl/libs/EGL/eglApi.cpp +++ b/opengl/libs/EGL/eglApi.cpp @@ -16,6 +16,7 @@ #define ATRACE_TAG ATRACE_TAG_GRAPHICS +#include #include #include #include @@ -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 1cfe56147..b905ea079 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; }; // ----------------------------------------------------------------------------