diff options
author | Armin Le Grand (Collabora) <Armin.Le.Grand@me.com> | 2020-02-14 12:32:42 +0100 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2020-02-14 16:44:26 +0100 |
commit | 0dc4fddb9c76a3f4682eca4059b42a079e74e735 (patch) | |
tree | d75c9e40979d9cc865b90468aea8d6763a2e0253 /include | |
parent | 75500a4161c86bba644d212f2f2eef78dfeb9dea (diff) |
tdf#130655 added callback interface to ::applyLineDashing
This version of the tooling method allows to avoid collecting line
snippets in a return value PolyPolygon. Instead, offer lambda
functions to get callbacks for created snippets. The original
method using a B2DPolyPolygon return value is adapted to already
use this, so serves as example of usage and ensures that only
one identical algorithm is used.
Change-Id: Ie306968a895ad280fc2425fb40b3244769216ba0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88684
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/basegfx/polygon/b2dpolygontools.hxx | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/include/basegfx/polygon/b2dpolygontools.hxx b/include/basegfx/polygon/b2dpolygontools.hxx index 565f8013ffe9..2ec15714088b 100644 --- a/include/basegfx/polygon/b2dpolygontools.hxx +++ b/include/basegfx/polygon/b2dpolygontools.hxx @@ -20,6 +20,9 @@ #ifndef INCLUDED_BASEGFX_POLYGON_B2DPOLYGONTOOLS_HXX #define INCLUDED_BASEGFX_POLYGON_B2DPOLYGONTOOLS_HXX +#include <vector> +#include <functional> + #include <basegfx/point/b2dpoint.hxx> #include <basegfx/vector/b2dvector.hxx> #include <basegfx/range/b2drectangle.hxx> @@ -27,7 +30,6 @@ #include <basegfx/polygon/b2dpolygontriangulator.hxx> #include <com/sun/star/drawing/PointSequence.hpp> #include <com/sun/star/drawing/FlagSequence.hpp> -#include <vector> #include <basegfx/basegfxdllapi.h> #include <o3tl/typed_flags_set.hxx> @@ -188,9 +190,29 @@ namespace basegfx @param fFullDashDotLen The summed-up length of the rDotDashArray. If zero, it will be calculated internally. + + There is now a 2nd version that allows to provide callback + functions that get called when a snippet of a line/gap is + produced and needs to be added. This allows to use it like + a 'pipeline'. When using this (e.g. the 1st version uses + this internally to guarantee the same algorithm is used) + it is not needed to accumulate a potentially huge number + of polygons in the result-polyPolygons, but e.g. consume + them directly in the caller. Example is renderinmg a + dashed line but without creating the potentially huge amount + of polygons. + The 2nd version will also merge first/last line/gap snippets + if the input polygon is closed and the start/end-points match + accordingly - at the cost that this will be delivered last. */ BASEGFX_DLLPUBLIC void applyLineDashing( const B2DPolygon& rCandidate, + const std::vector<double>& rDotDashArray, + std::function<void(const basegfx::B2DPolygon& rSnippet)> aLineTargetCallback, + std::function<void(const basegfx::B2DPolygon& rSnippet)> aGapTargetCallback = std::function<void(const basegfx::B2DPolygon&)>(), + double fDotDashLength = 0.0); + BASEGFX_DLLPUBLIC void applyLineDashing( + const B2DPolygon& rCandidate, const ::std::vector<double>& rDotDashArray, B2DPolyPolygon* pLineTarget, B2DPolyPolygon* pGapTarget = nullptr, |