diff options
author | Louis-Francis Ratté-Boulianne <lfrb@collabora.com> | 2014-11-22 08:09:29 -0500 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2014-12-02 15:47:22 +0100 |
commit | 1f4d25ecd2fc6c6f106966ce13e39cffcc5e4a1b (patch) | |
tree | 643a1e9087dc666cbdc8c073ffdbbf29f200249e /vcl/opengl | |
parent | 08effddd910c006740370e3e8046f4cdda7ae28d (diff) |
vcl: Improve precision and performance of clipping when region is a RegionBand
Change-Id: I7a481ba86d03b0eb8f4b456e38cfa89b6cbc209d
Diffstat (limited to 'vcl/opengl')
-rw-r--r-- | vcl/opengl/gdiimpl.cxx | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index c23816d8d587..576de5c08259 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -247,7 +247,10 @@ void OpenGLSalGraphicsImpl::ImplSetClipBit( const vcl::Region& rClip, GLuint nMa glClear( GL_STENCIL_BUFFER_BIT ); BeginSolid( MAKE_SALCOLOR( 0xFF, 0xFF, 0xFF ) ); - DrawPolyPolygon( rClip.GetAsB2DPolyPolygon() ); + if( rClip.getRegionBand() ) + DrawRegionBand( *rClip.getRegionBand() ); + else + DrawPolyPolygon( rClip.GetAsB2DPolyPolygon() ); EndSolid(); glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); @@ -793,6 +796,41 @@ void OpenGLSalGraphicsImpl::DrawPolyPolygon( const basegfx::B2DPolyPolygon& rPol CHECK_GL_ERROR(); } +void OpenGLSalGraphicsImpl::DrawRegionBand( const RegionBand& rRegion ) +{ + RectangleVector aRects; + std::vector<GLfloat> aVertices; + rRegion.GetRegionRectangles( aRects ); + + if( aRects.empty() ) + return; + +#define ADD_VERTICE(pt) \ + aVertices.push_back( 2 * pt.X() / GetWidth() - 1.0 ); \ + aVertices.push_back( 1.0 - (2 * pt.Y() / GetHeight()) ); + + for( size_t i = 0; i < aRects.size(); ++i ) + { + aRects[i].Bottom() += 1; + aRects[i].Right() += 1; + ADD_VERTICE( aRects[i].TopLeft() ); + ADD_VERTICE( aRects[i].TopRight() ); + ADD_VERTICE( aRects[i].BottomLeft() ); + ADD_VERTICE( aRects[i].BottomLeft() ); + ADD_VERTICE( aRects[i].TopRight() ); + ADD_VERTICE( aRects[i].BottomRight() ); + } + +#undef ADD_VERTICE + + glEnableVertexAttribArray( GL_ATTRIB_POS ); + glVertexAttribPointer( GL_ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, 0, &aVertices[0] ); + glDrawArrays( GL_TRIANGLES, 0, aVertices.size() / 2 ); + glDisableVertexAttribArray( GL_ATTRIB_POS ); + + CHECK_GL_ERROR(); +} + void OpenGLSalGraphicsImpl::DrawTextureRect( OpenGLTexture& rTexture, const SalTwoRect& rPosAry, bool bInverted ) { GLfloat aTexCoord[8]; |