diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-04-15 15:46:06 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-04-20 12:09:02 +0000 |
commit | a5928a57a53df84cacd2975e227f9e03d50456a6 (patch) | |
tree | d57963014e01a20f77cb7b3a25e3b7d9aa9a50b5 /drawinglayer/source | |
parent | e3d8431d00116e9aeb5570b15324a26258afba00 (diff) |
tdf#99315 VclPixelProcessor2D: fix double border line width
Regression from commit 2c91cb08d65cd35fa8ef6eaca3677aa82fb58cbe (better
drawing support for borders of different width, fdo#33634, 2012-04-04),
the problem is that previously the width of inner/outer double border
lines got rounded to integer values quite early, but after the commit
they are kept at a double precision for much longer, which needs pixel
correction in VclPixelProcessor2D.
Example: if the border with is 1.47, and the line gets moved by 0.2
pixels, then the inner and outer edge of the line will be 0.2 and 1.67,
which gets rounded to 0 -> 2 in the pixel processor. Previously the
input was rounded to 1, so moving by 0.2 resulted in 0.2 -> 1.2, which
got rounded to 0 -> 1. The result is that sometimes the line width is 1
pixel wider than expected.
Fix the problem by allowing VclPixelProcessor2D to request pixel
correction from BorderLinePrimitive2D. It wouldn't be possible to do
pixel correction only in VclPixelProcessor2D, as it has no idea what to
correct: it only gets polygons, so it has no idea if e.g. the top of a
polygon is the outer edge of a top border line or an inner edge of a
bottom border line.
Conflicts:
drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
(cherry picked from commits 1ee570a4e625719f8bf270d372926c0d829ae6f0,
555c9add26e06030402c73f885de98f4b96826f0,
304f50684d3ac08e973fd27e6acf3e821394d164,
422f10c5d7ebe6f4b778636c9c1eb6dbdf708a27,
ce12a5021a080cc1781e0e0256af5e0085e11ef2 and
cac70559013e575009657aa3c5168b88b1f14691)
Change-Id: I1971f3a952fbcdc598ab46c659e12d976c13cbe6
Reviewed-on: https://gerrit.libreoffice.org/24238
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'drawinglayer/source')
-rw-r--r-- | drawinglayer/source/primitive2d/borderlineprimitive2d.cxx | 28 | ||||
-rw-r--r-- | drawinglayer/source/processor2d/vclpixelprocessor2d.cxx | 7 |
2 files changed, 31 insertions, 4 deletions
diff --git a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx index 30e656d99866..30e7dcbacba6 100644 --- a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx @@ -28,6 +28,17 @@ #include <numeric> #include <algorithm> +#if defined(ANDROID) +namespace std +{ +template<typename T> +T round(T x) +{ + return ::round(x); +} +} +#endif + namespace drawinglayer { namespace { @@ -63,7 +74,7 @@ primitive2d::Primitive2DReference makeSolidLinePrimitive( const basegfx::B2DVector& rVector, const basegfx::BColor& rColor, double fLineWidth, double fGap) { const basegfx::B2DVector aPerpendicular = basegfx::getPerpendicular(rVector); - const basegfx::B2DVector aLineWidthOffset = ((fLineWidth + 1.0) * 0.5) * aPerpendicular; + const basegfx::B2DVector aLineWidthOffset = (fLineWidth * 0.5) * aPerpendicular; basegfx::B2DPolygon aPolygon; aPolygon.append(rStart + aLineWidthOffset); @@ -163,6 +174,11 @@ primitive2d::Primitive2DReference makeSolidLinePrimitive( Primitive2DSequence BorderLinePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const { + return createDecomposition(rViewInformation, false); + } + + Primitive2DSequence BorderLinePrimitive2D::createDecomposition(const geometry::ViewInformation2D& rViewInformation, bool bPixelCorrection) const + { Primitive2DSequence xRetval; if(!getStart().equal(getEnd()) && ( isInsideUsed() || isOutsideUsed() ) ) @@ -199,8 +215,11 @@ primitive2d::Primitive2DReference makeSolidLinePrimitive( xRetval[0] = makeHairLinePrimitive( getStart(), getEnd(), aVector, getRGBColorLeft(), 0.0); else + { + double fWidth = bPixelCorrection ? std::round(fLeftWidth) : fLeftWidth; xRetval[0] = makeSolidLinePrimitive( - aClipRegion, aTmpStart, aTmpEnd, aVector, getRGBColorLeft(), fLeftWidth, -fLeftWidth/2.0); + aClipRegion, aTmpStart, aTmpEnd, aVector, getRGBColorLeft(), fWidth, -fLeftWidth/2.0); + } // "outside" line @@ -208,8 +227,11 @@ primitive2d::Primitive2DReference makeSolidLinePrimitive( xRetval[1] = makeHairLinePrimitive( getStart(), getEnd(), aVector, getRGBColorRight(), fLeftWidth+mfDistance); else + { + double fWidth = bPixelCorrection ? std::round(fRightWidth) : fRightWidth; xRetval[1] = makeSolidLinePrimitive( - aClipRegion, aTmpStart, aTmpEnd, aVector, getRGBColorRight(), fRightWidth, mfDistance+fRightWidth/2.0); + aClipRegion, aTmpStart, aTmpEnd, aVector, getRGBColorRight(), fWidth, mfDistance+fRightWidth/2.0); + } } else { diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx index 8dcd74e77ac5..8398573ddb4e 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx @@ -1232,7 +1232,12 @@ namespace drawinglayer static_cast<const drawinglayer::primitive2d::BorderLinePrimitive2D&>(rCandidate); if (!tryDrawBorderLinePrimitive2DDirect(rBorder)) - process(rCandidate.get2DDecomposition(getViewInformation2D())); + { + if (rBorder.getStyle() == table::BorderLineStyle::DOUBLE) + process(rBorder.createDecomposition(getViewInformation2D(), true)); + else + process(rCandidate.get2DDecomposition(getViewInformation2D())); + } mpOutputDevice->SetAntialiasing(nAntiAliasing); break; |