summaryrefslogtreecommitdiff
path: root/vcl/headless
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-04-30 12:23:28 +0200
committerTomaž Vajngerl <quikee@gmail.com>2020-05-05 20:36:12 +0200
commit37f472c8d0e8a195c887e34cda796cdeae550ed6 (patch)
tree1c4fe7fd69fa508846100e06990ef3182589932a /vcl/headless
parent2cdec016bc763f5fc9dede8835c8f45139e811ca (diff)
fix line width in DrawPolyLine() with matrix (tdf#132498)
For backends that do the object-to-device coordinates transformation directly, it's necessary to also convert the size of line width. But simply multiplying it with the matrix can also rotate the line width "vector", making it e.g. negative. So don't use just the X coordinate, use vector length for the transformation, which is ok. In fact it doesn't even make sense to treat width as a vector, because a width simply is not a vector (and for this reason it's also not actually used). Change-Id: I1241c9cb29155df105170d568a879ebc32b11a5f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93203 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Jenkins
Diffstat (limited to 'vcl/headless')
-rw-r--r--vcl/headless/svpgdi.cxx19
1 files changed, 9 insertions, 10 deletions
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index b5649b093e31..fadf641fd290 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -1092,7 +1092,7 @@ void SvpSalGraphics::drawPolyLine(sal_uInt32 nPoints, const SalPoint* pPtAry)
basegfx::B2DHomMatrix(),
aPoly,
0.0,
- basegfx::B2DVector(1.0, 1.0),
+ 1.0,
nullptr, // MM01
basegfx::B2DLineJoin::Miter,
css::drawing::LineCap_BUTT,
@@ -1456,7 +1456,7 @@ bool SvpSalGraphics::drawPolyLine(
const basegfx::B2DHomMatrix& rObjectToDevice,
const basegfx::B2DPolygon& rPolyLine,
double fTransparency,
- const basegfx::B2DVector& rLineWidth,
+ double fLineWidth,
const std::vector< double >* pStroke, // MM01
basegfx::B2DLineJoin eLineJoin,
css::drawing::LineCap eLineCap,
@@ -1488,7 +1488,7 @@ bool SvpSalGraphics::drawPolyLine(
rObjectToDevice,
rPolyLine,
fTransparency,
- rLineWidth,
+ fLineWidth,
pStroke, // MM01
eLineJoin,
eLineCap,
@@ -1508,7 +1508,7 @@ bool SvpSalGraphics::drawPolyLine(
const basegfx::B2DHomMatrix& rObjectToDevice,
const basegfx::B2DPolygon& rPolyLine,
double fTransparency,
- const basegfx::B2DVector& rLineWidth,
+ double fLineWidth,
const std::vector< double >* pStroke, // MM01
basegfx::B2DLineJoin eLineJoin,
css::drawing::LineCap eLineCap,
@@ -1522,21 +1522,20 @@ bool SvpSalGraphics::drawPolyLine(
}
// need to check/handle LineWidth when ObjectToDevice transformation is used
- basegfx::B2DVector aLineWidth(rLineWidth);
const bool bObjectToDeviceIsIdentity(rObjectToDevice.isIdentity());
// tdf#124848 calculate-back logical LineWidth for a hairline
// since this implementation hands over the transformation to
// the graphic sub-system
- if(aLineWidth.equalZero())
+ if(fLineWidth == 0)
{
- aLineWidth = basegfx::B2DVector(1.0, 1.0);
+ fLineWidth = 1.0;
if(!bObjectToDeviceIsIdentity)
{
basegfx::B2DHomMatrix aObjectToDeviceInv(rObjectToDevice);
aObjectToDeviceInv.invert();
- aLineWidth = aObjectToDeviceInv * aLineWidth;
+ fLineWidth = (aObjectToDeviceInv * basegfx::B2DVector(fLineWidth, 0)).getLength();
}
}
@@ -1617,7 +1616,7 @@ bool SvpSalGraphics::drawPolyLine(
cairo_set_line_join(cr, eCairoLineJoin);
cairo_set_line_cap(cr, eCairoLineCap);
- cairo_set_line_width(cr, aLineWidth.getX());
+ cairo_set_line_width(cr, fLineWidth);
cairo_set_miter_limit(cr, fMiterLimit);
// try to access buffered data
@@ -1654,7 +1653,7 @@ bool SvpSalGraphics::drawPolyLine(
// check for basegfx::B2DLineJoin::NONE to react accordingly
const bool bNoJoin((basegfx::B2DLineJoin::NONE == eLineJoin
- && basegfx::fTools::more(aLineWidth.getX(), 0.0)));
+ && basegfx::fTools::more(fLineWidth, 0.0)));
if(pSystemDependentData_CairoPath)
{