diff options
author | Markus Mohrhard <markus.mohrhard@collabora.co.uk> | 2014-11-30 04:55:46 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2014-12-02 15:47:28 +0100 |
commit | d445965e9c21089cdb190ff83a27f37d04b0c2fd (patch) | |
tree | 3e18e6dc5f4e0103b6af3f606a1c14ba148e3479 | |
parent | 48839de90f977304546d96f379ed9b451e4d4789 (diff) |
use boost::shared_ptr instead of manual ref counting
Change-Id: I3c2ed9b5641202ff965c3a0c833c8201b2b1548b
-rw-r--r-- | include/vcl/opengl/OpenGLContext.hxx | 4 | ||||
-rw-r--r-- | vcl/inc/openglgdiimpl.hxx | 4 | ||||
-rw-r--r-- | vcl/opengl/gdiimpl.cxx | 22 | ||||
-rw-r--r-- | vcl/source/opengl/OpenGLContext.cxx | 12 |
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 da09a614348e..e693b2fc1866 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 9a87fcaf040b..93b425a7ca75 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() #endif } -void OpenGLContext::AddRef() -{ - mnRefCount++; -} - -void OpenGLContext::DeRef() -{ - if( --mnRefCount == 0 ) - delete this; -} - void OpenGLContext::requestLegacyContext() { mbRequestLegacyContext = true; |