summaryrefslogtreecommitdiff
path: root/vcl/opengl/gdiimpl.cxx
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-12-02 15:47:22 +0100
commit08effddd910c006740370e3e8046f4cdda7ae28d (patch)
tree4042db74310ebd9de1fc732cc0db55eea7e28372 /vcl/opengl/gdiimpl.cxx
parent7a5d05eae58e8cd92a470a929214d2fb3a64cfe5 (diff)
vcl: Track the GL context's clip region and update before drawing when needed
Change-Id: Ibec92851dc87f6696ee55a8db10fe160cd97d09c
Diffstat (limited to 'vcl/opengl/gdiimpl.cxx')
-rw-r--r--vcl/opengl/gdiimpl.cxx59
1 files changed, 31 insertions, 28 deletions
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 2f3099e35956..c23816d8d587 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;
}