From d1e8c8b43820cb8bba54bfe9275cc87f06c108aa Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Thu, 8 Jan 2015 18:09:49 +0100 Subject: implement optimized hairline drawing for opengl As a side effect, this prevents the lines from looking too wide, because of generic polygon drawing being a bit too generous with AA. Change-Id: I17314c39fd57e33ecbd10b8a8785c600bdc5b212 Signed-off-by: Michael Meeks --- vcl/opengl/gdiimpl.cxx | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'vcl') diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index 07a7cd7cff2b..6c565faf58f4 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -1219,17 +1219,19 @@ bool OpenGLSalGraphicsImpl::drawPolyLine( //bool bDrawnOk = true; if( bIsHairline ) { - // hairlines can benefit from a simplified tesselation - // e.g. for hairlines the linejoin style can be ignored - /*basegfx::B2DTrapezoidVector aB2DTrapVector; - basegfx::tools::createLineTrapezoidFromB2DPolygon( aB2DTrapVector, aPolygon, rLineWidth.getX() ); - - // draw tesselation result - const int nTrapCount = aB2DTrapVector.size(); - if( nTrapCount > 0 ) - bDrawnOk = drawFilledTrapezoids( &aB2DTrapVector[0], nTrapCount, fTransparency ); - - return bDrawnOk;*/ + // hairlines can be drawn in a simpler way (the linejoin and linecap styles can be ignored) + PreDraw(); + if( UseSolidAA( mnLineColor, fTransparency )) + { + for( sal_uInt32 j = 0; j < rPolygon.count() - 1; j++ ) + { + const ::basegfx::B2DPoint& rPt1( rPolygon.getB2DPoint( j ) ); + const ::basegfx::B2DPoint& rPt2( rPolygon.getB2DPoint(( j + 1 )) ); + DrawLineAA( rPt1.getX(), rPt1.getY(), rPt2.getX(), rPt2.getY()); + } + } + PostDraw(); + return true; } // get the area polygon for the line polygon -- cgit