diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2021-04-27 11:44:48 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2021-04-29 16:05:53 +0200 |
commit | b71d9a6d15cfb8a50afdea5ac064f40d84c561f8 (patch) | |
tree | 3a9bd3205754d28f411257e0207295a781451d6d /drawinglayer | |
parent | 5d4e450a7d64d3dc1caf34544dbfa35f4641d5c3 (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>
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 6f690ca55f46..0dc0904015f0 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)); |