summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorLouis-Francis Ratté-Boulianne <lfrb@collabora.com>2014-11-22 08:07:47 -0500
committerJan Holesovsky <kendy@collabora.com>2014-11-22 20:14:20 +0100
commitfa77801f3e57ad94f077230a95bded1067f528e9 (patch)
treeb121fac9c221f1d891d3267ebd6ee943c9ed99a1 /vcl
parent5f86a6165bdedec4fbac2cf22a958245f52168be (diff)
vcl: Track the GL context's clip region and update before drawing when needed
Change-Id: Ibec92851dc87f6696ee55a8db10fe160cd97d09c
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/openglgdiimpl.hxx2
-rw-r--r--vcl/opengl/gdiimpl.cxx59
2 files changed, 33 insertions, 28 deletions
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index cb06707daad5..85ec26298b8f 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -38,6 +38,7 @@ protected:
OpenGLContext* mpContext;
// clipping
+ vcl::Region maClipRegion;
bool mbUseScissor;
bool mbUseStencil;
@@ -91,6 +92,7 @@ protected:
GLuint mnRadialGradientEndColorUniform;
GLuint mnRadialGradientCenterUniform;
+ void ImplInitClipRegion();
void ImplSetClipBit( const vcl::Region& rClip, GLuint nMask );
bool CheckOffscreenTexture();
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 06b7e6b21913..65c11ca2f8e3 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -213,13 +213,7 @@ void OpenGLSalGraphicsImpl::PreDraw()
if( mbOffscreen )
CheckOffscreenTexture();
glViewport( 0, 0, GetWidth(), GetHeight() );
- if( mbUseScissor )
- glEnable( GL_SCISSOR_TEST );
- if( mbUseStencil )
- {
- glStencilFunc( GL_EQUAL, 1, 0x1 );
- glEnable( GL_STENCIL_TEST );
- }
+ ImplInitClipRegion();
CHECK_GL_ERROR();
}
@@ -263,36 +257,44 @@ void OpenGLSalGraphicsImpl::ImplSetClipBit( const vcl::Region& rClip, GLuint nMa
CHECK_GL_ERROR();
}
-bool OpenGLSalGraphicsImpl::setClipRegion( const vcl::Region& rClip )
+void OpenGLSalGraphicsImpl::ImplInitClipRegion()
{
- SAL_INFO( "vcl.opengl", "::setClipRegion " << rClip );
-
- if( rClip.IsEmpty() )
+ // make sure the context has the right clipping set
+ if( maClipRegion != mpContext->maClipRegion )
{
- ResetClipRegion();
- return true;
+ mpContext->maClipRegion = maClipRegion;
+ if( maClipRegion.IsRectangle() )
+ {
+ Rectangle aRect( maClipRegion.GetBoundRect() );
+ glScissor( aRect.Left(), GetHeight() - aRect.Bottom() - 1, aRect.GetWidth() + 1, aRect.GetHeight() + 1 );
+ }
+ else if( !maClipRegion.IsEmpty() )
+ {
+ ImplSetClipBit( maClipRegion, 0x01 );
+ }
}
- if( rClip.IsRectangle() )
+ if( mbUseScissor )
+ glEnable( GL_SCISSOR_TEST );
+ if( mbUseStencil )
{
- Rectangle aRect( rClip.GetBoundRect() );
+ glStencilFunc( GL_EQUAL, 1, 0x1 );
+ glEnable( GL_STENCIL_TEST );
+ }
+}
+
+bool OpenGLSalGraphicsImpl::setClipRegion( const vcl::Region& rClip )
+{
+ SAL_INFO( "vcl.opengl", "::setClipRegion " << rClip );
+ maClipRegion = rClip;
- mbUseStencil = false;
+ mbUseStencil = false;
+ mbUseScissor = false;
+ if( maClipRegion.IsRectangle() )
mbUseScissor = true;
- maContext.makeCurrent();
- glViewport( 0, 0, GetWidth(), GetHeight() );
- glScissor( aRect.Left(), GetHeight() - aRect.Bottom() - 1, aRect.GetWidth(), aRect.GetHeight() );
- }
- else
- {
+ else if ( !maClipRegion.IsEmpty() )
mbUseStencil = true;
- mbUseScissor = false;
- maContext.makeCurrent();
- glViewport( 0, 0, GetWidth(), GetHeight() );
- ImplSetClipBit( rClip, 0x01 );
- }
- CHECK_GL_ERROR();
return true;
}
@@ -300,6 +302,7 @@ bool OpenGLSalGraphicsImpl::setClipRegion( const vcl::Region& rClip )
void OpenGLSalGraphicsImpl::ResetClipRegion()
{
SAL_INFO( "vcl.opengl", "::ResetClipRegion" );
+ maClipRegion.SetEmpty();
mbUseScissor = false;
mbUseStencil = false;
}