diff options
author | Noel Grandin <noelgrandin@collabora.co.uk> | 2024-03-07 12:08:09 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-03-07 12:53:27 +0100 |
commit | 7979508e4328ceb9d6a2dff6a2a080ea64247c7e (patch) | |
tree | 3f3b9bfd3c02fbbcf2b6f623828fa3cfedf6e5d5 /basegfx | |
parent | 10e12d0e6316ac20388f589f062e784e8d9aa630 (diff) |
Simplify some basegfx::fTools::*orEqual calls
Comparing with zero is simple - the implementation of basegfx::fTools::moreOrEqual
calls rtl_math_approxEqual eventually, which special-zases zero.
Change-Id: I62f10f63f103d91a201dfeb20e5b3f9010f377c1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164526
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basegfx')
-rw-r--r-- | basegfx/source/curve/b2dcubicbezier.cxx | 2 | ||||
-rw-r--r-- | basegfx/source/numeric/ftools.cxx | 2 | ||||
-rw-r--r-- | basegfx/source/polygon/b2dlinegeometry.cxx | 4 | ||||
-rw-r--r-- | basegfx/source/polygon/b2dpolygontools.cxx | 6 | ||||
-rw-r--r-- | basegfx/source/polygon/b2dpolypolygoncutter.cxx | 8 | ||||
-rw-r--r-- | basegfx/source/polygon/b2dtrapezoid.cxx | 8 | ||||
-rw-r--r-- | basegfx/source/polygon/b3dpolygontools.cxx | 4 | ||||
-rw-r--r-- | basegfx/source/tools/bgradient.cxx | 3 |
8 files changed, 18 insertions, 19 deletions
diff --git a/basegfx/source/curve/b2dcubicbezier.cxx b/basegfx/source/curve/b2dcubicbezier.cxx index d33cd82b194d..927230fabcb1 100644 --- a/basegfx/source/curve/b2dcubicbezier.cxx +++ b/basegfx/source/curve/b2dcubicbezier.cxx @@ -541,7 +541,7 @@ namespace basegfx B2DVector B2DCubicBezier::getTangent(double t) const { - if(fTools::lessOrEqual(t, 0.0)) + if(t <= 0.0) { // tangent in start point B2DVector aTangent(getControlPointA() - getStartPoint()); diff --git a/basegfx/source/numeric/ftools.cxx b/basegfx/source/numeric/ftools.cxx index 246d8d548aac..4a01a4c0eca0 100644 --- a/basegfx/source/numeric/ftools.cxx +++ b/basegfx/source/numeric/ftools.cxx @@ -99,7 +99,7 @@ namespace basegfx double normalizeToRange(double v, const double fRange) { - if(fTools::lessOrEqual(fRange, 0.0)) + if(fRange <= 0.0) { // with a zero (or less) range, all normalizes to 0.0 return 0.0; diff --git a/basegfx/source/polygon/b2dlinegeometry.cxx b/basegfx/source/polygon/b2dlinegeometry.cxx index 437ebcbb496e..4f5de36a8295 100644 --- a/basegfx/source/polygon/b2dlinegeometry.cxx +++ b/basegfx/source/polygon/b2dlinegeometry.cxx @@ -147,7 +147,7 @@ namespace basegfx const B2DVector aTangentA(rCandidate.getTangent(0.0)); const double fScalarAE(aEdge.scalar(aTangentA)); - if(fTools::lessOrEqual(fScalarAE, 0.0)) + if(fScalarAE <= 0.0) { // angle between TangentA and Edge is bigger or equal 90 degrees return false; @@ -174,7 +174,7 @@ namespace basegfx const B2DVector aTangentB(rCandidate.getTangent(1.0)); const double fScalarBE(aEdge.scalar(aTangentB)); - if(fTools::lessOrEqual(fScalarBE, 0.0)) + if(fScalarBE <= 0.0) { // angle between TangentB and Edge is bigger or equal 90 degrees return false; diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx index b3f43669ddf4..0d9dbc15b42d 100644 --- a/basegfx/source/polygon/b2dpolygontools.cxx +++ b/basegfx/source/polygon/b2dpolygontools.cxx @@ -1239,12 +1239,12 @@ namespace basegfx::utils const sal_uInt32 nPointCount(rCandidate.count()); const sal_uInt32 nDotDashCount(rDotDashArray.size()); - if(fTools::lessOrEqual(fDotDashLength, 0.0)) + if(fDotDashLength <= 0.0) { fDotDashLength = std::accumulate(rDotDashArray.begin(), rDotDashArray.end(), 0.0); } - if(fTools::lessOrEqual(fDotDashLength, 0.0) || (!rLineTargetCallback && !rGapTargetCallback) || !nPointCount) + if(fDotDashLength <= 0.0 || (!rLineTargetCallback && !rGapTargetCallback) || !nPointCount) { // parameters make no sense, just add source to targets if (rLineTargetCallback) @@ -2846,7 +2846,7 @@ namespace basegfx::utils { OSL_ENSURE(rOld1.count() == rOld2.count(), "B2DPolygon interpolate: Different geometry (!)"); - if(fTools::lessOrEqual(t, 0.0) || rOld1 == rOld2) + if(t <= 0.0 || rOld1 == rOld2) { return rOld1; } diff --git a/basegfx/source/polygon/b2dpolypolygoncutter.cxx b/basegfx/source/polygon/b2dpolypolygoncutter.cxx index 42cfed615fe3..4ad6eb5b219d 100644 --- a/basegfx/source/polygon/b2dpolypolygoncutter.cxx +++ b/basegfx/source/polygon/b2dpolypolygoncutter.cxx @@ -146,16 +146,16 @@ namespace basegfx if(rVecA.cross(rVecB) > 0.0) { // b is left turn seen from a, test if Test is left of both and so inside (left is seen as inside) - const bool bBoolA(fTools::moreOrEqual(rVecA.cross(rTest), 0.0)); - const bool bBoolB(fTools::lessOrEqual(rVecB.cross(rTest), 0.0)); + const bool bBoolA(rVecA.cross(rTest) >= 0.0); + const bool bBoolB(rVecB.cross(rTest) <= 0.0); return (bBoolA && bBoolB); } else { // b is right turn seen from a, test if Test is right of both and so outside (left is seen as inside) - const bool bBoolA(fTools::lessOrEqual(rVecA.cross(rTest), 0.0)); - const bool bBoolB(fTools::moreOrEqual(rVecB.cross(rTest), 0.0)); + const bool bBoolA(rVecA.cross(rTest) <= 0.0); + const bool bBoolB(rVecB.cross(rTest) >= 0.0); return (!(bBoolA && bBoolB)); } diff --git a/basegfx/source/polygon/b2dtrapezoid.cxx b/basegfx/source/polygon/b2dtrapezoid.cxx index 2870c46d8236..654adc094ef9 100644 --- a/basegfx/source/polygon/b2dtrapezoid.cxx +++ b/basegfx/source/polygon/b2dtrapezoid.cxx @@ -293,7 +293,7 @@ namespace basegfx::trapezoidhelper const double fOldDeltaYStart(rCutPoint.getY() - aEdge.getStart().getY()); - if(fTools::lessOrEqual(fOldDeltaYStart, 0.0)) + if(fOldDeltaYStart <= 0.0) { // do not split: the resulting edge would be horizontal // correct it to new start point @@ -303,7 +303,7 @@ namespace basegfx::trapezoidhelper const double fNewDeltaYStart(aEdge.getEnd().getY() - rCutPoint.getY()); - if(fTools::lessOrEqual(fNewDeltaYStart, 0.0)) + if(fNewDeltaYStart <= 0.0) { // do not split: the resulting edge would be horizontal // correct it to new end point @@ -949,7 +949,7 @@ namespace basegfx::utils const B2DPoint& rPointB, double fLineWidth) { - if(fTools::lessOrEqual(fLineWidth, 0.0)) + if(fLineWidth <= 0.0) { // no line width return; @@ -1121,7 +1121,7 @@ namespace basegfx::utils const B2DPolygon& rPolygon, double fLineWidth) { - if(fTools::lessOrEqual(fLineWidth, 0.0)) + if(fLineWidth <= 0.0) { return; } diff --git a/basegfx/source/polygon/b3dpolygontools.cxx b/basegfx/source/polygon/b3dpolygontools.cxx index 7c92f5ddcea5..968624e0f28b 100644 --- a/basegfx/source/polygon/b3dpolygontools.cxx +++ b/basegfx/source/polygon/b3dpolygontools.cxx @@ -179,12 +179,12 @@ namespace basegfx::utils const sal_uInt32 nPointCount(rCandidate.count()); const sal_uInt32 nDotDashCount(rDotDashArray.size()); - if(fTools::lessOrEqual(fDotDashLength, 0.0)) + if(fDotDashLength <= 0.0) { fDotDashLength = std::accumulate(rDotDashArray.begin(), rDotDashArray.end(), 0.0); } - if(fTools::lessOrEqual(fDotDashLength, 0.0) || !rLineTargetCallback || !nPointCount) + if(fDotDashLength <= 0.0 || !rLineTargetCallback || !nPointCount) { // parameters make no sense, just add source to targets if (rLineTargetCallback) diff --git a/basegfx/source/tools/bgradient.cxx b/basegfx/source/tools/bgradient.cxx index 86e1812d21ac..b22df74d52e8 100644 --- a/basegfx/source/tools/bgradient.cxx +++ b/basegfx/source/tools/bgradient.cxx @@ -200,8 +200,7 @@ void BColorStops::replaceStartColor(const BColor& rStart) // search for highest existing non-StartColor - CAUTION, // there might be none, one or multiple with StopOffset 0.0 - while (a1stNonStartColor != end() - && basegfx::fTools::lessOrEqual(a1stNonStartColor->getStopOffset(), 0.0)) + while (a1stNonStartColor != end() && a1stNonStartColor->getStopOffset() <= 0.0) a1stNonStartColor++; // create new ColorStops by 1st adding new one and then all |