Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2f8fa855 authored by Siva Velusamy's avatar Siva Velusamy Committed by Android (Google) Code Review
Browse files

Merge "gltrace: Expose a function to set OpenGL trace level."

parents e56a5852 b13c78f8
Loading
Loading
Loading
Loading
+43 −17
Original line number Diff line number Diff line
@@ -61,11 +61,23 @@ EGLAPI pthread_key_t gGLTraceKey = -1;

// ----------------------------------------------------------------------------

int gEGLDebugLevel;

/**
 * There are two different tracing methods:
 * 1. libs/EGL/trace.cpp: Traces all functions to logcat.
 *    To enable:
 *      - set system property "debug.egl.trace" to 1 to trace all apps.
 *      - or call setGLTraceLevel(1) from an app to enable tracing for that app.
 * 2. libs/GLES_trace: Traces all functions via protobuf to host.
 *    To enable:
 *        - set system property "debug.egl.debug_proc" to the application name.
 *      - or call setGLDebugLevel(1) from the app.
 */
static int sEGLTraceLevel;
static int sEGLApplicationTraceLevel;

int gEGLDebugLevel;
static int sEGLApplicationDebugLevel;

extern gl_hooks_t gHooksTrace;

static inline void setGlTraceThreadSpecific(gl_hooks_t const *value) {
@@ -82,11 +94,13 @@ void initEglTraceLevel() {
    int propertyLevel = atoi(value);
    int applicationLevel = sEGLApplicationTraceLevel;
    sEGLTraceLevel = propertyLevel > applicationLevel ? propertyLevel : applicationLevel;
}

void initEglDebugLevel() {
    int propertyLevel = 0;
    char value[PROPERTY_VALUE_MAX];
    property_get("debug.egl.debug_proc", value, "");
    if (strlen(value) == 0)
        return;

    if (strlen(value) > 0) {
        long pid = getpid();
        char procPath[128] = {};
        sprintf(procPath, "/proc/%ld/cmdline", pid);
@@ -97,12 +111,14 @@ void initEglTraceLevel() {
                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
                gEGLDebugLevel = 1;
                    propertyLevel = 1;
                }
            }
            fclose(file);
        }
    }

    gEGLDebugLevel = propertyLevel || sEGLApplicationDebugLevel;
    if (gEGLDebugLevel > 0) {
        GLTrace_start();
    }
@@ -129,6 +145,15 @@ void setGLTraceLevel(int level) {
    sEGLApplicationTraceLevel = 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.
 */
void EGLAPI setGLDebugLevel(int level) {
    sEGLApplicationDebugLevel = level;
}

#else

void setGLHooksThreadSpecific(gl_hooks_t const *value) {
@@ -162,6 +187,7 @@ 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(
+2 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ static char const * const sExtensionString =
//      "EGL_ANDROID_blob_cache "               // strongly recommended

extern void initEglTraceLevel();
extern void initEglDebugLevel();
extern void setGLHooksThreadSpecific(gl_hooks_t const *value);

// ----------------------------------------------------------------------------
@@ -144,6 +145,7 @@ EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) {
    // Called both at early_init time and at this time. (Early_init is pre-zygote, so
    // the information from that call may be stale.)
    initEglTraceLevel();
    initEglDebugLevel();

#endif