Kaydet (Commit) acbf98d6 authored tarafından Michael Meeks's avatar Michael Meeks Kaydeden (comit) Markus Mohrhard

tdf#93867 - clear current GL context before thread switch.

Fixes regression from otherwise a nice cleanup in:
    d2009225

Also get polarity of debug logging only with a context right.

Change-Id: Id322471f01e5656e758aefc57b0d4d5ad073ec54
Reviewed-on: https://gerrit.libreoffice.org/18282Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst d55c97a5
......@@ -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
......
......@@ -55,7 +55,7 @@ void SalYieldMutex::release()
{
if ( mnCount == 1 )
{
OpenGLContext::clearCurrent();
OpenGLContext::prepareForYield();
mnThreadId = 0;
}
mnCount--;
......
......@@ -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--;
......
......@@ -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();
......
......@@ -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");
......
......@@ -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();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment