summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis-Francis Ratté-Boulianne <lfrb@collabora.com>2014-11-22 07:58:38 -0500
committerLouis-Francis Ratté-Boulianne <lfrb@collabora.com>2014-11-22 07:58:38 -0500
commite26c8fdd1922282ef5f0ce97b503ef9d7bb9907b (patch)
treeba554ea9eace17693c71304122f125e40ae16b45
parentc90741573814173e9df5bf945d8cbe9d7d77ec39 (diff)
vcl: Always use the same OpenGL context when drawing in a window
Change-Id: Ief0e947149c133aaa8e81973e088c4df6432bfdc
-rw-r--r--include/vcl/opengl/OpenGLContext.hxx8
-rw-r--r--vcl/inc/opengl/win/gdiimpl.hxx9
-rw-r--r--vcl/inc/opengl/x11/gdiimpl.hxx6
-rw-r--r--vcl/inc/openglgdiimpl.hxx22
-rw-r--r--vcl/inc/salgdiimpl.hxx2
-rw-r--r--vcl/inc/svdata.hxx3
-rw-r--r--vcl/inc/unx/x11/x11gdiimpl.h1
-rw-r--r--vcl/inc/win/salgdi.h1
-rw-r--r--vcl/opengl/gdiimpl.cxx142
-rw-r--r--vcl/opengl/win/gdiimpl.cxx30
-rw-r--r--vcl/opengl/x11/gdiimpl.cxx56
-rw-r--r--vcl/source/opengl/OpenGLContext.cxx38
-rw-r--r--vcl/unx/generic/gdi/salgdi.cxx2
-rw-r--r--vcl/win/source/gdi/gdiimpl.cxx4
-rw-r--r--vcl/win/source/gdi/gdiimpl.hxx2
-rw-r--r--vcl/win/source/gdi/salgdi.cxx10
16 files changed, 264 insertions, 72 deletions
diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index c5e53e873ff0..9414dac47da8 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -174,6 +174,9 @@ public:
bool init( HDC hDC, HWND hWnd );
#endif
+ void AddRef();
+ void DeRef();
+
void makeCurrent();
void resetCurrent();
void swapBuffers();
@@ -218,12 +221,17 @@ private:
SystemChildWindow* m_pChildWindow;
boost::scoped_ptr<SystemChildWindow> m_pChildWindowGC;
bool mbInitialized;
+ int mnRefCount;
bool mbRequestLegacyContext;
bool mbUseDoubleBufferedRendering;
bool mbRequestVirtualDevice;
#if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID
bool mbPixmap; // is a pixmap instead of a window
#endif
+
+public:
+ OpenGLContext* mpPrevContext;
+ OpenGLContext* mpNextContext;
};
#endif
diff --git a/vcl/inc/opengl/win/gdiimpl.hxx b/vcl/inc/opengl/win/gdiimpl.hxx
index 557e58a09af3..66a03332284c 100644
--- a/vcl/inc/opengl/win/gdiimpl.hxx
+++ b/vcl/inc/opengl/win/gdiimpl.hxx
@@ -15,6 +15,8 @@
#include "openglgdiimpl.hxx"
#include "win/salgdi.h"
+class OpenGLContext;
+
class WinOpenGLSalGraphicsImpl : public OpenGLSalGraphicsImpl
{
friend class WinLayout;
@@ -24,9 +26,16 @@ private:
public:
WinOpenGLSalGraphicsImpl(WinSalGraphics& rGraphics);
+ virtual void Init() SAL_OVERRIDE;
+
protected:
virtual GLfloat GetWidth() const SAL_OVERRIDE;
virtual GLfloat GetHeight() const SAL_OVERRIDE;
+ virtual bool IsOffscreen() const SAL_OVERRIDE;
+
+ virtual OpenGLContext* CreateWinContext() SAL_OVERRIDE;
+ virtual bool CompareWinContext( OpenGLContext* pContext ) SAL_OVERRIDE;
+ virtual OpenGLContext* CreatePixmapContext() SAL_OVERRIDE;
public:
virtual void copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics ) SAL_OVERRIDE;
diff --git a/vcl/inc/opengl/x11/gdiimpl.hxx b/vcl/inc/opengl/x11/gdiimpl.hxx
index d25d5d0212ca..f5e5bfb4f2f4 100644
--- a/vcl/inc/opengl/x11/gdiimpl.hxx
+++ b/vcl/inc/opengl/x11/gdiimpl.hxx
@@ -28,12 +28,16 @@ public:
protected:
GLfloat GetWidth() const SAL_OVERRIDE;
GLfloat GetHeight() const SAL_OVERRIDE;
+ bool IsOffscreen() const SAL_OVERRIDE;
+
+ virtual OpenGLContext* CreateWinContext() SAL_OVERRIDE;
+ virtual bool CompareWinContext( OpenGLContext* pContext ) SAL_OVERRIDE;
+ virtual OpenGLContext* CreatePixmapContext() SAL_OVERRIDE;
public:
// implementation of X11GraphicsImpl
virtual void copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics ) SAL_OVERRIDE;
- void Init() SAL_OVERRIDE;
bool FillPixmapFromScreen( X11Pixmap* pPixmap, int nX, int nY ) SAL_OVERRIDE;
bool RenderPixmapToScreen( X11Pixmap* pPixmap, X11Pixmap* pMask, int nX, int nY ) SAL_OVERRIDE;
};
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index 5a7382b5e3fd..a1cd14223909 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -35,9 +35,9 @@ class VCL_PLUGIN_PUBLIC OpenGLSalGraphicsImpl : public SalGraphicsImpl
{
protected:
- OpenGLContext maContext;
SalFrame* mpFrame;
int mnPainting;
+ OpenGLContext* mpContext;
// clipping
bool mbUseScissor;
@@ -144,21 +144,35 @@ public:
// get the height of the device
virtual GLfloat GetHeight() const = 0;
+ // check whether this instance is used for offscreen rendering
+ virtual bool IsOffscreen() const = 0;
+
// operations to do before painting
virtual void PreDraw();
// operations to do after painting
virtual void PostDraw();
- // enable/disable offscreen rendering
- virtual void SetOffscreen( bool bOffscreen );
+protected:
+ bool AcquireContext( bool bOffscreen );
+ bool ReleaseContext();
+
+ // create a new context for window rendering
+ virtual OpenGLContext* CreateWinContext() = 0;
+ // check whether the given context can be used by this instance
+ virtual bool CompareWinContext( OpenGLContext* pContext ) = 0;
+
+ // create a new context for window rendering
+ virtual OpenGLContext* CreatePixmapContext() = 0;
public:
OpenGLSalGraphicsImpl();
virtual ~OpenGLSalGraphicsImpl ();
- OpenGLContext& GetOpenGLContext() { return maContext; }
+ OpenGLContext& GetOpenGLContext() { return *mpContext; }
+
+ virtual void Init() SAL_OVERRIDE;
virtual void freeResources() SAL_OVERRIDE;
diff --git a/vcl/inc/salgdiimpl.hxx b/vcl/inc/salgdiimpl.hxx
index 2fd7f56df28e..e92c65f29738 100644
--- a/vcl/inc/salgdiimpl.hxx
+++ b/vcl/inc/salgdiimpl.hxx
@@ -44,6 +44,8 @@ public:
virtual ~SalGraphicsImpl();
+ virtual void Init() = 0;
+
virtual void freeResources() = 0;
virtual bool setClipRegion( const vcl::Region& ) = 0;
diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx
index c1d9eed2c45d..212e036ea13f 100644
--- a/vcl/inc/svdata.hxx
+++ b/vcl/inc/svdata.hxx
@@ -89,6 +89,7 @@ class SalI18NImeStatus;
class DockingManager;
class VclEventListeners2;
class SalData;
+class OpenGLContext;
namespace vcl { class DisplayConnection; class SettingsConfigItem; class DeleteOnDeinitBase; }
@@ -161,6 +162,8 @@ struct ImplSVGDIData
OutputDevice* mpLastPrnGraphics; // Last OutputDevice with a InfoPrinter Graphics
VirtualDevice* mpFirstVirDev; // First VirtualDevice
VirtualDevice* mpLastVirDev; // Last VirtualDevice
+ OpenGLContext* mpFirstContext; // First OpenGLContext
+ OpenGLContext* mpLastContext; // Last OpenGLContext
Printer* mpFirstPrinter; // First Printer
Printer* mpLastPrinter; // Last Printer
ImplPrnQueueList* mpPrinterQueueList; // List of all printer queue
diff --git a/vcl/inc/unx/x11/x11gdiimpl.h b/vcl/inc/unx/x11/x11gdiimpl.h
index 239d2174b45c..22859c315b6d 100644
--- a/vcl/inc/unx/x11/x11gdiimpl.h
+++ b/vcl/inc/unx/x11/x11gdiimpl.h
@@ -17,7 +17,6 @@ class X11GraphicsImpl
public:
virtual ~X11GraphicsImpl() {};
- virtual void Init() = 0;
virtual bool FillPixmapFromScreen( X11Pixmap* pPixmap, int nX, int nY ) = 0;
virtual bool RenderPixmapToScreen( X11Pixmap* pPixmap, X11Pixmap* pMask, int nX, int nY ) = 0;
};
diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 1af78077584c..443c1c2377af 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -181,6 +181,7 @@ public:
class WinSalGraphics : public SalGraphics
{
friend class WinSalGraphicsImpl;
+ friend class WinOpenGLSalGraphicsImpl;
friend class ScopedFont;
friend class OpenGLCompatibleDC;
friend class WinLayout;
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 54be610d558a..6e6ea5fece18 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -31,6 +31,7 @@
#include <vcl/opengl/OpenGLHelper.hxx>
#include "salgdi.hxx"
+#include "svdata.hxx"
#include "opengl/salbmp.hxx"
#include <glm/glm.hpp>
@@ -63,8 +64,7 @@
1.0f )
OpenGLSalGraphicsImpl::OpenGLSalGraphicsImpl()
- : mpFrame(NULL)
- , mnPainting(0)
+ : mpContext(0)
, mbUseScissor(false)
, mbUseStencil(false)
, mbOffscreen(false)
@@ -109,11 +109,106 @@ OpenGLSalGraphicsImpl::OpenGLSalGraphicsImpl()
OpenGLSalGraphicsImpl::~OpenGLSalGraphicsImpl()
{
+ ReleaseContext();
+}
+
+bool OpenGLSalGraphicsImpl::AcquireContext( bool bOffscreen )
+{
+ ImplSVData* pSVData = ImplGetSVData();
+
+ if( mpContext )
+ mpContext->DeRef();
+
+ if( bOffscreen )
+ {
+ mpContext = CreatePixmapContext();
+ return (mpContext != NULL);
+ }
+
+ OpenGLContext* pContext = pSVData->maGDIData.mpLastContext;
+ while( pContext )
+ {
+ // check if this context can be used by this SalGraphicsImpl instance
+ if( CompareWinContext( pContext ) )
+ break;
+ pContext = pContext->mpPrevContext;
+ }
+
+ if( pContext )
+ pContext->AddRef();
+ else
+ pContext = CreateWinContext();
+
+ mpContext = pContext;
+ return (mpContext != NULL);
+}
+
+bool OpenGLSalGraphicsImpl::ReleaseContext()
+{
+ if( mpContext )
+ mpContext->DeRef();
+ mpContext = NULL;
+ return true;
+}
+
+void OpenGLSalGraphicsImpl::Init()
+{
+ const bool bOffscreen = IsOffscreen();
+
+ // check if we can simply re-use the same context
+ if( mpContext )
+ {
+ if( bOffscreen != mbOffscreen || ( !mbOffscreen && CompareWinContext( mpContext ) ) )
+ ReleaseContext();
+ }
+
+ if( !mpContext && !AcquireContext( bOffscreen ) )
+ {
+ SAL_WARN( "vcl.opengl", "Couldn't acquire context for SalGraphics" );
+ return;
+ }
+
+ mpContext->makeCurrent();
+
+ if( mbOffscreen == bOffscreen )
+ {
+ // Nothing more to do for onscreen case
+ if( !mbOffscreen )
+ return;
+
+ // Already enabled and same size
+ if( maOffscreenTex.GetWidth() == GetWidth() &&
+ maOffscreenTex.GetHeight() == GetHeight() )
+ return;
+ }
+ else
+ {
+ mbOffscreen = bOffscreen;
+ if( bOffscreen )
+ glGenFramebuffers( 1, &mnFramebufferId );
+ else
+ glDeleteFramebuffers( 1, &mnFramebufferId );
+ }
+
+ // Create/update attached offscreen texture
+ if( mbOffscreen )
+ {
+ glBindFramebuffer( GL_FRAMEBUFFER, mnFramebufferId );
+ maOffscreenTex = OpenGLTexture( GetWidth(), GetHeight() );
+ glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, maOffscreenTex.Id(), 0 );
+ GLenum nStatus = glCheckFramebufferStatus( GL_FRAMEBUFFER );
+ if( nStatus != GL_FRAMEBUFFER_COMPLETE )
+ SAL_WARN( "vcl.opengl", "Incomplete framebuffer " << nStatus );
+ glBindFramebuffer( GL_FRAMEBUFFER, 0 );
+ CHECK_GL_ERROR();
+ }
}
void OpenGLSalGraphicsImpl::PreDraw()
{
- maContext.makeCurrent();
+ assert( mpContext && mpContext->isInitialized() );
+
+ mpContext->makeCurrent();
// TODO: lfrb: make sure the render target has the right size
if( mbOffscreen )
CheckOffscreenTexture();
@@ -273,46 +368,17 @@ void OpenGLSalGraphicsImpl::SetROPFillColor( SalROPColor /*nROPColor*/ )
{
}
-// enable/disbale offscreen rendering
-void OpenGLSalGraphicsImpl::SetOffscreen( bool bOffscreen )
-{
- if( bOffscreen == mbOffscreen )
- {
- // Already disabled
- if( !mbOffscreen )
- return;
-
- // Already enabled and same size
- if( maOffscreenTex.GetWidth() == GetWidth() &&
- maOffscreenTex.GetHeight() == GetHeight() )
- return;
- }
- else
- {
- mbOffscreen = bOffscreen;
- if( bOffscreen )
- glGenFramebuffers( 1, &mnFramebufferId );
- else
- glDeleteFramebuffers( 1, &mnFramebufferId );
- }
-
- if( mbOffscreen )
- {
- glBindFramebuffer( GL_FRAMEBUFFER, mnFramebufferId );
- maOffscreenTex = OpenGLTexture( GetWidth(), GetHeight() );
- glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, maOffscreenTex.Id(), 0 );
- glBindFramebuffer( GL_FRAMEBUFFER, 0 );
- }
-
- CHECK_GL_ERROR();
-}
-
bool OpenGLSalGraphicsImpl::CheckOffscreenTexture()
{
glBindFramebuffer( GL_FRAMEBUFFER, mnFramebufferId );
if( maOffscreenTex.IsUnique() )
+ {
+ GLenum nStatus = glCheckFramebufferStatus( GL_FRAMEBUFFER );
+ if( nStatus != GL_FRAMEBUFFER_COMPLETE )
+ SAL_WARN( "vcl.opengl", "Incomplete framebuffer " << nStatus );
return true;
+ }
SalTwoRect aPosAry;
aPosAry.mnSrcX = aPosAry.mnDestX = 0;
@@ -1816,7 +1882,7 @@ void OpenGLSalGraphicsImpl::endPaint()
SAL_INFO( "vcl.opengl", "END PAINT " << this );
if( mnPainting == 0 )
{
- maContext.makeCurrent();
+ mpContext->makeCurrent();
glFlush();
}
}
diff --git a/vcl/opengl/win/gdiimpl.cxx b/vcl/opengl/win/gdiimpl.cxx
index 67a192eb7f12..55b3c5a165ef 100644
--- a/vcl/opengl/win/gdiimpl.cxx
+++ b/vcl/opengl/win/gdiimpl.cxx
@@ -68,4 +68,34 @@ GLfloat WinOpenGLSalGraphicsImpl::GetHeight() const
return 1;
}
+bool WinOpenGLSalGraphicsImpl::IsOffscreen() const
+{
+ WinSalFrame* pFrame = GetWindowPtr( mrParent.gethWnd() );
+ return ( pFrame == NULL );
+}
+
+OpenGLContext* WinOpenGLSalGraphicsImpl::CreateWinContext()
+{
+ OpenGLContext* pContext = new OpenGLContext();
+ pContext->requestSingleBufferedRendering();
+ pContext->init( mrParent.mhLocalDC, mrParent.mhWnd );
+ return pContext;
+}
+
+bool WinOpenGLSalGraphicsImpl::CompareWinContext( OpenGLContext* pContext )
+{
+ if( !pContext || !pContext->isInitialized() )
+ return false;
+ return ( pContext->getOpenGLWindow().hWnd == mrParent.mhWnd );
+}
+
+OpenGLContext* WinOpenGLSalGraphicsImpl::CreatePixmapContext()
+{
+ OpenGLContext* pContext = new OpenGLContext();
+ pContext->requestVirtualDevice();
+ pContext->requestSingleBufferedRendering();
+ pContext->init( mrParent.mhLocalDC, mrParent.mhWnd );
+ return pContext;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/opengl/x11/gdiimpl.cxx b/vcl/opengl/x11/gdiimpl.cxx
index 838be1bad12d..b04bab64e24d 100644
--- a/vcl/opengl/x11/gdiimpl.cxx
+++ b/vcl/opengl/x11/gdiimpl.cxx
@@ -59,31 +59,53 @@ GLfloat X11OpenGLSalGraphicsImpl::GetHeight() const
return 1;
}
-void X11OpenGLSalGraphicsImpl::Init()
+bool X11OpenGLSalGraphicsImpl::IsOffscreen() const
{
X11WindowProvider *pProvider = dynamic_cast<X11WindowProvider*>(mrParent.m_pFrame);
-
- // Called after eg. a vdev re-size where we need to update the underlying pixmap
- maContext.resetToReInitialize();
- if (pProvider)
- {
- Window aWin = pProvider->GetX11Window();
- maContext.init( mrParent.GetXDisplay(), aWin, mrParent.m_nXScreen.getXScreen());
- SetOffscreen( false );
- }
+ if( pProvider )
+ return false;
else if( mrParent.m_pVDev )
- {
- maContext.init( mrParent.GetXDisplay(), mrParent.m_pVDev->GetDrawable(),
- mrParent.m_pVDev->GetWidth(), mrParent.m_pVDev->GetHeight(),
- mrParent.m_nXScreen.getXScreen() );
- SetOffscreen( true );
- }
+ return true;
else
{
SAL_WARN( "vcl.opengl", "what happened here?" );
+ return true;
}
}
+OpenGLContext* X11OpenGLSalGraphicsImpl::CreateWinContext()
+{
+ X11WindowProvider *pProvider = dynamic_cast<X11WindowProvider*>(mrParent.m_pFrame);
+
+ if( !pProvider )
+ return NULL;
+ Window aWin = pProvider->GetX11Window();
+ OpenGLContext* pContext = new OpenGLContext();
+ pContext->init( mrParent.GetXDisplay(), aWin,
+ mrParent.m_nXScreen.getXScreen() );
+ return pContext;
+}
+
+bool X11OpenGLSalGraphicsImpl::CompareWinContext( OpenGLContext* pContext )
+{
+ X11WindowProvider *pProvider = dynamic_cast<X11WindowProvider*>(mrParent.m_pFrame);
+
+ if( !pProvider || !pContext->isInitialized() )
+ return false;
+ return ( pContext->getOpenGLWindow().win == pProvider->GetX11Window() );
+}
+
+OpenGLContext* X11OpenGLSalGraphicsImpl::CreatePixmapContext()
+{
+ if( mrParent.m_pVDev == NULL )
+ return NULL;
+ OpenGLContext* pContext = new OpenGLContext();
+ pContext->init( mrParent.GetXDisplay(), mrParent.m_pVDev->GetDrawable(),
+ mrParent.m_pVDev->GetWidth(), mrParent.m_pVDev->GetHeight(),
+ mrParent.m_nXScreen.getXScreen() );
+ return pContext;
+}
+
void X11OpenGLSalGraphicsImpl::copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics )
{
OpenGLSalGraphicsImpl *pImpl = pSrcGraphics ? dynamic_cast< OpenGLSalGraphicsImpl* >(pSrcGraphics->GetImpl()) : static_cast< OpenGLSalGraphicsImpl *>(mrParent.GetImpl());
@@ -104,7 +126,7 @@ bool X11OpenGLSalGraphicsImpl::FillPixmapFromScreen( X11Pixmap* pPixmap, int nX,
return false;
// make sure everything is synced up before reading back
- maContext.makeCurrent();
+ mpContext->makeCurrent();
glXWaitX();
// TODO: lfrb: What if offscreen?
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index d1c1b729fcaf..9bbe1e2c85a6 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -27,6 +27,8 @@
#include <win/saldata.hxx>
#endif
+#include "svdata.hxx"
+
using namespace com::sun::star;
// TODO use rtl::Static instead of 'static'
@@ -47,13 +49,26 @@ OpenGLContext::OpenGLContext():
mpWindow(NULL),
m_pChildWindow(NULL),
mbInitialized(false),
+ mnRefCount(1),
mbRequestLegacyContext(false),
mbUseDoubleBufferedRendering(true),
- mbRequestVirtualDevice(false)
+ mbRequestVirtualDevice(false),
+ mpPrevContext(NULL),
+ mpNextContext(NULL)
{
#if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID
mbPixmap = false;
#endif
+
+ ImplSVData* pSVData = ImplGetSVData();
+ if( pSVData->maGDIData.mpLastContext )
+ {
+ pSVData->maGDIData.mpLastContext->mpNextContext = this;
+ mpPrevContext = pSVData->maGDIData.mpLastContext;
+ }
+ else
+ pSVData->maGDIData.mpFirstContext = this;
+ pSVData->maGDIData.mpLastContext = this;
}
OpenGLContext::~OpenGLContext()
@@ -67,6 +82,16 @@ OpenGLContext::~OpenGLContext()
wglDeleteContext( m_aGLWin.hRC );
ReleaseDC( m_aGLWin.hWnd, m_aGLWin.hDC );
}
+ ImplSVData* pSVData = ImplGetSVData();
+ if( mpPrevContext )
+ mpPrevContext->mpNextContext = mpNextContext;
+ else
+ pSVData->maGDIData.mpFirstContext = mpNextContext;
+ if( mpNextContext )
+ mpNextContext->mpPrevContext = mpPrevContext;
+ else
+ pSVData->maGDIData.mpLastContext = mpPrevContext;
+
#elif defined( MACOSX )
OpenGLWrapper::resetCurrent();
#elif defined( IOS ) || defined( ANDROID )
@@ -89,6 +114,17 @@ OpenGLContext::~OpenGLContext()
#endif
}
+void OpenGLContext::AddRef()
+{
+ mnRefCount++;
+}
+
+void OpenGLContext::DeRef()
+{
+ if( --mnRefCount == 0 )
+ delete this;
+}
+
void OpenGLContext::requestLegacyContext()
{
mbRequestLegacyContext = true;
diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx
index 34df86ddd770..3c1a7279c421 100644
--- a/vcl/unx/generic/gdi/salgdi.cxx
+++ b/vcl/unx/generic/gdi/salgdi.cxx
@@ -150,7 +150,7 @@ void X11SalGraphics::SetDrawable( Drawable aDrawable, SalX11Screen nXScreen )
if( hDrawable_ )
{
- dynamic_cast<X11GraphicsImpl&>(*mpImpl.get()).Init();
+ mpImpl->Init();
// TODO: moggi: FIXME nTextPixel_ = GetPixel( nTextColor_ );
}
}
diff --git a/vcl/win/source/gdi/gdiimpl.cxx b/vcl/win/source/gdi/gdiimpl.cxx
index 8a4b39062363..e17b3e11eead 100644
--- a/vcl/win/source/gdi/gdiimpl.cxx
+++ b/vcl/win/source/gdi/gdiimpl.cxx
@@ -294,6 +294,10 @@ WinSalGraphicsImpl::~WinSalGraphicsImpl()
}
+void WinSalGraphicsImpl::Init()
+{
+}
+
void WinSalGraphicsImpl::freeResources()
{
}
diff --git a/vcl/win/source/gdi/gdiimpl.hxx b/vcl/win/source/gdi/gdiimpl.hxx
index ded35ac85041..65e9d3f73bb3 100644
--- a/vcl/win/source/gdi/gdiimpl.hxx
+++ b/vcl/win/source/gdi/gdiimpl.hxx
@@ -52,6 +52,8 @@ public:
virtual ~WinSalGraphicsImpl();
+ virtual void Init() SAL_OVERRIDE;
+
virtual void freeResources() SAL_OVERRIDE;
virtual bool setClipRegion( const vcl::Region& ) SAL_OVERRIDE;
diff --git a/vcl/win/source/gdi/salgdi.cxx b/vcl/win/source/gdi/salgdi.cxx
index 678067d1add3..05279d10494c 100644
--- a/vcl/win/source/gdi/salgdi.cxx
+++ b/vcl/win/source/gdi/salgdi.cxx
@@ -482,15 +482,7 @@ void WinSalGraphics::InitGraphics()
::SetTextAlign( getHDC(), TA_BASELINE | TA_LEFT | TA_NOUPDATECP );
::SetBkMode( getHDC(), WIN32_TRANSPARENT );
::SetROP2( getHDC(), R2_COPYPEN );
-
- OpenGLSalGraphicsImpl* pImpl = dynamic_cast<OpenGLSalGraphicsImpl*>(mpImpl.get());
- if (pImpl)
- {
- if (mbVirDev)
- pImpl->GetOpenGLContext().requestVirtualDevice();
- pImpl->GetOpenGLContext().requestSingleBufferedRendering();
- pImpl->GetOpenGLContext().init(mhLocalDC, mhWnd);
- }
+ mpImpl->Init();
}
void WinSalGraphics::DeInitGraphics()