From a15a538fb191b1851f366716914822411b583c58 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Tue, 2 Dec 2014 21:51:50 +0100 Subject: Revert "use boost::shared_ptr instead of manual ref counting" This reverts commit 8eeb02dcc1a4bc99b083b1a591b4a70003a1604f. Conflicts: include/vcl/opengl/OpenGLContext.hxx vcl/inc/openglgdiimpl.hxx vcl/opengl/gdiimpl.cxx Change-Id: I85cc7a46876ffba5ab861f6dd83b07da466b212b --- include/vcl/opengl/OpenGLContext.hxx | 3 +++ vcl/inc/openglgdiimpl.hxx | 4 +--- vcl/opengl/gdiimpl.cxx | 21 ++++++++++++++------- vcl/source/opengl/OpenGLContext.cxx | 12 ++++++++++++ 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 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 #include -#include - class SalFrame; class SalVirtualDevice; @@ -41,7 +39,7 @@ class VCL_PLUGIN_PUBLIC OpenGLSalGraphicsImpl : public SalGraphicsImpl { protected: - boost::shared_ptr 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; -- cgit v1.2.3