summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2016-08-06 14:27:55 +0900
committerCaolán McNamara <caolanm@redhat.com>2016-08-08 11:32:47 +0000
commit09fe869bf8ef14a6011317c8c494067c09951820 (patch)
tree8af9a399c9c13fb6cbf2353412a61b18798d834e
parenteca7f703490cef3f6d09fae5a2c9e01d8f553760 (diff)
tdf#100915 draw antialiased line just for polygon outline
To get the anti-aliased polygon we draw a anti-aliased line around every trapezoid. This works fine until we draw a transparent polygon where the lines become visible because of blending. A much better and faster way is to just draw the polygon outline with anti-aliased lines. This is done with this commit. Same fix as aeb0c407a620ea8c28903f61d9d53e6d9ae7c53a in master, but the code differs in 5.2 from master so much that it is generally a separate implementation. Change-Id: I95f98cc930caa7138a59048af68d4015046334d4 Reviewed-on: https://gerrit.libreoffice.org/27923 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--vcl/opengl/gdiimpl.cxx37
1 files changed, 24 insertions, 13 deletions
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index b96ee6728272..4f1da078cb9d 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -1142,14 +1142,13 @@ void OpenGLSalGraphicsImpl::DrawPolygon( sal_uInt32 nPoints, const SalPoint* pPt
void OpenGLSalGraphicsImpl::DrawPolyPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon, bool blockAA )
{
- const basegfx::B2DPolyPolygon& aSimplePolyPolygon = ::basegfx::tools::solveCrossovers( rPolyPolygon );
basegfx::B2DTrapezoidVector aB2DTrapVector;
- basegfx::tools::trapezoidSubdivide( aB2DTrapVector, aSimplePolyPolygon );
+ basegfx::tools::trapezoidSubdivide(aB2DTrapVector, rPolyPolygon);
// draw tesselation result
- if( aB2DTrapVector.size())
+ if (aB2DTrapVector.size())
{
- for(basegfx::B2DTrapezoid & i : aB2DTrapVector)
- DrawTrapezoid( i, blockAA );
+ for(basegfx::B2DTrapezoid & rTrapezoid : aB2DTrapVector)
+ DrawTrapezoid(rTrapezoid, blockAA);
}
}
@@ -1838,20 +1837,32 @@ void OpenGLSalGraphicsImpl::drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32*
bool OpenGLSalGraphicsImpl::drawPolyPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon, double fTransparency )
{
VCL_GL_INFO( "::drawPolyPolygon trans " << fTransparency );
+
if( rPolyPolygon.count() <= 0 )
return true;
- PreDraw( XOROption::IMPLEMENT_XOR );
+ bool bUseAA = mrParent.getAntiAliasB2DDraw();
- if( UseSolid( mnFillColor, fTransparency ) )
- DrawPolyPolygon( rPolyPolygon );
+ PreDraw(XOROption::IMPLEMENT_XOR);
+
+ if (mnFillColor != SALCOLOR_NONE && UseSolid(mnFillColor, fTransparency))
+ {
+ DrawPolyPolygon(rPolyPolygon, true);
+ }
- if( mnLineColor != mnFillColor && UseSolid( mnLineColor, fTransparency ))
+ if (mnLineColor != SALCOLOR_NONE || bUseAA)
{
- basegfx::B2DTrapezoidVector aB2DTrapVector;
- basegfx::tools::createLineTrapezoidFromB2DPolyPolygon( aB2DTrapVector, rPolyPolygon );
- for(basegfx::B2DTrapezoid & i : aB2DTrapVector)
- DrawTrapezoid( i );
+ SalColor nColor = (mnLineColor == SALCOLOR_NONE) ? mnFillColor : mnLineColor;
+ if (UseLine(nColor, fTransparency, 1.0, bUseAA))
+ {
+ for (const basegfx::B2DPolygon& rPolygon : rPolyPolygon)
+ {
+ basegfx::B2DPolygon aPolygon(rPolygon);
+ if (rPolygon.areControlPointsUsed())
+ aPolygon = rPolygon.getDefaultAdaptiveSubdivision();
+ DrawPolyLine(aPolygon, 1.0f, basegfx::B2DLineJoin::NONE, css::drawing::LineCap_BUTT, float(15.0 * F_PI180));
+ }
+ }
}
PostDraw();