summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de>2018-09-15 13:48:12 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2018-09-21 13:50:17 +0200
commit98fcc65a173d2f9ea2c2bba2c4670aaa7699c50e (patch)
tree225cf135fcd49fb3db6a3969ad0325116cc1bab5 /include
parent73f95c17bc6e295e364d777c29a6f0cd4d3c71a6 (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> Reviewed-on: https://gerrit.libreoffice.org/60857 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'include')
-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 5aefafbe679b..106096dcd8ed 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 = css::drawing::LineCap_BUTT,
double fMaxAllowedAngle = (12.5 * F_PI180),
double fMaxPartOfEdge = 0.4,
- double fMiterMinimumAngle = (15.0 * F_PI180));
+ double fMiterMinimumAngle = (15.0 * F_PI180),
+ basegfx::triangulator::B2DTriangleVector* pTriangles = nullptr);
} // end of namespace tools
} // end of namespace basegfx
diff --git a/include/basegfx/polygon/b2dpolygontools.hxx b/include/basegfx/polygon/b2dpolygontools.hxx
index 423cf8f30ef4..36b837525dc1 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>
@@ -359,7 +360,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