summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2015-09-07 22:21:15 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-09-11 09:48:21 +0000
commit3265f2b2ea074965e145496c219360819996d432 (patch)
tree0738e921f36bbf6d6ab86f90a413c34375d50bd6
parent24b7b71fb21923d964d31d4aa46fff9be75a0118 (diff)
tdf#94006 - re-factor and fix OpenGLContext mis-use.
Squashes two related patches from master: Don't use rtl::Reference for the global / list state, so the ref-count reflects the number of real users. Hold a reference during ~OpenGLContext. Fix mis-use in: gltf rendering, OpenGL canvas, GL transitions & GL capable (charts) Avoid GLX operations on un-initialized contexts. Signed-off-by: Miklos Vajna <vmiklos@collabora.co.uk> Conflicts: vcl/source/opengl/OpenGLContext.cxx vcl/workben/vcldemo.cxx canvas/source/opengl/ogl_spritedevicehelper.hxx Change-Id: I7ea29b544d53bb80b25fa6663d39f345bf8f4e64 Reviewed-on: https://gerrit.libreoffice.org/18443 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--avmedia/source/opengl/oglplayer.cxx15
-rw-r--r--avmedia/source/opengl/oglplayer.hxx2
-rw-r--r--avmedia/source/opengl/oglwindow.cxx10
-rw-r--r--avmedia/source/opengl/oglwindow.hxx4
-rw-r--r--canvas/source/opengl/ogl_spritedevicehelper.cxx33
-rw-r--r--canvas/source/opengl/ogl_spritedevicehelper.hxx2
-rw-r--r--include/vcl/opengl/OpenGLContext.hxx19
-rw-r--r--slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx8
-rw-r--r--svx/inc/svdoopengl.hxx4
-rw-r--r--svx/source/sdr/contact/viewobjectcontactofopenglobj.cxx4
-rw-r--r--svx/source/svdraw/svdoopengl.cxx7
-rw-r--r--vcl/inc/opengl/salbmp.hxx4
-rw-r--r--vcl/inc/opengl/win/gdiimpl.hxx7
-rw-r--r--vcl/inc/opengl/x11/gdiimpl.hxx4
-rw-r--r--vcl/inc/openglgdiimpl.hxx10
-rw-r--r--vcl/inc/salgdi.hxx2
-rw-r--r--vcl/opengl/gdiimpl.cxx47
-rw-r--r--vcl/opengl/salbmp.cxx16
-rw-r--r--vcl/opengl/texture.cxx6
-rw-r--r--vcl/opengl/win/gdiimpl.cxx10
-rw-r--r--vcl/opengl/x11/gdiimpl.cxx10
-rw-r--r--vcl/source/app/svdata.cxx12
-rw-r--r--vcl/source/gdi/salgdilayout.cxx2
-rw-r--r--vcl/source/opengl/OpenGLContext.cxx66
-rw-r--r--vcl/source/window/openglwin.cxx7
-rw-r--r--vcl/unx/generic/window/salframe.cxx4
-rw-r--r--vcl/workben/vcldemo.cxx7
27 files changed, 141 insertions, 181 deletions
diff --git a/avmedia/source/opengl/oglplayer.cxx b/avmedia/source/opengl/oglplayer.cxx
index f1a3adad1376..7d04807b6b72 100644
--- a/avmedia/source/opengl/oglplayer.cxx
+++ b/avmedia/source/opengl/oglplayer.cxx
@@ -28,6 +28,7 @@ namespace avmedia { namespace ogl {
OGLPlayer::OGLPlayer()
: Player_BASE(m_aMutex)
, m_pHandle(NULL)
+ , m_xContext(OpenGLContext::Create())
, m_pOGLWindow(NULL)
, m_bIsRendering(false)
{
@@ -38,7 +39,7 @@ OGLPlayer::~OGLPlayer()
osl::MutexGuard aGuard(m_aMutex);
if( m_pHandle )
{
- m_aContext.makeCurrent();
+ m_xContext->makeCurrent();
gltf_renderer_release(m_pHandle);
}
releaseInputFiles();
@@ -258,13 +259,13 @@ uno::Reference< media::XPlayerWindow > SAL_CALL OGLPlayer::createPlayerWindow( c
}
assert(pChildWindow->GetParent());
- if( !m_aContext.init(pChildWindow) )
+ if( !m_xContext->init(pChildWindow) )
{
SAL_WARN("avmedia.opengl", "Context initialization failed");
return uno::Reference< media::XPlayerWindow >();
}
- if( !m_aContext.supportMultiSampling() )
+ if( !m_xContext->supportMultiSampling() )
{
SAL_WARN("avmedia.opengl", "Context does not support multisampling!");
return uno::Reference< media::XPlayerWindow >();
@@ -277,7 +278,7 @@ uno::Reference< media::XPlayerWindow > SAL_CALL OGLPlayer::createPlayerWindow( c
}
Size aSize = pChildWindow->GetSizePixel();
- m_aContext.setWinSize(aSize);
+ m_xContext->setWinSize(aSize);
m_pHandle->viewport.x = 0;
m_pHandle->viewport.y = 0;
m_pHandle->viewport.width = aSize.Width();
@@ -294,7 +295,7 @@ uno::Reference< media::XPlayerWindow > SAL_CALL OGLPlayer::createPlayerWindow( c
// The background color is white by default, but we need to separate the
// OpenGL window from the main window so set background color to grey
glClearColor(0.5f, 0.5f, 0.5f, 0.5f);
- m_pOGLWindow = new OGLWindow(*m_pHandle, m_aContext, *pChildWindow->GetParent());
+ m_pOGLWindow = new OGLWindow(*m_pHandle, m_xContext, *pChildWindow->GetParent());
return uno::Reference< media::XPlayerWindow >( m_pOGLWindow );
}
@@ -304,13 +305,13 @@ uno::Reference< media::XFrameGrabber > SAL_CALL OGLPlayer::createFrameGrabber()
osl::MutexGuard aGuard(m_aMutex);
assert(m_pHandle);
- if( !m_aContext.init() )
+ if( !m_xContext->init() )
{
SAL_WARN("avmedia.opengl", "Offscreen context initialization failed");
return uno::Reference< media::XFrameGrabber >();
}
- if( !m_aContext.supportMultiSampling() )
+ if( !m_xContext->supportMultiSampling() )
{
SAL_WARN("avmedia.opengl", "Context does not support multisampling!");
return uno::Reference< media::XFrameGrabber >();
diff --git a/avmedia/source/opengl/oglplayer.hxx b/avmedia/source/opengl/oglplayer.hxx
index 605233d47f92..212633935d5c 100644
--- a/avmedia/source/opengl/oglplayer.hxx
+++ b/avmedia/source/opengl/oglplayer.hxx
@@ -69,7 +69,7 @@ private:
libgltf::glTFHandle* m_pHandle;
std::vector<libgltf::glTFFile> m_vInputFiles;
- OpenGLContext m_aContext;
+ rtl::Reference<OpenGLContext> m_xContext;
AutoTimer m_aTimer;
OGLWindow* m_pOGLWindow;
bool m_bIsRendering;
diff --git a/avmedia/source/opengl/oglwindow.cxx b/avmedia/source/opengl/oglwindow.cxx
index 956ce967d0b1..fe637f882c46 100644
--- a/avmedia/source/opengl/oglwindow.cxx
+++ b/avmedia/source/opengl/oglwindow.cxx
@@ -15,9 +15,9 @@ using namespace libgltf;
namespace avmedia { namespace ogl {
-OGLWindow::OGLWindow( glTFHandle& rHandle, OpenGLContext& rContext, vcl::Window& rEventHandlerParent )
+OGLWindow::OGLWindow( glTFHandle& rHandle, const rtl::Reference<OpenGLContext> &rContext, vcl::Window& rEventHandlerParent )
: m_rHandle( rHandle )
- , m_rContext( rContext )
+ , m_xContext( rContext )
, m_rEventHandler( rEventHandlerParent )
, m_bVisible ( false )
, m_aLastMousePos(Point(0,0))
@@ -32,7 +32,7 @@ OGLWindow::~OGLWindow()
void SAL_CALL OGLWindow::update() throw (css::uno::RuntimeException, std::exception)
{
- m_rContext.makeCurrent();
+ m_xContext->makeCurrent();
int nRet = gltf_prepare_renderer(&m_rHandle);
if( nRet != 0 )
{
@@ -41,7 +41,7 @@ void SAL_CALL OGLWindow::update() throw (css::uno::RuntimeException, std::except
}
gltf_renderer(&m_rHandle);
gltf_complete_renderer(&m_rHandle);
- m_rContext.swapBuffers();
+ m_xContext->swapBuffers();
}
sal_Bool SAL_CALL OGLWindow::setZoomLevel( css::media::ZoomLevel /*eZoomLevel*/ ) throw (css::uno::RuntimeException, std::exception)
@@ -98,7 +98,7 @@ void SAL_CALL OGLWindow::setPosSize( sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidt
if( m_rHandle.viewport.x != nX || m_rHandle.viewport.x != nY ||
m_rHandle.viewport.width != nWidth || m_rHandle.viewport.height != nHeight )
{
- m_rContext.setWinSize(Size(nWidth,nHeight));
+ m_xContext->setWinSize(Size(nWidth,nHeight));
m_rHandle.viewport.x = nX;
m_rHandle.viewport.y = nY;
m_rHandle.viewport.width = nWidth;
diff --git a/avmedia/source/opengl/oglwindow.hxx b/avmedia/source/opengl/oglwindow.hxx
index 5b0e151c9b84..0b1d1e189298 100644
--- a/avmedia/source/opengl/oglwindow.hxx
+++ b/avmedia/source/opengl/oglwindow.hxx
@@ -28,7 +28,7 @@ class OGLWindow : public ::cppu::WeakImplHelper2 < com::sun::star::media::XPlaye
com::sun::star::lang::XServiceInfo >
{
public:
- OGLWindow( libgltf::glTFHandle& rHandle, OpenGLContext& rContext, vcl::Window& rEventHandlerParent );
+ OGLWindow( libgltf::glTFHandle& rHandle, const rtl::Reference<OpenGLContext> & rContext, vcl::Window& rEventHandlerParent );
virtual ~OGLWindow();
virtual void SAL_CALL update() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
@@ -67,7 +67,7 @@ private:
DECL_LINK( CameraHandler, VclWindowEvent* );
libgltf::glTFHandle& m_rHandle;
- OpenGLContext& m_rContext;
+ rtl::Reference<OpenGLContext> m_xContext;
vcl::Window& m_rEventHandler;
bool m_bVisible;
diff --git a/canvas/source/opengl/ogl_spritedevicehelper.cxx b/canvas/source/opengl/ogl_spritedevicehelper.cxx
index 37122d8740ca..091279c27242 100644
--- a/canvas/source/opengl/ogl_spritedevicehelper.cxx
+++ b/canvas/source/opengl/ogl_spritedevicehelper.cxx
@@ -87,7 +87,8 @@ namespace oglcanvas
mnRadialTwoColorGradientProgram(0),
mnRadialMultiColorGradientProgram(0),
mnRectangularTwoColorGradientProgram(0),
- mnRectangularMultiColorGradientProgram(0)
+ mnRectangularMultiColorGradientProgram(0),
+ mxContext(OpenGLContext::Create())
{}
SpriteDeviceHelper::~SpriteDeviceHelper()
@@ -104,8 +105,8 @@ namespace oglcanvas
VCLUnoHelper::GetInterface(&rWindow),
uno::UNO_QUERY_THROW) );
- maContext.requestLegacyContext();
- maContext.init(&rWindow);
+ mxContext->requestLegacyContext();
+ mxContext->init(&rWindow);
// init window context
initContext();
@@ -127,7 +128,7 @@ namespace oglcanvas
mnRectangularTwoColorGradientProgram =
OpenGLHelper::LoadShaders("dummyVertexShader", "rectangularTwoColorGradientFragmentShader");
- maContext.makeCurrent();
+ mxContext->makeCurrent();
notifySizeUpdate(rViewArea);
// TODO(E3): check for GL_ARB_imaging extension
@@ -140,7 +141,7 @@ namespace oglcanvas
mpDevice = NULL;
mpTextureCache.reset();
- if( maContext.isInitialized() )
+ if( mxContext->isInitialized() )
{
glDeleteProgram( mnRectangularTwoColorGradientProgram );
glDeleteProgram( mnRectangularMultiColorGradientProgram );
@@ -153,11 +154,11 @@ namespace oglcanvas
geometry::RealSize2D SpriteDeviceHelper::getPhysicalResolution()
{
- if( !maContext.isInitialized() )
+ if( !mxContext->isInitialized() )
return ::canvas::tools::createInfiniteSize2D(); // we're disposed
// Map a one-by-one millimeter box to pixel
- SystemChildWindow* pChildWindow = maContext.getChildWindow();
+ SystemChildWindow* pChildWindow = mxContext->getChildWindow();
const MapMode aOldMapMode( pChildWindow->GetMapMode() );
pChildWindow->SetMapMode( MapMode(MAP_MM) );
const Size aPixelSize( pChildWindow->LogicToPixel(Size(1,1)) );
@@ -168,11 +169,11 @@ namespace oglcanvas
geometry::RealSize2D SpriteDeviceHelper::getPhysicalSize()
{
- if( !maContext.isInitialized() )
+ if( !mxContext->isInitialized() )
return ::canvas::tools::createInfiniteSize2D(); // we're disposed
// Map the pixel dimensions of the output window to millimeter
- SystemChildWindow* pChildWindow = maContext.getChildWindow();
+ SystemChildWindow* pChildWindow = mxContext->getChildWindow();
const MapMode aOldMapMode( pChildWindow->GetMapMode() );
pChildWindow->SetMapMode( MapMode(MAP_MM) );
const Size aLogSize( pChildWindow->PixelToLogic(pChildWindow->GetOutputSizePixel()) );
@@ -273,13 +274,13 @@ namespace oglcanvas
bool SpriteDeviceHelper::showBuffer( bool bIsVisible, bool /*bUpdateAll*/ )
{
// hidden or disposed?
- if( !bIsVisible || !maContext.isInitialized() || !mpSpriteCanvas )
+ if( !bIsVisible || !mxContext->isInitialized() || !mpSpriteCanvas )
return false;
if( !activateWindowContext() )
return false;
- SystemChildWindow* pChildWindow = maContext.getChildWindow();
+ SystemChildWindow* pChildWindow = mxContext->getChildWindow();
const ::Size& rOutputSize = pChildWindow->GetSizePixel();
initTransformation(rOutputSize);
@@ -329,7 +330,7 @@ namespace oglcanvas
unx::glXWaitGL();
XSync( reinterpret_cast<unx::Display*>(mpDisplay), false );
*/
- maContext.swapBuffers();
+ mxContext->swapBuffers();
// flush texture cache, such that it does not build up
// indefinitely.
@@ -353,7 +354,7 @@ namespace oglcanvas
uno::Any SpriteDeviceHelper::getDeviceHandle() const
{
- const SystemChildWindow* pChildWindow = maContext.getChildWindow();
+ const SystemChildWindow* pChildWindow = mxContext->getChildWindow();
return uno::makeAny( reinterpret_cast< sal_Int64 >(pChildWindow) );
}
@@ -372,9 +373,9 @@ namespace oglcanvas
void SpriteDeviceHelper::notifySizeUpdate( const awt::Rectangle& rBounds )
{
- if( maContext.isInitialized() )
+ if( mxContext->isInitialized() )
{
- SystemChildWindow* pChildWindow = maContext.getChildWindow();
+ SystemChildWindow* pChildWindow = mxContext->getChildWindow();
pChildWindow->setPosSizePixel(
0,0,rBounds.Width,rBounds.Height);
}
@@ -509,7 +510,7 @@ namespace oglcanvas
bool SpriteDeviceHelper::activateWindowContext()
{
- maContext.makeCurrent();
+ mxContext->makeCurrent();
return true;
}
diff --git a/canvas/source/opengl/ogl_spritedevicehelper.hxx b/canvas/source/opengl/ogl_spritedevicehelper.hxx
index b1a988d51305..3d05f23b7445 100644
--- a/canvas/source/opengl/ogl_spritedevicehelper.hxx
+++ b/canvas/source/opengl/ogl_spritedevicehelper.hxx
@@ -140,7 +140,7 @@ namespace oglcanvas
unsigned int mnRectangularTwoColorGradientProgram;
unsigned int mnRectangularMultiColorGradientProgram;
- OpenGLContext maContext;
+ rtl::Reference<OpenGLContext> mxContext;
};
}
diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index dd96150657e5..88e9e71c5fa4 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -56,6 +56,7 @@ class NSOpenGLView;
#include <vcl/window.hxx>
#include <tools/gen.hxx>
#include <vcl/syschild.hxx>
+#include <rtl/ref.hxx>
#include <set>
@@ -168,9 +169,12 @@ struct GLWindow
class VCL_DLLPUBLIC OpenGLContext
{
friend class OpenGLTests;
-public:
OpenGLContext();
+public:
+ static rtl::Reference<OpenGLContext> Create();
~OpenGLContext();
+ void acquire() { mnRefCount++; }
+ void release() { if ( --mnRefCount == 0 ) delete this; }
void requestLegacyContext();
void requestSingleBufferedRendering();
@@ -196,13 +200,7 @@ public:
OpenGLFramebuffer* AcquireFramebuffer( const OpenGLTexture& rTexture );
static void ReleaseFramebuffer( OpenGLFramebuffer* pFramebuffer );
void UnbindTextureFromFramebuffers( GLuint nTexture );
-#ifdef DBG_UTIL
- void AddRef(SalGraphicsImpl*);
- void DeRef(SalGraphicsImpl*);
-#else
- void AddRef();
- void DeRef();
-#endif
+
void ReleaseFramebuffer( const OpenGLTexture& rTexture );
void ReleaseFramebuffers();
@@ -295,8 +293,9 @@ public:
vcl::Region maClipRegion;
int mnPainting;
- OpenGLContext* mpPrevContext;
- OpenGLContext* mpNextContext;
+ // Don't hold references to ourselves:
+ OpenGLContext *mpPrevContext;
+ OpenGLContext *mpNextContext;
};
#endif
diff --git a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx
index 50a89061af9a..9f2b60b6649d 100644
--- a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx
+++ b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx
@@ -228,7 +228,7 @@ private:
void impl_finishTransition();
private:
- boost::shared_ptr<OpenGLContext> mpContext;
+ rtl::Reference<OpenGLContext> mpContext;
/** OpenGL handle to the leaving slide's texture
*/
@@ -368,7 +368,7 @@ bool OGLTransitionerImpl::initWindowFromSlideShowView( const Reference< presenta
sal_Int64 aVal = 0;
aDeviceParams[1] >>= aVal;
- mpContext = boost::make_shared<OpenGLContext>();
+ mpContext = OpenGLContext::Create();
mpContext->requestLegacyContext();
if( !mpContext->init( reinterpret_cast< vcl::Window* >( aVal ) ) )
@@ -1323,7 +1323,7 @@ void OGLTransitionerImpl::impl_dispose()
{
impl_finishTransition();
disposeTextures();
- mpContext.reset();
+ mpContext.clear();
}
// we are about to be disposed (someone call dispose() on us)
@@ -1350,7 +1350,7 @@ void OGLTransitionerImpl::disposing()
#endif
#if defined( UNX ) && !defined( MACOSX )
- if( mbRestoreSync && bool(mpContext) ) {
+ if( mbRestoreSync && bool(mpContext.is()) ) {
// try to reestablish synchronize state
char* sal_synchronize = getenv("SAL_SYNCHRONIZE");
XSynchronize( mpContext->getOpenGLWindow().dpy, sal_synchronize && *sal_synchronize == '1' );
diff --git a/svx/inc/svdoopengl.hxx b/svx/inc/svdoopengl.hxx
index e30baeacfd0a..8a438ccd24c4 100644
--- a/svx/inc/svdoopengl.hxx
+++ b/svx/inc/svdoopengl.hxx
@@ -30,7 +30,7 @@ public:
virtual ~SdrOpenGLObj();
virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact() SAL_OVERRIDE;
- OpenGLContext* getOpenGLContext() { return mpContext;}
+ rtl::Reference<OpenGLContext> getOpenGLContext() { return mpContext;}
virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) SAL_OVERRIDE;
@@ -41,7 +41,7 @@ public:
private:
- OpenGLContext* mpContext;
+ rtl::Reference<OpenGLContext> mpContext;
boost::scoped_ptr<IOpenGLRenderer> mpRenderer;
};
diff --git a/svx/source/sdr/contact/viewobjectcontactofopenglobj.cxx b/svx/source/sdr/contact/viewobjectcontactofopenglobj.cxx
index 68d7ba130b2f..03c64809ef1d 100644
--- a/svx/source/sdr/contact/viewobjectcontactofopenglobj.cxx
+++ b/svx/source/sdr/contact/viewobjectcontactofopenglobj.cxx
@@ -24,8 +24,8 @@ ViewObjectContactOfOpenGLObj::ViewObjectContactOfOpenGLObj(
: ViewObjectContactOfSdrObj( rObjectContact, rViewContact )
{
#if HAVE_FEATURE_DESKTOP
- OpenGLContext* pContext = static_cast<SdrOpenGLObj&>(static_cast<ViewContactOfSdrObj&>(rViewContact).GetSdrObject()).getOpenGLContext();
- if (pContext)
+ rtl::Reference<OpenGLContext> pContext = static_cast<SdrOpenGLObj&>(static_cast<ViewContactOfSdrObj&>(rViewContact).GetSdrObject()).getOpenGLContext();
+ if (pContext.is())
pContext->init(getWindow());
#endif
}
diff --git a/svx/source/svdraw/svdoopengl.cxx b/svx/source/svdraw/svdoopengl.cxx
index 1b3398359c83..c84f8fb98887 100644
--- a/svx/source/svdraw/svdoopengl.cxx
+++ b/svx/source/svdraw/svdoopengl.cxx
@@ -20,13 +20,12 @@ SdrOpenGLObj::SdrOpenGLObj()
mpContext(NULL)
{
#if HAVE_FEATURE_DESKTOP
- mpContext = new OpenGLContext;
+ mpContext = OpenGLContext::Create();
#endif
}
SdrOpenGLObj::~SdrOpenGLObj()
{
- delete mpContext;
}
sdr::contact::ViewContact* SdrOpenGLObj::CreateObjectSpecificViewContact()
@@ -40,7 +39,7 @@ void SdrOpenGLObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fra
SdrObject::NbcResize(rRef, xFact, yFact);
// now pass the information to the OpenGL context
- if (mpContext)
+ if (mpContext.is())
mpContext->setWinSize(aOutRect.GetSize());
SAL_WARN("svx.opengl", "resized opengl drawinglayer object");
@@ -59,7 +58,7 @@ IOpenGLRenderer* SdrOpenGLObj::getRenderer()
bool SdrOpenGLObj::isOpenGLInitialized()
{
- return mpContext && mpContext->isInitialized();
+ return mpContext.is() && mpContext->isInitialized();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/opengl/salbmp.hxx b/vcl/inc/opengl/salbmp.hxx
index 602d47b7c449..3dd31a2783f1 100644
--- a/vcl/inc/opengl/salbmp.hxx
+++ b/vcl/inc/opengl/salbmp.hxx
@@ -39,7 +39,7 @@ class BitmapPalette;
class VCL_PLUGIN_PUBLIC OpenGLSalBitmap : public SalBitmap
{
private:
- OpenGLContext* mpContext;
+ rtl::Reference<OpenGLContext> mpContext;
OpenGLTexture maTexture;
bool mbDirtyTexture;
BitmapPalette maPalette;
@@ -91,7 +91,7 @@ public:
bool Create( const OpenGLTexture& rTex, long nX, long nY, long nWidth, long nHeight );
OpenGLTexture& GetTexture() const;
- static OpenGLContext* GetBitmapContext();
+ static rtl::Reference<OpenGLContext> GetBitmapContext();
private:
diff --git a/vcl/inc/opengl/win/gdiimpl.hxx b/vcl/inc/opengl/win/gdiimpl.hxx
index e1fa195286a6..04bb15194de6 100644
--- a/vcl/inc/opengl/win/gdiimpl.hxx
+++ b/vcl/inc/opengl/win/gdiimpl.hxx
@@ -14,8 +14,7 @@
#include "openglgdiimpl.hxx"
#include "win/salgdi.h"
-
-class OpenGLContext;
+#include <vcl/opengl/OpenGLContext.hxx>
class WinOpenGLSalGraphicsImpl : public OpenGLSalGraphicsImpl
{
@@ -31,8 +30,8 @@ public:
SalGeometryProvider *mpProvider);
protected:
- virtual OpenGLContext* CreateWinContext() SAL_OVERRIDE;
- virtual bool UseContext( OpenGLContext* pContext ) SAL_OVERRIDE;
+ virtual rtl::Reference<OpenGLContext> CreateWinContext() SAL_OVERRIDE;
+ virtual bool UseContext( const rtl::Reference<OpenGLContext> &pContext ) 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 a87a9dec2de2..19804a8aff17 100644
--- a/vcl/inc/opengl/x11/gdiimpl.hxx
+++ b/vcl/inc/opengl/x11/gdiimpl.hxx
@@ -28,8 +28,8 @@ public:
virtual ~X11OpenGLSalGraphicsImpl();
protected:
- virtual OpenGLContext* CreateWinContext() SAL_OVERRIDE;
- virtual bool UseContext( OpenGLContext* pContext ) SAL_OVERRIDE;
+ virtual rtl::Reference<OpenGLContext> CreateWinContext() SAL_OVERRIDE;
+ virtual bool UseContext( const rtl::Reference<OpenGLContext> &pContext ) SAL_OVERRIDE;
bool RenderPixmap(X11Pixmap* pPixmap, X11Pixmap* pMask, int nX, int nY, TextureCombo& rCombo);
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index 2ed88f1ee645..e16dd611dd77 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -52,7 +52,7 @@ class VCL_DLLPUBLIC OpenGLSalGraphicsImpl : public SalGraphicsImpl
friend class OpenGLTests;
protected:
- OpenGLContext* mpContext;
+ rtl::Reference<OpenGLContext> mpContext;
SalGraphics& mrParent;
/// Pointer to the SalFrame or SalVirtualDevice
SalGeometryProvider* mpProvider;
@@ -138,19 +138,19 @@ protected:
bool ReleaseContext();
// retrieve the default context for offscreen rendering
- static OpenGLContext* GetDefaultContext();
+ static rtl::Reference<OpenGLContext> GetDefaultContext();
// create a new context for window rendering
- virtual OpenGLContext* CreateWinContext() = 0;
+ virtual rtl::Reference<OpenGLContext> CreateWinContext() = 0;
// check whether the given context can be used by this instance
- virtual bool UseContext( OpenGLContext* pContext ) = 0;
+ virtual bool UseContext( const rtl::Reference<OpenGLContext> &pContext ) = 0;
public:
OpenGLSalGraphicsImpl(SalGraphics& pParent, SalGeometryProvider *pProvider);
virtual ~OpenGLSalGraphicsImpl ();
- OpenGLContext* GetOpenGLContext();
+ rtl::Reference<OpenGLContext> GetOpenGLContext();
virtual void Init() SAL_OVERRIDE;
diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx
index 50e5e5a30646..f00aae421d13 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -88,7 +88,7 @@ public:
virtual SalGraphicsImpl* GetImpl() const = 0;
/// Check that our mpImpl is OpenGL and return the context, otherwise NULL.
- OpenGLContext* GetOpenGLContext() const;
+ rtl::Reference<OpenGLContext> GetOpenGLContext() const;
void setAntiAliasB2DDraw(bool bNew) { m_bAntiAliasB2DDraw = bNew; }
bool getAntiAliasB2DDraw() const { return m_bAntiAliasB2DDraw; }
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 4aee0f8340be..b3c9ea299635 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -61,14 +61,14 @@ OpenGLSalGraphicsImpl::~OpenGLSalGraphicsImpl()
ReleaseContext();
}
-OpenGLContext* OpenGLSalGraphicsImpl::GetOpenGLContext()
+rtl::Reference<OpenGLContext> OpenGLSalGraphicsImpl::GetOpenGLContext()
{
if( !AcquireContext() )
return NULL;
return mpContext;
}
-OpenGLContext* OpenGLSalGraphicsImpl::GetDefaultContext()
+rtl::Reference<OpenGLContext> OpenGLSalGraphicsImpl::GetDefaultContext()
{
return ImplGetDefaultWindow()->GetGraphics()->GetOpenGLContext();
}
@@ -77,19 +77,14 @@ bool OpenGLSalGraphicsImpl::AcquireContext( )
{
ImplSVData* pSVData = ImplGetSVData();
- if( mpContext )
+ if( mpContext.is() )
{
if( mpContext->isInitialized() )
return true;
-#ifdef DBG_UTIL
- mpContext->DeRef(this);
-#else
- mpContext->DeRef();
-#endif
+ mpContext.clear();
}
-
- OpenGLContext* pContext = pSVData->maGDIData.mpLastContext;
+ OpenGLContext *pContext = pSVData->maGDIData.mpLastContext;
while( pContext )
{
// check if this context can be used by this SalGraphicsImpl instance
@@ -99,31 +94,17 @@ bool OpenGLSalGraphicsImpl::AcquireContext( )
}
if( pContext )
- {
-#ifdef DBG_UTIL
- pContext->AddRef(this);
-#else
- pContext->AddRef();
-#endif
- }
+ mpContext = pContext;
else
- pContext = mbOffscreen ? GetDefaultContext() : CreateWinContext();
+ mpContext = mbOffscreen ? GetDefaultContext() : CreateWinContext();
- mpContext = pContext;
- return (mpContext != NULL);
+ return mpContext.is();
}
bool OpenGLSalGraphicsImpl::ReleaseContext()
{
- if( mpContext )
- {
-#ifdef DBG_UTIL
- mpContext->DeRef(this);
-#else
- mpContext->DeRef();
-#endif
- }
- mpContext = NULL;
+ mpContext.clear();
+
return true;
}
@@ -132,7 +113,7 @@ void OpenGLSalGraphicsImpl::Init()
mbOffscreen = IsOffscreen();
// check if we can simply re-use the same context
- if( mpContext )
+ if( mpContext.is() )
{
if( !UseContext( mpContext ) )
ReleaseContext();
@@ -143,7 +124,7 @@ void OpenGLSalGraphicsImpl::Init()
maOffscreenTex.GetWidth() != GetWidth() ||
maOffscreenTex.GetHeight() != GetHeight() )
{
- if( mpContext ) // valid context
+ if( mpContext.is() ) // valid context
mpContext->ReleaseFramebuffer( maOffscreenTex );
maOffscreenTex = OpenGLTexture();
}
@@ -158,7 +139,7 @@ void OpenGLSalGraphicsImpl::DeInit()
// let it know. Other eg. VirtualDevice contexts which have
// references on and rely on this context continuing to work will
// get a shiny new context in AcquireContext:: next PreDraw.
- if( mpContext && !IsOffscreen() )
+ if( mpContext.is() && !IsOffscreen() )
mpContext->reset();
}
@@ -216,7 +197,7 @@ void OpenGLSalGraphicsImpl::ApplyProgramMatrices(float fPixelOffset)
void OpenGLSalGraphicsImpl::freeResources()
{
// TODO Delete shaders, programs and textures if not shared
- if( mbOffscreen && mpContext && mpContext->isInitialized() )
+ if( mbOffscreen && mpContext.is() && mpContext->isInitialized() )
{
mpContext->makeCurrent();
mpContext->ReleaseFramebuffer( maOffscreenTex );
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index 05a55d7d504e..f3f131bb2075 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -595,7 +595,7 @@ void OpenGLSalBitmap::updateChecksum() const
OpenGLSalBitmap* pThis = const_cast<OpenGLSalBitmap*>(this);
- if (!mpContext)
+ if (!mpContext.is())
{
pThis->CreateTexture();
}
@@ -614,7 +614,7 @@ void OpenGLSalBitmap::updateChecksum() const
}
}
-OpenGLContext* OpenGLSalBitmap::GetBitmapContext()
+rtl::Reference<OpenGLContext> OpenGLSalBitmap::GetBitmapContext()
{
return ImplGetDefaultWindow()->GetGraphics()->GetOpenGLContext();
}
@@ -624,12 +624,14 @@ void OpenGLSalBitmap::makeCurrent()
ImplSVData* pSVData = ImplGetSVData();
// TODO: make sure we can really use the last used context
- mpContext = pSVData->maGDIData.mpLastContext;
- while( mpContext && !mpContext->isInitialized() )
- mpContext = mpContext->mpPrevContext;
- if( !mpContext )
+ OpenGLContext *pContext = pSVData->maGDIData.mpLastContext;
+ while( pContext && !pContext->isInitialized() )
+ pContext = pContext->mpPrevContext;
+ if( pContext )
+ mpContext = pContext;
+ else
mpContext = GetBitmapContext();
- assert(mpContext && "Couldn't get an OpenGL context");
+ assert(mpContext.is() && "Couldn't get an OpenGL context");
mpContext->makeCurrent();
}
diff --git a/vcl/opengl/texture.cxx b/vcl/opengl/texture.cxx
index 9895dc8d322f..afb2b47ad72d 100644
--- a/vcl/opengl/texture.cxx
+++ b/vcl/opengl/texture.cxx
@@ -112,8 +112,8 @@ ImplOpenGLTexture::~ImplOpenGLTexture()
// Check we have been correctly un-bound from all framebuffers.
ImplSVData* pSVData = ImplGetSVData();
- OpenGLContext* pContext = pSVData->maGDIData.mpLastContext;
- if (pContext)
+ rtl::Reference<OpenGLContext> pContext = pSVData->maGDIData.mpLastContext;
+ if (pContext.is())
pContext->UnbindTextureFromFramebuffers( mnTexture );
glDeleteTextures( 1, &mnTexture );
@@ -383,7 +383,7 @@ void OpenGLTexture::Read( GLenum nFormat, GLenum nType, sal_uInt8* pData )
{
// Retrieve current context
ImplSVData* pSVData = ImplGetSVData();
- OpenGLContext* pContext = pSVData->maGDIData.mpLastContext;
+ rtl::Reference<OpenGLContext> pContext = pSVData->maGDIData.mpLastContext;
OpenGLFramebuffer* pFramebuffer;
pFramebuffer = pContext->AcquireFramebuffer( *this );
diff --git a/vcl/opengl/win/gdiimpl.cxx b/vcl/opengl/win/gdiimpl.cxx
index 6896a024ec7d..30088a9deb88 100644
--- a/vcl/opengl/win/gdiimpl.cxx
+++ b/vcl/opengl/win/gdiimpl.cxx
@@ -29,21 +29,21 @@ void WinOpenGLSalGraphicsImpl::copyBits( const SalTwoRect& rPosAry, SalGraphics*
OpenGLSalGraphicsImpl::DoCopyBits( rPosAry, *pImpl );
}
-OpenGLContext* WinOpenGLSalGraphicsImpl::CreateWinContext()
+rtl::Reference<OpenGLContext> WinOpenGLSalGraphicsImpl::CreateWinContext()
{
- OpenGLContext* pContext = new OpenGLContext();
+ rtl::Reference<OpenGLContext> pContext = OpenGLContext::Create();
pContext->requestSingleBufferedRendering();
pContext->init( mrParent.mhLocalDC, mrParent.mhWnd );
return pContext;
}
-bool WinOpenGLSalGraphicsImpl::UseContext( OpenGLContext* pContext )
+bool WinOpenGLSalGraphicsImpl::UseContext( const rtl::Reference<OpenGLContext> &pContext )
{
- if( !pContext || !pContext->isInitialized() )
+ if( !pContext.is() || !pContext->isInitialized() )
return false;
if( IsOffscreen() )
return true;
- return ( pContext->getOpenGLWindow().hWnd == mrParent.mhWnd );
+ return pContext->getOpenGLWindow().hWnd == mrParent.mhWnd;
}
namespace
diff --git a/vcl/opengl/x11/gdiimpl.cxx b/vcl/opengl/x11/gdiimpl.cxx
index 4c592842d9d8..65b279b43f11 100644
--- a/vcl/opengl/x11/gdiimpl.cxx
+++ b/vcl/opengl/x11/gdiimpl.cxx
@@ -44,7 +44,7 @@ void X11OpenGLSalGraphicsImpl::Init()
OpenGLSalGraphicsImpl::Init();
}
-OpenGLContext* X11OpenGLSalGraphicsImpl::CreateWinContext()
+rtl::Reference<OpenGLContext> X11OpenGLSalGraphicsImpl::CreateWinContext()
{
X11WindowProvider *pProvider = dynamic_cast<X11WindowProvider*>(mrParent.m_pFrame);
@@ -52,13 +52,13 @@ OpenGLContext* X11OpenGLSalGraphicsImpl::CreateWinContext()
return NULL;
Window aWin = pProvider->GetX11Window();
- OpenGLContext* pContext = new OpenGLContext();
+ rtl::Reference<OpenGLContext> pContext = OpenGLContext::Create();
pContext->init( mrParent.GetXDisplay(), aWin,
mrParent.m_nXScreen.getXScreen() );
return pContext;
}
-bool X11OpenGLSalGraphicsImpl::UseContext( OpenGLContext* pContext )
+bool X11OpenGLSalGraphicsImpl::UseContext( const rtl::Reference<OpenGLContext> &pContext )
{
X11WindowProvider *pProvider = dynamic_cast<X11WindowProvider*>(mrParent.m_pFrame);
@@ -66,9 +66,9 @@ bool X11OpenGLSalGraphicsImpl::UseContext( OpenGLContext* pContext )
return false;
if( !pProvider )
- return ( pContext->getOpenGLWindow().win != None );
+ return pContext->getOpenGLWindow().win != None;
else
- return ( pContext->getOpenGLWindow().win == pProvider->GetX11Window() );
+ return pContext->getOpenGLWindow().win == pProvider->GetX11Window();
}
void X11OpenGLSalGraphicsImpl::copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics )
diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx
index 14cf94de9dd2..71d7628165d7 100644
--- a/vcl/source/app/svdata.cxx
+++ b/vcl/source/app/svdata.cxx
@@ -140,15 +140,9 @@ vcl::Window* ImplGetDefaultWindow()
pSVData->mpDefaultWin->SetText( OUString( "VCL ImplGetDefaultWindow" ) );
// Add a reference to the default context so it never gets deleted
- OpenGLContext* pContext = pSVData->mpDefaultWin->GetGraphics()->GetOpenGLContext();
- if( pContext )
- {
-#ifdef DBG_UTIL
- pContext->AddRef(NULL);
-#else
- pContext->AddRef();
-#endif
- }
+ rtl::Reference<OpenGLContext> pContext = pSVData->mpDefaultWin->GetGraphics()->GetOpenGLContext();
+ if( pContext.is() )
+ pContext->acquire();
}
Application::GetSolarMutex().release();
}
diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx
index bd5d8bd3de42..4844f84e4bc8 100644
--- a/vcl/source/gdi/salgdilayout.cxx
+++ b/vcl/source/gdi/salgdilayout.cxx
@@ -77,7 +77,7 @@ SalGraphics::~SalGraphics()
{
}
-OpenGLContext* SalGraphics::GetOpenGLContext() const
+rtl::Reference<OpenGLContext> SalGraphics::GetOpenGLContext() const
{
OpenGLSalGraphicsImpl *pImpl = dynamic_cast<OpenGLSalGraphicsImpl*>(GetImpl());
if (pImpl)
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 73ff51e8a3bf..3b70641433e6 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -57,7 +57,7 @@ OpenGLContext::OpenGLContext():
mpWindow(NULL),
m_pChildWindow(NULL),
mbInitialized(false),
- mnRefCount(1),
+ mnRefCount(0),
mbRequestLegacyContext(false),
mbUseDoubleBufferedRendering(true),
mbRequestVirtualDevice(false),
@@ -93,6 +93,9 @@ OpenGLContext::OpenGLContext():
OpenGLContext::~OpenGLContext()
{
VCL_GL_INFO("vcl.opengl", "delete context: " << this);
+ assert (mnRefCount == 0);
+
+ mnRefCount = 1; // guard the shutdown paths.
reset();
ImplSVData* pSVData = ImplGetSVData();
@@ -106,43 +109,14 @@ OpenGLContext::~OpenGLContext()
pSVData->maGDIData.mpLastContext = mpPrevContext;
m_pChildWindow.disposeAndClear();
+ assert (mnRefCount == 1);
}
-#ifdef DBG_UTIL
-void OpenGLContext::AddRef(SalGraphicsImpl* pImpl)
+rtl::Reference<OpenGLContext> OpenGLContext::Create()
{
- assert(mnRefCount > 0);
- mnRefCount++;
-
- maParents.insert(pImpl);
+ return rtl::Reference<OpenGLContext>(new OpenGLContext);
}
-void OpenGLContext::DeRef(SalGraphicsImpl* pImpl)
-{
-
- auto it = maParents.find(pImpl);
- if(it != maParents.end())
- maParents.erase(it);
-
- assert(mnRefCount > 0);
- if( --mnRefCount == 0 )
- delete this;
-}
-#else
-void OpenGLContext::AddRef()
-{
- assert(mnRefCount > 0);
- mnRefCount++;
-}
-
-void OpenGLContext::DeRef()
-{
- assert(mnRefCount > 0);
- if( --mnRefCount == 0 )
- delete this;
-}
-#endif
-
void OpenGLContext::requestLegacyContext()
{
mbRequestLegacyContext = true;
@@ -1429,8 +1403,8 @@ void OpenGLContext::clearCurrent()
// release all framebuffers from the old context so we can re-attach the
// texture in the new context
- OpenGLContext* pCurrentCtx = pSVData->maGDIData.mpLastContext;
- if( pCurrentCtx && pCurrentCtx->isCurrent() )
+ rtl::Reference<OpenGLContext> pCurrentCtx = pSVData->maGDIData.mpLastContext;
+ if( pCurrentCtx.is() && pCurrentCtx->isCurrent() )
pCurrentCtx->ReleaseFramebuffers();
}
@@ -1438,11 +1412,16 @@ void OpenGLContext::prepareForYield()
{
ImplSVData* pSVData = ImplGetSVData();
- SAL_INFO("vcl.opengl", "Unbinding contexts in preparation for yield");
// release all framebuffers from the old context so we can re-attach the
// texture in the new context
- OpenGLContext* pCurrentCtx = pSVData->maGDIData.mpLastContext;
- if( pCurrentCtx && pCurrentCtx->isCurrent() )
+ rtl::Reference<OpenGLContext> pCurrentCtx = pSVData->maGDIData.mpLastContext;
+
+ if ( !pCurrentCtx.is() )
+ return; // Not using OpenGL
+
+ SAL_INFO("vcl.opengl", "Unbinding contexts in preparation for yield");
+
+ if( pCurrentCtx->isCurrent() )
pCurrentCtx->resetCurrent();
assert (!hasCurrent());
@@ -1473,11 +1452,14 @@ void OpenGLContext::makeCurrent()
TempErrorHandler aErrorHandler(m_aGLWin.dpy, unxErrorHandler);
#endif
- GLXDrawable nDrawable = mbPixmap ? m_aGLWin.glPix : m_aGLWin.win;
- if (!glXMakeCurrent( m_aGLWin.dpy, nDrawable, m_aGLWin.ctx ))
+ if (m_aGLWin.dpy)
{
- SAL_WARN("vcl.opengl", "OpenGLContext::makeCurrent failed on drawable " << nDrawable << " pixmap? " << mbPixmap);
- return;
+ GLXDrawable nDrawable = mbPixmap ? m_aGLWin.glPix : m_aGLWin.win;
+ if (!glXMakeCurrent( m_aGLWin.dpy, nDrawable, m_aGLWin.ctx ))
+ {
+ SAL_WARN("vcl.opengl", "OpenGLContext::makeCurrent failed on drawable " << nDrawable << " pixmap? " << mbPixmap);
+ return;
+ }
}
#endif
diff --git a/vcl/source/window/openglwin.cxx b/vcl/source/window/openglwin.cxx
index 30094e439b5d..37d1ea5b18e6 100644
--- a/vcl/source/window/openglwin.cxx
+++ b/vcl/source/window/openglwin.cxx
@@ -17,18 +17,19 @@ class OpenGLWindowImpl
public:
OpenGLWindowImpl(vcl::Window* pWindow);
~OpenGLWindowImpl() { mxChildWindow.disposeAndClear(); }
- OpenGLContext& getContext() { return maContext;}
+ OpenGLContext& getContext() { return *mxContext.get(); }
private:
- OpenGLContext maContext;
+ rtl::Reference<OpenGLContext> mxContext;
VclPtr<SystemChildWindow> mxChildWindow;
};
OpenGLWindowImpl::OpenGLWindowImpl(vcl::Window* pWindow)
+ : mxContext(OpenGLContext::Create())
{
SystemWindowData aData = OpenGLContext::generateWinData(pWindow, false);
mxChildWindow.reset(VclPtr<SystemChildWindow>::Create(pWindow, 0, &aData));
mxChildWindow->Show();
- maContext.init(mxChildWindow.get());
+ mxContext->init(mxChildWindow.get());
pWindow->SetMouseTransparent(false);
}
diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx
index 14e11d5be9ef..fb64cc32e63c 100644
--- a/vcl/unx/generic/window/salframe.cxx
+++ b/vcl/unx/generic/window/salframe.cxx
@@ -891,8 +891,8 @@ X11SalFrame::~X11SalFrame()
}
// reset all OpenGL contexts using this window
- OpenGLContext* pContext = ImplGetSVData()->maGDIData.mpLastContext;
- while( pContext )
+ rtl::Reference<OpenGLContext> pContext = ImplGetSVData()->maGDIData.mpLastContext;
+ while( pContext.is() )
{
if( pContext->getOpenGLWindow().win == mhWindow )
pContext->reset();
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index 96ab22f3ea7a..2db38bdf3605 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -1641,8 +1641,8 @@ class OpenGLTests
VclPtr<WorkWindow> mxWinB;
OpenGLSalGraphicsImpl *mpImplA;
OpenGLSalGraphicsImpl *mpImplB;
- OpenGLContext *mpA;
- OpenGLContext *mpB;
+ rtl::Reference<OpenGLContext> mpA;
+ rtl::Reference<OpenGLContext> mpB;
static OpenGLSalGraphicsImpl *getImpl(const VclPtr<WorkWindow> &xWin)
{
@@ -1666,7 +1666,8 @@ public:
mpA = mpImplA->GetOpenGLContext();
mpB = mpImplB->GetOpenGLContext();
- assert (mpA && mpB);
+ assert (mpA.is() && mpB.is());
+ assert (mpA != mpB);
}
~OpenGLTests()
{