From b1cfad5e8b38fc02de498993cf46e2404ced1058 Mon Sep 17 00:00:00 2001 From: Louis-Francis Ratté-Boulianne Date: Tue, 2 Dec 2014 09:05:19 -0500 Subject: vcl: Don't create new contexts for Virtual Devices on Windows Change-Id: I561a8142f986aca89e796ce2c4a0902fae41f9e6 --- vcl/inc/opengl/win/gdiimpl.hxx | 1 - vcl/inc/opengl/x11/gdiimpl.hxx | 1 - vcl/inc/openglgdiimpl.hxx | 6 +++--- vcl/opengl/gdiimpl.cxx | 16 ++++++---------- vcl/opengl/win/gdiimpl.cxx | 11 ++--------- vcl/opengl/x11/gdiimpl.cxx | 10 ---------- vcl/source/opengl/OpenGLContext.cxx | 11 ----------- 7 files changed, 11 insertions(+), 45 deletions(-) (limited to 'vcl') diff --git a/vcl/inc/opengl/win/gdiimpl.hxx b/vcl/inc/opengl/win/gdiimpl.hxx index 30ade233b543..03007c9ad188 100644 --- a/vcl/inc/opengl/win/gdiimpl.hxx +++ b/vcl/inc/opengl/win/gdiimpl.hxx @@ -30,7 +30,6 @@ public: protected: virtual OpenGLContext* CreateWinContext() SAL_OVERRIDE; virtual bool UseContext( 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 d6ef0101920b..feb3961a5e71 100644 --- a/vcl/inc/opengl/x11/gdiimpl.hxx +++ b/vcl/inc/opengl/x11/gdiimpl.hxx @@ -27,7 +27,6 @@ public: protected: virtual OpenGLContext* CreateWinContext() SAL_OVERRIDE; - virtual OpenGLContext* CreatePixmapContext() SAL_OVERRIDE; virtual bool UseContext( OpenGLContext* pContext ) SAL_OVERRIDE; public: diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx index d328ab724b2f..03d1c239b0d6 100644 --- a/vcl/inc/openglgdiimpl.hxx +++ b/vcl/inc/openglgdiimpl.hxx @@ -110,12 +110,12 @@ protected: bool AcquireContext(); bool ReleaseContext(); + // retrieve the default context for offscreen rendering + virtual OpenGLContext* GetDefaultContext(); + // create a new context for window rendering virtual OpenGLContext* CreateWinContext() = 0; - // create a new context for offscreen rendering - virtual OpenGLContext* CreatePixmapContext() = 0; - // check whether the given context can be used by this instance virtual bool UseContext( OpenGLContext* pContext ) = 0; diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index 970957cf1555..e836e821f82f 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -61,6 +61,11 @@ OpenGLContext* OpenGLSalGraphicsImpl::GetOpenGLContext() return mpContext; } +OpenGLContext* OpenGLSalGraphicsImpl::GetDefaultContext() +{ + return ImplGetDefaultWindow()->GetGraphics()->GetOpenGLContext(); +} + bool OpenGLSalGraphicsImpl::AcquireContext( ) { ImplSVData* pSVData = ImplGetSVData(); @@ -81,7 +86,7 @@ bool OpenGLSalGraphicsImpl::AcquireContext( ) if( pContext ) pContext->AddRef(); else - pContext = mbOffscreen ? CreatePixmapContext() : CreateWinContext(); + pContext = mbOffscreen ? GetDefaultContext() : CreateWinContext(); mpContext = pContext; return (mpContext != NULL); @@ -112,15 +117,6 @@ void OpenGLSalGraphicsImpl::Init() maOffscreenTex.GetHeight() != GetHeight() ) { maOffscreenTex = OpenGLTexture(); -#if defined(WNT) - // URGH ... VirtualDevice may have destroyed the underlying resource - // our context is associated with - FIXME: can we do better here ? - if (mpContext) - { - mpContext->resetToReInitialize(); - ReleaseContext(); - } -#endif } } diff --git a/vcl/opengl/win/gdiimpl.cxx b/vcl/opengl/win/gdiimpl.cxx index 939d4e0a1c50..a56ea3063b14 100644 --- a/vcl/opengl/win/gdiimpl.cxx +++ b/vcl/opengl/win/gdiimpl.cxx @@ -38,16 +38,9 @@ bool WinOpenGLSalGraphicsImpl::UseContext( OpenGLContext* pContext ) { if( !pContext || !pContext->isInitialized() ) return false; + if( IsOffscreen() ) + return true; 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 e5070d7b02c7..d0d890b97fc6 100644 --- a/vcl/opengl/x11/gdiimpl.cxx +++ b/vcl/opengl/x11/gdiimpl.cxx @@ -56,16 +56,6 @@ OpenGLContext* X11OpenGLSalGraphicsImpl::CreateWinContext() return pContext; } -OpenGLContext* X11OpenGLSalGraphicsImpl::CreatePixmapContext() -{ - X11OpenGLSalVirtualDevice* pVDev = dynamic_cast(mrParent.m_pVDev); - - if( pVDev == NULL ) - return NULL; - - return ImplGetDefaultWindow()->GetGraphics()->GetOpenGLContext(); -} - bool X11OpenGLSalGraphicsImpl::UseContext( OpenGLContext* pContext ) { X11WindowProvider *pProvider = dynamic_cast(mrParent.m_pFrame); diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx index 01b74b9f6900..16db85f9d9ef 100644 --- a/vcl/source/opengl/OpenGLContext.cxx +++ b/vcl/source/opengl/OpenGLContext.cxx @@ -634,17 +634,6 @@ bool OpenGLContext::init(SystemChildWindow* pChildWindow) return ImplInit(); } -#if defined( WNT ) -// FIXME share resetToReInitialize() across platforms... -void OpenGLContext::resetToReInitialize() -{ - if( !mbInitialized ) - return; - resetCurrent(); - mbInitialized = false; -} -#endif - #if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID bool OpenGLContext::init(Display* dpy, Window win, int screen) { -- cgit v1.2.3