Merge "EGL translator: fixes shared context on windows"
This commit is contained in:
@@ -23,7 +23,8 @@ EglDisplay::EglDisplay(EGLNativeDisplayType dpy,bool isDefault) :
|
||||
m_initialized(false),
|
||||
m_configInitialized(false),
|
||||
m_isDefault(isDefault),
|
||||
m_nextEglImageId(0)
|
||||
m_nextEglImageId(0),
|
||||
m_globalSharedContext(NULL)
|
||||
{
|
||||
m_manager[GLES_1_1] = new ObjectNameManager(&m_globalNameSpace);
|
||||
m_manager[GLES_2_0] = new ObjectNameManager(&m_globalNameSpace);
|
||||
@@ -31,6 +32,15 @@ EglDisplay::EglDisplay(EGLNativeDisplayType dpy,bool isDefault) :
|
||||
|
||||
EglDisplay::~EglDisplay() {
|
||||
android::Mutex::Autolock mutex(m_lock);
|
||||
|
||||
//
|
||||
// Destroy the global context if one was created.
|
||||
// (should be true for windows platform only)
|
||||
//
|
||||
if (m_globalSharedContext != NULL) {
|
||||
EglOS::destroyContext( m_dpy, m_globalSharedContext);
|
||||
}
|
||||
|
||||
if(m_isDefault) {
|
||||
EglOS::releaseDisplay(m_dpy);
|
||||
}
|
||||
@@ -264,7 +274,6 @@ EGLContext EglDisplay::addContext(ContextPtr ctx ) {
|
||||
if(m_contexts.find(hndl) != m_contexts.end()) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
m_contexts[hndl] = ctx;
|
||||
return ret;
|
||||
}
|
||||
@@ -294,3 +303,28 @@ bool EglDisplay:: destroyImageKHR(EGLImageKHR img) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
EGLNativeContextType EglDisplay::getGlobalSharedContext(){
|
||||
android::Mutex::Autolock mutex(m_lock);
|
||||
#ifndef _WIN32
|
||||
return (EGLNativeContextType)m_manager[GLES_1_1]->getGlobalContext();
|
||||
#else
|
||||
if (!m_globalSharedContext) {
|
||||
//
|
||||
// On windows we create a dummy context to serve as the
|
||||
// "global context" which all contexts share with.
|
||||
// This is because on windows it is not possible to share
|
||||
// with a context which is already current. This dummy context
|
||||
// will never be current to any thread so it is safe to share with.
|
||||
// Create that context using the first config
|
||||
if (m_configs.size() < 1) {
|
||||
// Should not happen! config list should be initialized at this point
|
||||
return NULL;
|
||||
}
|
||||
EglConfig *cfg = (*m_configs.begin());
|
||||
m_globalSharedContext = EglOS::createContext(m_dpy,cfg,NULL);
|
||||
}
|
||||
|
||||
return m_globalSharedContext;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ public:
|
||||
ImagePtr getImage(EGLImageKHR img);
|
||||
EGLImageKHR addImageKHR(ImagePtr);
|
||||
bool destroyImageKHR(EGLImageKHR img);
|
||||
EGLNativeContextType getGlobalSharedContext();
|
||||
|
||||
private:
|
||||
int doChooseConfigs(const EglConfig& dummy,EGLConfig* configs,int config_size);
|
||||
@@ -83,6 +84,7 @@ private:
|
||||
android::Mutex m_lock;
|
||||
ImagesHndlMap m_eglImages;
|
||||
unsigned int m_nextEglImageId;
|
||||
EGLNativeContextType m_globalSharedContext;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -641,7 +641,9 @@ EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay display, EGLConfig con
|
||||
nativeShared = sharedCtxPtr->nativeType();
|
||||
}
|
||||
|
||||
EGLNativeContextType nativeContext = EglOS::createContext(dpy->nativeType(),cfg,static_cast<EGLNativeContextType>(dpy->getManager(version)->getGlobalContext()));
|
||||
EGLNativeContextType globalSharedContext = dpy->getGlobalSharedContext();
|
||||
EGLNativeContextType nativeContext = EglOS::createContext(dpy->nativeType(),cfg,globalSharedContext);
|
||||
|
||||
if(nativeContext) {
|
||||
ContextPtr ctx(new EglContext(nativeContext,sharedCtxPtr,cfg,glesCtx,version,dpy->getManager(version)));
|
||||
return dpy->addContext(ctx);
|
||||
|
||||
Reference in New Issue
Block a user