From b8f0e6452cc019744c44997c92831d94086b35b7 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Thu, 28 Apr 2016 20:01:28 +0900 Subject: opengl: track the state of stencil test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Id3e15e91316df740f04a42ed8c95b77d83240b5a Reviewed-on: https://gerrit.libreoffice.org/24505 Reviewed-by: Tomaž Vajngerl Tested-by: Tomaž Vajngerl --- vcl/opengl/gdiimpl.cxx | 33 ++++++++++++++------------------- vcl/opengl/salbmp.cxx | 4 ++++ vcl/opengl/scale.cxx | 1 + 3 files changed, 19 insertions(+), 19 deletions(-) (limited to 'vcl/opengl') diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index ca5f4395594f..70b2d65df7c5 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -234,11 +234,6 @@ void OpenGLSalGraphicsImpl::PostDraw() CHECK_GL_ERROR(); } - if( mbUseStencil ) - { - glDisable( GL_STENCIL_TEST ); - CHECK_GL_ERROR(); - } if( mpProgram ) { mpProgram->Clean(); @@ -271,6 +266,7 @@ void OpenGLSalGraphicsImpl::freeResources() mpContext->makeCurrent(); FlushDeferredDrawing(); mpContext->state()->scissor().disable(); + mpContext->state()->stencil().disable(); mpContext->ReleaseFramebuffer( maOffscreenTex ); } ReleaseContext(); @@ -278,7 +274,7 @@ void OpenGLSalGraphicsImpl::freeResources() void OpenGLSalGraphicsImpl::ImplSetClipBit( const vcl::Region& rClip, GLuint nMask ) { - glEnable( GL_STENCIL_TEST ); + mpContext->state()->stencil().enable(); VCL_GL_INFO( "Adding complex clip / stencil" ); GLuint nStencil = maOffscreenTex.StencilId(); @@ -317,8 +313,8 @@ void OpenGLSalGraphicsImpl::ImplSetClipBit( const vcl::Region& rClip, GLuint nMa CHECK_GL_ERROR(); glStencilMask( 0x00 ); CHECK_GL_ERROR(); - glDisable( GL_STENCIL_TEST ); - CHECK_GL_ERROR(); + + mpContext->state()->stencil().disable(); } void OpenGLSalGraphicsImpl::ImplInitClipRegion() @@ -348,8 +344,11 @@ void OpenGLSalGraphicsImpl::ImplInitClipRegion() { glStencilFunc( GL_EQUAL, 1, 0x1 ); CHECK_GL_ERROR(); - glEnable( GL_STENCIL_TEST ); - CHECK_GL_ERROR(); + mpContext->state()->stencil().enable(); + } + else + { + mpContext->state()->stencil().disable(); } } @@ -1501,11 +1500,7 @@ void OpenGLSalGraphicsImpl::DrawTransformedTexture( // so if we do not disable the scissor test, the texture produced // by the first downscaling is clipped to the current window size. mpContext->state()->scissor().disable(); - CHECK_GL_ERROR(); - - // Maybe it can give problems too. - glDisable(GL_STENCIL_TEST); - CHECK_GL_ERROR(); + mpContext->state()->stencil().disable(); // the square root of the whole inverted scale ratio double ixscalesqrt = std::floor(std::sqrt(ixscale)); @@ -1529,10 +1524,7 @@ void OpenGLSalGraphicsImpl::DrawTransformedTexture( mpContext->state()->scissor().enable(); if (mbUseStencil) - { - glEnable(GL_STENCIL_TEST); - CHECK_GL_ERROR(); - } + mpContext->state()->stencil().enable(); } } @@ -2507,6 +2499,7 @@ void OpenGLSalGraphicsImpl::flush() FlushDeferredDrawing(); mpContext->state()->scissor().disable(); + mpContext->state()->stencil().disable(); if( IsOffscreen() ) return; @@ -2525,6 +2518,7 @@ void OpenGLSalGraphicsImpl::doFlush() FlushDeferredDrawing(); mpContext->state()->scissor().disable(); + mpContext->state()->stencil().disable(); if( IsOffscreen() ) return; @@ -2570,6 +2564,7 @@ void OpenGLSalGraphicsImpl::doFlush() CHECK_GL_ERROR(); mpWindowContext->state()->scissor().disable(); + mpWindowContext->state()->stencil().disable(); #if OSL_DEBUG_LEVEL > 0 // random background glClear glClearColor((float)rand()/RAND_MAX, (float)rand()/RAND_MAX, diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx index 1cc17d1f8321..b9b7a5f0b457 100644 --- a/vcl/opengl/salbmp.cxx +++ b/vcl/opengl/salbmp.cxx @@ -541,6 +541,7 @@ bool OpenGLSalBitmap::ReadTexture() rtl::Reference xContext = OpenGLContext::getVCLContext(); xContext->state()->scissor().disable(); + xContext->state()->stencil().disable(); if (mnBits == 8 || mnBits == 16 || mnBits == 24 || mnBits == 32) { @@ -624,6 +625,7 @@ bool OpenGLSalBitmap::calcChecksumGL(OpenGLTexture& rInputTexture, ChecksumType& rtl::Reference< OpenGLContext > xContext = OpenGLContext::getVCLContext(); xContext->state()->scissor().disable(); + xContext->state()->stencil().disable(); static vcl::DeleteOnDeinit gCRCTableTexture( new OpenGLTexture(512, 1, GL_RGBA, GL_UNSIGNED_BYTE, @@ -893,6 +895,7 @@ bool OpenGLSalBitmap::Replace( const Color& rSearchColor, const Color& rReplaceC OpenGLZone aZone; rtl::Reference xContext = OpenGLContext::getVCLContext(); xContext->state()->scissor().disable(); + xContext->state()->stencil().disable(); OpenGLFramebuffer* pFramebuffer; OpenGLProgram* pProgram; @@ -932,6 +935,7 @@ bool OpenGLSalBitmap::ConvertToGreyscale() OpenGLZone aZone; rtl::Reference xContext = OpenGLContext::getVCLContext(); xContext->state()->scissor().disable(); + xContext->state()->stencil().disable(); OpenGLFramebuffer* pFramebuffer; OpenGLProgram* pProgram; diff --git a/vcl/opengl/scale.cxx b/vcl/opengl/scale.cxx index 61ecf31a6221..9feb933d0ed4 100644 --- a/vcl/opengl/scale.cxx +++ b/vcl/opengl/scale.cxx @@ -329,6 +329,7 @@ bool OpenGLSalBitmap::ImplScale( const double& rScaleX, const double& rScaleY, B OpenGLVCLContextZone aContextZone; rtl::Reference xContext = OpenGLContext::getVCLContext(); xContext->state()->scissor().disable(); + xContext->state()->stencil().disable(); if (rScaleX <= 1 && rScaleY <= 1) { -- cgit