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(-)
New commits: commit a15a538fb191b1851f366716914822411b583c58 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Tue Dec 2 21:51:50 2014 +0100 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 diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx index 843821d..595a2ae 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 3f3ef4e..d328ab7 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 46d72dc6..970957c 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 2160c6e..01b74b9 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; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits