summaryrefslogtreecommitdiff
path: root/vcl/opengl
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/opengl
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/opengl')
-rw-r--r--vcl/opengl/RenderList.cxx6
-rw-r--r--vcl/opengl/gdiimpl.cxx14
2 files changed, 10 insertions, 10 deletions
diff --git a/vcl/opengl/RenderList.cxx b/vcl/opengl/RenderList.cxx
index 81817950d05a..4830f1040de9 100644
--- a/vcl/opengl/RenderList.cxx
+++ b/vcl/opengl/RenderList.cxx
@@ -372,7 +372,7 @@ void RenderList::addDrawTextureWithMaskColor(OpenGLTexture const & rTexture, Col
}
void RenderList::addDrawPolyLine(const basegfx::B2DPolygon& rPolygon, double fTransparency,
- const basegfx::B2DVector& rLineWidth, basegfx::B2DLineJoin eLineJoin,
+ double fLineWidth, basegfx::B2DLineJoin eLineJoin,
css::drawing::LineCap eLineCap, double fMiterMinimumAngle,
Color nLineColor, bool bUseAA)
{
@@ -383,8 +383,8 @@ void RenderList::addDrawPolyLine(const basegfx::B2DPolygon& rPolygon, double fTr
if (fTransparency == 1.0)
return;
- const bool bIsHairline = (rLineWidth.getX() == rLineWidth.getY()) && (rLineWidth.getX() <= 1.2);
- const float fLineWidth = bIsHairline ? 1.0f : rLineWidth.getX();
+ const bool bIsHairline = fLineWidth <= 1.2;
+ fLineWidth = bIsHairline ? 1.0f : fLineWidth;
basegfx::B2DPolygon aPolygon(rPolygon);
if (rPolygon.areControlPointsUsed())
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 25cac157a56b..6c76154ea498 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -1560,7 +1560,7 @@ void OpenGLSalGraphicsImpl::drawPolyLine( sal_uInt32 nPoints, const SalPoint* pP
basegfx::B2DHomMatrix(),
aPoly,
0.0,
- basegfx::B2DVector(1.0, 1.0),
+ 1.0,
nullptr, // MM01
basegfx::B2DLineJoin::Miter,
css::drawing::LineCap_BUTT,
@@ -1638,7 +1638,7 @@ bool OpenGLSalGraphicsImpl::drawPolyLine(
const basegfx::B2DHomMatrix& rObjectToDevice,
const basegfx::B2DPolygon& rPolygon,
double fTransparency,
- const basegfx::B2DVector& rLineWidth,
+ double fLineWidth,
const std::vector< double >* pStroke, // MM01
basegfx::B2DLineJoin eLineJoin,
css::drawing::LineCap eLineCap,
@@ -1680,10 +1680,10 @@ bool OpenGLSalGraphicsImpl::drawPolyLine(
if(bPixelSnapHairline) { aPolyPolygonLine = basegfx::utils::snapPointsOfHorizontalOrVerticalEdges(aPolyPolygonLine); }
// tdf#124848 get correct LineWidth in discrete coordinates,
- // take hairline case into account
- const basegfx::B2DVector aLineWidth(rLineWidth.equalZero()
- ? basegfx::B2DVector(1.0, 1.0)
- : rObjectToDevice * rLineWidth);
+ if(fLineWidth == 0) // hairline
+ fLineWidth = 1.0;
+ else // Adjust line width for object-to-device scale.
+ fLineWidth = (rObjectToDevice * basegfx::B2DVector(fLineWidth, 0)).getLength();
for(sal_uInt32 a(0); a < aPolyPolygonLine.count(); a++)
{
@@ -1695,7 +1695,7 @@ bool OpenGLSalGraphicsImpl::drawPolyLine(
mpRenderList->addDrawPolyLine(
aPolyLine,
fTransparency,
- aLineWidth,
+ fLineWidth,
eLineJoin,
eLineCap,
fMiterMinimumAngle,