summaryrefslogtreecommitdiff
path: root/vcl/source/opengl/OpenGLContext.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/source/opengl/OpenGLContext.cxx')
-rw-r--r--vcl/source/opengl/OpenGLContext.cxx48
1 files changed, 11 insertions, 37 deletions
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index df8c6a60c18b..d070e3fb3b6b 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -58,7 +58,7 @@ OpenGLContext::OpenGLContext():
mpWindow(NULL),
m_pChildWindow(NULL),
mbInitialized(false),
- mnRefCount(1),
+ mnRefCount(0),
mbRequestLegacyContext(false),
mbUseDoubleBufferedRendering(true),
mnFramebufferCount(0),
@@ -93,6 +93,9 @@ OpenGLContext::OpenGLContext():
OpenGLContext::~OpenGLContext()
{
VCL_GL_INFO("vcl.opengl", "delete context: " << this);
+ assert (mnRefCount == 0);
+
+ mnRefCount = 1; // guard the shutdown paths.
reset();
ImplSVData* pSVData = ImplGetSVData();
@@ -106,42 +109,13 @@ OpenGLContext::~OpenGLContext()
pSVData->maGDIData.mpLastContext = mpPrevContext;
m_pChildWindow.disposeAndClear();
+ assert (mnRefCount == 1);
}
-#ifdef DBG_UTIL
-void OpenGLContext::AddRef(SalGraphicsImpl* pImpl)
-{
- assert(mnRefCount > 0);
- mnRefCount++;
-
- maParents.insert(pImpl);
-}
-
-void OpenGLContext::DeRef(SalGraphicsImpl* pImpl)
+rtl::Reference<OpenGLContext> OpenGLContext::Create()
{
-
- auto it = maParents.find(pImpl);
- if(it != maParents.end())
- maParents.erase(it);
-
- assert(mnRefCount > 0);
- if( --mnRefCount == 0 )
- delete this;
+ return rtl::Reference<OpenGLContext>(new OpenGLContext);
}
-#else
-void OpenGLContext::AddRef()
-{
- assert(mnRefCount > 0);
- mnRefCount++;
-}
-
-void OpenGLContext::DeRef()
-{
- assert(mnRefCount > 0);
- if( --mnRefCount == 0 )
- delete this;
-}
-#endif
void OpenGLContext::requestLegacyContext()
{
@@ -1337,8 +1311,8 @@ void OpenGLContext::clearCurrent()
// 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() )
+ rtl::Reference<OpenGLContext> pCurrentCtx = pSVData->maGDIData.mpLastContext;
+ if( pCurrentCtx.is() && pCurrentCtx->isCurrent() )
pCurrentCtx->ReleaseFramebuffers();
}
@@ -1348,9 +1322,9 @@ void OpenGLContext::prepareForYield()
// release all framebuffers from the old context so we can re-attach the
// texture in the new context
- OpenGLContext* pCurrentCtx = pSVData->maGDIData.mpLastContext;
+ rtl::Reference<OpenGLContext> pCurrentCtx = pSVData->maGDIData.mpLastContext;
- if ( !pCurrentCtx )
+ if ( !pCurrentCtx.is() )
return; // Not using OpenGL
SAL_INFO("vcl.opengl", "Unbinding contexts in preparation for yield");