diff options
author | Cary Clark <caryclark@skia.org> | 2017-11-08 11:44:31 -0500 |
---|---|---|
committer | Ravi Mistry <rmistry@google.com> | 2017-11-08 18:25:17 +0000 |
commit | df429f3beac1c191289ba1e3bd918bf84df57bf5 (patch) | |
tree | 65f7f049b218ef8984d054524c05dd3fcea392a3 /tests | |
parent | 21ad53fd8839af82bcb11da6ab3e256ee7752f2b (diff) |
move parts of SkPoint to SkPointPriv
Move specialized SkPoint methods to SkPointPriv.
Use constexpr and inline initialization where possible.
R=reed@google.com,bsalomon@google.com
Bug: skia: 6898
Change-Id: I01ec5186f010f2dc80c068c70d9cc352f3221338
Reviewed-on: https://skia-review.googlesource.com/68700
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Ravi Mistry <rmistry@google.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/GeometryTest.cpp | 5 | ||||
-rw-r--r-- | tests/PathCoverageTest.cpp | 4 | ||||
-rw-r--r-- | tests/PointTest.cpp | 6 | ||||
-rw-r--r-- | tests/RoundRectTest.cpp | 4 | ||||
-rw-r--r-- | tests/StrokerTest.cpp | 19 |
5 files changed, 21 insertions, 17 deletions
diff --git a/tests/GeometryTest.cpp b/tests/GeometryTest.cpp index ad3a6b4baf..a9265016ac 100644 --- a/tests/GeometryTest.cpp +++ b/tests/GeometryTest.cpp @@ -6,8 +6,9 @@ */ #include "SkGeometry.h" -#include "Test.h" +#include "SkPointPriv.h" #include "SkRandom.h" +#include "Test.h" #include <array> static bool nearly_equal(const SkPoint& a, const SkPoint& b) { @@ -152,7 +153,7 @@ static void test_this_conic_to_quad(skiatest::Reporter* r, const SkPoint pts[3], const int qcount = quadder.countQuads(); const int pcount = qcount * 2 + 1; - REPORTER_ASSERT(r, SkPointsAreFinite(qpts, pcount)); + REPORTER_ASSERT(r, SkPointPriv::AreFinite(qpts, pcount)); } /** diff --git a/tests/PathCoverageTest.cpp b/tests/PathCoverageTest.cpp index 255156394a..ed5ed0eaeb 100644 --- a/tests/PathCoverageTest.cpp +++ b/tests/PathCoverageTest.cpp @@ -6,7 +6,7 @@ */ #include "SkMathPriv.h" -#include "SkPoint.h" +#include "SkPointPriv.h" #include "SkScalar.h" #include "Test.h" @@ -42,7 +42,7 @@ static inline int estimate_distance(const SkPoint points[]) { } static inline SkScalar compute_distance(const SkPoint points[]) { - return points[1].distanceToLineSegmentBetween(points[0], points[2]); + return SkPointPriv::DistanceToLineSegmentBetween(points[1], points[0], points[2]); } static inline uint32_t estimate_pointCount(int distance) { diff --git a/tests/PointTest.cpp b/tests/PointTest.cpp index c0d1f26086..76ac3a1a79 100644 --- a/tests/PointTest.cpp +++ b/tests/PointTest.cpp @@ -6,7 +6,7 @@ */ // Unit tests for src/core/SkPoint.cpp and its header -#include "SkPoint.h" +#include "SkPointPriv.h" #include "SkRect.h" #include "Test.h" @@ -17,7 +17,7 @@ static void test_casts(skiatest::Reporter* reporter) { const SkScalar* pPtr = SkTCast<const SkScalar*>(&p); const SkScalar* rPtr = SkTCast<const SkScalar*>(&r); - REPORTER_ASSERT(reporter, p.asScalars() == pPtr); + REPORTER_ASSERT(reporter, SkPointPriv::AsScalars(p) == pPtr); REPORTER_ASSERT(reporter, r.asScalars() == rPtr); } @@ -146,7 +146,7 @@ DEF_TEST(Point_setLengthFast, reporter) { SkPoint slow = kOne, fast = kOne; slow.setLength(tests[i]); - fast.setLengthFast(tests[i]); + SkPointPriv::SetLengthFast(&fast, tests[i]); if (slow.length() < FLT_MIN && fast.length() < FLT_MIN) continue; diff --git a/tests/RoundRectTest.cpp b/tests/RoundRectTest.cpp index d9b7a9aa08..2e31cf1b65 100644 --- a/tests/RoundRectTest.cpp +++ b/tests/RoundRectTest.cpp @@ -6,6 +6,7 @@ */ #include "SkMatrix.h" +#include "SkPointPriv.h" #include "SkRRect.h" #include "Test.h" @@ -197,7 +198,8 @@ static void test_round_rect_basic(skiatest::Reporter* reporter) { for (int i = 0; i < 4; ++i) { REPORTER_ASSERT(reporter, - rr2.radii((SkRRect::Corner) i).equalsWithinTolerance(halfPoint)); + SkPointPriv::EqualsWithinTolerance(rr2.radii((SkRRect::Corner) i), + halfPoint)); } SkRRect rr2_2; // construct the same RR using the most general set function SkVector rr2_2_radii[4] = { { halfPoint.fX, halfPoint.fY }, { halfPoint.fX, halfPoint.fY }, diff --git a/tests/StrokerTest.cpp b/tests/StrokerTest.cpp index aa6435f2a1..1ccb51814c 100644 --- a/tests/StrokerTest.cpp +++ b/tests/StrokerTest.cpp @@ -11,6 +11,7 @@ #include "SkPathOpsCubic.h" #include "SkPaint.h" #include "SkPath.h" +#include "SkPointPriv.h" #include "SkRandom.h" #include "SkStrokerPriv.h" #include "SkTime.h" @@ -239,12 +240,12 @@ DEF_TEST(QuadStrokerConstrained, reporter) { do { quad[1].fX = r.nextRangeF(0, 500); quad[1].fY = r.nextRangeF(0, 500); - } while (quad[0].distanceToSqd(quad[1]) < halfSquared); + } while (SkPointPriv::DistanceToSqd(quad[0], quad[1]) < halfSquared); do { quad[2].fX = r.nextRangeF(0, 500); quad[2].fY = r.nextRangeF(0, 500); - } while (quad[0].distanceToSqd(quad[2]) < halfSquared - || quad[1].distanceToSqd(quad[2]) < halfSquared); + } while (SkPointPriv::DistanceToSqd(quad[0], quad[2]) < halfSquared + || SkPointPriv::DistanceToSqd(quad[1], quad[2]) < halfSquared); path.moveTo(quad[0].fX, quad[0].fY); path.quadTo(quad[1].fX, quad[1].fY, quad[2].fX, quad[2].fY); p.setStrokeWidth(r.nextRangeF(0, 500)); @@ -291,18 +292,18 @@ DEF_TEST(CubicStrokerConstrained, reporter) { do { cubic[1].fX = r.nextRangeF(0, 500); cubic[1].fY = r.nextRangeF(0, 500); - } while (cubic[0].distanceToSqd(cubic[1]) < halfSquared); + } while (SkPointPriv::DistanceToSqd(cubic[0], cubic[1]) < halfSquared); do { cubic[2].fX = r.nextRangeF(0, 500); cubic[2].fY = r.nextRangeF(0, 500); - } while ( cubic[0].distanceToSqd(cubic[2]) < halfSquared - || cubic[1].distanceToSqd(cubic[2]) < halfSquared); + } while ( SkPointPriv::DistanceToSqd(cubic[0], cubic[2]) < halfSquared + || SkPointPriv::DistanceToSqd(cubic[1], cubic[2]) < halfSquared); do { cubic[3].fX = r.nextRangeF(0, 500); cubic[3].fY = r.nextRangeF(0, 500); - } while ( cubic[0].distanceToSqd(cubic[3]) < halfSquared - || cubic[1].distanceToSqd(cubic[3]) < halfSquared - || cubic[2].distanceToSqd(cubic[3]) < halfSquared); + } while ( SkPointPriv::DistanceToSqd(cubic[0], cubic[3]) < halfSquared + || SkPointPriv::DistanceToSqd(cubic[1], cubic[3]) < halfSquared + || SkPointPriv::DistanceToSqd(cubic[2], cubic[3]) < halfSquared); path.moveTo(cubic[0].fX, cubic[0].fY); path.cubicTo(cubic[1].fX, cubic[1].fY, cubic[2].fX, cubic[2].fY, cubic[3].fX, cubic[3].fY); p.setStrokeWidth(r.nextRangeF(0, 500)); |