summaryrefslogtreecommitdiff
path: root/vcl/opengl
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2016-04-28 20:01:28 +0900
committerTomaž Vajngerl <quikee@gmail.com>2016-04-30 03:07:51 +0000
commitb8f0e6452cc019744c44997c92831d94086b35b7 (patch)
treee3dfa16ec177e33b5675b69305118d867347c2ab /vcl/opengl
parent51e953a3579fb91f30f7f0d6159b737684976959 (diff)
opengl: track the state of stencil test
Change-Id: Id3e15e91316df740f04a42ed8c95b77d83240b5a Reviewed-on: https://gerrit.libreoffice.org/24505 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/opengl')
-rw-r--r--vcl/opengl/gdiimpl.cxx33
-rw-r--r--vcl/opengl/salbmp.cxx4
-rw-r--r--vcl/opengl/scale.cxx1
3 files changed, 19 insertions, 19 deletions
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<OpenGLContext> 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<OpenGLTexture> 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<OpenGLContext> 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<OpenGLContext> 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<OpenGLContext> xContext = OpenGLContext::getVCLContext();
xContext->state()->scissor().disable();
+ xContext->state()->stencil().disable();
if (rScaleX <= 1 && rScaleY <= 1)
{