diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/Android.mk b/tools/emulator/opengl/host/libs/Translator/EGL/Android.mk index 5c078e94f..2fd38fad2 100644 --- a/tools/emulator/opengl/host/libs/Translator/EGL/Android.mk +++ b/tools/emulator/opengl/host/libs/Translator/EGL/Android.mk @@ -51,13 +51,11 @@ LOCAL_MODULE_TAGS := debug LOCAL_MODULE := libEGL_translator LOCAL_STATIC_LIBRARIES := \ + libGLcommon \ libcutils \ libutils \ liblog \ libOpenglOsUtils -LOCAL_SHARED_LIBRARIES := \ - libGLcommon - include $(BUILD_HOST_SHARED_LIBRARY) diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp index 9f3e8ccb5..ad64c9061 100644 --- a/tools/emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp +++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp @@ -18,7 +18,16 @@ #include #include -EglDisplay::EglDisplay(EGLNativeDisplayType dpy,bool isDefault):m_dpy(dpy),m_initialized(false),m_configInitialized(false),m_isDefault(isDefault),m_nextEglImageId(0){}; +EglDisplay::EglDisplay(EGLNativeDisplayType dpy,bool isDefault) : + m_dpy(dpy), + m_initialized(false), + m_configInitialized(false), + m_isDefault(isDefault), + m_nextEglImageId(0) +{ + m_manager[GLES_1_1] = new ObjectNameManager(&m_globalNameSpace); + m_manager[GLES_2_0] = new ObjectNameManager(&m_globalNameSpace); +}; EglDisplay::~EglDisplay() { android::Mutex::Autolock mutex(m_lock); @@ -31,6 +40,9 @@ EglDisplay::~EglDisplay() { EglConfig* pConfig = *it; if(pConfig) delete pConfig; } + + delete m_manager[GLES_1_1]; + delete m_manager[GLES_2_0]; } EGLNativeDisplayType EglDisplay::nativeType(){return m_dpy;} diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglDisplay.h b/tools/emulator/opengl/host/libs/Translator/EGL/EglDisplay.h index 28e4abe29..dadda0926 100644 --- a/tools/emulator/opengl/host/libs/Translator/EGL/EglDisplay.h +++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglDisplay.h @@ -55,7 +55,7 @@ public: ContextPtr getContext(EGLContext ctx); bool removeContext(EGLContext ctx); bool removeContext(ContextPtr ctx); - ObjectNameManager* getManager(GLESVersion ver){ return &m_manager[ver];} + ObjectNameManager* getManager(GLESVersion ver){ return m_manager[ver];} ~EglDisplay(); void initialize(int renderableType); @@ -76,7 +76,8 @@ private: ConfigsList m_configs; ContextsHndlMap m_contexts; SurfacesHndlMap m_surfaces; - ObjectNameManager m_manager[MAX_GLES_VERSION]; + GlobalNameSpace m_globalNameSpace; + ObjectNameManager *m_manager[MAX_GLES_VERSION]; android::Mutex m_lock; ImagesHndlMap m_eglImages; unsigned int m_nextEglImageId; diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/Android.mk b/tools/emulator/opengl/host/libs/Translator/GLES_CM/Android.mk index 36fbc0d3b..b18492efa 100644 --- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/Android.mk +++ b/tools/emulator/opengl/host/libs/Translator/GLES_CM/Android.mk @@ -17,13 +17,11 @@ LOCAL_C_INCLUDES += \ $(translator_path)/../../../shared LOCAL_STATIC_LIBRARIES := \ + libGLcommon \ libOpenglOsUtils \ libutils \ libcutils -LOCAL_SHARED_LIBRARIES := \ - libGLcommon - LOCAL_CFLAGS := -g -O0 LOCAL_MODULE_TAGS := debug LOCAL_MODULE := libGLES_CM_translator diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/Android.mk b/tools/emulator/opengl/host/libs/Translator/GLES_V2/Android.mk index 40990d93a..723bd384e 100644 --- a/tools/emulator/opengl/host/libs/Translator/GLES_V2/Android.mk +++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/Android.mk @@ -14,9 +14,19 @@ LOCAL_SRC_FILES := \ LOCAL_C_INCLUDES += \ $(translator_path)/include \ +LOCAL_STATIC_LIBRARIES := \ + libGLcommon \ + libOpenglOsUtils \ + libutils \ + libcutils -LOCAL_SHARED_LIBRARIES := \ - libGLcommon +ifeq ($(HOST_OS),linux) + LOCAL_LDLIBS := -lGL -ldl +endif + +ifeq ($(HOST_OS),windows) + LOCAL_LDLIBS := -lopengl32 -lgdi32 +endif LOCAL_CFLAGS := -g -O0 LOCAL_MODULE_TAGS := debug diff --git a/tools/emulator/opengl/host/libs/Translator/GLcommon/Android.mk b/tools/emulator/opengl/host/libs/Translator/GLcommon/Android.mk index 370139086..0e9cb9706 100644 --- a/tools/emulator/opengl/host/libs/Translator/GLcommon/Android.mk +++ b/tools/emulator/opengl/host/libs/Translator/GLcommon/Android.mk @@ -39,4 +39,4 @@ ifeq ($(HOST_OS),windows) LOCAL_LDLIBS := -lopengl32 -lgdi32 endif -include $(BUILD_HOST_SHARED_LIBRARY) +include $(BUILD_HOST_STATIC_LIBRARY) diff --git a/tools/emulator/opengl/host/libs/Translator/GLcommon/objectNameManager.cpp b/tools/emulator/opengl/host/libs/Translator/GLcommon/objectNameManager.cpp index 32f97c26a..e6d42cf0f 100644 --- a/tools/emulator/opengl/host/libs/Translator/GLcommon/objectNameManager.cpp +++ b/tools/emulator/opengl/host/libs/Translator/GLcommon/objectNameManager.cpp @@ -16,58 +16,11 @@ #include #include -class GlobalNameSpace -{ -public: - GlobalNameSpace() - { - mutex_init(&m_lock); - for (int i=0; i= NUM_OBJECT_TYPES ) return 0; - - mutex_lock(&m_lock); - unsigned int name = m_nameSpace[p_type]->genName(0, false); - mutex_unlock(&m_lock); - return name; - } - - void deleteName(NamedObjectType p_type, unsigned int p_name) - { - if ( p_type >= NUM_OBJECT_TYPES ) return; - - mutex_lock(&m_lock); - m_nameSpace[p_type]->deleteName(p_name); - mutex_unlock(&m_lock); - } - -private: - mutex_t m_lock; - NameSpace *m_nameSpace[NUM_OBJECT_TYPES]; -}; - -static GlobalNameSpace *s_globalNameSpace = NULL; - -NameSpace::NameSpace(NamedObjectType p_type) : +NameSpace::NameSpace(NamedObjectType p_type, GlobalNameSpace *globalNameSpace) : m_nextName(0), - m_type(p_type) + m_type(p_type), + m_globalNameSpace(globalNameSpace) { } @@ -76,7 +29,7 @@ NameSpace::~NameSpace() for (NamesMap::iterator n = m_localToGlobalMap.begin(); n != m_localToGlobalMap.end(); n++) { - s_globalNameSpace->deleteName(m_type, (*n).second); + m_globalNameSpace->deleteName(m_type, (*n).second); } } @@ -92,7 +45,7 @@ NameSpace::genName(unsigned int p_localName, bool genGlobal) } if (genGlobal) { - unsigned int globalName = s_globalNameSpace->genName(m_type); + unsigned int globalName = m_globalNameSpace->genName(m_type); m_localToGlobalMap[localName] = globalName; } @@ -131,7 +84,7 @@ NameSpace::deleteName(unsigned int p_localName) { NamesMap::iterator n( m_localToGlobalMap.find(p_localName) ); if (n != m_localToGlobalMap.end()) { - s_globalNameSpace->deleteName(m_type, (*n).second); + m_globalNameSpace->deleteName(m_type, (*n).second); m_localToGlobalMap.erase(p_localName); } } @@ -147,7 +100,7 @@ NameSpace::replaceGlobalName(unsigned int p_localName, unsigned int p_globalName { NamesMap::iterator n( m_localToGlobalMap.find(p_localName) ); if (n != m_localToGlobalMap.end()) { - s_globalNameSpace->deleteName(m_type, (*n).second); + m_globalNameSpace->deleteName(m_type, (*n).second); (*n).second = p_globalName; } } @@ -155,12 +108,12 @@ NameSpace::replaceGlobalName(unsigned int p_localName, unsigned int p_globalName typedef std::pair ObjectIDPair; typedef std::map ObjectDataMap; -ShareGroup::ShareGroup() +ShareGroup::ShareGroup(GlobalNameSpace *globalNameSpace) { mutex_init(&m_lock); for (int i=0; i(p_groupName, shareGroupReturn) ); } @@ -332,8 +284,6 @@ ObjectNameManager::getShareGroup(void *p_groupName) { mutex_lock(&m_lock); - if (!s_globalNameSpace) s_globalNameSpace = new GlobalNameSpace(); - ShareGroupPtr shareGroupReturn(NULL); ShareGroupsMap::iterator s( m_groups.find(p_groupName) ); @@ -350,8 +300,6 @@ ObjectNameManager::attachShareGroup(void *p_groupName, void *p_existingGroupName { mutex_lock(&m_lock); - if (!s_globalNameSpace) s_globalNameSpace = new GlobalNameSpace(); - ShareGroupPtr shareGroupReturn; ShareGroupsMap::iterator s( m_groups.find(p_existingGroupName) ); @@ -383,10 +331,6 @@ ObjectNameManager::deleteShareGroup(void *p_groupName) m_groups.erase(s); } - if (m_groups.size() == 0 && s_globalNameSpace) { - delete s_globalNameSpace; - s_globalNameSpace = NULL; - } mutex_unlock(&m_lock); } diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h index 4241ea890..5f2e82c62 100644 --- a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h +++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h @@ -48,13 +48,14 @@ typedef SmartPtr ObjectDataPtr; // NOTE: this class does not used by the EGL/GLES layer directly, // the EGL/GLES layer creates objects using the ShareGroup class // interface (see below). +class GlobalNameSpace; class NameSpace { friend class ShareGroup; friend class GlobalNameSpace; private: - explicit NameSpace(NamedObjectType p_type); + NameSpace(NamedObjectType p_type, GlobalNameSpace *globalNameSpace); ~NameSpace(); // @@ -98,6 +99,54 @@ private: unsigned int m_nextName; NamesMap m_localToGlobalMap; const NamedObjectType m_type; + GlobalNameSpace *m_globalNameSpace; +}; + +class GlobalNameSpace +{ +public: + GlobalNameSpace() + { + mutex_init(&m_lock); + + for (int i=0; i= NUM_OBJECT_TYPES ) return 0; + + mutex_lock(&m_lock); + unsigned int name = m_nameSpace[p_type]->genName(0, false); + mutex_unlock(&m_lock); + return name; + } + + void deleteName(NamedObjectType p_type, unsigned int p_name) + { + if ( p_type >= NUM_OBJECT_TYPES ) return; + + mutex_lock(&m_lock); + m_nameSpace[p_type]->deleteName(p_name); + mutex_unlock(&m_lock); + } + +private: + mutex_t m_lock; + NameSpace *m_nameSpace[NUM_OBJECT_TYPES]; }; // @@ -163,7 +212,7 @@ public: ObjectDataPtr getObjectData(NamedObjectType p_type, unsigned int p_localName); private: - ShareGroup(); + explicit ShareGroup(GlobalNameSpace *globalNameSpace); ~ShareGroup(); private: @@ -187,7 +236,7 @@ typedef std::multimap ShareGroupsMap; class ObjectNameManager { public: - ObjectNameManager(); + explicit ObjectNameManager(GlobalNameSpace *globalNameSpace); ~ObjectNameManager(); // @@ -226,6 +275,7 @@ public: private: ShareGroupsMap m_groups; mutex_t m_lock; + GlobalNameSpace *m_globalNameSpace; }; #endif diff --git a/tools/emulator/opengl/tests/translator_tests/GLES_CM/Android.mk b/tools/emulator/opengl/tests/translator_tests/GLES_CM/Android.mk index 573c5b447..a411ccf0d 100644 --- a/tools/emulator/opengl/tests/translator_tests/GLES_CM/Android.mk +++ b/tools/emulator/opengl/tests/translator_tests/GLES_CM/Android.mk @@ -13,7 +13,6 @@ LOCAL_SRC_FILES:= \ LOCAL_SHARED_LIBRARIES := \ - libGLcommon \ libEGL_translator \ libGLES_CM_translator diff --git a/tools/emulator/opengl/tests/translator_tests/GLES_V2/Android.mk b/tools/emulator/opengl/tests/translator_tests/GLES_V2/Android.mk index b57ed579b..5cb5c4abc 100644 --- a/tools/emulator/opengl/tests/translator_tests/GLES_V2/Android.mk +++ b/tools/emulator/opengl/tests/translator_tests/GLES_V2/Android.mk @@ -13,7 +13,6 @@ LOCAL_SRC_FILES:= \ LOCAL_SHARED_LIBRARIES := \ - libGLcommon \ libEGL_translator \ libGLES_V2_translator