summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2014-11-30 04:55:46 +0100
committerMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2014-12-01 07:37:06 +0100
commit8eeb02dcc1a4bc99b083b1a591b4a70003a1604f (patch)
tree41192f5d3308d7bbc48ec8c31e4b92c4fe491fea
parent1cbab726772e3c0eba74202043699584a00eb931 (diff)
use boost::shared_ptr instead of manual ref counting
Change-Id: I3c2ed9b5641202ff965c3a0c833c8201b2b1548b
-rw-r--r--include/vcl/opengl/OpenGLContext.hxx4
-rw-r--r--vcl/inc/openglgdiimpl.hxx4
-rw-r--r--vcl/opengl/gdiimpl.cxx22
-rw-r--r--vcl/source/opengl/OpenGLContext.cxx12
4 files changed, 10 insertions, 32 deletions
diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index ebfa6ff5f884..7931f4b26e4d 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -175,9 +175,6 @@ public:
bool init( HDC hDC, HWND hWnd );
#endif
- void AddRef();
- void DeRef();
-
void makeCurrent();
void resetCurrent();
void swapBuffers();
@@ -222,7 +219,6 @@ 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 83c5bdb9ac46..bc813f180862 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -29,6 +29,8 @@
#include <tools/poly.hxx>
#include <vcl/opengl/OpenGLContext.hxx>
+#include <boost/shared_ptr.hpp>
+
class SalFrame;
class SalVirtualDevice;
@@ -36,7 +38,7 @@ class VCL_PLUGIN_PUBLIC OpenGLSalGraphicsImpl : public SalGraphicsImpl
{
protected:
- OpenGLContext* mpContext;
+ boost::shared_ptr<OpenGLContext> mpContext;
// clipping
vcl::Region maClipRegion;
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index cd97cdf08180..3b6f67b46aac 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -109,20 +109,16 @@ OpenGLSalGraphicsImpl::OpenGLSalGraphicsImpl()
OpenGLSalGraphicsImpl::~OpenGLSalGraphicsImpl()
{
- ReleaseContext();
}
bool OpenGLSalGraphicsImpl::AcquireContext( bool bOffscreen )
{
ImplSVData* pSVData = ImplGetSVData();
- if( mpContext )
- mpContext->DeRef();
-
if( bOffscreen )
{
- mpContext = CreatePixmapContext();
- return (mpContext != NULL);
+ mpContext.reset(CreatePixmapContext());
+ return (mpContext.get() != NULL);
}
OpenGLContext* pContext = pSVData->maGDIData.mpLastContext;
@@ -134,20 +130,16 @@ bool OpenGLSalGraphicsImpl::AcquireContext( bool bOffscreen )
pContext = pContext->mpPrevContext;
}
- if( pContext )
- pContext->AddRef();
- else
- pContext = CreateWinContext();
+ if (!pContext)
+ pContext =CreateWinContext();
- mpContext = pContext;
+ mpContext.reset(pContext);
return (mpContext != NULL);
}
bool OpenGLSalGraphicsImpl::ReleaseContext()
{
- if( mpContext )
- mpContext->DeRef();
- mpContext = NULL;
+ mpContext.reset();
return true;
}
@@ -158,7 +150,7 @@ void OpenGLSalGraphicsImpl::Init()
// check if we can simply re-use the same context
if( mpContext )
{
- if( bOffscreen != mbOffscreen || ( !mbOffscreen && CompareWinContext( mpContext ) ) )
+ if( bOffscreen != mbOffscreen || ( !mbOffscreen && CompareWinContext( mpContext.get() ) ) )
ReleaseContext();
}
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index fb0e4edb89d8..4c64f6344257 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -49,7 +49,6 @@ OpenGLContext::OpenGLContext():
mpWindow(NULL),
m_pChildWindow(NULL),
mbInitialized(false),
- mnRefCount(1),
mbRequestLegacyContext(false),
mbUseDoubleBufferedRendering(true),
mbRequestVirtualDevice(false),
@@ -115,17 +114,6 @@ OpenGLContext::~OpenGLContext()
pSVData->maGDIData.mpLastContext = mpPrevContext;
}
-void OpenGLContext::AddRef()
-{
- mnRefCount++;
-}
-
-void OpenGLContext::DeRef()
-{
- if( --mnRefCount == 0 )
- delete this;
-}
-
void OpenGLContext::requestLegacyContext()
{
mbRequestLegacyContext = true;