summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2015-09-02 22:14:10 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-09-02 21:49:07 +0000
commitacbf98d6f1af77510bd0fbe0a47fba97080c1bbc (patch)
tree2f22780acda87adfa779206bf80735ea1cdd6836
parentd55c97a58442346810493f2d816c8e965a5f704c (diff)
tdf#93867 - clear current GL context before thread switch.
Fixes regression from otherwise a nice cleanup in: d20092259c7ea63885a539f911788715f8147ee9 Also get polarity of debug logging only with a context right. Change-Id: Id322471f01e5656e758aefc57b0d4d5ad073ec54 Reviewed-on: https://gerrit.libreoffice.org/18282 Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r--include/vcl/opengl/OpenGLContext.hxx3
-rw-r--r--vcl/generic/app/geninst.cxx2
-rw-r--r--vcl/osx/salinst.cxx2
-rw-r--r--vcl/source/opengl/OpenGLContext.cxx14
-rw-r--r--vcl/source/opengl/OpenGLHelper.cxx2
-rw-r--r--vcl/win/source/app/salinst.cxx5
6 files changed, 24 insertions, 4 deletions
diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index 5aa318eff69c..259222a4d1d0 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -212,7 +212,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 327d8807d4f6..d73b72e2a652 100644
--- a/vcl/generic/app/geninst.cxx
+++ b/vcl/generic/app/geninst.cxx
@@ -55,7 +55,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 cec89e8a05db..58a52d58accf 100644
--- a/vcl/osx/salinst.cxx
+++ b/vcl/osx/salinst.cxx
@@ -271,7 +271,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 ad31a36ac99b..e2176905f46a 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -1424,6 +1424,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 d2a917fb962a..c4302eb52659 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -698,7 +698,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 1ef22b274181..d2fbb52629bf 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
@@ -176,7 +176,10 @@ void SalYieldMutex::release()
else
{
if ( mnCount == 1 )
+ {
mnThreadId = 0;
+ OpenGLContext::prepareForYield();
+ }
mnCount--;
m_mutex.release();
}