From 4c424d785275494835287aa3c171ee2fd5c4f884 Mon Sep 17 00:00:00 2001 From: Louis-Francis Ratté-Boulianne Date: Thu, 4 Dec 2014 22:21:50 -0500 Subject: vcl: Keep the same context for VirtualDevice to avoid FBO switches Change-Id: I66496fae902db9df5b8301b00bb779f42adaa7a7 --- vcl/opengl/gdiimpl.cxx | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'vcl/opengl') diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index 86a592952234..4edd843355c3 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -56,8 +56,8 @@ OpenGLSalGraphicsImpl::~OpenGLSalGraphicsImpl() OpenGLContext* OpenGLSalGraphicsImpl::GetOpenGLContext() { - if( !mpContext ) - AcquireContext(); + if( !AcquireContext() ) + return NULL; return mpContext; } @@ -71,7 +71,11 @@ bool OpenGLSalGraphicsImpl::AcquireContext( ) ImplSVData* pSVData = ImplGetSVData(); if( mpContext ) + { + if( mpContext->isInitialized() ) + return true; mpContext->DeRef(); + } OpenGLContext* pContext = pSVData->maGDIData.mpLastContext; @@ -122,7 +126,7 @@ void OpenGLSalGraphicsImpl::Init() void OpenGLSalGraphicsImpl::PreDraw() { - if( !mpContext && !AcquireContext() ) + if( !AcquireContext() ) { SAL_WARN( "vcl.opengl", "Couldn't acquire context" ); return; @@ -161,11 +165,6 @@ void OpenGLSalGraphicsImpl::PostDraw() mpFramebuffer = NULL; CHECK_GL_ERROR(); - - // release the context as there is no guarantee the underlying window - // will still be valid for the next draw operation - if( mbOffscreen ) - ReleaseContext(); } void OpenGLSalGraphicsImpl::freeResources() @@ -1414,7 +1413,7 @@ bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPoly, void OpenGLSalGraphicsImpl::beginPaint() { - if( !mpContext && !AcquireContext() ) + if( !AcquireContext() ) return; mpContext->mnPainting++; @@ -1422,7 +1421,7 @@ void OpenGLSalGraphicsImpl::beginPaint() void OpenGLSalGraphicsImpl::endPaint() { - if( !mpContext && !AcquireContext() ) + if( !AcquireContext() ) return; mpContext->mnPainting--; -- cgit