summaryrefslogtreecommitdiff
path: root/include/basegfx
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de>2018-09-15 13:48:12 +0200
committerArmin Le Grand <Armin.Le.Grand@cib.de>2018-09-20 20:01:07 +0200
commit66232248ff55639052ddb76918d555e21dc9c46b (patch)
tree57ab3314e473f12b1ba3f2594f13abeded3d4fed /include/basegfx
parentad15354a7061b39d2ba22011a6d74b4ba2af4fae (diff)
Support buffering SystemDependent GraphicData (III)
This change is for speedup of fat line drawing when using X11. This is a long-term problem which never really progressed, but is avoided using Cairo in the future. Still - if used, speedup using current state and buffering possibilities. Two speedup steps will be used: (1) The tesselation is no longer done using trapezoids. That works (but was done wrong leaving artifacts) but is not fast and done every time. It is even not done with FatLines and more than 1000 points. New version will use triangulation. Dspite using the existing triangulator (that works but is slow) extend the FatLine geometry creator to directly create triangles. This is also necessary since for buffering that data a transformation-invariant version is needed (in device coordinates the data changes all the time when scrolling). Trapezoids are by definition *not* transformation-invariant (e.g. rotation) (2) Buffer that triangulation - with the needed care and watch. It is e.g. necessary to react on 'hairlines' since these change their logical LineWidth view-dependent (zoom). In those cases, the buffered data *has* to be removed due to the base for buffering is the created FatLine geometry based on one stable logical LineWidth Also took the time to adapt B2DPolygonTriangulator to use an own data type (B2DTriangle) and a vector of these for better understandability and security. Adapted all usages as needed. Change-Id: Iedb2932b094a8786fd9c32d0d0ab1ca603a1a7b2 Reviewed-on: https://gerrit.libreoffice.org/60818 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
Diffstat (limited to 'include/basegfx')
-rw-r--r--include/basegfx/polygon/b2dlinegeometry.hxx9
-rw-r--r--include/basegfx/polygon/b2dpolygontools.hxx5
-rw-r--r--include/basegfx/polygon/b2dpolygontriangulator.hxx35
3 files changed, 44 insertions, 5 deletions
diff --git a/include/basegfx/polygon/b2dlinegeometry.hxx b/include/basegfx/polygon/b2dlinegeometry.hxx
index 29be9934ede0..cdfad4a0ddc5 100644
--- a/include/basegfx/polygon/b2dlinegeometry.hxx
+++ b/include/basegfx/polygon/b2dlinegeometry.hxx
@@ -26,7 +26,7 @@
#include <basegfx/polygon/b2dpolygon.hxx>
#include <com/sun/star/drawing/LineCap.hpp>
#include <basegfx/basegfxdllapi.h>
-
+#include <basegfx/polygon/b2dpolygontriangulator.hxx>
namespace basegfx
{
@@ -124,6 +124,10 @@ namespace basegfx
the usual fallback to bevel is used. Allowed range is cropped
to [F_PI .. 0.01 * F_PI].
+ @param pTriangles
+ If given, the methjod will additionally add the created geometry as
+ B2DTriangle's
+
@return
The tools::PolyPolygon containing the geometry of the extended line by
it's line width. Contains bezier segments and edge roundings as
@@ -136,7 +140,8 @@ namespace basegfx
css::drawing::LineCap eCap,
double fMaxAllowedAngle = basegfx::deg2rad(12.5),
double fMaxPartOfEdge = 0.4,
- double fMiterMinimumAngle = basegfx::deg2rad(15.0));
+ double fMiterMinimumAngle = basegfx::deg2rad(15.0),
+ basegfx::triangulator::B2DTriangleVector* pTriangles = nullptr);
} // end of namespace utils
} // end of namespace basegfx
diff --git a/include/basegfx/polygon/b2dpolygontools.hxx b/include/basegfx/polygon/b2dpolygontools.hxx
index 039000f053d1..62430d323cef 100644
--- a/include/basegfx/polygon/b2dpolygontools.hxx
+++ b/include/basegfx/polygon/b2dpolygontools.hxx
@@ -25,6 +25,7 @@
#include <basegfx/range/b2drectangle.hxx>
#include <basegfx/polygon/b2dpolypolygon.hxx>
#include <basegfx/polygon/b3dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontriangulator.hxx>
#include <com/sun/star/drawing/PointSequence.hpp>
#include <com/sun/star/drawing/FlagSequence.hpp>
#include <vector>
@@ -356,7 +357,9 @@ namespace basegfx
// add triangles for given rCandidate to rTarget. For each triangle, 3 points will be added to rCandidate.
// All triangles will go from the start point of rCandidate to two consecutive points, building (rCandidate.count() - 2)
// triangles.
- BASEGFX_DLLPUBLIC void addTriangleFan(const B2DPolygon& rCandidate, B2DPolygon& rTarget);
+ BASEGFX_DLLPUBLIC void addTriangleFan(
+ const B2DPolygon& rCandidate,
+ triangulator::B2DTriangleVector& rTarget);
// grow for polygon. Move all geometry in each point in the direction of the normal in that point
// with the given amount. Value may be negative.
diff --git a/include/basegfx/polygon/b2dpolygontriangulator.hxx b/include/basegfx/polygon/b2dpolygontriangulator.hxx
index d3e92a017d79..7ecb819b3241 100644
--- a/include/basegfx/polygon/b2dpolygontriangulator.hxx
+++ b/include/basegfx/polygon/b2dpolygontriangulator.hxx
@@ -28,11 +28,42 @@ namespace basegfx
{
namespace triangulator
{
+ // Simple B2D-based triangle. Main reason is to
+ // keep the data types separated (before a B2DPolygon
+ // was used with the convention that three points in
+ // a row define a triangle)
+ class BASEGFX_DLLPUBLIC B2DTriangle
+ {
+ // positions
+ basegfx::B2DPoint maA;
+ basegfx::B2DPoint maB;
+ basegfx::B2DPoint maC;
+
+ public:
+ B2DTriangle(
+ const basegfx::B2DPoint& rA,
+ const basegfx::B2DPoint& rB,
+ const basegfx::B2DPoint& rC)
+ : maA(rA),
+ maB(rB),
+ maC(rC)
+ {
+ }
+
+ // get positions
+ const basegfx::B2DPoint& getA() const { return maA; }
+ const basegfx::B2DPoint& getB() const { return maB; }
+ const basegfx::B2DPoint& getC() const { return maC; }
+ };
+
+ // typedef for a vector of B2DTriangle
+ typedef ::std::vector< B2DTriangle > B2DTriangleVector;
+
// triangulate given polygon
- BASEGFX_DLLPUBLIC ::basegfx::B2DPolygon triangulate(const ::basegfx::B2DPolygon& rCandidate);
+ BASEGFX_DLLPUBLIC B2DTriangleVector triangulate(const ::basegfx::B2DPolygon& rCandidate);
// triangulate given PolyPolygon
- BASEGFX_DLLPUBLIC ::basegfx::B2DPolygon triangulate(const ::basegfx::B2DPolyPolygon& rCandidate);
+ BASEGFX_DLLPUBLIC B2DTriangleVector triangulate(const ::basegfx::B2DPolyPolygon& rCandidate);
} // end of namespace triangulator
} // end of namespace basegfx