summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis-Francis Ratté-Boulianne <lfrb@collabora.com>2014-11-22 08:09:29 -0500
committerLouis-Francis Ratté-Boulianne <lfrb@collabora.com>2014-11-22 08:09:29 -0500
commit11b2007fc5a827228822150a66b53997e67d0287 (patch)
treec6786d5429a99293e4aa247bee01efb75a2900e5
parent6563a9071d6da2cc92f4967da7be5f6f67154081 (diff)
vcl: Improve precision and performance of clipping when region is a RegionBand
Change-Id: I7a481ba86d03b0eb8f4b456e38cfa89b6cbc209d
-rw-r--r--vcl/inc/openglgdiimpl.hxx2
-rw-r--r--vcl/opengl/gdiimpl.cxx40
2 files changed, 41 insertions, 1 deletions
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index a6495b71bc6f..ee7889ea69a4 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 f7b8bdfa45f5..85d2a1cd894c 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];