summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/vcl/opengl/OpenGLContext.hxx3
-rw-r--r--vcl/inc/openglgdiimpl.hxx4
-rw-r--r--vcl/opengl/gdiimpl.cxx21
-rw-r--r--vcl/source/opengl/OpenGLContext.cxx12
4 files changed, 30 insertions, 10 deletions
diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index 843821dd75d4..595a2aeaabac 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -211,6 +211,8 @@ public:
bool AcquireFramebuffer( OpenGLFramebuffer* pFramebuffer );
OpenGLFramebuffer* AcquireFramebuffer( const OpenGLTexture& rTexture );
void ReleaseFramebuffer( OpenGLFramebuffer* pFramebuffer );
+ void AddRef();
+ void DeRef();
// retrieve a program from the cache or compile/link it
OpenGLProgram* GetProgram( const OUString& rVertexShader, const OUString& rFragmentShader );
@@ -260,6 +262,7 @@ private:
SystemChildWindow* m_pChildWindow;
boost::scoped_ptr<SystemChildWindow> m_pChildWindowGC;
bool mbInitialized;
+ int mnRefCount;
bool mbRequestLegacyContext;
bool mbUseDoubleBufferedRendering;
bool mbRequestVirtualDevice;
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index 3f3ef4ed29a1..d328ab724b2f 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -32,8 +32,6 @@
#include <tools/poly.hxx>
#include <vcl/opengl/OpenGLContext.hxx>
-#include <boost/shared_ptr.hpp>
-
class SalFrame;
class SalVirtualDevice;
@@ -41,7 +39,7 @@ class VCL_PLUGIN_PUBLIC OpenGLSalGraphicsImpl : public SalGraphicsImpl
{
protected:
- boost::shared_ptr<OpenGLContext> mpContext;
+ OpenGLContext* mpContext;
/// Pointer to the SalFrame or SalVirtualDevice
SalGeometryProvider* mpParent;
OpenGLFramebuffer* mpFramebuffer;
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 46d72dc6854b..970957cf1555 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -51,20 +51,23 @@ OpenGLSalGraphicsImpl::OpenGLSalGraphicsImpl(SalGeometryProvider* pParent)
OpenGLSalGraphicsImpl::~OpenGLSalGraphicsImpl()
{
+ ReleaseContext();
}
OpenGLContext* OpenGLSalGraphicsImpl::GetOpenGLContext()
{
if( !mpContext )
AcquireContext();
- return mpContext.get();
+ return mpContext;
}
bool OpenGLSalGraphicsImpl::AcquireContext( )
{
ImplSVData* pSVData = ImplGetSVData();
- mpContext.reset();
+ if( mpContext )
+ mpContext->DeRef();
+
OpenGLContext* pContext = pSVData->maGDIData.mpLastContext;
while( pContext )
@@ -75,16 +78,20 @@ bool OpenGLSalGraphicsImpl::AcquireContext( )
pContext = pContext->mpPrevContext;
}
- if (!pContext)
+ if( pContext )
+ pContext->AddRef();
+ else
pContext = mbOffscreen ? CreatePixmapContext() : CreateWinContext();
- mpContext.reset(pContext);
- return (mpContext != nullptr);
+ mpContext = pContext;
+ return (mpContext != NULL);
}
bool OpenGLSalGraphicsImpl::ReleaseContext()
{
- mpContext.reset();
+ if( mpContext )
+ mpContext->DeRef();
+ mpContext = NULL;
return true;
}
@@ -95,7 +102,7 @@ void OpenGLSalGraphicsImpl::Init()
// check if we can simply re-use the same context
if( mpContext )
{
- if( !UseContext( mpContext.get() ) )
+ if( !UseContext( mpContext ) )
ReleaseContext();
}
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 2160c6e04ba0..01b74b9f6900 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -53,6 +53,7 @@ OpenGLContext::OpenGLContext():
mpWindow(NULL),
m_pChildWindow(NULL),
mbInitialized(false),
+ mnRefCount(1),
mbRequestLegacyContext(false),
mbUseDoubleBufferedRendering(true),
mbRequestVirtualDevice(false),
@@ -122,6 +123,17 @@ OpenGLContext::~OpenGLContext()
#endif
}
+void OpenGLContext::AddRef()
+{
+ mnRefCount++;
+}
+
+void OpenGLContext::DeRef()
+{
+ if( --mnRefCount == 0 )
+ delete this;
+}
+
void OpenGLContext::requestLegacyContext()
{
mbRequestLegacyContext = true;