diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2015-09-07 22:21:15 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-09-08 17:06:50 +0200 |
commit | 61b7d3436fb789fecf460d2b47c7210585f496a5 (patch) | |
tree | 8d2d0547dac553be91230ebb4f6ee1b3a723574e /canvas | |
parent | eb570808aae8080e2dbb925db6b15cc257b2b9e5 (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
Diffstat (limited to 'canvas')
-rw-r--r-- | canvas/source/opengl/ogl_spritedevicehelper.cxx | 33 | ||||
-rw-r--r-- | canvas/source/opengl/ogl_spritedevicehelper.hxx | 2 |
2 files changed, 18 insertions, 17 deletions
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; }; } |