21#include <initializer_list>
38 b.moveTo(10, 10).lineTo(20, 20).quadTo(30, 10, 10, 20);
68 for (
const SkPath& path : {
b.snapshot(),
b.detach() }) {
76 std::vector<SkPoint> iter_pts;
81 iter_pts.push_back(p[0]);
84 iter_pts.push_back(p[1]);
88 iter_pts.push_back(p[1]);
89 iter_pts.push_back(p[2]);
92 iter_pts.push_back(p[1]);
93 iter_pts.push_back(p[2]);
94 iter_pts.push_back(p[3]);
100 if (iter_pts.size() !=
count) {
103 for (
size_t i = 0; i <
count; ++i) {
104 if (iter_pts[i] != expected[i]) {
116 {0, 0}, {10, 10}, {20, 30},
120 b.reset().moveTo(20, 20).lineTo(10, 10).lineTo(20, 30).close().lineTo(60, 60);
122 {20, 20}, {10, 10}, {20, 30},
129 const SkRect r = { 10, 20, 30, 40 };
131 for (
int i = 0; i < 4; ++i) {
135 auto bp =
b.detach();
146 p.addRect(r, dir, i);
159 bool is_a =
a.isOval(&ra);
160 bool is_b =
b.isOval(&rb);
164 if (is_a && (ra != rb)) {
171 bool is_a =
a.isRRect(&rra);
172 bool is_b =
b.isRRect(&rrb);
176 if (is_a && (rra != rrb)) {
195 const SkRect r = { 10, 20, 30, 40 };
199 for (
int i = 0; i < 4; ++i) {
202 p.addOval(r, dir, i);
222 for (
int i = 0; i < 4; ++i) {
225 auto bp =
b.detach();
228 p.addRRect(rr, dir, i);
246 constexpr int N = 100;
254 for (
int i = 1; i <
N; ++i) {
260 auto p0 =
b.detach();
261 auto p1 =
SkPath::Make(pts,
N, vbs,
N,
nullptr, 0, p0.getFillType());
268 builder.lineTo(10, 10);
269 auto p1 = builder.snapshot();
271 builder.lineTo(10, 20);
272 auto p2 = builder.snapshot();
278 SkPoint pts[] = {{1, 2}, {3, 4}, {5, 6}, {7, 8}};
280 auto addpoly = [](
const SkPoint pts[],
int count,
bool isClosed) {
283 builder.moveTo(pts[0]);
284 for (
int i = 1; i <
count; ++i) {
285 builder.lineTo(pts[i]);
291 return builder.detach();
294 for (
bool isClosed : {
false,
true}) {
295 for (
size_t i = 0; i <= std::size(pts); ++i) {
297 auto path1 = addpoly(pts, i, isClosed);
307 .
quadTo(200, 100, 100, 200)
310 .
cubicTo(210, 200, 210, 300, 200, 300)
311 .
conicTo(150, 250, 100, 200, 1.4f);
323 {0, 1}, {2, 3}, {4, 5},
325 constexpr int N = (
int)std::size(pts);
327 for (
int ctrCount = 1; ctrCount < 4; ++ctrCount) {
328 const int lastMoveToIndex = (ctrCount - 1) *
N;
330 for (
bool isClosed : {
false,
true}) {
334 for (
int i = 0; i < ctrCount; ++i) {
335 builder.addPolygon(pts,
N, isClosed);
336 b.addPoly(pts,
N, isClosed);
338 a = builder.detach();
341 const int expected = isClosed ? ~lastMoveToIndex : lastMoveToIndex;
353 auto [v, pts,
w] = *(*iter)++;
362 auto [v, pts,
w] = *(*iter)++;
414 test(
"first point equals previous point", {0, 0}, {1, 2}, 1, {0, 0});
415 test(
"two points equal", {5, 7}, {5, 7}, 1, {5, 7});
416 test(
"radius is zero", {-3, 5}, {-7, 11}, 0, {-3, 5});
417 test(
"second point equals previous point", {5, 4}, {0, 0}, 1, {5, 4});
static void is_empty(skiatest::Reporter *reporter, const SkPath &p)
static bool is_eq(const SkPath &a, const SkPath &b)
static void assertIsMoveTo(skiatest::Reporter *reporter, SkPathPriv::RangeIter *iter, SkScalar x0, SkScalar y0)
static bool check_points(const SkPath &path, const SkPoint expected[], size_t count)
static void assertIsDone(skiatest::Reporter *reporter, SkPathPriv::RangeIter *iter, SkPath *p)
static void assertIsLineTo(skiatest::Reporter *reporter, SkPathPriv::RangeIter *iter, SkScalar x1, SkScalar y1)
@ kClose
SkPath::RawIter returns 0 points.
@ kCubic
SkPath::RawIter returns 4 points.
@ kConic
SkPath::RawIter returns 3 points + 1 weight.
@ kQuad
SkPath::RawIter returns 3 points.
@ kMove
SkPath::RawIter returns 1 point.
@ kLine
SkPath::RawIter returns 2 points.
#define DEF_TEST(name, reporter)
#define REPORTER_ASSERT(r, cond,...)
Type::kYUV Type::kRGBA() int(0.7 *637)
SkPathBuilder & arcTo(const SkRect &oval, SkScalar startAngleDeg, SkScalar sweepAngleDeg, bool forceMoveTo)
SkPathBuilder & lineTo(SkPoint pt)
SkPathBuilder & addRect(const SkRect &, SkPathDirection, unsigned startIndex)
SkPathBuilder & addRRect(const SkRRect &, SkPathDirection, unsigned startIndex)
SkPathBuilder & moveTo(SkPoint pt)
SkPathBuilder & addOval(const SkRect &, SkPathDirection, unsigned startIndex)
SkPathBuilder & addPolygon(const SkPoint pts[], int count, bool isClosed)
static int LastMoveToIndex(const SkPath &path)
static bool HasComputedBounds(const SkPath &path)
static SkPathConvexity GetConvexityOrUnknown(const SkPath &path)
SkPath::RangeIter RangeIter
SkPath & moveTo(SkScalar x, SkScalar y)
SkPath & lineTo(SkScalar x, SkScalar y)
static SkPath Make(const SkPoint[], int pointCount, const uint8_t[], int verbCount, const SkScalar[], int conicWeightCount, SkPathFillType, bool isVolatile=false)
SkPath & quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2)
const SkRect & getBounds() const
SkPath & cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3)
SkPath & conicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar w)
static SkRRect MakeRectXY(const SkRect &rect, SkScalar xRad, SkScalar yRad)
SkPath::RangeIter begin()
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)