diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2021-04-27 11:44:48 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2021-05-06 16:40:10 +0200 |
commit | ca29019ed56b970327ae3c5c215b5db52ff30444 (patch) | |
tree | 0e2ed80d916967058a774cbef29e0280a7412454 /drawinglayer | |
parent | 8abf1dca16a86ee43fd30786926c9e1556841a9e (diff) |
do not apply line dashing in drawinglayer (tdf#136957)
basegfx::utils::applyLineDashing() is not as good as the actual
VCL backend dashing, and there are some rounding errors because of
all the canvas transformation matrices or whatever, which leads
to the drawing problem. So use LineInfo to carry the dashing
information.
As a part of this change, also make LineInfo use doubles instead
of ints. The use of transformation matrices means that the values
may be fractional and less than one.
Change-Id: Ia5ac7d266cab344b7137052c81fbd96c1ce28003
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114710
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
(cherry picked from commit b71d9a6d15cfb8a50afdea5ac064f40d84c561f8)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115038
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
Diffstat (limited to 'drawinglayer')
-rw-r--r-- | drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx | 53 |
1 files changed, 41 insertions, 12 deletions
diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx index 526f00518910..f518663707c4 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx @@ -1574,31 +1574,60 @@ void VclMetafileProcessor2D::processPolygonStrokePrimitive2D( if (basegfx::fTools::more(rLine.getWidth(), 0.0)) { const attribute::StrokeAttribute& rStroke = rStrokePrimitive.getStrokeAttribute(); - basegfx::B2DPolyPolygon aHairLinePolyPolygon; + const basegfx::BColor aHairlineColor( + maBColorModifierStack.getModifiedColor(rLine.getColor())); + mpOutputDevice->SetLineColor(Color(aHairlineColor)); + mpOutputDevice->SetFillColor(); + + // use the transformed line width + LineInfo aLineInfo(LineStyle::Solid, + basegfx::fround(getTransformedLineWidth(rLine.getWidth()))); + aLineInfo.SetLineJoin(rLine.getLineJoin()); + aLineInfo.SetLineCap(rLine.getLineCap()); + + basegfx::B2DPolyPolygon aHairLinePolyPolygon; if (0.0 == rStroke.getFullDotDashLen()) { aHairLinePolyPolygon.append(rBasePolygon); } + else if (rStroke.getDotDashArray().size() == 2) + { + aHairLinePolyPolygon.append(rBasePolygon); + // This will be used by setupStrokeAttributes() in cppcanvas. + aLineInfo.SetStyle(LineStyle::Dash); + aLineInfo.SetDashCount(1); + aLineInfo.SetDashLen( + basegfx::fround(getTransformedLineWidth(rStroke.getDotDashArray()[0]))); + aLineInfo.SetDistance( + basegfx::fround(getTransformedLineWidth(rStroke.getDotDashArray()[1]))); + } + else if (rStroke.getDotDashArray().size() == 4 + && rStroke.getDotDashArray()[1] == rStroke.getDotDashArray()[3]) + { + aHairLinePolyPolygon.append(rBasePolygon); + // This will be used by setupStrokeAttributes() in cppcanvas. + aLineInfo.SetStyle(LineStyle::Dash); + aLineInfo.SetDashCount(1); + aLineInfo.SetDashLen( + basegfx::fround(getTransformedLineWidth(rStroke.getDotDashArray()[0]))); + aLineInfo.SetDistance( + basegfx::fround(getTransformedLineWidth(rStroke.getDotDashArray()[1]))); + aLineInfo.SetDotCount(1); + aLineInfo.SetDotLen( + basegfx::fround(getTransformedLineWidth(rStroke.getDotDashArray()[2]))); + } else { + // LineInfo can hold only limited info about dashing, apply dashing manually + // if LineInfo cannot describe it. That should not happen though. + SAL_WARN("drawinglayer", "dotdash array cannot be converted to LineInfo"); basegfx::utils::applyLineDashing(rBasePolygon, rStroke.getDotDashArray(), &aHairLinePolyPolygon, nullptr, rStroke.getFullDotDashLen()); } - - const basegfx::BColor aHairlineColor( - maBColorModifierStack.getModifiedColor(rLine.getColor())); - mpOutputDevice->SetLineColor(Color(aHairlineColor)); - mpOutputDevice->SetFillColor(); aHairLinePolyPolygon.transform(maCurrentTransformation); - // use the transformed line width - LineInfo aLineInfo(LineStyle::Solid, - basegfx::fround(getTransformedLineWidth(rLine.getWidth()))); - aLineInfo.SetLineJoin(rLine.getLineJoin()); - aLineInfo.SetLineCap(rLine.getLineCap()); - for (sal_uInt32 a(0); a < aHairLinePolyPolygon.count(); a++) { const basegfx::B2DPolygon& aCandidate(aHairLinePolyPolygon.getB2DPolygon(a)); |