diff options
Diffstat (limited to 'opengl/libs/EGL/egl.cpp')
-rw-r--r-- | opengl/libs/EGL/egl.cpp | 108 |
1 files changed, 57 insertions, 51 deletions
diff --git a/opengl/libs/EGL/egl.cpp b/opengl/libs/EGL/egl.cpp index 0d4bed5..6ac8724 100644 --- a/opengl/libs/EGL/egl.cpp +++ b/opengl/libs/EGL/egl.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. */ @@ -23,8 +23,6 @@ #include <EGL/egl.h> #include <EGL/eglext.h> -#include <GLES/gl.h> -#include <GLES/glext.h> #include <cutils/log.h> #include <cutils/atomic.h> @@ -34,11 +32,11 @@ #include <utils/CallStack.h> #include <utils/String8.h> -#include "egldefs.h" -#include "egl_impl.h" +#include "../egl_impl.h" +#include "../glestrace.h" + #include "egl_tls.h" -#include "glestrace.h" -#include "hooks.h" +#include "egldefs.h" #include "Loader.h" #include "egl_display.h" @@ -84,13 +82,20 @@ static int sEGLApplicationTraceLevel; static bool sEGLSystraceEnabled; static bool sEGLGetErrorEnabled; -int gEGLDebugLevel; -static int sEGLApplicationDebugLevel; +static volatile int sEGLDebugLevel; extern gl_hooks_t gHooksTrace; extern gl_hooks_t gHooksSystrace; extern gl_hooks_t gHooksErrorTrace; +int getEGLDebugLevel() { + return sEGLDebugLevel; +} + +void setEGLDebugLevel(int level) { + sEGLDebugLevel = level; +} + static inline void setGlTraceThreadSpecific(gl_hooks_t const *value) { pthread_setspecific(gGLTraceKey, value); } @@ -122,36 +127,36 @@ void initEglTraceLevel() { } void initEglDebugLevel() { - int propertyLevel = 0; - char value[PROPERTY_VALUE_MAX]; - - // check system property only on userdebug or eng builds - property_get("ro.debuggable", value, "0"); - if (value[0] == '0') - return; + if (getEGLDebugLevel() == 0) { + char value[PROPERTY_VALUE_MAX]; - property_get("debug.egl.debug_proc", value, ""); - if (strlen(value) > 0) { - long pid = getpid(); - char procPath[128] = {}; - sprintf(procPath, "/proc/%ld/cmdline", pid); - FILE * file = fopen(procPath, "r"); - if (file) { - char cmdline[256] = {}; - if (fgets(cmdline, sizeof(cmdline) - 1, file)) { - if (!strncmp(value, cmdline, strlen(value))) { - // set EGL debug if the "debug.egl.debug_proc" property - // matches the prefix of this application's command line - propertyLevel = 1; + // check system property only on userdebug or eng builds + property_get("ro.debuggable", value, "0"); + if (value[0] == '0') + return; + + property_get("debug.egl.debug_proc", value, ""); + if (strlen(value) > 0) { + FILE * file = fopen("/proc/self/cmdline", "r"); + if (file) { + char cmdline[256]; + if (fgets(cmdline, sizeof(cmdline), file)) { + if (!strncmp(value, cmdline, strlen(value))) { + // set EGL debug if the "debug.egl.debug_proc" property + // matches the prefix of this application's command line + setEGLDebugLevel(1); + } } + fclose(file); } - fclose(file); } } - gEGLDebugLevel = propertyLevel || sEGLApplicationDebugLevel; - if (gEGLDebugLevel > 0) { - GLTrace_start(); + if (getEGLDebugLevel() > 0) { + if (GLTrace_start() < 0) { + ALOGE("Error starting Tracer for OpenGL ES. Disabling.."); + setEGLDebugLevel(0); + } } } @@ -165,10 +170,11 @@ void setGLHooksThreadSpecific(gl_hooks_t const *value) { } else if (sEGLTraceLevel > 0) { setGlTraceThreadSpecific(value); setGlThreadSpecific(&gHooksTrace); - } else if (gEGLDebugLevel > 0 && value != &gHooksNoContext) { + } else if (getEGLDebugLevel() > 0 && value != &gHooksNoContext) { setGlTraceThreadSpecific(value); setGlThreadSpecific(GLTrace_getGLHooks()); } else { + setGlTraceThreadSpecific(NULL); setGlThreadSpecific(value); } } @@ -186,9 +192,12 @@ void setGLTraceLevel(int level) { * Global entry point to allow applications to modify their own debug level. * Debugging is enabled if either the application requested it, or if the system property * matches the application's name. + * Note that this only sets the debug level. The value is read and used either in + * initEglDebugLevel() if the application hasn't initialized its display yet, or when + * eglSwapBuffers() is called next. */ void EGLAPI setGLDebugLevel(int level) { - sEGLApplicationDebugLevel = level; + setEGLDebugLevel(level); } #else @@ -213,15 +222,13 @@ static int gl_no_context() { char value[PROPERTY_VALUE_MAX]; property_get("debug.egl.callstack", value, "0"); if (atoi(value)) { - CallStack stack; - stack.update(); - stack.dump(); + CallStack stack(LOG_TAG); } } return 0; } -static void early_egl_init(void) +static void early_egl_init(void) { #if !USE_FAST_TLS_KEY pthread_key_create(&gGLWrapperKey, NULL); @@ -229,12 +236,11 @@ static void early_egl_init(void) #if EGL_TRACE pthread_key_create(&gGLTraceKey, NULL); initEglTraceLevel(); - initEglDebugLevel(); #endif uint32_t addr = (uint32_t)((void*)gl_no_context); android_memset32( - (uint32_t*)(void*)&gHooksNoContext, - addr, + (uint32_t*)(void*)&gHooksNoContext, + addr, sizeof(gHooksNoContext)); setGLHooksThreadSpecific(&gHooksNoContext); @@ -381,7 +387,7 @@ gl_hooks_t const* getGlThreadSpecific() { #define EGL_ENTRY(_r, _api, ...) #_api, char const * const gl_names[] = { - #include "entries.in" + #include "../entries.in" NULL }; |