summaryrefslogtreecommitdiff
path: root/vcl/unx
diff options
context:
space:
mode:
authorArmin Le Grand (Collabora) <Armin.Le.Grand@me.com>2020-02-06 18:53:12 +0100
committerArmin Le Grand <Armin.Le.Grand@me.com>2020-02-07 18:49:18 +0100
commit5f61c9fe99ac93087b898adddbb4d4733f1fcd07 (patch)
tree50e5e98702db8a12eba1e4f5dc730e76db2cca1e /vcl/unx
parent1fb4887613f2487be6081dd62c4df30f6170e2c0 (diff)
tdf#130478 Enhance Dashed line drawing on all systems
For more info and explanation including state of process information and discussion(s) see task please. Adding corrections for gerrit build Change-Id: Ie10fb8093a86459dee80db5ab4355b47e46c1f8c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88130 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'vcl/unx')
-rw-r--r--vcl/unx/generic/gdi/gdiimpl.cxx88
-rw-r--r--vcl/unx/generic/gdi/gdiimpl.hxx1
-rw-r--r--vcl/unx/generic/gdi/salgdi.cxx3
-rw-r--r--vcl/unx/generic/print/genpspgraphics.cxx1
4 files changed, 85 insertions, 8 deletions
diff --git a/vcl/unx/generic/gdi/gdiimpl.cxx b/vcl/unx/generic/gdi/gdiimpl.cxx
index f738591f6b28..12ac59808e4b 100644
--- a/vcl/unx/generic/gdi/gdiimpl.cxx
+++ b/vcl/unx/generic/gdi/gdiimpl.cxx
@@ -18,6 +18,8 @@
*/
#include <memory>
+#include <numeric>
+
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/extensions/Xrender.h>
@@ -1584,6 +1586,7 @@ private:
basegfx::B2DLineJoin meJoin;
css::drawing::LineCap meCap;
double mfMiterMinimumAngle;
+ std::vector< double > maStroke;
public:
SystemDependentData_Triangulation(
@@ -1592,13 +1595,16 @@ public:
const basegfx::B2DVector& rLineWidth,
basegfx::B2DLineJoin eJoin,
css::drawing::LineCap eCap,
- double fMiterMinimumAngle);
+ double fMiterMinimumAngle,
+ const std::vector< double >* pStroke); // MM01
+ // read access
const basegfx::triangulator::B2DTriangleVector& getTriangles() const { return maTriangles; }
const basegfx::B2DVector& getLineWidth() const { return maLineWidth; }
const basegfx::B2DLineJoin& getJoin() const { return meJoin; }
const css::drawing::LineCap& getCap() const { return meCap; }
double getMiterMinimumAngle() const { return mfMiterMinimumAngle; }
+ const std::vector< double >& getStroke() const { return maStroke; }
virtual sal_Int64 estimateUsageInBytes() const override;
};
@@ -1611,14 +1617,20 @@ SystemDependentData_Triangulation::SystemDependentData_Triangulation(
const basegfx::B2DVector& rLineWidth,
basegfx::B2DLineJoin eJoin,
css::drawing::LineCap eCap,
- double fMiterMinimumAngle)
+ double fMiterMinimumAngle,
+ const std::vector< double >* pStroke)
: basegfx::SystemDependentData(rSystemDependentDataManager),
maTriangles(rTriangles),
maLineWidth(rLineWidth),
meJoin(eJoin),
meCap(eCap),
- mfMiterMinimumAngle(fMiterMinimumAngle)
+ mfMiterMinimumAngle(fMiterMinimumAngle),
+ maStroke()
{
+ if(nullptr != pStroke)
+ {
+ maStroke = *pStroke;
+ }
}
sal_Int64 SystemDependentData_Triangulation::estimateUsageInBytes() const
@@ -1638,6 +1650,7 @@ bool X11SalGraphicsImpl::drawPolyLine(
const basegfx::B2DPolygon& rPolygon,
double fTransparency,
const basegfx::B2DVector& rLineWidth,
+ const std::vector< double >* pStroke, // MM01
basegfx::B2DLineJoin eLineJoin,
css::drawing::LineCap eLineCap,
double fMiterMinimumAngle,
@@ -1655,7 +1668,6 @@ bool X11SalGraphicsImpl::drawPolyLine(
const basegfx::B2DVector aDeviceLineWidths(bObjectToDeviceIsIdentity ? rLineWidth : rObjectToDevice * rLineWidth);
const bool bCorrectLineWidth(!bObjectToDeviceIsIdentity && aDeviceLineWidths.getX() < 1.0 && aLineWidth.getX() >= 1.0);
basegfx::B2DHomMatrix aObjectToDeviceInv;
- basegfx::B2DPolygon aPolygon(rPolygon);
if(bCorrectLineWidth)
{
@@ -1673,6 +1685,25 @@ bool X11SalGraphicsImpl::drawPolyLine(
std::shared_ptr<SystemDependentData_Triangulation> pSystemDependentData_Triangulation(
rPolygon.getSystemDependentData<SystemDependentData_Triangulation>());
+ // MM01 need to do line dashing as fallback stuff here now
+ const double fDotDashLength(nullptr != pStroke ? std::accumulate(pStroke->begin(), pStroke->end(), 0.0) : 0.0);
+ const bool bStrokeUsed(0.0 != fDotDashLength);
+
+ if(pSystemDependentData_Triangulation)
+ {
+ // MM01 - check on stroke change. Used against not used, or if oth used,
+ // equal or different? Triangulation geometry creation depends heavily
+ // on stroke, independent of being transformation independent
+ const bool bStrokeWasUsed(!pSystemDependentData_Triangulation->getStroke().empty());
+
+ if(bStrokeWasUsed != bStrokeUsed
+ || (bStrokeUsed && *pStroke != pSystemDependentData_Triangulation->getStroke()))
+ {
+ // data invalid, forget
+ pSystemDependentData_Triangulation.reset();
+ }
+ }
+
if(pSystemDependentData_Triangulation)
{
// check data validity (I)
@@ -1709,15 +1740,36 @@ bool X11SalGraphicsImpl::drawPolyLine(
if(!pSystemDependentData_Triangulation)
{
+ // MM01 need to do line dashing as fallback stuff here now
+ basegfx::B2DPolyPolygon aPolyPolygonLine;
+
+ if(bStrokeUsed)
+ {
+ // apply LineStyle
+ basegfx::utils::applyLineDashing(
+ rPolygon, // source
+ *pStroke, // pattern
+ &aPolyPolygonLine, // traget for lines
+ nullptr, // target for gaps
+ fDotDashLength); // full length if available
+ }
+ else
+ {
+ // no line dashing, just copy
+ aPolyPolygonLine.append(rPolygon);
+ }
+
// try to create data
if(bPixelSnapHairline)
{
+ // Do NOT transform, but keep device-independent. To
+ // do so, transform to device for snap, but back again after
if(!bObjectToDeviceIsIdentity)
{
- aPolygon.transform(rObjectToDevice);
+ aPolyPolygonLine.transform(rObjectToDevice);
}
- aPolygon = basegfx::utils::snapPointsOfHorizontalOrVerticalEdges(aPolygon);
+ aPolyPolygonLine = basegfx::utils::snapPointsOfHorizontalOrVerticalEdges(aPolyPolygonLine);
if(!bObjectToDeviceIsIdentity)
{
@@ -1727,12 +1779,31 @@ bool X11SalGraphicsImpl::drawPolyLine(
aObjectToDeviceInv.invert();
}
- aPolygon.transform(aObjectToDeviceInv);
+ aPolyPolygonLine.transform(aObjectToDeviceInv);
}
}
basegfx::triangulator::B2DTriangleVector aTriangles;
+ // MM01 checked/verified for X11 (linux)
+ for(sal_uInt32 a(0); a < aPolyPolygonLine.count(); a++)
+ {
+ const basegfx::B2DPolygon aPolyLine(aPolyPolygonLine.getB2DPolygon(a));
+ // MM01 upps - commit 51b5b93092d6231615de470c62494c24e54828a1 removed
+ // this *central* geometry-creating lines (!) probably due to aAreaPolyPoly
+ // *not* being used - that's true, but the work is inside of filling
+ // aTriangles data (!)
+ basegfx::utils::createAreaGeometry(
+ aPolyLine,
+ 0.5 * aLineWidth.getX(),
+ eLineJoin,
+ eLineCap,
+ basegfx::deg2rad(12.5),
+ 0.4,
+ fMiterMinimumAngle,
+ &aTriangles); // CAUTION! This is *needed* since it creates the data!
+ }
+
if(!aTriangles.empty())
{
// Add to buffering mechanism
@@ -1744,7 +1815,8 @@ bool X11SalGraphicsImpl::drawPolyLine(
aLineWidth,
eLineJoin,
eLineCap,
- fMiterMinimumAngle);
+ fMiterMinimumAngle,
+ pStroke);
}
}
diff --git a/vcl/unx/generic/gdi/gdiimpl.hxx b/vcl/unx/generic/gdi/gdiimpl.hxx
index 6660e191342d..9a4940eab7d0 100644
--- a/vcl/unx/generic/gdi/gdiimpl.hxx
+++ b/vcl/unx/generic/gdi/gdiimpl.hxx
@@ -172,6 +172,7 @@ public:
const basegfx::B2DPolygon&,
double fTransparency,
const basegfx::B2DVector& rLineWidths,
+ const std::vector< double >* pStroke, // MM01
basegfx::B2DLineJoin,
css::drawing::LineCap,
double fMiterMinimumAngle,
diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx
index 864d3fdb8bd7..d5b6281bed3b 100644
--- a/vcl/unx/generic/gdi/salgdi.cxx
+++ b/vcl/unx/generic/gdi/salgdi.cxx
@@ -699,6 +699,7 @@ bool X11SalGraphics::drawPolyLine(
const basegfx::B2DPolygon& rPolygon,
double fTransparency,
const basegfx::B2DVector& rLineWidth,
+ const std::vector< double >* pStroke, // MM01
basegfx::B2DLineJoin eLineJoin,
css::drawing::LineCap eLineCap,
double fMiterMinimumAngle,
@@ -735,6 +736,7 @@ bool X11SalGraphics::drawPolyLine(
rPolygon,
fTransparency,
rLineWidth,
+ pStroke, // MM01
eLineJoin,
eLineCap,
fMiterMinimumAngle,
@@ -754,6 +756,7 @@ bool X11SalGraphics::drawPolyLine(
rPolygon,
fTransparency,
rLineWidth,
+ pStroke, // MM01
eLineJoin,
eLineCap,
fMiterMinimumAngle,
diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx
index 901edb5c0f49..e0a6778f76ba 100644
--- a/vcl/unx/generic/print/genpspgraphics.cxx
+++ b/vcl/unx/generic/print/genpspgraphics.cxx
@@ -433,6 +433,7 @@ bool GenPspGraphics::drawPolyLine(
const basegfx::B2DPolygon&,
double /*fTransparency*/,
const basegfx::B2DVector& /*rLineWidths*/,
+ const std::vector< double >* /*pStroke*/, // MM01
basegfx::B2DLineJoin /*eJoin*/,
css::drawing::LineCap /*eLineCap*/,
double /*fMiterMinimumAngle*/,