void initEglDebugLevel() {
    int propertyLevel = 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;
                }
            }
            fclose(file);
        }
    }

    gEGLDebugLevel = propertyLevel || sEGLApplicationDebugLevel;
    if (gEGLDebugLevel > 0) {
        GLTrace_start();
    }
}
Пример #2
0
void initEglDebugLevel() {
    if (getEGLDebugLevel() == 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;

        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);
            }
        }
    }

    if (getEGLDebugLevel() > 0) {
        if (GLTrace_start() < 0) {
            ALOGE("Error starting Tracer for OpenGL ES. Disabling..");
            setEGLDebugLevel(0);
        }
    }
}