diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/Android.mk b/tools/emulator/opengl/host/libs/Translator/EGL/Android.mk index 9d6321d09..8f7601b81 100644 --- a/tools/emulator/opengl/host/libs/Translator/EGL/Android.mk +++ b/tools/emulator/opengl/host/libs/Translator/EGL/Android.mk @@ -10,7 +10,7 @@ OS_SRCS:= ifeq ($(HOST_OS),linux) OS_SRCS = EglX11Api.cpp - LOCAL_LDLIBS := -lX11 -lGL -ldl + LOCAL_LDLIBS := -lX11 -lGL -ldl -lpthread endif ifeq ($(HOST_OS),darwin) diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp index e45000ae3..5895e4257 100644 --- a/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp +++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp @@ -34,14 +34,15 @@ #define MINOR 1 #define MAJOR 4 -//declerations +//declarations + EglImage *attachEGLImage(unsigned int imageId); void detachEGLImage(unsigned int imageId); +#define tls_thread EglThreadInfo::get() EglGlobalInfo* g_eglInfo = EglGlobalInfo::getInstance(); -__thread EglThreadInfo* tls_thread = NULL; static EGLiface s_eglIface = { getThreadInfo : getThreadInfo, // implemented in ThreadInfo.cpp eglAttachEGLImage:attachEGLImage, @@ -71,10 +72,7 @@ static EglExtentionDescriptor s_extentions[] = { /****************************************************************************************************************************************/ //macros for accessing global egl info & tls objects -#define CURRENT_THREAD() \ - if(!tls_thread) { \ - tls_thread = new EglThreadInfo(); \ - } +#define CURRENT_THREAD() do {} while (0); #define RETURN_ERROR(ret,err) \ CURRENT_THREAD() \ diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp index e7f92ba87..327588cd4 100644 --- a/tools/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp +++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp @@ -20,7 +20,7 @@ //TODO: implementation for mac for all funcs namespace EglOS { -EGLNativeDisplayType getDefaultDisplay() {return NULL} +EGLNativeDisplayType getDefaultDisplay() {return NULL;} bool releaseDisplay(EGLNativeDisplayType dpy) { return false; @@ -53,6 +53,10 @@ EGLNativePbufferType createPbuffer(EGLNativeDisplayType dpy,EglConfig* cfg,EglPb return NULL; } +bool releasePbuffer(EGLNativeDisplayType dis,EGLNativePbufferType pb) { + return true; +} + EGLNativeContextType createContext(EGLNativeDisplayType dpy,EglConfig* cfg,EGLNativeContextType sharedContext) { return NULL; } diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglOsApi.h b/tools/emulator/opengl/host/libs/Translator/EGL/EglOsApi.h index 6bd2b7611..f72dfd633 100644 --- a/tools/emulator/opengl/host/libs/Translator/EGL/EglOsApi.h +++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglOsApi.h @@ -17,7 +17,11 @@ #define EGL_OS_API_H #include +#ifdef __APPLE__ +#include +#else #include +#endif #include "EglConfig.h" #include "EglDisplay.h" #include "EglPbufferSurface.h" diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglThreadInfo.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglThreadInfo.cpp index a9bfc56dc..1b403f257 100644 --- a/tools/emulator/opengl/host/libs/Translator/EGL/EglThreadInfo.cpp +++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglThreadInfo.cpp @@ -17,3 +17,26 @@ #include "EglOsApi.h" EglThreadInfo::EglThreadInfo():m_err(EGL_SUCCESS),m_api(EGL_OPENGL_ES_API) {} + +#include + +static thread_store_t s_tls = THREAD_STORE_INITIALIZER; + +static void tlsDestruct(void *ptr) +{ + if (ptr) { + EglThreadInfo *ti = (EglThreadInfo *)ptr; + delete ti; + } +} + +EglThreadInfo* EglThreadInfo::get(void) +{ + EglThreadInfo *ti = (EglThreadInfo *)thread_store_get(&s_tls); + if (!ti) { + ti = new EglThreadInfo(); + thread_store_set(&s_tls, ti, tlsDestruct); + } + return ti; +} + diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglThreadInfo.h b/tools/emulator/opengl/host/libs/Translator/EGL/EglThreadInfo.h index c811508b0..9d2df102a 100644 --- a/tools/emulator/opengl/host/libs/Translator/EGL/EglThreadInfo.h +++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglThreadInfo.h @@ -32,6 +32,8 @@ public: void setApi(EGLenum api){m_api = api;} EGLenum getApi(){return m_api;} + static EglThreadInfo* get(void) __attribute__((const)); + private: EglDisplay* m_currentDisplay; EGLint m_err; diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.cpp index ed2880f4a..6814fe9d2 100644 --- a/tools/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.cpp +++ b/tools/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.cpp @@ -16,7 +16,6 @@ #include -__thread ThreadInfo* thread = NULL; void ThreadInfo::updateInfo(void* eglCtx,void* dpy,void* glesCtx,ShareGroupPtr share,ObjectNameManager* manager) { eglContext = eglCtx; @@ -27,6 +26,9 @@ void ThreadInfo::updateInfo(void* eglCtx,void* dpy,void* glesCtx,ShareGroupPtr s } #ifdef __linux__ + +__thread ThreadInfo* thread = NULL; + ThreadInfo* getThreadInfo(){ if(!thread) { thread = new ThreadInfo(); @@ -35,6 +37,7 @@ ThreadInfo* getThreadInfo(){ } #else + #include static thread_store_t s_tls = THREAD_STORE_INITIALIZER; @@ -46,13 +49,14 @@ static void tlsDestruct(void *ptr) } } -RenderThreadInfo *getRenderThreadInfo() +ThreadInfo *getThreadInfo() { ThreadInfo *ti = (ThreadInfo *)thread_store_get(&s_tls); if (!ti) { - ti = new RenderThreadInfo(); + ti = new ThreadInfo(); thread_store_set(&s_tls, ti, tlsDestruct); } return ti; } + #endif diff --git a/tools/emulator/opengl/host/libs/Translator/include/EGL/eglplatform.h b/tools/emulator/opengl/host/libs/Translator/include/EGL/eglplatform.h index 8ee5634b2..ec70a0d1e 100644 --- a/tools/emulator/opengl/host/libs/Translator/include/EGL/eglplatform.h +++ b/tools/emulator/opengl/host/libs/Translator/include/EGL/eglplatform.h @@ -73,6 +73,16 @@ typedef HDC EGLNativeDisplayType; typedef HBITMAP EGLNativePixmapType; typedef HWND EGLNativeWindowType; +#elif defined(__APPLE__) + +typedef int EGLNativePixelFormatType; + +typedef struct _EGLNativeContextType* EGLNativeContextType; +typedef struct _EGLNativePbufferType* EGLNativePbufferType; +typedef struct _EGLNativeDisplayType* EGLNativeDisplayType; +typedef int EGLNativePixmapType; +typedef int EGLNativeWindowType; + #elif defined(__unix__) /* X11 (tentative) */