Kaydet (Commit) 8091457a authored tarafından Markus Mohrhard's avatar Markus Mohrhard

Revert "use boost::shared_ptr instead of manual ref counting"

This reverts commit 8eeb02dc.

Conflicts:
	include/vcl/opengl/OpenGLContext.hxx
	vcl/inc/openglgdiimpl.hxx
	vcl/opengl/gdiimpl.cxx

Change-Id: I85cc7a46876ffba5ab861f6dd83b07da466b212b
üst 6ae099ff
...@@ -211,6 +211,8 @@ public: ...@@ -211,6 +211,8 @@ public:
bool AcquireFramebuffer( OpenGLFramebuffer* pFramebuffer ); bool AcquireFramebuffer( OpenGLFramebuffer* pFramebuffer );
OpenGLFramebuffer* AcquireFramebuffer( const OpenGLTexture& rTexture ); OpenGLFramebuffer* AcquireFramebuffer( const OpenGLTexture& rTexture );
void ReleaseFramebuffer( OpenGLFramebuffer* pFramebuffer ); void ReleaseFramebuffer( OpenGLFramebuffer* pFramebuffer );
void AddRef();
void DeRef();
// retrieve a program from the cache or compile/link it // retrieve a program from the cache or compile/link it
OpenGLProgram* GetProgram( const OUString& rVertexShader, const OUString& rFragmentShader ); OpenGLProgram* GetProgram( const OUString& rVertexShader, const OUString& rFragmentShader );
...@@ -260,6 +262,7 @@ private: ...@@ -260,6 +262,7 @@ private:
SystemChildWindow* m_pChildWindow; SystemChildWindow* m_pChildWindow;
boost::scoped_ptr<SystemChildWindow> m_pChildWindowGC; boost::scoped_ptr<SystemChildWindow> m_pChildWindowGC;
bool mbInitialized; bool mbInitialized;
int mnRefCount;
bool mbRequestLegacyContext; bool mbRequestLegacyContext;
bool mbUseDoubleBufferedRendering; bool mbUseDoubleBufferedRendering;
bool mbRequestVirtualDevice; bool mbRequestVirtualDevice;
......
...@@ -32,8 +32,6 @@ ...@@ -32,8 +32,6 @@
#include <tools/poly.hxx> #include <tools/poly.hxx>
#include <vcl/opengl/OpenGLContext.hxx> #include <vcl/opengl/OpenGLContext.hxx>
#include <boost/shared_ptr.hpp>
class SalFrame; class SalFrame;
class SalVirtualDevice; class SalVirtualDevice;
...@@ -41,7 +39,7 @@ class VCL_PLUGIN_PUBLIC OpenGLSalGraphicsImpl : public SalGraphicsImpl ...@@ -41,7 +39,7 @@ class VCL_PLUGIN_PUBLIC OpenGLSalGraphicsImpl : public SalGraphicsImpl
{ {
protected: protected:
boost::shared_ptr<OpenGLContext> mpContext; OpenGLContext* mpContext;
/// Pointer to the SalFrame or SalVirtualDevice /// Pointer to the SalFrame or SalVirtualDevice
SalGeometryProvider* mpParent; SalGeometryProvider* mpParent;
OpenGLFramebuffer* mpFramebuffer; OpenGLFramebuffer* mpFramebuffer;
......
...@@ -51,20 +51,23 @@ OpenGLSalGraphicsImpl::OpenGLSalGraphicsImpl(SalGeometryProvider* pParent) ...@@ -51,20 +51,23 @@ OpenGLSalGraphicsImpl::OpenGLSalGraphicsImpl(SalGeometryProvider* pParent)
OpenGLSalGraphicsImpl::~OpenGLSalGraphicsImpl() OpenGLSalGraphicsImpl::~OpenGLSalGraphicsImpl()
{ {
ReleaseContext();
} }
OpenGLContext* OpenGLSalGraphicsImpl::GetOpenGLContext() OpenGLContext* OpenGLSalGraphicsImpl::GetOpenGLContext()
{ {
if( !mpContext ) if( !mpContext )
AcquireContext(); AcquireContext();
return mpContext.get(); return mpContext;
} }
bool OpenGLSalGraphicsImpl::AcquireContext( ) bool OpenGLSalGraphicsImpl::AcquireContext( )
{ {
ImplSVData* pSVData = ImplGetSVData(); ImplSVData* pSVData = ImplGetSVData();
mpContext.reset(); if( mpContext )
mpContext->DeRef();
OpenGLContext* pContext = pSVData->maGDIData.mpLastContext; OpenGLContext* pContext = pSVData->maGDIData.mpLastContext;
while( pContext ) while( pContext )
...@@ -75,16 +78,20 @@ bool OpenGLSalGraphicsImpl::AcquireContext( ) ...@@ -75,16 +78,20 @@ bool OpenGLSalGraphicsImpl::AcquireContext( )
pContext = pContext->mpPrevContext; pContext = pContext->mpPrevContext;
} }
if (!pContext) if( pContext )
pContext->AddRef();
else
pContext = mbOffscreen ? CreatePixmapContext() : CreateWinContext(); pContext = mbOffscreen ? CreatePixmapContext() : CreateWinContext();
mpContext.reset(pContext); mpContext = pContext;
return (mpContext != nullptr); return (mpContext != NULL);
} }
bool OpenGLSalGraphicsImpl::ReleaseContext() bool OpenGLSalGraphicsImpl::ReleaseContext()
{ {
mpContext.reset(); if( mpContext )
mpContext->DeRef();
mpContext = NULL;
return true; return true;
} }
...@@ -95,7 +102,7 @@ void OpenGLSalGraphicsImpl::Init() ...@@ -95,7 +102,7 @@ void OpenGLSalGraphicsImpl::Init()
// check if we can simply re-use the same context // check if we can simply re-use the same context
if( mpContext ) if( mpContext )
{ {
if( !UseContext( mpContext.get() ) ) if( !UseContext( mpContext ) )
ReleaseContext(); ReleaseContext();
} }
......
...@@ -53,6 +53,7 @@ OpenGLContext::OpenGLContext(): ...@@ -53,6 +53,7 @@ OpenGLContext::OpenGLContext():
mpWindow(NULL), mpWindow(NULL),
m_pChildWindow(NULL), m_pChildWindow(NULL),
mbInitialized(false), mbInitialized(false),
mnRefCount(1),
mbRequestLegacyContext(false), mbRequestLegacyContext(false),
mbUseDoubleBufferedRendering(true), mbUseDoubleBufferedRendering(true),
mbRequestVirtualDevice(false), mbRequestVirtualDevice(false),
...@@ -121,6 +122,17 @@ OpenGLContext::~OpenGLContext() ...@@ -121,6 +122,17 @@ OpenGLContext::~OpenGLContext()
#endif #endif
} }
void OpenGLContext::AddRef()
{
mnRefCount++;
}
void OpenGLContext::DeRef()
{
if( --mnRefCount == 0 )
delete this;
}
void OpenGLContext::requestLegacyContext() void OpenGLContext::requestLegacyContext()
{ {
mbRequestLegacyContext = true; mbRequestLegacyContext = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment