GLES2Dbg: change GLES2_dbg to shared library
Change-Id: I493e9bff431bd939f4e80e1e9c614dd557307fa2
Signed-off-by: David Li <davidxli@google.com>
diff --git a/opengl/libs/GLES2_dbg/Android.mk b/opengl/libs/GLES2_dbg/Android.mk
index fc40799..853cce6 100644
--- a/opengl/libs/GLES2_dbg/Android.mk
+++ b/opengl/libs/GLES2_dbg/Android.mk
@@ -11,7 +11,7 @@
src/server.cpp \
src/vertex.cpp
-LOCAL_C_INCLUDES := \
+LOCAL_C_INCLUDES := \
$(LOCAL_PATH) \
$(LOCAL_PATH)/../ \
external/stlport/stlport \
@@ -21,7 +21,8 @@
#LOCAL_CFLAGS += -O0 -g -DDEBUG -UNDEBUG
LOCAL_CFLAGS := -DGOOGLE_PROTOBUF_NO_RTTI
-
+LOCAL_STATIC_LIBRARIES := libprotobuf-cpp-2.3.0-lite liblzf
+LOCAL_SHARED_LIBRARIES := libcutils libutils libstlport
ifeq ($(TARGET_ARCH),arm)
LOCAL_CFLAGS += -fstrict-aliasing
endif
@@ -43,4 +44,4 @@
LOCAL_MODULE:= libGLESv2_dbg
LOCAL_MODULE_TAGS := optional
-include $(BUILD_STATIC_LIBRARY)
+include $(BUILD_SHARED_LIBRARY)
diff --git a/opengl/libs/GLES2_dbg/generate_api_cpp.py b/opengl/libs/GLES2_dbg/generate_api_cpp.py
index 66c110f..072125e 100755
--- a/opengl/libs/GLES2_dbg/generate_api_cpp.py
+++ b/opengl/libs/GLES2_dbg/generate_api_cpp.py
@@ -192,11 +192,16 @@
// auto generated by generate_api_cpp.py
+#include <utils/Debug.h>
+
#include "src/header.h"
#include "src/api.h"
-template<typename T> static int ToInt(const T & t) { STATIC_ASSERT(sizeof(T) == sizeof(int), bitcast); return (int &)t; }
-template<typename T> static T FromInt(const int & t) { STATIC_ASSERT(sizeof(T) == sizeof(int), bitcast); return (T &)t; }
+template<typename T> static int ToInt(const T & t)
+{
+ COMPILE_TIME_ASSERT_FUNCTION_SCOPE(sizeof(T) == sizeof(int));
+ return (int &)t;
+}
"""
lines = open("gl2_api_annotated.in").readlines()
generate_api(lines)
diff --git a/opengl/libs/GLES2_dbg/generate_caller_cpp.py b/opengl/libs/GLES2_dbg/generate_caller_cpp.py
index eac2292..ee4208d 100755
--- a/opengl/libs/GLES2_dbg/generate_caller_cpp.py
+++ b/opengl/libs/GLES2_dbg/generate_caller_cpp.py
@@ -177,7 +177,6 @@
{
LOGD("GenerateCall function=%u", cmd.function());
const int * ret = prevRet; // only some functions have return value
- gl_hooks_t::gl_t const * const _c = &getGLTraceThreadSpecific()->gl;
nsecs_t c0 = systemTime(timeMode);
switch (cmd.function()) {""")
diff --git a/opengl/libs/GLES2_dbg/src/api.cpp b/opengl/libs/GLES2_dbg/src/api.cpp
index 130ca7e..e26e1d7 100644
--- a/opengl/libs/GLES2_dbg/src/api.cpp
+++ b/opengl/libs/GLES2_dbg/src/api.cpp
@@ -16,11 +16,16 @@
// auto generated by generate_api_cpp.py
+#include <utils/Debug.h>
+
#include "src/header.h"
#include "src/api.h"
-template<typename T> static int ToInt(const T & t) { STATIC_ASSERT(sizeof(T) == sizeof(int), bitcast); return (int &)t; }
-template<typename T> static T FromInt(const int & t) { STATIC_ASSERT(sizeof(T) == sizeof(int), bitcast); return (T &)t; }
+template<typename T> static int ToInt(const T & t)
+{
+ COMPILE_TIME_ASSERT_FUNCTION_SCOPE(sizeof(T) == sizeof(int));
+ return (int &)t;
+}
void Debug_glActiveTexture(GLenum texture)
{
diff --git a/opengl/libs/GLES2_dbg/src/caller.cpp b/opengl/libs/GLES2_dbg/src/caller.cpp
index 9992f05..ad9440b 100644
--- a/opengl/libs/GLES2_dbg/src/caller.cpp
+++ b/opengl/libs/GLES2_dbg/src/caller.cpp
@@ -105,7 +105,6 @@
{
LOGD("GenerateCall function=%u", cmd.function());
const int * ret = prevRet; // only some functions have return value
- gl_hooks_t::gl_t const * const _c = &getGLTraceThreadSpecific()->gl;
nsecs_t c0 = systemTime(timeMode);
switch (cmd.function()) { case glesv2debugger::Message_Function_glActiveTexture:
dbg->hooks->gl.glActiveTexture(
diff --git a/opengl/libs/GLES2_dbg/src/dbgcontext.cpp b/opengl/libs/GLES2_dbg/src/dbgcontext.cpp
index cc7336c..40a77d7 100644
--- a/opengl/libs/GLES2_dbg/src/dbgcontext.cpp
+++ b/opengl/libs/GLES2_dbg/src/dbgcontext.cpp
@@ -15,6 +15,7 @@
*/
#include "header.h"
+#include "egl_tls.h"
extern "C"
{
@@ -24,6 +25,14 @@
namespace android
{
+static pthread_key_t sEGLThreadLocalStorageKey = -1;
+
+DbgContext * getDbgContextThreadSpecific()
+{
+ tls_t* tls = (tls_t*)pthread_getspecific(sEGLThreadLocalStorageKey);
+ return tls->dbg;
+}
+
DbgContext::DbgContext(const unsigned version, const gl_hooks_t * const hooks,
const unsigned MAX_VERTEX_ATTRIBS)
: lzf_buf(NULL), lzf_readIndex(0), lzf_refSize(0), lzf_refBufSize(0)
@@ -47,8 +56,10 @@
free(lzf_ref[1]);
}
-DbgContext * CreateDbgContext(const unsigned version, const gl_hooks_t * const hooks)
+DbgContext * CreateDbgContext(const pthread_key_t EGLThreadLocalStorageKey,
+ const unsigned version, const gl_hooks_t * const hooks)
{
+ sEGLThreadLocalStorageKey = EGLThreadLocalStorageKey;
assert(version < 2);
assert(GL_NO_ERROR == hooks->gl.glGetError());
GLint MAX_VERTEX_ATTRIBS = 0;
diff --git a/opengl/libs/GLES2_dbg/src/header.h b/opengl/libs/GLES2_dbg/src/header.h
index 9218da5..9d51e8e 100644
--- a/opengl/libs/GLES2_dbg/src/header.h
+++ b/opengl/libs/GLES2_dbg/src/header.h
@@ -14,6 +14,9 @@
** limitations under the License.
*/
+#ifndef ANDROID_GLES2_DBG_HEADER_H
+#define ANDROID_GLES2_DBG_HEADER_H
+
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
@@ -24,9 +27,7 @@
#include <cutils/log.h>
#include <utils/Timers.h>
-#include <../../../libcore/include/StaticAssert.h>
-#define EGL_TRACE 1
#include "hooks.h"
#include "glesv2dbg.h"
@@ -39,8 +40,6 @@
using namespace android;
using namespace com::android;
-#define API_ENTRY(_api) Debug_##_api
-
#ifndef __location__
#define __HIERALLOC_STRING_0__(s) #s
#define __HIERALLOC_STRING_1__(s) __HIERALLOC_STRING_0__(s)
@@ -141,9 +140,7 @@
void glDeleteBuffers(GLsizei n, const GLuint *buffers);
};
-
DbgContext * getDbgContextThreadSpecific();
-#define DBGCONTEXT(ctx) DbgContext * const ctx = getDbgContextThreadSpecific();
struct FunctionCall {
virtual const int * operator()(gl_hooks_t::gl_t const * const _c,
@@ -169,3 +166,5 @@
const int * GenerateCall(DbgContext * const dbg, const glesv2debugger::Message & cmd,
glesv2debugger::Message & msg, const int * const prevRet);
}; // namespace android {
+
+#endif // #ifndef ANDROID_GLES2_DBG_HEADER_H