diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-01-12 20:51:39 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-01-13 07:36:48 +0100 |
commit | bfe32f3e50b5406810e740ac41368f101033e766 (patch) | |
tree | e5021955a50738e3a35ed4405473bc115b06ced6 /svx | |
parent | b0c68f982dfabd33b6049c3614734401f70bae50 (diff) |
optimise ensureGeometry
for complex polygons, return early
Change-Id: Id4bb2311f84508d95a71a3f4353872164baabe6e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128354
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/sdr/contact/viewcontactofsdrpathobj.cxx | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx b/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx index fae763c28e1c..8798d40fb70b 100644 --- a/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx @@ -43,7 +43,8 @@ namespace sdr::contact { } - static sal_uInt32 ensureGeometry(basegfx::B2DPolyPolygon& rUnitPolyPolygon) + /// return true if polycount == 1 + static bool ensureGeometry(basegfx::B2DPolyPolygon& rUnitPolyPolygon) { sal_uInt32 nPolyCount(rUnitPolyPolygon.count()); sal_uInt32 nPointCount(0); @@ -51,6 +52,8 @@ namespace sdr::contact for(auto const& rPolygon : std::as_const(rUnitPolyPolygon)) { nPointCount += rPolygon.count(); + if (nPointCount > 1) + return false; } if(!nPointCount) @@ -64,7 +67,7 @@ namespace sdr::contact nPolyCount = 1; } - return nPolyCount; + return nPolyCount == 1; } void ViewContactOfSdrPathObj::createViewIndependentPrimitive2DSequence(drawinglayer::primitive2d::Primitive2DDecompositionVisitor& rVisitor) const @@ -76,14 +79,14 @@ namespace sdr::contact GetPathObj().getText(0), false)); basegfx::B2DPolyPolygon aUnitPolyPolygon(GetPathObj().GetPathPoly()); - sal_uInt32 nPolyCount(ensureGeometry(aUnitPolyPolygon)); + bool bPolyCountIsOne(ensureGeometry(aUnitPolyPolygon)); // prepare object transformation and unit polygon (direct model data) basegfx::B2DHomMatrix aObjectMatrix; basegfx::B2DPolyPolygon aUnitDefinitionPolyPolygon; bool bIsLine( !aUnitPolyPolygon.areControlPointsUsed() - && 1 == nPolyCount + && bPolyCountIsOne && 2 == aUnitPolyPolygon.getB2DPolygon(0).count()); if(bIsLine) @@ -113,12 +116,12 @@ namespace sdr::contact aUnitPolyPolygon = basegfx::utils::clipPolyPolygonOnRange(aUnitPolyPolygon, aClipRange, true, true); - nPolyCount = ensureGeometry(aUnitPolyPolygon); + bPolyCountIsOne = ensureGeometry(aUnitPolyPolygon); // re-check that we have't been clipped out to oblivion bIsLine = !aUnitPolyPolygon.areControlPointsUsed() - && 1 == nPolyCount + && bPolyCountIsOne && 2 == aUnitPolyPolygon.getB2DPolygon(0).count(); } } |