Merge "don't error out when eglTerminate()ing an already terminated display"
diff --git a/opengl/libs/Android.mk b/opengl/libs/Android.mk
index c5c2618..42aaa24 100644
--- a/opengl/libs/Android.mk
+++ b/opengl/libs/Android.mk
@@ -41,7 +41,12 @@
endif
ifeq ($(TARGET_BOARD_PLATFORM),msm7k)
-LOCAL_CFLAGS += -DADRENO130=1
+ LOCAL_CFLAGS += -DADRENO130=1
+endif
+
+ifeq ($(TARGET_BOARD_PLATFORM), s5pc110)
+ # see Loader.cpp for details
+ LOCAL_CFLAGS += -DSYSTEMUI_PBSIZE_HACK=1
endif
ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true)
diff --git a/opengl/libs/EGL/Loader.cpp b/opengl/libs/EGL/Loader.cpp
index 0b1016c..9ee3686 100644
--- a/opengl/libs/EGL/Loader.cpp
+++ b/opengl/libs/EGL/Loader.cpp
@@ -81,6 +81,24 @@
// ----------------------------------------------------------------------------
+static char const * getProcessCmdline() {
+ long pid = getpid();
+ char procPath[128];
+ snprintf(procPath, 128, "/proc/%ld/cmdline", pid);
+ FILE * file = fopen(procPath, "r");
+ if (file) {
+ static char cmdline[256];
+ char *str = fgets(cmdline, sizeof(cmdline) - 1, file);
+ fclose(file);
+ if (str) {
+ return cmdline;
+ }
+ }
+ return NULL;
+}
+
+// ----------------------------------------------------------------------------
+
Loader::driver_t::driver_t(void* gles)
{
dso[0] = gles;
@@ -280,6 +298,35 @@
ALOGE_IF(!getProcAddress,
"can't find eglGetProcAddress() in %s", driver_absolute_path);
+#ifdef SYSTEMUI_PBSIZE_HACK
+#warning "SYSTEMUI_PBSIZE_HACK enabled"
+ /*
+ * TODO: replace SYSTEMUI_PBSIZE_HACK by something less hackish
+ *
+ * Here we adjust the PB size from its default value to 512KB which
+ * is the minimum acceptable for the systemui process.
+ * We do this on low-end devices only because it allows us to enable
+ * h/w acceleration in the systemui process while keeping the
+ * memory usage down.
+ *
+ * Obviously, this is the wrong place and wrong way to make this
+ * adjustment, but at the time of this writing this was the safest
+ * solution.
+ */
+ const char *cmdline = getProcessCmdline();
+ if (strstr(cmdline, "systemui")) {
+ void *imgegl = dlopen("/vendor/lib/libIMGegl.so", RTLD_LAZY);
+ if (imgegl) {
+ unsigned int *PVRDefaultPBS =
+ (unsigned int *)dlsym(imgegl, "PVRDefaultPBS");
+ if (PVRDefaultPBS) {
+ ALOGD("setting default PBS to 512KB, was %d KB", *PVRDefaultPBS / 1024);
+ *PVRDefaultPBS = 512*1024;
+ }
+ }
+ }
+#endif
+
egl_t* egl = &cnx->egl;
__eglMustCastToProperFunctionPointerType* curr =
(__eglMustCastToProperFunctionPointerType*)egl;
diff --git a/opengl/libs/GLES_trace/src/gltrace_context.cpp b/opengl/libs/GLES_trace/src/gltrace_context.cpp
index 45dbb43..91b291e 100644
--- a/opengl/libs/GLES_trace/src/gltrace_context.cpp
+++ b/opengl/libs/GLES_trace/src/gltrace_context.cpp
@@ -119,7 +119,7 @@
const size_t DEFAULT_BUFFER_SIZE = 8192;
BufferedOutputStream *stream = new BufferedOutputStream(mStream, DEFAULT_BUFFER_SIZE);
- GLTraceContext *traceContext = new GLTraceContext(id, this, stream);
+ GLTraceContext *traceContext = new GLTraceContext(id, version, this, stream);
mPerContextState[eglContext] = traceContext;
return traceContext;
@@ -129,8 +129,10 @@
return mPerContextState[c];
}
-GLTraceContext::GLTraceContext(int id, GLTraceState *state, BufferedOutputStream *stream) :
+GLTraceContext::GLTraceContext(int id, int version, GLTraceState *state,
+ BufferedOutputStream *stream) :
mId(id),
+ mVersion(version),
mState(state),
mBufferedOutputStream(stream),
mElementArrayBuffers(DefaultKeyedVector<GLuint, ElementArrayBuffer*>(NULL))
@@ -143,6 +145,10 @@
return mId;
}
+int GLTraceContext::getVersion() {
+ return mVersion;
+}
+
GLTraceState *GLTraceContext::getGlobalTraceState() {
return mState;
}
diff --git a/opengl/libs/GLES_trace/src/gltrace_context.h b/opengl/libs/GLES_trace/src/gltrace_context.h
index 323cfdc..4c38bba 100644
--- a/opengl/libs/GLES_trace/src/gltrace_context.h
+++ b/opengl/libs/GLES_trace/src/gltrace_context.h
@@ -50,6 +50,7 @@
/** GL Trace Context info associated with each EGLContext */
class GLTraceContext {
int mId; /* unique context id */
+ int mVersion; /* GL version, e.g: egl_connection_t::GLESv2_INDEX */
GLTraceState *mState; /* parent GL Trace state (for per process GL Trace State Info) */
void *fbcontents; /* memory area to read framebuffer contents */
@@ -65,8 +66,9 @@
public:
gl_hooks_t *hooks;
- GLTraceContext(int id, GLTraceState *state, BufferedOutputStream *stream);
+ GLTraceContext(int id, int version, GLTraceState *state, BufferedOutputStream *stream);
int getId();
+ int getVersion();
GLTraceState *getGlobalTraceState();
void getCompressedFB(void **fb, unsigned *fbsize,
unsigned *fbwidth, unsigned *fbheight,
diff --git a/opengl/libs/GLES_trace/src/gltrace_fixup.cpp b/opengl/libs/GLES_trace/src/gltrace_fixup.cpp
index 3597b26..1bd790e 100644
--- a/opengl/libs/GLES_trace/src/gltrace_fixup.cpp
+++ b/opengl/libs/GLES_trace/src/gltrace_fixup.cpp
@@ -15,6 +15,7 @@
*/
#include <cutils/log.h>
+#include <EGL/egldefs.h>
#include <GLES/gl.h>
#include <GLES/glext.h>
#include <GLES2/gl2.h>
@@ -592,6 +593,11 @@
}
void trace_VertexAttribPointerDataForGlDrawArrays(GLTraceContext *context, GLMessage *glmsg) {
+ if (context->getVersion() == egl_connection_t::GLESv1_INDEX) {
+ // only supported for GLES2 and above
+ return;
+ }
+
/* void glDrawArrays(GLenum mode, GLint first, GLsizei count) */
GLsizei count = glmsg->args(2).intvalue(0);
@@ -604,6 +610,11 @@
void trace_VertexAttribPointerDataForGlDrawElements(GLTraceContext *context, GLMessage *glmsg,
GLvoid *indices) {
+ if (context->getVersion() == egl_connection_t::GLESv1_INDEX) {
+ // only supported for GLES2 and above
+ return;
+ }
+
/* void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices) */
GLsizei count = glmsg->args(1).intvalue(0);
GLenum type = glmsg->args(2).intvalue(0);