diff options
-rw-r--r-- | include/vcl/opengl/OpenGLContext.hxx | 3 | ||||
-rw-r--r-- | vcl/generic/app/geninst.cxx | 2 | ||||
-rw-r--r-- | vcl/osx/salinst.cxx | 2 | ||||
-rw-r--r-- | vcl/source/opengl/OpenGLContext.cxx | 14 | ||||
-rw-r--r-- | vcl/source/opengl/OpenGLHelper.cxx | 2 | ||||
-rw-r--r-- | vcl/win/source/app/salinst.cxx | 5 |
6 files changed, 24 insertions, 4 deletions
diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx index cf8bd6d0272a..c588a215aa86 100644 --- a/include/vcl/opengl/OpenGLContext.hxx +++ b/include/vcl/opengl/OpenGLContext.hxx @@ -210,7 +210,10 @@ public: /// Is this GL context the current context ? bool isCurrent(); + /// release bound resources from the current context static void clearCurrent(); + /// release contexts etc. before (potentially) allowing another thread run. + static void prepareForYield(); /// Is there a current GL context ? static bool hasCurrent(); /// make this GL context current - so it is implicit in subsequent GL calls diff --git a/vcl/generic/app/geninst.cxx b/vcl/generic/app/geninst.cxx index eeb2a574f714..ef7bec0ed0d9 100644 --- a/vcl/generic/app/geninst.cxx +++ b/vcl/generic/app/geninst.cxx @@ -54,7 +54,7 @@ void SalYieldMutex::release() { if ( mnCount == 1 ) { - OpenGLContext::clearCurrent(); + OpenGLContext::prepareForYield(); mnThreadId = 0; } mnCount--; diff --git a/vcl/osx/salinst.cxx b/vcl/osx/salinst.cxx index 9d8f80e17e48..b92c6ba8a4ff 100644 --- a/vcl/osx/salinst.cxx +++ b/vcl/osx/salinst.cxx @@ -276,7 +276,7 @@ void SalYieldMutex::release() { if ( mnCount == 1 ) { - // TODO: add OpenGLContext::clearCurrent with vcl OpenGL support + // TODO: add OpenGLContext::prepareForYield with vcl OpenGL support mnThreadId = 0; } mnCount--; diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx index 49feb75368b4..3c305d523d98 100644 --- a/vcl/source/opengl/OpenGLContext.cxx +++ b/vcl/source/opengl/OpenGLContext.cxx @@ -1336,6 +1336,20 @@ void OpenGLContext::clearCurrent() pCurrentCtx->ReleaseFramebuffers(); } +void OpenGLContext::prepareForYield() +{ + ImplSVData* pSVData = ImplGetSVData(); + + SAL_INFO("vcl.opengl", "Unbinding contexts in preparation for yield"); + // release all framebuffers from the old context so we can re-attach the + // texture in the new context + OpenGLContext* pCurrentCtx = pSVData->maGDIData.mpLastContext; + if( pCurrentCtx && pCurrentCtx->isCurrent() ) + pCurrentCtx->resetCurrent(); + + assert (!hasCurrent()); +} + void OpenGLContext::makeCurrent() { ImplSVData* pSVData = ImplGetSVData(); diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx index 6019850c88fe..62cb91887d4e 100644 --- a/vcl/source/opengl/OpenGLHelper.cxx +++ b/vcl/source/opengl/OpenGLHelper.cxx @@ -694,7 +694,7 @@ void OpenGLHelper::debugMsgPrint(const char *pArea, const char *pFormat, ...) vsnprintf(pStr, sizeof(pStr), pFormat, aArgs); pStr[sizeof(pStr)-20] = '\0'; - bool bHasContext = !OpenGLContext::hasCurrent(); + bool bHasContext = OpenGLContext::hasCurrent(); if (!bHasContext) strcat(pStr, "- no GL context"); diff --git a/vcl/win/source/app/salinst.cxx b/vcl/win/source/app/salinst.cxx index 8726814548b3..7458efa20214 100644 --- a/vcl/win/source/app/salinst.cxx +++ b/vcl/win/source/app/salinst.cxx @@ -153,7 +153,7 @@ void SalYieldMutex::release() { if ( mnCount == 1 ) { - OpenGLContext::clearCurrent(); + OpenGLContext::prepareForYield(); // If we don't call these message, the Output from the // Java clients doesn't come in the right order @@ -178,7 +178,10 @@ void SalYieldMutex::release() else { if ( mnCount == 1 ) + { mnThreadId = 0; + OpenGLContext::prepareForYield(); + } mnCount--; m_mutex.release(); } |