diff options
author | Louis-Francis Ratté-Boulianne <lfrb@collabora.com> | 2014-11-22 08:09:29 -0500 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2014-11-22 20:14:21 +0100 |
commit | 7a64d1e1ccc190c145c298cb74b3b5ee9bf338e2 (patch) | |
tree | 6706369973d744dd9ba7faaf9deac2766edc0fb5 /vcl | |
parent | fa77801f3e57ad94f077230a95bded1067f528e9 (diff) |
vcl: Improve precision and performance of clipping when region is a RegionBand
Change-Id: I7a481ba86d03b0eb8f4b456e38cfa89b6cbc209d
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/openglgdiimpl.hxx | 2 | ||||
-rw-r--r-- | vcl/opengl/gdiimpl.cxx | 40 |
2 files changed, 41 insertions, 1 deletions
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx index 85ec26298b8f..83c5bdb9ac46 100644 --- a/vcl/inc/openglgdiimpl.hxx +++ b/vcl/inc/openglgdiimpl.hxx @@ -24,6 +24,7 @@ #include <vcl/dllapi.h> #include "opengl/texture.hxx" +#include "regionband.hxx" #include <tools/poly.hxx> #include <vcl/opengl/OpenGLContext.hxx> @@ -125,6 +126,7 @@ public: void DrawRect( const Rectangle& rRect ); void DrawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ); void DrawPolyPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon ); + void DrawRegionBand( const RegionBand& rRegion ); void DrawTextureRect( OpenGLTexture& rTexture, const SalTwoRect& rPosAry, bool bInverted = false ); void DrawTexture( OpenGLTexture& rTexture, const SalTwoRect& rPosAry, bool bInverted = false ); void DrawTransformedTexture( OpenGLTexture& rTexture, OpenGLTexture& rMask, const basegfx::B2DPoint& rNull, const basegfx::B2DPoint& rX, const basegfx::B2DPoint& rY ); diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index 65c11ca2f8e3..d4e09172f436 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]; |