Kaydet (Commit) 7a64d1e1 authored tarafından Louis-Francis Ratté-Boulianne's avatar Louis-Francis Ratté-Boulianne Kaydeden (comit) Jan Holesovsky

vcl: Improve precision and performance of clipping when region is a RegionBand

Change-Id: I7a481ba86d03b0eb8f4b456e38cfa89b6cbc209d
üst fa77801f
......@@ -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 );
......
......@@ -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];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment