diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2020-04-29 16:12:11 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2020-04-30 15:56:16 +0200 |
commit | fa4fe362cd15f89996cf877f31efbac7363f64af (patch) | |
tree | 0837ca88f3eb2a51cd8870ed2ad27f2ba26de8e8 /vcl/skia | |
parent | 9c67355fe438c2c8ebc61b170e102dc9dbfd7448 (diff) |
implement basegfx::B2DLineJoin::NONE for Skia drawPolyLine()
Change-Id: I186622aec3e944b89536bdcd44ff0be6b1d9cd8c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93213
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl/skia')
-rw-r--r-- | vcl/skia/gdiimpl.cxx | 53 |
1 files changed, 35 insertions, 18 deletions
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx index 2ffd68dee132..efecb95b7920 100644 --- a/vcl/skia/gdiimpl.cxx +++ b/vcl/skia/gdiimpl.cxx @@ -778,12 +778,6 @@ bool SkiaSalGraphicsImpl::drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDev const basegfx::B2DVector aLineWidth(rLineWidth.equalZero() ? basegfx::B2DVector(1.0, 1.0) : rObjectToDevice * rLineWidth); - // Skia does not support B2DLineJoin::NONE; return false to use - // the fallback (own geometry preparation), - // linejoin-mode and thus the above only applies to "fat" lines. - if ((basegfx::B2DLineJoin::NONE == eLineJoin) && (aLineWidth.getX() > 1.3)) - return false; - // MM01 need to do line dashing as fallback stuff here now const double fDotDashLength( nullptr != pStroke ? std::accumulate(pStroke->begin(), pStroke->end(), 0.0) : 0.0); @@ -857,21 +851,44 @@ bool SkiaSalGraphicsImpl::drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDev aPaint.setStrokeWidth(aLineWidth.getX()); aPaint.setAntiAlias(mParent.getAntiAliasB2DDraw()); - SkPath aPath; - - // MM01 checked/verified for Skia (on Win) - for (sal_uInt32 a(0); a < aPolyPolygonLine.count(); a++) + if (eLineJoin != basegfx::B2DLineJoin::NONE) + { + SkPath aPath; + aPath.setFillType(SkPathFillType::kEvenOdd); + for (sal_uInt32 a(0); a < aPolyPolygonLine.count(); a++) + addPolygonToPath(aPolyPolygonLine.getB2DPolygon(a), aPath); + // Apply the same adjustment as toSkX()/toSkY() do. Do it here even in the non-GPU + // case as it seems to produce better results. + aPath.offset(0.5, 0.5, nullptr); + getDrawCanvas()->drawPath(aPath, aPaint); + addXorRegion(aPath.getBounds()); + } + else // Skia does not support basegfx::B2DLineJoin::NONE, draw each line separately { - const basegfx::B2DPolygon aPolyLine(aPolyPolygonLine.getB2DPolygon(a)); - addPolygonToPath(aPolyLine, aPath); + for (sal_uInt32 i = 0; i < aPolyPolygonLine.count(); ++i) + { + const basegfx::B2DPolygon& rPolygon = aPolyPolygonLine.getB2DPolygon(i); + sal_uInt32 nPoints = rPolygon.count(); + bool bClosed = rPolygon.isClosed(); + for (sal_uInt32 j = 0; j < (bClosed ? nPoints : nPoints - 1); ++j) + { + sal_uInt32 index1 = (j + 0) % nPoints; + sal_uInt32 index2 = (j + 1) % nPoints; + SkPath aPath; + aPath.moveTo(rPolygon.getB2DPoint(index1).getX(), + rPolygon.getB2DPoint(index1).getY()); + aPath.lineTo(rPolygon.getB2DPoint(index2).getX(), + rPolygon.getB2DPoint(index2).getY()); + + // Apply the same adjustment as toSkX()/toSkY() do. Do it here even in the non-GPU + // case as it seems to produce better results. + aPath.offset(0.5, 0.5, nullptr); + getDrawCanvas()->drawPath(aPath, aPaint); + addXorRegion(aPath.getBounds()); + } + } } - aPath.setFillType(SkPathFillType::kEvenOdd); - // Apply the same adjustment as toSkX()/toSkY() do. Do it here even in the non-GPU - // case as it seems to produce better results. - aPath.offset(0.5, 0.5, nullptr); - getDrawCanvas()->drawPath(aPath, aPaint); - addXorRegion(aPath.getBounds()); postDraw(); return true; |