Use flat version of path-direction enum

Bug: skia:9663
Change-Id: I00077d9f2b14b3e983e6a46ef6f560cabdb1678d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/242557
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
This commit is contained in:
Mike Reed 2019-11-21 15:27:04 -05:00 committed by Skia Commit-Bot
parent 9c2b7cfe90
commit e0fbe94351
83 changed files with 1271 additions and 1199 deletions

View File

@ -34,8 +34,8 @@ public:
paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, fRadius));
SkPath path;
path.addRect(fOuter, SkPath::kCW_Direction);
path.addRect(fInner, SkPath::kCW_Direction);
path.addRect(fOuter, SkPathDirection::kCW);
path.addRect(fInner, SkPathDirection::kCW);
for (int i = 0; i < loops; i++) {
canvas->drawPath(path, paint);

View File

@ -271,7 +271,7 @@ protected:
void onDraw(int loops, SkCanvas* canvas) override {
for (int i = 0; i < loops; ++i) {
fPath.setConvexity(SkPath::kUnknown_Convexity);
fPath.setConvexityType(SkPathConvexityType::kUnknown);
(void)fPath.isConvex();
}
}

View File

@ -691,7 +691,7 @@ protected:
// mimic how Chrome does circles
temp.arcTo(r, 0, 0, false);
temp.addOval(r, SkPath::kCCW_Direction);
temp.addOval(r, SkPathDirection::kCCW);
temp.arcTo(r, 360, 0, true);
temp.close();
@ -1206,7 +1206,7 @@ public:
fPath.addRRect(SkRRect::MakeRectXY(r, w/8.0f, h/8.0f));
if (forceConcave) {
fPath.setConvexity(SkPath::kConcave_Convexity);
fPath.setConvexityType(SkPathConvexityType::kConcave);
SkASSERT(!fPath.isConvex());
} else {
SkASSERT(fPath.isConvex());

View File

@ -34,7 +34,7 @@ void draw(SkCanvas* canvas) {
path.arcTo({56, 56}, {32, 56}, 24);
break;
case '5':
path.arcTo({24, 24}, 0, SkPath::kSmall_ArcSize, SkPath::kCW_Direction, {32, 56});
path.arcTo({24, 24}, 0, SkPath::kSmall_ArcSize, SkPathDirection::kCW, {32, 56});
break;
case '6':
path.conicTo({56, 56}, {32, 56}, SK_ScalarRoot2Over2);

View File

@ -7,12 +7,12 @@ void draw(SkCanvas* canvas) {
SkPaint paint;
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
for (auto sweep: { SkPath::kCW_Direction, SkPath::kCCW_Direction } ) {
for (auto sweep: { SkPathDirection::kCW, SkPathDirection::kCCW } ) {
for (auto arcSize : { SkPath::kSmall_ArcSize, SkPath::kLarge_ArcSize } ) {
SkPath path;
path.moveTo({120, 50});
path.arcTo(70, 40, 30, arcSize, sweep, 156, 100);
if (SkPath::kCCW_Direction == sweep && SkPath::kLarge_ArcSize == arcSize) {
if (SkPathDirection::kCCW == sweep && SkPath::kLarge_ArcSize == arcSize) {
paint.setColor(SK_ColorBLUE);
paint.setStrokeWidth(3);
}

View File

@ -16,14 +16,14 @@ void draw(SkCanvas* canvas) {
arrowPath.addPoly(arrow, SK_ARRAY_COUNT(arrow), true);
arrowPaint.setPathEffect(SkPath1DPathEffect::Make(arrowPath, 320, 0,
SkPath1DPathEffect::kRotate_Style));
for (auto direction : { SkPath::kCW_Direction, SkPath::kCCW_Direction } ) {
for (auto direction : { SkPathDirection::kCW, SkPathDirection::kCCW } ) {
canvas->drawRect(rect, rectPaint);
for (unsigned start : { 0, 1, 2, 3 } ) {
SkPath path;
path.addRect(rect, direction, start);
canvas->drawPath(path, arrowPaint);
}
canvas->drawString(SkPath::kCW_Direction == direction ? "CW" : "CCW", rect.centerX(),
canvas->drawString(SkPathDirection::kCW == direction ? "CW" : "CCW", rect.centerX(),
rect.centerY(), textPaint);
canvas->translate(120, 0);
}

View File

@ -5,10 +5,10 @@
REG_FIDDLE(Path_FillType_a, 256, 100, false, 0) {
void draw(SkCanvas* canvas) {
SkPath path;
path.addRect({10, 10, 30, 30}, SkPath::kCW_Direction);
path.addRect({20, 20, 40, 40}, SkPath::kCW_Direction);
path.addRect({10, 60, 30, 80}, SkPath::kCW_Direction);
path.addRect({20, 70, 40, 90}, SkPath::kCCW_Direction);
path.addRect({10, 10, 30, 30}, SkPathDirection::kCW);
path.addRect({20, 20, 40, 40}, SkPathDirection::kCW);
path.addRect({10, 60, 30, 80}, SkPathDirection::kCW);
path.addRect({20, 70, 40, 90}, SkPathDirection::kCCW);
SkPaint strokePaint;
strokePaint.setStyle(SkPaint::kStroke_Style);
SkRect clipRect = {0, 0, 51, 100};

View File

@ -6,8 +6,8 @@
REG_FIDDLE(Path_FillType_b, 256, 230, false, 0) {
void draw(SkCanvas* canvas) {
SkPath path;
path.addRect({20, 10, 80, 70}, SkPath::kCW_Direction);
path.addRect({40, 30, 100, 90}, SkPath::kCW_Direction);
path.addRect({20, 10, 80, 70}, SkPathDirection::kCW);
path.addRect({40, 30, 100, 90}, SkPathDirection::kCW);
SkPaint strokePaint;
strokePaint.setStyle(SkPaint::kStroke_Style);
SkRect clipRect = {0, 0, 128, 128};

View File

@ -10,7 +10,7 @@ void draw(SkCanvas* canvas) {
paint.setStrokeWidth(10);
for (int size = 10; size < 300; size += 20) {
SkPath path;
path.addCircle(128, 128, size, SkPath::kCW_Direction);
path.addCircle(128, 128, size, SkPathDirection::kCW);
canvas->drawPath(path, paint);
}
}

View File

@ -16,7 +16,7 @@ void draw(SkCanvas* canvas) {
arrowPath.addPoly(arrow, SK_ARRAY_COUNT(arrow), true);
arrowPaint.setPathEffect(SkPath1DPathEffect::Make(arrowPath, 176, 0,
SkPath1DPathEffect::kRotate_Style));
for (auto direction : { SkPath::kCW_Direction, SkPath::kCCW_Direction } ) {
for (auto direction : { SkPathDirection::kCW, SkPathDirection::kCCW } ) {
for (unsigned start : { 0, 1, 2, 3 } ) {
SkPath path;
path.addOval(rect, direction, start);
@ -26,7 +26,7 @@ void draw(SkCanvas* canvas) {
canvas->translate(64, 0);
}
canvas->translate(-256, 72);
canvas->drawString(SkPath::kCW_Direction == direction ? "clockwise" : "counterclockwise",
canvas->drawString(SkPathDirection::kCW == direction ? "clockwise" : "counterclockwise",
128, 0, textPaint);
}
}

View File

@ -7,7 +7,7 @@ void draw(SkCanvas* canvas) {
SkPaint paint;
paint.setStyle(SkPaint::kStroke_Style);
SkPath dest, path;
path.addOval({-80, 20, 0, 60}, SkPath::kCW_Direction, 1);
path.addOval({-80, 20, 0, 60}, SkPathDirection::kCW, 1);
for (int i = 0; i < 2; i++) {
dest.addPath(path, SkPath::kExtend_AddPathMode);
dest.offset(100, 0);

View File

@ -7,7 +7,7 @@ void draw(SkCanvas* canvas) {
SkPaint paint;
paint.setStyle(SkPaint::kStroke_Style);
SkPath dest, path;
path.addOval({20, 20, 200, 120}, SkPath::kCW_Direction, 1);
path.addOval({20, 20, 200, 120}, SkPathDirection::kCW, 1);
for (int i = 0; i < 6; i++) {
SkMatrix matrix;
matrix.reset();

View File

@ -13,7 +13,7 @@ void draw(SkCanvas* canvas) {
canvas->drawPath(path, paint);
for (int start = 0; start < 8; ++start) {
SkPath textPath;
textPath.addRRect(rrect, SkPath::kCW_Direction, start);
textPath.addRRect(rrect, SkPathDirection::kCW, start);
SkPathMeasure pathMeasure(textPath, false);
SkPoint position;
SkVector tangent;

View File

@ -11,10 +11,10 @@ void draw(SkCanvas* canvas) {
paint.setStyle(SkPaint::kStroke_Style);
paint.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 0));
SkPath path;
path.addRect({20, 20, 100, 100}, SkPath::kCW_Direction);
path.addRect({20, 20, 100, 100}, SkPathDirection::kCW);
canvas->drawPath(path, paint);
path.rewind();
path.addRect({140, 20, 220, 100}, SkPath::kCCW_Direction);
path.addRect({140, 20, 220, 100}, SkPathDirection::kCCW);
canvas->drawPath(path, paint);
}
} // END FIDDLE

View File

@ -14,7 +14,7 @@ void draw(SkCanvas* canvas) {
arrowPath.addPoly(arrow, SK_ARRAY_COUNT(arrow), true);
arrowPaint.setPathEffect(SkPath1DPathEffect::Make(arrowPath, 176, 0,
SkPath1DPathEffect::kRotate_Style));
for (auto direction : { SkPath::kCW_Direction, SkPath::kCCW_Direction } ) {
for (auto direction : { SkPathDirection::kCW, SkPathDirection::kCCW } ) {
for (unsigned start : { 0, 1, 2, 3 } ) {
SkPath path;
path.addRect(rect, direction, start);

View File

@ -10,7 +10,7 @@ void draw(SkCanvas* canvas) {
float intervals[] = { 5, 21.75f };
paint.setStyle(SkPaint::kStroke_Style);
paint.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 0));
for (auto direction : { SkPath::kCW_Direction, SkPath::kCCW_Direction } ) {
for (auto direction : { SkPathDirection::kCW, SkPathDirection::kCCW } ) {
SkPath path;
path.addRect(20, 20, 100, 100, direction);
canvas->drawPath(path, paint);

View File

@ -7,12 +7,12 @@ void draw(SkCanvas* canvas) {
SkPaint paint;
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
for (auto sweep: { SkPath::kCW_Direction, SkPath::kCCW_Direction } ) {
for (auto sweep: { SkPathDirection::kCW, SkPathDirection::kCCW } ) {
for (auto arcSize : { SkPath::kSmall_ArcSize, SkPath::kLarge_ArcSize } ) {
SkPath path;
path.moveTo({120, 50});
path.arcTo(70, 40, 30, arcSize, sweep, 120.1f, 50);
if (SkPath::kCCW_Direction == sweep && SkPath::kLarge_ArcSize == arcSize) {
if (SkPathDirection::kCCW == sweep && SkPath::kLarge_ArcSize == arcSize) {
paint.setColor(SK_ColorBLUE);
paint.setStrokeWidth(3);
}

View File

@ -6,8 +6,8 @@ REG_FIDDLE(Path_getConvexity, 256, 256, true, 0) {
void draw(SkCanvas* canvas) {
auto debugster = [](const char* prefix, const SkPath& path) -> void {
SkDebugf("%s path convexity is %s\n", prefix,
SkPath::kUnknown_Convexity == path.getConvexity() ? "unknown" :
SkPath::kConvex_Convexity == path.getConvexity() ? "convex" : "concave"); };
SkPathConvexityType::kUnknown == path.getConvexityType() ? "unknown" :
SkPathConvexityType::kConvex == path.getConvexityType() ? "convex" : "concave"); };
SkPath path;
debugster("initial", path);
path.lineTo(50, 0);

View File

@ -6,17 +6,17 @@ REG_FIDDLE(Path_getConvexityOrUnknown, 256, 256, true, 0) {
void draw(SkCanvas* canvas) {
auto debugster = [](const char* prefix, const SkPath& path) -> void {
SkDebugf("%s path convexity is %s\n", prefix,
SkPath::kUnknown_Convexity == path.getConvexityOrUnknown() ? "unknown" :
SkPath::kConvex_Convexity == path.getConvexityOrUnknown() ? "convex" : "concave"); };
SkPathConvexityType::kUnknown == path.getConvexityTypeOrUnknown() ? "unknown" :
SkPathConvexityType::kConvex == path.getConvexityTypeOrUnknown() ? "convex" : "concave"); };
SkPath path;
debugster("initial", path);
path.lineTo(50, 0);
debugster("first line", path);
path.getConvexity();
path.getConvexityType();
path.lineTo(50, 50);
debugster("second line", path);
path.lineTo(100, 50);
path.getConvexity();
path.getConvexityType();
debugster("third line", path);
}
} // END FIDDLE

View File

@ -6,12 +6,12 @@ REG_FIDDLE(Path_isRect, 256, 256, true, 0) {
void draw(SkCanvas* canvas) {
auto debugster = [](const char* prefix, const SkPath& path) -> void {
SkRect rect;
SkPath::Direction direction;
SkPathDirection direction;
bool isClosed;
path.isRect(&rect, &isClosed, &direction) ?
SkDebugf("%s is rect (%g, %g, %g, %g); is %s" "closed; direction %s\n", prefix,
rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, isClosed ? "" : "not ",
SkPath::kCW_Direction == direction ? "CW" : "CCW") :
SkPathDirection::kCW == direction ? "CW" : "CCW") :
SkDebugf("%s is not rect\n", prefix);
};
SkPath path;

View File

@ -13,8 +13,8 @@ void draw(SkCanvas* canvas) {
one.addRect({10, 20, 30, 40});
two.addRect({10, 20, 30, 40});
debugster("add rect", one, two);
one.setConvexity(SkPath::kConcave_Convexity);
one.setConvexityType(SkPathConvexityType::kConcave);
debugster("setConvexity", one, two);
SkDebugf("convexity %c=\n", one.getConvexity() == two.getConvexity() ? '=' : '!');
SkDebugf("convexity %c=\n", one.getConvexityType() == two.getConvexityType() ? '=' : '!');
}
} // END FIDDLE

View File

@ -9,7 +9,7 @@ void draw(SkCanvas* canvas) {
const SkPoint starts[] = {{20, 20}, {120, 20}, {70, 60}};
for (auto start : starts) {
path.moveTo(start.fX, start.fY);
path.rArcTo(20, 20, 0, SkPath::kSmall_ArcSize, SkPath::kCCW_Direction, 60, 0);
path.rArcTo(20, 20, 0, SkPath::kSmall_ArcSize, SkPathDirection::kCCW, 60, 0);
}
canvas->drawPath(path, paint);
}

View File

@ -6,7 +6,7 @@
REG_FIDDLE(Path_rMoveTo, 256, 100, false, 0) {
void draw(SkCanvas* canvas) {
SkPath path;
path.addRect({20, 20, 80, 80}, SkPath::kCW_Direction, 2);
path.addRect({20, 20, 80, 80}, SkPathDirection::kCW, 2);
path.rMoveTo(25, 2);
SkVector arrow[] = {{0, -4}, {-20, 0}, {0, -3}, {-5, 5}, {5, 5}, {0, -3}, {20, 0}};
for (unsigned i = 0; i < SK_ARRAY_COUNT(arrow); ++i) {

View File

@ -6,15 +6,15 @@ REG_FIDDLE(Path_setConvexity, 256, 256, true, 0) {
void draw(SkCanvas* canvas) {
auto debugster = [](const char* prefix, const SkPath& path) -> void {
SkDebugf("%s path convexity is %s\n", prefix,
SkPath::kUnknown_Convexity == path.getConvexity() ? "unknown" :
SkPath::kConvex_Convexity == path.getConvexity() ? "convex" : "concave"); };
SkPathConvexityType::kUnknown == path.getConvexityTypeOrUnknown() ? "unknown" :
SkPathConvexityType::kConvex == path.getConvexityTypeOrUnknown() ? "convex" : "concave"); };
SkPoint quad[] = {{70, 70}, {20, 20}, {120, 20}, {120, 120}};
SkPath path;
path.addPoly(quad, SK_ARRAY_COUNT(quad), true);
debugster("initial", path);
path.setConvexity(SkPath::kConcave_Convexity);
path.setConvexityType(SkPathConvexityType::kConcave);
debugster("after forcing concave", path);
path.setConvexity(SkPath::kUnknown_Convexity);
path.setConvexityType(SkPathConvexityType::kUnknown);
debugster("after forcing unknown", path);
}
} // END FIDDLE

View File

@ -15,10 +15,10 @@ void draw(SkCanvas* canvas) {
SkRRect rrect;
SkVector corners[] = {{15, 17}, {17, 19}, {19, 15}, {15, 15}};
rrect.setRectRadii({20, 20, 100, 100}, corners);
path.addRRect(rrect, SkPath::kCW_Direction);
path.addRRect(rrect, SkPathDirection::kCW);
canvas->drawPath(path, paint);
path.rewind();
path.addRRect(rrect, SkPath::kCCW_Direction, 1);
path.addRRect(rrect, SkPathDirection::kCCW, 1);
canvas->translate(120, 0);
canvas->drawPath(path, paint);
}

View File

@ -52,7 +52,7 @@ void FuzzNicePath(Fuzz* fuzz, SkPath* path, int maxOps) {
SkMatrix m;
SkRRect rr;
SkRect r;
SkPath::Direction dir;
SkPathDirection dir;
unsigned int ui;
SkScalar a, b, c, d, e, f;
switch (op) {
@ -112,32 +112,32 @@ void FuzzNicePath(Fuzz* fuzz, SkPath* path, int maxOps) {
case 13:
fuzz_nice_rect(fuzz, &r);
fuzz->nextRange(&ui, 0, 1);
dir = static_cast<SkPath::Direction>(ui);
dir = static_cast<SkPathDirection>(ui);
path->addRect(r, dir);
break;
case 14:
fuzz->nextRange(&ui, 0, 1);
dir = static_cast<SkPath::Direction>(ui);
dir = static_cast<SkPathDirection>(ui);
fuzz_nice_rect(fuzz, &r);
fuzz->next(&ui);
path->addRect(r, dir, ui);
break;
case 15:
fuzz->nextRange(&ui, 0, 1);
dir = static_cast<SkPath::Direction>(ui);
dir = static_cast<SkPathDirection>(ui);
fuzz_nice_rect(fuzz, &r);
path->addOval(r, dir);
break;
case 16:
fuzz->nextRange(&ui, 0, 1);
dir = static_cast<SkPath::Direction>(ui);
dir = static_cast<SkPathDirection>(ui);
fuzz_nice_rect(fuzz, &r);
fuzz->next(&ui);
path->addOval(r, dir, ui);
break;
case 17:
fuzz->nextRange(&ui, 0, 1);
dir = static_cast<SkPath::Direction>(ui);
dir = static_cast<SkPathDirection>(ui);
fuzz_nice_float(fuzz, &a, &b, &c);
path->addCircle(a, b, c, dir);
break;
@ -150,18 +150,18 @@ void FuzzNicePath(Fuzz* fuzz, SkPath* path, int maxOps) {
fuzz_nice_float(fuzz, &a, &b);
fuzz_nice_rect(fuzz, &r);
fuzz->nextRange(&ui, 0, 1);
dir = static_cast<SkPath::Direction>(ui);
dir = static_cast<SkPathDirection>(ui);
path->addRoundRect(r, a, b, dir);
break;
case 20:
FuzzNiceRRect(fuzz, &rr);
fuzz->nextRange(&ui, 0, 1);
dir = static_cast<SkPath::Direction>(ui);
dir = static_cast<SkPathDirection>(ui);
path->addRRect(rr, dir);
break;
case 21:
fuzz->nextRange(&ui, 0, 1);
dir = static_cast<SkPath::Direction>(ui);
dir = static_cast<SkPathDirection>(ui);
FuzzNiceRRect(fuzz, &rr);
path->addRRect(rr, dir, ui);
break;

View File

@ -64,7 +64,7 @@ DEF_SIMPLE_GM(analytic_antialias_convex, canvas, W, H) {
SkBits2Float(0x4344f079), SkBits2Float(0x4397e900), SkBits2Float(0x3f3504f3));
path.close();
// Manually setting convexity is required. Otherwise, this path will be considered concave.
path.setConvexity(SkPath::kConvex_Convexity);
path.setConvexityType(SkPathConvexityType::kConvex);
canvas->drawPath(path, p);
// skbug.com/7573

View File

@ -79,13 +79,13 @@ DEF_SIMPLE_GM(arcto, canvas, 500, 600) {
SkScalar ovalHeight = oval.height() / oHeight;
svgArc.moveTo(oval.fLeft, oval.fTop);
svgArc.arcTo(oval.width() / 2, ovalHeight, SkIntToScalar(angle), SkPath::kSmall_ArcSize,
SkPath::kCW_Direction, oval.right(), oval.bottom());
SkPathDirection::kCW, oval.right(), oval.bottom());
canvas->drawPath(svgArc, paint);
svgArc.reset();
svgArc.moveTo(oval.fLeft + 100, oval.fTop + 100);
svgArc.arcTo(oval.width() / 2, ovalHeight, SkIntToScalar(angle), SkPath::kLarge_ArcSize,
SkPath::kCCW_Direction, oval.right(), oval.bottom() + 100);
SkPathDirection::kCCW, oval.right(), oval.bottom() + 100);
canvas->drawPath(svgArc, paint);
oval.offset(50, 0);
svgArc.reset();
@ -114,12 +114,12 @@ DEF_SIMPLE_GM(arcto, canvas, 500, 600) {
paint.setStrokeCap(SkPaint::kRound_Cap);
SkPath path;
path.moveTo(100, 100);
path.arcTo(0, 0, 0, SkPath::kLarge_ArcSize, SkPath::kCW_Direction, 200, 200);
path.arcTo(0, 0, 0, SkPath::kLarge_ArcSize, SkPathDirection::kCW, 200, 200);
canvas->drawPath(path, paint);
path.reset();
path.moveTo(200, 100);
path.arcTo(80, 80, 0, SkPath::kLarge_ArcSize, SkPath::kCW_Direction, 200, 100);
path.arcTo(80, 80, 0, SkPath::kLarge_ArcSize, SkPathDirection::kCW, 200, 100);
canvas->drawPath(path, paint);
}

View File

@ -52,7 +52,7 @@ protected:
SkPath rectori;
rectori.addRect(bigRect);
rectori.addRect(insetRect, SkPath::kCCW_Direction);
rectori.addRect(insetRect, SkPathDirection::kCCW);
// The blur extends 3*kSigma out from the big rect.
// Offset the close-up windows so we get the entire blur

View File

@ -89,8 +89,8 @@ DEF_SIMPLE_GM(blur2rects, canvas, 700, 500) {
SkRect outer = SkRect::MakeXYWH(10.125f, 10.125f, 100.125f, 100);
SkRect inner = SkRect::MakeXYWH(20.25f, 20.125f, 80, 80);
SkPath path;
path.addRect(outer, SkPath::kCW_Direction);
path.addRect(inner, SkPath::kCCW_Direction);
path.addRect(outer, SkPathDirection::kCW);
path.addRect(inner, SkPathDirection::kCCW);
canvas->drawPath(path, paint);
// important to translate by a factional amount to exercise a different "phase"
@ -107,8 +107,8 @@ DEF_SIMPLE_GM(blur2rectsnonninepatch, canvas, 700, 500) {
SkRect outer = SkRect::MakeXYWH(10, 110, 100, 100);
SkRect inner = SkRect::MakeXYWH(50, 150, 10, 10);
SkPath path;
path.addRect(outer, SkPath::kCW_Direction);
path.addRect(inner, SkPath::kCW_Direction);
path.addRect(outer, SkPathDirection::kCW);
path.addRect(inner, SkPathDirection::kCW);
canvas->drawPath(path, paint);
SkScalar dx = SkScalarRoundToScalar(path.getBounds().width()) + 40 + 0.25f;

View File

@ -28,8 +28,8 @@ protected:
fY = 50;
fR = 40;
fCircle1.addCircle(fX1, fY, fR, SkPath::kCW_Direction);
fCircle2.addCircle(fX2, fY, fR, SkPath::kCW_Direction);
fCircle1.addCircle(fX1, fY, fR, SkPathDirection::kCW);
fCircle2.addCircle(fX2, fY, fR, SkPathDirection::kCW);
}

View File

@ -183,7 +183,7 @@ protected:
SkISize onISize() override { return SkISize::Make(kGMWidth, kGMHeight); }
bool runAsBench() const override { return true; }
static SkPath GetPath(int index, SkPath::Direction dir) {
static SkPath GetPath(int index, SkPathDirection dir) {
std::unique_ptr<SkPoint[]> data(nullptr);
const SkPoint* points;
int numPts;
@ -238,7 +238,7 @@ protected:
SkPath path;
if (SkPath::kCW_Direction == dir) {
if (SkPathDirection::kCW == dir) {
path.moveTo(points[0]);
for (int i = 1; i < numPts; ++i) {
path.lineTo(points[i]);
@ -273,7 +273,7 @@ protected:
SkPoint center;
{
SkPath path = GetPath(index, SkPath::kCW_Direction);
SkPath path = GetPath(index, SkPathDirection::kCW);
if (offset->fX+path.getBounds().width() > kGMWidth) {
offset->fX = 0;
offset->fY += kMaxPathHeight;
@ -290,7 +290,7 @@ protected:
}
const SkColor colors[2] = { SK_ColorBLACK, SK_ColorWHITE };
const SkPath::Direction dirs[2] = { SkPath::kCW_Direction, SkPath::kCCW_Direction };
const SkPathDirection dirs[2] = { SkPathDirection::kCW, SkPathDirection::kCCW };
const float scales[] = { 1.0f, 0.75f, 0.5f, 0.25f, 0.1f, 0.01f, 0.001f };
const SkPaint::Join joins[3] = { SkPaint::kRound_Join,
SkPaint::kBevel_Join,

View File

@ -66,36 +66,36 @@ class ConvexPathsGM : public skiagm::GM {
fPaths.push_back().addRect(0, 0,
100 * SK_Scalar1, 100 * SK_Scalar1,
SkPath::kCW_Direction);
SkPathDirection::kCW);
fPaths.push_back().addRect(0, 0,
100 * SK_Scalar1, 100 * SK_Scalar1,
SkPath::kCCW_Direction);
SkPathDirection::kCCW);
fPaths.push_back().addCircle(50 * SK_Scalar1, 50 * SK_Scalar1,
50 * SK_Scalar1, SkPath::kCW_Direction);
50 * SK_Scalar1, SkPathDirection::kCW);
fPaths.push_back().addOval(SkRect::MakeXYWH(0, 0,
50 * SK_Scalar1,
100 * SK_Scalar1),
SkPath::kCW_Direction);
SkPathDirection::kCW);
fPaths.push_back().addOval(SkRect::MakeXYWH(0, 0,
100 * SK_Scalar1,
5 * SK_Scalar1),
SkPath::kCCW_Direction);
SkPathDirection::kCCW);
fPaths.push_back().addOval(SkRect::MakeXYWH(0, 0,
SK_Scalar1,
100 * SK_Scalar1),
SkPath::kCCW_Direction);
SkPathDirection::kCCW);
fPaths.push_back().addRoundRect(SkRect::MakeXYWH(0, 0,
SK_Scalar1 * 100,
SK_Scalar1 * 100),
40 * SK_Scalar1, 20 * SK_Scalar1,
SkPath::kCW_Direction);
SkPathDirection::kCW);
// large number of points
enum {

View File

@ -208,8 +208,8 @@ static void drawTextPath(SkCanvas* canvas, bool doStroke) {
SkPath path;
const float baseline_offset = -5;
const SkPath::Direction dirs[] = {
SkPath::kCW_Direction, SkPath::kCCW_Direction,
const SkPathDirection dirs[] = {
SkPathDirection::kCW, SkPathDirection::kCCW,
};
for (auto d : dirs) {
path.reset();

View File

@ -34,7 +34,7 @@ static SkPath generate_rect_line(SkScalar cx, SkScalar cy, SkScalar l) {
static SkPath generate_circle(SkScalar cx, SkScalar cy, SkScalar d) {
SkPath path;
path.addCircle(cx, cy, d/2, SkPath::kCW_Direction);
path.addCircle(cx, cy, d/2, SkPathDirection::kCW);
return path;
}

View File

@ -53,7 +53,7 @@ protected:
kShapeCount
};
static void AddShape(SkPath* path, const SkRect& rect, Shapes shape, SkPath::Direction dir) {
static void AddShape(SkPath* path, const SkRect& rect, Shapes shape, SkPathDirection dir) {
switch (shape) {
case kRect_Shape:
path->addRect(rect, dir);
@ -105,9 +105,9 @@ protected:
for (size_t innerRect = 0; innerRect < SK_ARRAY_COUNT(innerRects); ++innerRect) {
SkPath path;
AddShape(&path, outerRect, (Shapes) outerShape, SkPath::kCW_Direction);
AddShape(&path, outerRect, (Shapes) outerShape, SkPathDirection::kCW);
AddShape(&path, innerRects[innerRect], (Shapes) innerShape,
SkPath::kCCW_Direction);
SkPathDirection::kCCW);
canvas->save();
if (fFlipped) {

View File

@ -55,19 +55,19 @@ protected:
void onDraw(SkCanvas* canvas) override {
drawDirs(canvas, [](const SkRect& rect, SkPath::Direction dir, unsigned startIndex) {
drawDirs(canvas, [](const SkRect& rect, SkPathDirection dir, unsigned startIndex) {
SkPath path;
path.addRect(rect, dir, startIndex);
return path;
});
drawDirs(canvas, [](const SkRect& rect, SkPath::Direction dir, unsigned startIndex) {
drawDirs(canvas, [](const SkRect& rect, SkPathDirection dir, unsigned startIndex) {
SkPath path;
path.addOval(rect, dir, startIndex);
return path;
});
drawDirs(canvas, [](const SkRect& rect, SkPath::Direction dir, unsigned startIndex) {
drawDirs(canvas, [](const SkRect& rect, SkPathDirection dir, unsigned startIndex) {
SkRRect rrect;
const SkVector radii[4] = { {15, 15}, {15, 15}, {15, 15}, {15, 15}};
rrect.setRectRadii(rect, radii);
@ -77,7 +77,7 @@ protected:
return path;
});
drawDirs(canvas, [](const SkRect& rect, SkPath::Direction dir, unsigned startIndex) {
drawDirs(canvas, [](const SkRect& rect, SkPathDirection dir, unsigned startIndex) {
SkRRect rrect;
rrect.setRect(rect);
@ -86,7 +86,7 @@ protected:
return path;
});
drawDirs(canvas, [](const SkRect& rect, SkPath::Direction dir, unsigned startIndex) {
drawDirs(canvas, [](const SkRect& rect, SkPathDirection dir, unsigned startIndex) {
SkRRect rrect;
rrect.setOval(rect);
@ -105,15 +105,15 @@ private:
SkRect fRect;
void drawDirs(SkCanvas* canvas,
SkPath (*makePath)(const SkRect&, SkPath::Direction, unsigned)) const {
drawOneColumn(canvas, SkPath::kCW_Direction, makePath);
SkPath (*makePath)(const SkRect&, SkPathDirection, unsigned)) const {
drawOneColumn(canvas, SkPathDirection::kCW, makePath);
canvas->translate(kImageWidth / 10, 0);
drawOneColumn(canvas, SkPath::kCCW_Direction, makePath);
drawOneColumn(canvas, SkPathDirection::kCCW, makePath);
canvas->translate(kImageWidth / 10, 0);
}
void drawOneColumn(SkCanvas* canvas, SkPath::Direction dir,
SkPath (*makePath)(const SkRect&, SkPath::Direction, unsigned)) const {
void drawOneColumn(SkCanvas* canvas, SkPathDirection dir,
SkPath (*makePath)(const SkRect&, SkPathDirection, unsigned)) const {
SkAutoCanvasRestore acr(canvas, true);
for (unsigned i = 0; i < 8; ++i) {

View File

@ -148,9 +148,9 @@ protected:
path.reset();
SkRect r = { 0, 0, 250, 120 };
path.addOval(r, SkPath::kCW_Direction);
path.addOval(r, SkPathDirection::kCW);
r.inset(50, 50);
path.addRect(r, SkPath::kCCW_Direction);
path.addRect(r, SkPathDirection::kCCW);
canvas->translate(320, 20);
for (size_t i = 0; i < SK_ARRAY_COUNT(gPE2); i++) {

View File

@ -76,8 +76,8 @@ protected:
for (int innerCW = 0; innerCW <= 1; ++innerCW) {
SkPath path;
path.setFillType(doEvenOdd ? SkPath::kEvenOdd_FillType : SkPath::kWinding_FillType);
SkPath::Direction outerDir = outerCW ? SkPath::kCW_Direction : SkPath::kCCW_Direction;
SkPath::Direction innerDir = innerCW ? SkPath::kCW_Direction : SkPath::kCCW_Direction;
SkPathDirection outerDir = outerCW ? SkPathDirection::kCW : SkPathDirection::kCCW;
SkPathDirection innerDir = innerCW ? SkPathDirection::kCW : SkPathDirection::kCCW;
SkRect r = insetFirst ? inset(rect) : rect;
if (outerRR) {

View File

@ -23,12 +23,12 @@
#include <functional>
#include <memory>
static void create_ngon(int n, SkPoint* pts, SkScalar w, SkScalar h, SkPath::Direction dir) {
static void create_ngon(int n, SkPoint* pts, SkScalar w, SkScalar h, SkPathDirection dir) {
float angleStep = 360.0f / n, angle = 0.0f;
if ((n % 2) == 1) {
angle = angleStep/2.0f;
}
if (SkPath::kCCW_Direction == dir) {
if (SkPathDirection::kCCW == dir) {
angle = -angle;
angleStep = -angleStep;
}
@ -438,13 +438,13 @@ protected:
SkISize onISize() override { return SkISize::Make(kGMWidth, kGMHeight); }
bool runAsBench() const override { return true; }
static void GetConvexPolygon(int index, SkPath::Direction dir,
static void GetConvexPolygon(int index, SkPathDirection dir,
std::unique_ptr<SkPoint[]>* data, int* numPts) {
if (index < (int)SK_ARRAY_COUNT(PolygonOffsetData::gConvexPoints)) {
// manually specified
*numPts = (int)PolygonOffsetData::gConvexSizes[index];
data->reset(new SkPoint[*numPts]);
if (SkPath::kCW_Direction == dir) {
if (SkPathDirection::kCW == dir) {
for (int i = 0; i < *numPts; ++i) {
(*data)[i] = PolygonOffsetData::gConvexPoints[index][i];
}
@ -473,13 +473,13 @@ protected:
}
}
static void GetSimplePolygon(int index, SkPath::Direction dir,
static void GetSimplePolygon(int index, SkPathDirection dir,
std::unique_ptr<SkPoint[]>* data, int* numPts) {
if (index < (int)SK_ARRAY_COUNT(PolygonOffsetData::gSimplePoints)) {
// manually specified
*numPts = (int)PolygonOffsetData::gSimpleSizes[index];
data->reset(new SkPoint[*numPts]);
if (SkPath::kCW_Direction == dir) {
if (SkPathDirection::kCW == dir) {
for (int i = 0; i < *numPts; ++i) {
(*data)[i] = PolygonOffsetData::gSimplePoints[index][i];
}
@ -515,9 +515,9 @@ protected:
std::unique_ptr<SkPoint[]> data(nullptr);
int numPts;
if (fConvexOnly) {
GetConvexPolygon(index, SkPath::kCW_Direction, &data, &numPts);
GetConvexPolygon(index, SkPathDirection::kCW, &data, &numPts);
} else {
GetSimplePolygon(index, SkPath::kCW_Direction, &data, &numPts);
GetSimplePolygon(index, SkPathDirection::kCW, &data, &numPts);
}
bounds.setBounds(data.get(), numPts);
if (!fConvexOnly) {
@ -531,7 +531,7 @@ protected:
offset->fX += bounds.width();
}
const SkPath::Direction dirs[2] = { SkPath::kCW_Direction, SkPath::kCCW_Direction };
const SkPathDirection dirs[2] = { SkPathDirection::kCW, SkPathDirection::kCCW };
const float insets[] = { 5, 10, 15, 20, 25, 30, 35, 40 };
const float offsets[] = { 2, 5, 9, 14, 20, 27, 35, 44, -2, -5, -9 };
const SkColor colors[] = { 0xFF901313, 0xFF8D6214, 0xFF698B14, 0xFF1C8914,

View File

@ -283,24 +283,24 @@ DEF_SIMPLE_GM_BG_NAME(strokefill, canvas, 640, 480, SK_ColorWHITE,
SkPath path;
path.setFillType(SkPath::kWinding_FillType);
path.addCircle(x, y + SkIntToScalar(200), SkIntToScalar(50), SkPath::kCW_Direction);
path.addCircle(x, y + SkIntToScalar(200), SkIntToScalar(40), SkPath::kCCW_Direction);
path.addCircle(x, y + SkIntToScalar(200), SkIntToScalar(50), SkPathDirection::kCW);
path.addCircle(x, y + SkIntToScalar(200), SkIntToScalar(40), SkPathDirection::kCCW);
canvas->drawPath(path, paint);
SkPath path2;
path2.setFillType(SkPath::kWinding_FillType);
path2.addCircle(x + SkIntToScalar(120), y + SkIntToScalar(200), SkIntToScalar(50), SkPath::kCCW_Direction);
path2.addCircle(x + SkIntToScalar(120), y + SkIntToScalar(200), SkIntToScalar(40), SkPath::kCW_Direction);
path2.addCircle(x + SkIntToScalar(120), y + SkIntToScalar(200), SkIntToScalar(50), SkPathDirection::kCCW);
path2.addCircle(x + SkIntToScalar(120), y + SkIntToScalar(200), SkIntToScalar(40), SkPathDirection::kCW);
canvas->drawPath(path2, paint);
path2.reset();
path2.addCircle(x + SkIntToScalar(240), y + SkIntToScalar(200), SkIntToScalar(50), SkPath::kCCW_Direction);
path2.addCircle(x + SkIntToScalar(240), y + SkIntToScalar(200), SkIntToScalar(50), SkPathDirection::kCCW);
canvas->drawPath(path2, paint);
SkASSERT(SkPathPriv::CheapIsFirstDirection(path2, SkPathPriv::kCCW_FirstDirection));
path2.reset();
SkASSERT(!SkPathPriv::CheapComputeFirstDirection(path2, nullptr));
path2.addCircle(x + SkIntToScalar(360), y + SkIntToScalar(200), SkIntToScalar(50), SkPath::kCW_Direction);
path2.addCircle(x + SkIntToScalar(360), y + SkIntToScalar(200), SkIntToScalar(50), SkPathDirection::kCW);
SkASSERT(SkPathPriv::CheapIsFirstDirection(path2, SkPathPriv::kCW_FirstDirection));
canvas->drawPath(path2, paint);
@ -308,25 +308,25 @@ DEF_SIMPLE_GM_BG_NAME(strokefill, canvas, 640, 480, SK_ColorWHITE,
SkIntToScalar(100), SkIntToScalar(100));
SkPath path3;
path3.setFillType(SkPath::kWinding_FillType);
path3.addRect(r, SkPath::kCW_Direction);
path3.addRect(r, SkPathDirection::kCW);
r.inset(SkIntToScalar(10), SkIntToScalar(10));
path3.addRect(r, SkPath::kCCW_Direction);
path3.addRect(r, SkPathDirection::kCCW);
canvas->drawPath(path3, paint);
r = SkRect::MakeXYWH(x + SkIntToScalar(70), y + SkIntToScalar(280),
SkIntToScalar(100), SkIntToScalar(100));
SkPath path4;
path4.setFillType(SkPath::kWinding_FillType);
path4.addRect(r, SkPath::kCCW_Direction);
path4.addRect(r, SkPathDirection::kCCW);
r.inset(SkIntToScalar(10), SkIntToScalar(10));
path4.addRect(r, SkPath::kCW_Direction);
path4.addRect(r, SkPathDirection::kCW);
canvas->drawPath(path4, paint);
r = SkRect::MakeXYWH(x + SkIntToScalar(190), y + SkIntToScalar(280),
SkIntToScalar(100), SkIntToScalar(100));
path4.reset();
SkASSERT(!SkPathPriv::CheapComputeFirstDirection(path4, nullptr));
path4.addRect(r, SkPath::kCCW_Direction);
path4.addRect(r, SkPathDirection::kCCW);
SkASSERT(SkPathPriv::CheapIsFirstDirection(path4, SkPathPriv::kCCW_FirstDirection));
path4.moveTo(0, 0); // test for crbug.com/247770
canvas->drawPath(path4, paint);
@ -335,7 +335,7 @@ DEF_SIMPLE_GM_BG_NAME(strokefill, canvas, 640, 480, SK_ColorWHITE,
SkIntToScalar(100), SkIntToScalar(100));
path4.reset();
SkASSERT(!SkPathPriv::CheapComputeFirstDirection(path4, nullptr));
path4.addRect(r, SkPath::kCW_Direction);
path4.addRect(r, SkPathDirection::kCW);
SkASSERT(SkPathPriv::CheapIsFirstDirection(path4, SkPathPriv::kCW_FirstDirection));
path4.moveTo(0, 0); // test for crbug.com/247770
canvas->drawPath(path4, paint);

View File

@ -344,42 +344,42 @@ static SkRect inset(const SkRect& r) {
class Strokes3GM : public skiagm::GM {
static void make0(SkPath* path, const SkRect& bounds, SkString* title) {
path->addRect(bounds, SkPath::kCW_Direction);
path->addRect(inset(bounds), SkPath::kCW_Direction);
path->addRect(bounds, SkPathDirection::kCW);
path->addRect(inset(bounds), SkPathDirection::kCW);
title->set("CW CW");
}
static void make1(SkPath* path, const SkRect& bounds, SkString* title) {
path->addRect(bounds, SkPath::kCW_Direction);
path->addRect(inset(bounds), SkPath::kCCW_Direction);
path->addRect(bounds, SkPathDirection::kCW);
path->addRect(inset(bounds), SkPathDirection::kCCW);
title->set("CW CCW");
}
static void make2(SkPath* path, const SkRect& bounds, SkString* title) {
path->addOval(bounds, SkPath::kCW_Direction);
path->addOval(inset(bounds), SkPath::kCW_Direction);
path->addOval(bounds, SkPathDirection::kCW);
path->addOval(inset(bounds), SkPathDirection::kCW);
title->set("CW CW");
}
static void make3(SkPath* path, const SkRect& bounds, SkString* title) {
path->addOval(bounds, SkPath::kCW_Direction);
path->addOval(inset(bounds), SkPath::kCCW_Direction);
path->addOval(bounds, SkPathDirection::kCW);
path->addOval(inset(bounds), SkPathDirection::kCCW);
title->set("CW CCW");
}
static void make4(SkPath* path, const SkRect& bounds, SkString* title) {
path->addRect(bounds, SkPath::kCW_Direction);
path->addRect(bounds, SkPathDirection::kCW);
SkRect r = bounds;
r.inset(bounds.width() / 10, -bounds.height() / 10);
path->addOval(r, SkPath::kCW_Direction);
path->addOval(r, SkPathDirection::kCW);
title->set("CW CW");
}
static void make5(SkPath* path, const SkRect& bounds, SkString* title) {
path->addRect(bounds, SkPath::kCW_Direction);
path->addRect(bounds, SkPathDirection::kCW);
SkRect r = bounds;
r.inset(bounds.width() / 10, -bounds.height() / 10);
path->addOval(r, SkPath::kCCW_Direction);
path->addOval(r, SkPathDirection::kCCW);
title->set("CW CCW");
}

View File

@ -41,6 +41,7 @@ class SkWStream;
class SK_API SkPath {
public:
#ifdef SK_SUPPORT_LEGACY_PATH_DIRECTION_ENUM
/** \enum SkPath::Direction
Direction describes whether contour is clockwise or counterclockwise.
When SkPath contains multiple overlapping contours, Direction together with
@ -58,6 +59,7 @@ public:
kCW_Direction = static_cast<int>(SkPathDirection::kCW),
kCCW_Direction = static_cast<int>(SkPathDirection::kCCW)
};
#endif
/** Constructs an empty SkPath. By default, SkPath has no verbs, no SkPoint, and no weights.
SkPath::FillType is set to kWinding_FillType.
@ -211,6 +213,44 @@ public:
fFillType ^= 2;
}
/** Returns the comvexity type, computing if needed. Never returns kUnknown.
@return path's convexity type (convex or concave)
*/
SkPathConvexityType getConvexityType() const {
SkPathConvexityType convexity = this->getConvexityTypeOrUnknown();
if (convexity != SkPathConvexityType::kUnknown) {
return convexity;
}
return this->internalGetConvexity();
}
/** If the path's convexity is already known, return it, else return kUnknown.
* If you always want to know the convexity, even if that means having to compute it,
* call getConvexitytype().
*
* @return known convexity, or kUnknown
*/
SkPathConvexityType getConvexityTypeOrUnknown() const {
return (SkPathConvexityType)fConvexity.load(std::memory_order_relaxed);
}
/** Stores a convexity type for this path. This is what will be returned if
* getConvexityTypeOrUnknown() is called. If you pass kUnknown, then if getContexityType()
* is called, the real convexity will be computed.
*
* @param convexity one of: kUnknown, kConvex, or kConcave
*
* example: https://fiddle.skia.org/c/@Path_setConvexity
*/
void setConvexityType(SkPathConvexityType convexity);
/** Returns true if the path is convex. If necessary, it will first compute the convexity.
*/
bool isConvex() const {
return SkPathConvexityType::kConvex == this->getConvexityType();
}
#ifdef SK_SUPPORT_LEGACY_PATH_DIRECTION_ENUM
/** \enum SkPath::Convexity
SkPath is convex if it contains one contour and contour loops no more than
360 degrees, and contour angles all have same Direction. Convex SkPath
@ -229,53 +269,12 @@ public:
kConcave_Convexity = static_cast<int>(SkPathConvexityType::kConcave),
};
/** Computes SkPath::Convexity if required, and returns stored value.
SkPath::Convexity is computed if stored value is kUnknown_Convexity,
or if SkPath has been altered since SkPath::Convexity was computed or set.
@return computed or stored SkPath::Convexity
*/
Convexity getConvexity() const {
Convexity convexity = this->getConvexityOrUnknown();
if (convexity != kUnknown_Convexity) {
return convexity;
}
return this->internalGetConvexity();
}
/** Returns last computed SkPath::Convexity, or kUnknown_Convexity if
SkPath has been altered since SkPath::Convexity was computed or set.
@return stored SkPath::Convexity
*/
Convexity getConvexityOrUnknown() const { return fConvexity.load(std::memory_order_relaxed); }
/** Stores convexity so that it is later returned by getConvexity() or getConvexityOrUnknown().
convexity may differ from getConvexity(), although setting an incorrect value may
cause incorrect or inefficient drawing.
If convexity is kUnknown_Convexity: getConvexity() will
compute SkPath::Convexity, and getConvexityOrUnknown() will return kUnknown_Convexity.
If convexity is kConvex_Convexity or kConcave_Convexity, getConvexity()
and getConvexityOrUnknown() will return convexity until the path is
altered.
@param convexity one of: kUnknown_Convexity, kConvex_Convexity, or kConcave_Convexity
example: https://fiddle.skia.org/c/@Path_setConvexity
*/
void setConvexity(Convexity convexity);
/** Computes SkPath::Convexity if required, and returns true if value is kConvex_Convexity.
If setConvexity() was called with kConvex_Convexity or kConcave_Convexity, and
the path has not been altered, SkPath::Convexity is not recomputed.
@return true if SkPath::Convexity stored or computed is kConvex_Convexity
*/
bool isConvex() const {
return kConvex_Convexity == this->getConvexity();
Convexity getConvexity() const { return (Convexity)this->getConvexityType(); }
Convexity getConvexityOrUnknown() const { return (Convexity)this->getConvexityTypeOrUnknown(); }
void setConvexity(Convexity convexity) {
this->setConvexityType((SkPathConvexityType)convexity);
}
#endif
/** Returns true if this path is recognized as an oval or circle.
@ -968,7 +967,7 @@ public:
@return reference to SkPath
*/
SkPath& arcTo(SkScalar rx, SkScalar ry, SkScalar xAxisRotate, ArcSize largeArc,
Direction sweep, SkScalar x, SkScalar y);
SkPathDirection sweep, SkScalar x, SkScalar y);
/** Appends arc to SkPath. Arc is implemented by one or more conic weighted to describe
part of oval with radii (r.fX, r.fY) rotated by xAxisRotate degrees. Arc curves
@ -993,7 +992,7 @@ public:
@param xy end of arc
@return reference to SkPath
*/
SkPath& arcTo(const SkPoint r, SkScalar xAxisRotate, ArcSize largeArc, Direction sweep,
SkPath& arcTo(const SkPoint r, SkScalar xAxisRotate, ArcSize largeArc, SkPathDirection sweep,
const SkPoint xy) {
return this->arcTo(r.fX, r.fY, xAxisRotate, largeArc, sweep, xy.fX, xy.fY);
}
@ -1025,7 +1024,7 @@ public:
@return reference to SkPath
*/
SkPath& rArcTo(SkScalar rx, SkScalar ry, SkScalar xAxisRotate, ArcSize largeArc,
Direction sweep, SkScalar dx, SkScalar dy);
SkPathDirection sweep, SkScalar dx, SkScalar dy);
/** Appends kClose_Verb to SkPath. A closed contour connects the first and last SkPoint
with line, forming a continuous loop. Open and closed contour draw the same
@ -1114,7 +1113,7 @@ public:
example: https://fiddle.skia.org/c/@Path_isRect
*/
bool isRect(SkRect* rect, bool* isClosed = nullptr, Direction* direction = nullptr) const;
bool isRect(SkRect* rect, bool* isClosed = nullptr, SkPathDirection* direction = nullptr) const;
/** Adds SkRect to SkPath, appending kMove_Verb, three kLine_Verb, and kClose_Verb,
starting with top-left corner of SkRect; followed by top-right, bottom-right,
@ -1127,7 +1126,7 @@ public:
example: https://fiddle.skia.org/c/@Path_addRect
*/
SkPath& addRect(const SkRect& rect, Direction dir = kCW_Direction);
SkPath& addRect(const SkRect& rect, SkPathDirection dir = SkPathDirection::kCW);
/** Adds SkRect to SkPath, appending kMove_Verb, three kLine_Verb, and kClose_Verb.
If dir is kCW_Direction, SkRect corners are added clockwise; if dir is
@ -1141,7 +1140,7 @@ public:
example: https://fiddle.skia.org/c/@Path_addRect_2
*/
SkPath& addRect(const SkRect& rect, Direction dir, unsigned start);
SkPath& addRect(const SkRect& rect, SkPathDirection dir, unsigned start);
/** Adds SkRect (left, top, right, bottom) to SkPath,
appending kMove_Verb, three kLine_Verb, and kClose_Verb,
@ -1157,7 +1156,7 @@ public:
@return reference to SkPath
*/
SkPath& addRect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom,
Direction dir = kCW_Direction);
SkPathDirection dir = SkPathDirection::kCW);
/** Adds oval to path, appending kMove_Verb, four kConic_Verb, and kClose_Verb.
Oval is upright ellipse bounded by SkRect oval with radii equal to half oval width
@ -1170,7 +1169,7 @@ public:
example: https://fiddle.skia.org/c/@Path_addOval
*/
SkPath& addOval(const SkRect& oval, Direction dir = kCW_Direction);
SkPath& addOval(const SkRect& oval, SkPathDirection dir = SkPathDirection::kCW);
/** Adds oval to SkPath, appending kMove_Verb, four kConic_Verb, and kClose_Verb.
Oval is upright ellipse bounded by SkRect oval with radii equal to half oval width
@ -1184,7 +1183,7 @@ public:
example: https://fiddle.skia.org/c/@Path_addOval_2
*/
SkPath& addOval(const SkRect& oval, Direction dir, unsigned start);
SkPath& addOval(const SkRect& oval, SkPathDirection dir, unsigned start);
/** Adds circle centered at (x, y) of size radius to SkPath, appending kMove_Verb,
four kConic_Verb, and kClose_Verb. Circle begins at: (x + radius, y), continuing
@ -1199,7 +1198,7 @@ public:
@return reference to SkPath
*/
SkPath& addCircle(SkScalar x, SkScalar y, SkScalar radius,
Direction dir = kCW_Direction);
SkPathDirection dir = SkPathDirection::kCW);
/** Appends arc to SkPath, as the start of new contour. Arc added is part of ellipse
bounded by oval, from startAngle through sweepAngle. Both startAngle and
@ -1238,7 +1237,7 @@ public:
@return reference to SkPath
*/
SkPath& addRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry,
Direction dir = kCW_Direction);
SkPathDirection dir = SkPathDirection::kCW);
/** Appends SkRRect to SkPath, creating a new closed contour. SkRRect has bounds
equal to rect; each corner is 90 degrees of an ellipse with radii from the
@ -1250,7 +1249,7 @@ public:
@return reference to SkPath
*/
SkPath& addRoundRect(const SkRect& rect, const SkScalar radii[],
Direction dir = kCW_Direction);
SkPathDirection dir = SkPathDirection::kCW);
/** Adds rrect to SkPath, creating a new closed contour. If
dir is kCW_Direction, rrect starts at top-left of the lower-left corner and
@ -1265,7 +1264,7 @@ public:
example: https://fiddle.skia.org/c/@Path_addRRect
*/
SkPath& addRRect(const SkRRect& rrect, Direction dir = kCW_Direction);
SkPath& addRRect(const SkRRect& rrect, SkPathDirection dir = SkPathDirection::kCW);
/** Adds rrect to SkPath, creating a new closed contour. If dir is kCW_Direction, rrect
winds clockwise; if dir is kCCW_Direction, rrect winds counterclockwise.
@ -1278,7 +1277,7 @@ public:
example: https://fiddle.skia.org/c/@Path_addRRect_2
*/
SkPath& addRRect(const SkRRect& rrect, Direction dir, unsigned start);
SkPath& addRRect(const SkRRect& rrect, SkPathDirection dir, unsigned start);
/** Adds contour created from line array, adding (count - 1) line segments.
Contour added starts at pts[0], then adds a line for every additional SkPoint
@ -1776,10 +1775,62 @@ public:
*/
bool isValid() const { return this->isValidImpl() && fPathRef->isValid(); }
#ifdef SK_SUPPORT_LEGACY_PATH_DIRECTION_ENUM
SkPath& arcTo(SkScalar rx, SkScalar ry, SkScalar xAxisRotate, ArcSize largeArc,
Direction sweep, SkScalar x, SkScalar y) {
return this->arcTo(rx, ry, xAxisRotate, largeArc, (SkPathDirection)sweep, x, y);
}
SkPath& arcTo(const SkPoint r, SkScalar xAxisRotate, ArcSize largeArc, Direction sweep,
const SkPoint xy) {
return this->arcTo(r.fX, r.fY, xAxisRotate, largeArc, (SkPathDirection)sweep, xy.fX, xy.fY);
}
SkPath& rArcTo(SkScalar rx, SkScalar ry, SkScalar xAxisRotate, ArcSize largeArc,
Direction sweep, SkScalar dx, SkScalar dy) {
return this->rArcTo(rx, ry, xAxisRotate, largeArc, (SkPathDirection)sweep, dx, dy);
}
bool isRect(SkRect* rect, bool* isClosed, Direction* direction) const {
return this->isRect(rect, isClosed, (SkPathDirection*)direction);
}
bool isRect(SkRect* rect, bool* isClosed, nullptr_t) const {
return this->isRect(rect, isClosed);
}
SkPath& addRect(const SkRect& rect, Direction dir) {
return this->addRect(rect, (SkPathDirection)dir);
}
SkPath& addRect(const SkRect& rect, Direction dir, unsigned start) {
return this->addRect(rect, (SkPathDirection)dir, start);
}
SkPath& addRect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom,
Direction dir) {
return this->addRect(left, top, right, bottom, (SkPathDirection)dir);
}
SkPath& addOval(const SkRect& oval, Direction dir) {
return addOval(oval, (SkPathDirection)dir);
}
SkPath& addOval(const SkRect& oval, Direction dir, unsigned start) {
return this->addOval(oval, (SkPathDirection)dir, start);
}
SkPath& addCircle(SkScalar x, SkScalar y, SkScalar radius, Direction dir) {
return this->addCircle(x, y, radius, (SkPathDirection)dir);
}
SkPath& addRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry, Direction dir) {
return this->addRoundRect(rect, rx, ry, (SkPathDirection)dir);
}
SkPath& addRoundRect(const SkRect& rect, const SkScalar radii[], Direction dir) {
return this->addRoundRect(rect, radii, (SkPathDirection)dir);
}
SkPath& addRRect(const SkRRect& rrect, Direction dir) {
return this->addRRect(rrect, (SkPathDirection)dir);
}
SkPath& addRRect(const SkRRect& rrect, Direction dir, unsigned start) {
return this->addRRect(rrect, (SkPathDirection)dir, start);
}
#endif
private:
sk_sp<SkPathRef> fPathRef;
int fLastMoveToIndex;
mutable std::atomic<Convexity> fConvexity;
mutable std::atomic<uint8_t> fConvexity; // SkPathConvexityType
mutable std::atomic<uint8_t> fFirstDirection; // really an SkPathPriv::FirstDirection
uint8_t fFillType : 2;
uint8_t fIsVolatile : 1;
@ -1820,7 +1871,7 @@ private:
inline bool hasOnlyMoveTos() const;
Convexity internalGetConvexity() const;
SkPathConvexityType internalGetConvexity() const;
/** Asserts if SkPath data is inconsistent.
Debugging check intended for internal use only.
@ -1852,7 +1903,7 @@ private:
// Bottlenecks for working with fConvexity and fFirstDirection.
// Notice the setters are const... these are mutable atomic fields.
void setConvexity(Convexity) const;
void setConvexityType(SkPathConvexityType) const;
void setFirstDirection(uint8_t) const;
uint8_t getFirstDirection() const;

View File

@ -193,8 +193,7 @@ void ApplyAddArc(SkPath& orig, const SkRect& oval, SkScalar startAngle, SkScalar
}
void ApplyAddOval(SkPath& orig, const SkRect& oval, bool ccw, unsigned start) {
orig.addOval(oval, ccw ? SkPath::Direction::kCCW_Direction :
SkPath::Direction::kCW_Direction, start);
orig.addOval(oval, ccw ? SkPathDirection::kCCW : SkPathDirection::kCW, start);
}
void ApplyAddPath(SkPath& orig, const SkPath& newPath,
@ -211,9 +210,7 @@ void ApplyAddPath(SkPath& orig, const SkPath& newPath,
void ApplyAddRect(SkPath& path, SkScalar left, SkScalar top,
SkScalar right, SkScalar bottom, bool ccw) {
path.addRect(left, top, right, bottom,
ccw ? SkPath::Direction::kCCW_Direction :
SkPath::Direction::kCW_Direction);
path.addRect(left, top, right, bottom, ccw ? SkPathDirection::kCCW : SkPathDirection::kCW);
}
void ApplyAddRoundRect(SkPath& path, SkScalar left, SkScalar top,
@ -222,7 +219,7 @@ void ApplyAddRoundRect(SkPath& path, SkScalar left, SkScalar top,
// See comment below for uintptr_t explanation
const SkScalar* radii = reinterpret_cast<const SkScalar*>(rPtr);
path.addRoundRect(SkRect::MakeLTRB(left, top, right, bottom), radii,
ccw ? SkPath::Direction::kCCW_Direction : SkPath::Direction::kCW_Direction);
ccw ? SkPathDirection::kCCW : SkPathDirection::kCW);
}
@ -238,14 +235,14 @@ void ApplyArcToAngle(SkPath& p, SkRect& oval, SkScalar startAngle, SkScalar swee
void ApplyArcToArcSize(SkPath& orig, SkScalar rx, SkScalar ry, SkScalar xAxisRotate,
bool useSmallArc, bool ccw, SkScalar x, SkScalar y) {
auto arcSize = useSmallArc ? SkPath::ArcSize::kSmall_ArcSize : SkPath::ArcSize::kLarge_ArcSize;
auto sweep = ccw ? SkPath::Direction::kCCW_Direction : SkPath::Direction::kCW_Direction;
auto sweep = ccw ? SkPathDirection::kCCW : SkPathDirection::kCW;
orig.arcTo(rx, ry, xAxisRotate, arcSize, sweep, x, y);
}
void ApplyRArcToArcSize(SkPath& orig, SkScalar rx, SkScalar ry, SkScalar xAxisRotate,
bool useSmallArc, bool ccw, SkScalar dx, SkScalar dy) {
auto arcSize = useSmallArc ? SkPath::ArcSize::kSmall_ArcSize : SkPath::ArcSize::kLarge_ArcSize;
auto sweep = ccw ? SkPath::Direction::kCCW_Direction : SkPath::Direction::kCW_Direction;
auto sweep = ccw ? SkPathDirection::kCCW : SkPathDirection::kCW;
orig.rArcTo(rx, ry, xAxisRotate, arcSize, sweep, dx, dy);
}

View File

@ -41,8 +41,8 @@ sk_sp<sksg::GeometryNode> AttachPathGeometry(const skjson::ObjectValue& jpath,
sk_sp<sksg::GeometryNode> AttachRRectGeometry(const skjson::ObjectValue& jrect,
const AnimationBuilder* abuilder) {
auto rect_node = sksg::RRect::Make();
rect_node->setDirection(ParseDefault(jrect["d"], -1) == 3 ? SkPath::kCCW_Direction
: SkPath::kCW_Direction);
rect_node->setDirection(ParseDefault(jrect["d"], -1) == 3 ? SkPathDirection::kCCW
: SkPathDirection::kCW);
rect_node->setInitialPointIndex(2); // starting point: (Right, Top - radius.y)
auto adapter = sk_make_sp<RRectAdapter>(rect_node);
@ -70,8 +70,8 @@ sk_sp<sksg::GeometryNode> AttachRRectGeometry(const skjson::ObjectValue& jrect,
sk_sp<sksg::GeometryNode> AttachEllipseGeometry(const skjson::ObjectValue& jellipse,
const AnimationBuilder* abuilder) {
auto rect_node = sksg::RRect::Make();
rect_node->setDirection(ParseDefault(jellipse["d"], -1) == 3 ? SkPath::kCCW_Direction
: SkPath::kCW_Direction);
rect_node->setDirection(ParseDefault(jellipse["d"], -1) == 3 ? SkPathDirection::kCCW
: SkPathDirection::kCW);
rect_node->setInitialPointIndex(1); // starting point: (Center, Top)
auto adapter = sk_make_sp<RRectAdapter>(rect_node);

View File

@ -32,8 +32,8 @@ public:
SG_ATTRIBUTE(R, SkScalar, fRect.fRight )
SG_ATTRIBUTE(B, SkScalar, fRect.fBottom)
SG_MAPPED_ATTRIBUTE(Direction , SkPath::Direction, fAttrContaier)
SG_MAPPED_ATTRIBUTE(InitialPointIndex, uint8_t , fAttrContaier)
SG_MAPPED_ATTRIBUTE(Direction , SkPathDirection, fAttrContaier)
SG_MAPPED_ATTRIBUTE(InitialPointIndex, uint8_t , fAttrContaier)
protected:
void onClip(SkCanvas*, bool antiAlias) const override;
@ -52,15 +52,15 @@ private:
uint8_t fDirection : 1;
uint8_t fInitialPointIndex : 2;
SkPath::Direction getDirection() const {
return static_cast<SkPath::Direction>(fDirection);
SkPathDirection getDirection() const {
return static_cast<SkPathDirection>(fDirection);
}
void setDirection(SkPath::Direction dir) { fDirection = SkTo<uint8_t>(dir); }
void setDirection(SkPathDirection dir) { fDirection = SkTo<uint8_t>(dir); }
uint8_t getInitialPointIndex() const { return fInitialPointIndex; }
void setInitialPointIndex(uint8_t idx) { fInitialPointIndex = idx; }
};
AttrContainer fAttrContaier = { SkPath::kCW_Direction, 0 };
AttrContainer fAttrContaier = { (int)SkPathDirection::kCW, 0 };
using INHERITED = GeometryNode;
};
@ -75,7 +75,7 @@ public:
SG_ATTRIBUTE(RRect, SkRRect, fRRect)
SG_MAPPED_ATTRIBUTE(Direction , SkPath::Direction, fAttrContaier)
SG_MAPPED_ATTRIBUTE(Direction , SkPathDirection, fAttrContaier)
SG_MAPPED_ATTRIBUTE(InitialPointIndex, uint8_t , fAttrContaier)
protected:
@ -95,15 +95,15 @@ private:
uint8_t fDirection : 1;
uint8_t fInitialPointIndex : 2;
SkPath::Direction getDirection() const {
return static_cast<SkPath::Direction>(fDirection);
SkPathDirection getDirection() const {
return static_cast<SkPathDirection>(fDirection);
}
void setDirection(SkPath::Direction dir) { fDirection = SkTo<uint8_t>(dir); }
void setDirection(SkPathDirection dir) { fDirection = SkTo<uint8_t>(dir); }
uint8_t getInitialPointIndex() const { return fInitialPointIndex; }
void setInitialPointIndex(uint8_t idx) { fInitialPointIndex = idx; }
};
AttrContainer fAttrContaier = { SkPath::kCW_Direction, 0 };
AttrContainer fAttrContaier = { (int)SkPathDirection::kCW, 0 };
using INHERITED = GeometryNode;
};

View File

@ -53,7 +53,7 @@ class ShadowsView : public Sample {
fRRPath.addRRect(SkRRect::MakeRectXY(SkRect::MakeXYWH(-100, -50, 200, 100), 4, 4));
fFunkyRRPath.addRoundRect(SkRect::MakeXYWH(-50, -50, SK_Scalar1 * 100, SK_Scalar1 * 100),
40 * SK_Scalar1, 20 * SK_Scalar1,
SkPath::kCW_Direction);
SkPathDirection::kCW);
fCubicPath.cubicTo(100 * SK_Scalar1, 50 * SK_Scalar1,
20 * SK_Scalar1, 100 * SK_Scalar1,
0 * SK_Scalar1, 0 * SK_Scalar1);

View File

@ -160,7 +160,7 @@ class ClockView : public Sample {
#ifdef USE_PATH
path.reset();
path.arcTo(rect, 0, 0, false);
path.addOval(rect, SkPath::kCCW_Direction);
path.addOval(rect, SkPathDirection::kCCW);
path.arcTo(rect, 360, 0, true);
canvas->drawPath(path, paintFill);
#else
@ -170,7 +170,7 @@ class ClockView : public Sample {
#ifdef USE_PATH
path.reset();
path.arcTo(rect, 0, 0, false);
path.addOval(rect, SkPath::kCCW_Direction);
path.addOval(rect, SkPathDirection::kCCW);
path.arcTo(rect, 360, 0, true);
canvas->drawPath(path, paintStroke);
#else
@ -180,7 +180,7 @@ class ClockView : public Sample {
#ifdef USE_PATH
rect = SkRect::MakeLTRB(-6, -6, 6, 6);
path.arcTo(rect, 0, 0, false);
path.addOval(rect, SkPath::kCCW_Direction);
path.addOval(rect, SkPathDirection::kCCW);
path.arcTo(rect, 360, 0, true);
canvas->drawPath(path, paintFill);
#else
@ -196,7 +196,7 @@ class ClockView : public Sample {
#ifdef USE_PATH
path.reset();
path.arcTo(rect, 0, 0, false);
path.addOval(rect, SkPath::kCCW_Direction);
path.addOval(rect, SkPathDirection::kCCW);
path.arcTo(rect, 360, 0, true);
canvas->drawPath(path, paintStroke);
#else

View File

@ -646,9 +646,9 @@ protected:
path.reset();
SkRRect rr2;
rr.inset(width/2, width/2, &rr2);
path.addRRect(rr2, SkPath::kCCW_Direction);
path.addRRect(rr2, SkPathDirection::kCCW);
rr.inset(-width/2, -width/2, &rr2);
path.addRRect(rr2, SkPath::kCW_Direction);
path.addRRect(rr2, SkPathDirection::kCW);
SkPaint paint;
paint.setAntiAlias(true);
paint.setColor(0x40FF8844);

View File

@ -32,7 +32,7 @@ static void test_strokerect(SkCanvas* canvas) {
SkPath path;
path.addRect(0.0f, 0.0f,
SkIntToScalar(width), SkIntToScalar(height),
SkPath::kCW_Direction);
SkPathDirection::kCW);
SkRect r = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
SkCanvas c(bitmap);

View File

@ -136,9 +136,9 @@ static void patheffect_slide(SkCanvas* canvas) {
path.reset();
SkRect r = { 0, 0, 250, 120 };
path.addOval(r, SkPath::kCW_Direction);
path.addOval(r, SkPathDirection::kCW);
r.inset(50, 50);
path.addRect(r, SkPath::kCCW_Direction);
path.addRect(r, SkPathDirection::kCCW);
canvas->translate(320, 20);
for (i = 0; i < SK_ARRAY_COUNT(gPE2); i++) {

View File

@ -112,8 +112,8 @@ protected:
"Z";
SkParsePath::FromSVGString(str, &fPath);
#else
fPath.addCircle(0, 0, SkIntToScalar(50), SkPath::kCW_Direction);
fPath.addCircle(0, SkIntToScalar(-50), SkIntToScalar(30), SkPath::kCW_Direction);
fPath.addCircle(0, 0, SkIntToScalar(50), SkPathDirection::kCW);
fPath.addCircle(0, SkIntToScalar(-50), SkIntToScalar(30), SkPathDirection::kCW);
#endif
scale_to_width(&fPath, fWidth);

View File

@ -56,13 +56,13 @@ static void from_c_matrix(const sk_matrix_t* cmatrix, SkMatrix* matrix) {
const struct {
sk_path_direction_t fC;
SkPath::Direction fSk;
SkPathDirection fSk;
} gPathDirMap[] = {
{ CW_SK_PATH_DIRECTION, SkPath::kCW_Direction },
{ CCW_SK_PATH_DIRECTION, SkPath::kCCW_Direction },
{ CW_SK_PATH_DIRECTION, SkPathDirection::kCW },
{ CCW_SK_PATH_DIRECTION, SkPathDirection::kCCW },
};
static bool from_c_path_direction(sk_path_direction_t cdir, SkPath::Direction* dir) {
static bool from_c_path_direction(sk_path_direction_t cdir, SkPathDirection* dir) {
for (size_t i = 0; i < SK_ARRAY_COUNT(gPathDirMap); ++i) {
if (gPathDirMap[i].fC == cdir) {
if (dir) {
@ -202,7 +202,7 @@ void sk_path_close(sk_path_t* cpath) {
}
void sk_path_add_rect(sk_path_t* cpath, const sk_rect_t* crect, sk_path_direction_t cdir) {
SkPath::Direction dir;
SkPathDirection dir;
if (!from_c_path_direction(cdir, &dir)) {
return;
}
@ -210,7 +210,7 @@ void sk_path_add_rect(sk_path_t* cpath, const sk_rect_t* crect, sk_path_directio
}
void sk_path_add_oval(sk_path_t* cpath, const sk_rect_t* crect, sk_path_direction_t cdir) {
SkPath::Direction dir;
SkPathDirection dir;
if (!from_c_path_direction(cdir, &dir)) {
return;
}

View File

@ -107,8 +107,8 @@ public:
}
~SkAutoPathBoundsUpdate() {
fPath->setConvexity(fDegenerate ? SkPath::kConvex_Convexity
: SkPath::kUnknown_Convexity);
fPath->setConvexityType(fDegenerate ? SkPathConvexityType::kConvex
: SkPathConvexityType::kUnknown);
if ((fEmpty || fHasValidBounds) && fRect.isFinite()) {
fPath->setBounds(fRect);
}
@ -152,7 +152,7 @@ void SkPath::resetFields() {
//fPathRef is assumed to have been emptied by the caller.
fLastMoveToIndex = INITIAL_LASTMOVETOINDEX_VALUE;
fFillType = kWinding_FillType;
this->setConvexity(kUnknown_Convexity);
this->setConvexityType(SkPathConvexityType::kUnknown);
this->setFirstDirection(SkPathPriv::kUnknown_FirstDirection);
// We don't touch Android's fSourcePath. It's used to track texture garbage collection, so we
@ -187,7 +187,7 @@ void SkPath::copyFields(const SkPath& that) {
fIsVolatile = that.fIsVolatile;
// Non-atomic assignment of atomic values.
this->setConvexity(that.getConvexityOrUnknown());
this->setConvexityType(that.getConvexityTypeOrUnknown());
this->setFirstDirection(that.getFirstDirection());
}
@ -212,9 +212,9 @@ void SkPath::swap(SkPath& that) {
that.fIsVolatile = iv;
// Non-atomic swaps of atomic values.
Convexity c = this->getConvexityOrUnknown();
this->setConvexity(that.getConvexityOrUnknown());
that.setConvexity(c);
SkPathConvexityType c = this->getConvexityTypeOrUnknown();
this->setConvexityType(that.getConvexityTypeOrUnknown());
that.setConvexityType(c);
uint8_t fd = this->getFirstDirection();
this->setFirstDirection(that.getFirstDirection());
@ -271,7 +271,7 @@ static inline bool check_edge_against_rect(const SkPoint& p0,
bool SkPath::conservativelyContainsRect(const SkRect& rect) const {
// This only handles non-degenerate convex paths currently.
if (kConvex_Convexity != this->getConvexity()) {
if (!this->isConvex()) {
return false;
}
@ -455,7 +455,7 @@ static int rect_make_dir(SkScalar dx, SkScalar dy) {
return ((0 != dx) << 0) | ((dx > 0 || dy > 0) << 1);
}
bool SkPath::isRect(SkRect* rect, bool* isClosed, Direction* direction) const {
bool SkPath::isRect(SkRect* rect, bool* isClosed, SkPathDirection* direction) const {
SkDEBUGCODE(this->validate();)
int currVerb = 0;
const SkPoint* pts = fPathRef->points();
@ -559,13 +559,13 @@ void SkPath::setLastPt(SkScalar x, SkScalar y) {
}
// This is the public-facing non-const setConvexity().
void SkPath::setConvexity(Convexity c) {
fConvexity.store(c, std::memory_order_relaxed);
void SkPath::setConvexityType(SkPathConvexityType c) {
fConvexity.store((uint8_t)c, std::memory_order_relaxed);
}
// Const hooks for working with fConvexity and fFirstDirection from const methods.
void SkPath::setConvexity(Convexity c) const {
fConvexity.store(c, std::memory_order_relaxed);
void SkPath::setConvexityType(SkPathConvexityType c) const {
fConvexity.store((uint8_t)c, std::memory_order_relaxed);
}
void SkPath::setFirstDirection(uint8_t d) const {
fFirstDirection.store(d, std::memory_order_relaxed);
@ -579,7 +579,7 @@ uint8_t SkPath::getFirstDirection() const {
#define DIRTY_AFTER_EDIT \
do { \
this->setConvexity(kUnknown_Convexity); \
this->setConvexityType(SkPathConvexityType::kUnknown); \
this->setFirstDirection(SkPathPriv::kUnknown_FirstDirection); \
} while (0)
@ -760,20 +760,20 @@ SkPath& SkPath::close() {
///////////////////////////////////////////////////////////////////////////////
static void assert_known_direction(int dir) {
SkASSERT(SkPath::kCW_Direction == dir || SkPath::kCCW_Direction == dir);
static void assert_known_direction(SkPathDirection dir) {
SkASSERT(SkPathDirection::kCW == dir || SkPathDirection::kCCW == dir);
}
SkPath& SkPath::addRect(const SkRect& rect, Direction dir) {
SkPath& SkPath::addRect(const SkRect& rect, SkPathDirection dir) {
return this->addRect(rect, dir, 0);
}
SkPath& SkPath::addRect(SkScalar left, SkScalar top, SkScalar right,
SkScalar bottom, Direction dir) {
SkScalar bottom, SkPathDirection dir) {
return this->addRect(SkRect::MakeLTRB(left, top, right, bottom), dir, 0);
}
SkPath& SkPath::addRect(const SkRect &rect, Direction dir, unsigned startIndex) {
SkPath& SkPath::addRect(const SkRect &rect, SkPathDirection dir, unsigned startIndex) {
assert_known_direction(dir);
this->setFirstDirection(this->hasOnlyMoveTos() ? (SkPathPriv::FirstDirection)dir
: SkPathPriv::kUnknown_FirstDirection);
@ -903,18 +903,18 @@ static int build_arc_conics(const SkRect& oval, const SkVector& start, const SkV
}
SkPath& SkPath::addRoundRect(const SkRect& rect, const SkScalar radii[],
Direction dir) {
SkPathDirection dir) {
SkRRect rrect;
rrect.setRectRadii(rect, (const SkVector*) radii);
return this->addRRect(rrect, dir);
}
SkPath& SkPath::addRRect(const SkRRect& rrect, Direction dir) {
SkPath& SkPath::addRRect(const SkRRect& rrect, SkPathDirection dir) {
// legacy start indices: 6 (CW) and 7(CCW)
return this->addRRect(rrect, dir, dir == kCW_Direction ? 6 : 7);
return this->addRRect(rrect, dir, dir == SkPathDirection::kCW ? 6 : 7);
}
SkPath& SkPath::addRRect(const SkRRect &rrect, Direction dir, unsigned startIndex) {
SkPath& SkPath::addRRect(const SkRRect &rrect, SkPathDirection dir, unsigned startIndex) {
assert_known_direction(dir);
bool isRRect = hasOnlyMoveTos();
@ -934,7 +934,7 @@ SkPath& SkPath::addRRect(const SkRRect &rrect, Direction dir, unsigned startInde
SkAutoDisableDirectionCheck addc(this);
// we start with a conic on odd indices when moving CW vs. even indices when moving CCW
const bool startsWithConic = ((startIndex & 1) == (dir == kCW_Direction));
const bool startsWithConic = ((startIndex & 1) == (dir == SkPathDirection::kCW));
const SkScalar weight = SK_ScalarRoot2Over2;
SkDEBUGCODE(int initialVerbCount = this->countVerbs());
@ -946,7 +946,7 @@ SkPath& SkPath::addRRect(const SkRRect &rrect, Direction dir, unsigned startInde
SkPath_RRectPointIterator rrectIter(rrect, dir, startIndex);
// Corner iterator indices follow the collapsed radii model,
// adjusted such that the start pt is "behind" the radii start pt.
const unsigned rectStartIndex = startIndex / 2 + (dir == kCW_Direction ? 0 : 1);
const unsigned rectStartIndex = startIndex / 2 + (dir == SkPathDirection::kCW ? 0 : 1);
SkPath_RectPointIterator rectIter(bounds, dir, rectStartIndex);
this->moveTo(rrectIter.current());
@ -966,7 +966,7 @@ SkPath& SkPath::addRRect(const SkRRect &rrect, Direction dir, unsigned startInde
this->close();
SkPathRef::Editor ed(&fPathRef);
ed.setIsRRect(isRRect, dir, startIndex % 8);
ed.setIsRRect(isRRect, dir == SkPathDirection::kCCW, startIndex % 8);
SkASSERT(this->countVerbs() == initialVerbCount + kVerbs);
}
@ -1006,7 +1006,7 @@ bool SkPath::isZeroLengthSincePoint(int startPtIndex) const {
}
SkPath& SkPath::addRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry,
Direction dir) {
SkPathDirection dir) {
assert_known_direction(dir);
if (rx < 0 || ry < 0) {
@ -1018,12 +1018,12 @@ SkPath& SkPath::addRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry,
return this->addRRect(rrect, dir);
}
SkPath& SkPath::addOval(const SkRect& oval, Direction dir) {
SkPath& SkPath::addOval(const SkRect& oval, SkPathDirection dir) {
// legacy start index: 1
return this->addOval(oval, dir, 1);
}
SkPath& SkPath::addOval(const SkRect &oval, Direction dir, unsigned startPointIndex) {
SkPath& SkPath::addOval(const SkRect &oval, SkPathDirection dir, unsigned startPointIndex) {
assert_known_direction(dir);
/* If addOval() is called after previous moveTo(),
@ -1048,7 +1048,7 @@ SkPath& SkPath::addOval(const SkRect &oval, Direction dir, unsigned startPointIn
SkPath_OvalPointIterator ovalIter(oval, dir, startPointIndex);
// The corner iterator pts are tracking "behind" the oval/radii pts.
SkPath_RectPointIterator rectIter(oval, dir, startPointIndex + (dir == kCW_Direction ? 0 : 1));
SkPath_RectPointIterator rectIter(oval, dir, startPointIndex + (dir == SkPathDirection::kCW ? 0 : 1));
const SkScalar weight = SK_ScalarRoot2Over2;
this->moveTo(ovalIter.current());
@ -1061,11 +1061,11 @@ SkPath& SkPath::addOval(const SkRect &oval, Direction dir, unsigned startPointIn
SkPathRef::Editor ed(&fPathRef);
ed.setIsOval(isOval, kCCW_Direction == dir, startPointIndex % 4);
ed.setIsOval(isOval, SkPathDirection::kCCW == dir, startPointIndex % 4);
return *this;
}
SkPath& SkPath::addCircle(SkScalar x, SkScalar y, SkScalar r, Direction dir) {
SkPath& SkPath::addCircle(SkScalar x, SkScalar y, SkScalar r, SkPathDirection dir) {
if (r > 0) {
this->addOval(SkRect::MakeLTRB(x - r, y - r, x + r, y + r), dir);
}
@ -1145,7 +1145,7 @@ SkPath& SkPath::arcTo(const SkRect& oval, SkScalar startAngle, SkScalar sweepAng
// http://www.w3.org/TR/SVG/implnote.html#ArcConversionEndpointToCenter
// Note that arcSweep bool value is flipped from the original implementation.
SkPath& SkPath::arcTo(SkScalar rx, SkScalar ry, SkScalar angle, SkPath::ArcSize arcLarge,
SkPath::Direction arcSweep, SkScalar x, SkScalar y) {
SkPathDirection arcSweep, SkScalar x, SkScalar y) {
this->injectMoveToIfNeeded();
SkPoint srcPts[2];
this->getLastPt(&srcPts[0]);
@ -1196,7 +1196,7 @@ SkPath& SkPath::arcTo(SkScalar rx, SkScalar ry, SkScalar angle, SkPath::ArcSize
SkScalar scaleFactorSquared = SkTMax(1 / d - 0.25f, 0.f);
SkScalar scaleFactor = SkScalarSqrt(scaleFactorSquared);
if (SkToBool(arcSweep) != SkToBool(arcLarge)) { // flipped from the original implementation
if ((arcSweep == SkPathDirection::kCCW) != SkToBool(arcLarge)) { // flipped from the original implementation
scaleFactor = -scaleFactor;
}
delta.scale(scaleFactor);
@ -1208,9 +1208,9 @@ SkPath& SkPath::arcTo(SkScalar rx, SkScalar ry, SkScalar angle, SkPath::ArcSize
SkScalar theta1 = SkScalarATan2(unitPts[0].fY, unitPts[0].fX);
SkScalar theta2 = SkScalarATan2(unitPts[1].fY, unitPts[1].fX);
SkScalar thetaArc = theta2 - theta1;
if (thetaArc < 0 && !arcSweep) { // arcSweep flipped from the original implementation
if (thetaArc < 0 && (arcSweep == SkPathDirection::kCW)) { // arcSweep flipped from the original implementation
thetaArc += SK_ScalarPI * 2;
} else if (thetaArc > 0 && arcSweep) { // arcSweep flipped from the original implementation
} else if (thetaArc > 0 && (arcSweep != SkPathDirection::kCW)) { // arcSweep flipped from the original implementation
thetaArc -= SK_ScalarPI * 2;
}
@ -1270,7 +1270,7 @@ SkPath& SkPath::arcTo(SkScalar rx, SkScalar ry, SkScalar angle, SkPath::ArcSize
}
SkPath& SkPath::rArcTo(SkScalar rx, SkScalar ry, SkScalar xAxisRotate, SkPath::ArcSize largeArc,
SkPath::Direction sweep, SkScalar dx, SkScalar dy) {
SkPathDirection sweep, SkScalar dx, SkScalar dy) {
SkPoint currentPoint;
this->getLastPt(&currentPoint);
return this->arcTo(rx, ry, xAxisRotate, largeArc, sweep,
@ -1294,7 +1294,7 @@ SkPath& SkPath::addArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAn
// Index 1 is at startAngle == 0.
SkScalar startIndex = std::fmod(startOver90I + 1.f, 4.f);
startIndex = startIndex < 0 ? startIndex + 4.f : startIndex;
return this->addOval(oval, sweepAngle > 0 ? kCW_Direction : kCCW_Direction,
return this->addOval(oval, sweepAngle > 0 ? SkPathDirection::kCW : SkPathDirection::kCCW,
(unsigned) startIndex);
}
}
@ -1597,7 +1597,7 @@ void SkPath::transform(const SkMatrix& matrix, SkPath* dst) const {
matrix.mapPoints(ed.writablePoints(), ed.pathRef()->countPoints());
dst->setFirstDirection(SkPathPriv::kUnknown_FirstDirection);
} else {
Convexity convexity = this->getConvexityOrUnknown();
SkPathConvexityType convexity = this->getConvexityTypeOrUnknown();
SkPathRef::CreateTransformedCopy(&dst->fPathRef, *fPathRef.get(), matrix);
@ -1617,9 +1617,9 @@ void SkPath::transform(const SkMatrix& matrix, SkPath* dst) const {
// check, and keep convex paths marked as such after a general transform...
//
if (matrix.isScaleTranslate() && SkPathPriv::IsAxisAligned(*this)) {
dst->setConvexity(convexity);
dst->setConvexityType(convexity);
} else {
dst->setConvexity(kUnknown_Convexity);
dst->setConvexityType(SkPathConvexityType::kUnknown);
}
if (this->getFirstDirection() == SkPathPriv::kUnknown_FirstDirection) {
@ -2294,7 +2294,7 @@ struct Convexicator {
return true;
}
static SkPath::Convexity BySign(const SkPoint points[], int count) {
static SkPathConvexityType BySign(const SkPoint points[], int count) {
const SkPoint* last = points + count;
SkPoint currPt = *points++;
SkPoint firstPt = currPt;
@ -2308,14 +2308,14 @@ struct Convexicator {
if (!vec.isZero()) {
// give up if vector construction failed
if (!vec.isFinite()) {
return SkPath::kUnknown_Convexity;
return SkPathConvexityType::kUnknown;
}
int sx = sign(vec.fX);
int sy = sign(vec.fY);
dxes += (sx != lastSx);
dyes += (sy != lastSy);
if (dxes > 3 || dyes > 3) {
return SkPath::kConcave_Convexity;
return SkPathConvexityType::kConcave;
}
lastSx = sx;
lastSy = sy;
@ -2327,7 +2327,7 @@ struct Convexicator {
}
points = &firstPt;
}
return SkPath::kConvex_Convexity; // that is, it may be convex, don't know yet
return SkPathConvexityType::kConvex; // that is, it may be convex, don't know yet
}
bool close() {
@ -2407,13 +2407,13 @@ private:
bool fIsFinite { true };
};
SkPath::Convexity SkPath::internalGetConvexity() const {
SkPathConvexityType SkPath::internalGetConvexity() const {
SkPoint pts[4];
SkPath::Verb verb;
SkPath::Iter iter(*this, true);
auto setComputedConvexity = [=](Convexity convexity){
SkASSERT(kUnknown_Convexity != convexity);
this->setConvexity(convexity);
auto setComputedConvexity = [=](SkPathConvexityType convexity){
SkASSERT(SkPathConvexityType::kUnknown != convexity);
this->setConvexityType(convexity);
return convexity;
};
@ -2431,15 +2431,15 @@ SkPath::Convexity SkPath::internalGetConvexity() const {
++points;
}
--points;
SkPath::Convexity convexity = Convexicator::BySign(points, (int) (last - points));
if (SkPath::kConcave_Convexity == convexity) {
return setComputedConvexity(SkPath::kConcave_Convexity);
} else if (SkPath::kUnknown_Convexity == convexity) {
return SkPath::kUnknown_Convexity;
SkPathConvexityType convexity = Convexicator::BySign(points, (int) (last - points));
if (SkPathConvexityType::kConcave == convexity) {
return setComputedConvexity(SkPathConvexityType::kConcave);
} else if (SkPathConvexityType::kUnknown == convexity) {
return SkPathConvexityType::kUnknown;
}
iter.setPath(*this, true);
} else if (!this->isFinite()) {
return kUnknown_Convexity;
return SkPathConvexityType::kUnknown;
}
int contourCount = 0;
@ -2447,16 +2447,16 @@ SkPath::Convexity SkPath::internalGetConvexity() const {
Convexicator state;
auto setFail = [=](){
if (!state.isFinite()) {
return SkPath::kUnknown_Convexity;
return SkPathConvexityType::kUnknown;
}
return setComputedConvexity(SkPath::kConcave_Convexity);
return setComputedConvexity(SkPathConvexityType::kConcave);
};
while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
switch (verb) {
case kMove_Verb:
if (++contourCount > 1) {
return setComputedConvexity(kConcave_Convexity);
return setComputedConvexity(SkPathConvexityType::kConcave);
}
state.setMovePt(pts[0]);
count = 0;
@ -2480,7 +2480,7 @@ SkPath::Convexity SkPath::internalGetConvexity() const {
break;
default:
SkDEBUGFAIL("bad verb");
return setComputedConvexity(kConcave_Convexity);
return setComputedConvexity(SkPathConvexityType::kConcave);
}
for (int i = 1; i <= count; i++) {
if (!state.addPt(pts[i])) {
@ -2493,16 +2493,16 @@ SkPath::Convexity SkPath::internalGetConvexity() const {
if (state.getFirstDirection() == SkPathPriv::kUnknown_FirstDirection
&& !this->getBounds().isEmpty()) {
return setComputedConvexity(state.reversals() < 3 ?
kConvex_Convexity : kConcave_Convexity);
SkPathConvexityType::kConvex : SkPathConvexityType::kConcave);
}
this->setFirstDirection(state.getFirstDirection());
}
return setComputedConvexity(kConvex_Convexity);
return setComputedConvexity(SkPathConvexityType::kConvex);
}
bool SkPathPriv::IsConvex(const SkPoint points[], int count) {
SkPath::Convexity convexity = Convexicator::BySign(points, count);
if (SkPath::kConvex_Convexity != convexity) {
SkPathConvexityType convexity = Convexicator::BySign(points, count);
if (SkPathConvexityType::kConvex != convexity) {
return false;
}
Convexicator state;
@ -2701,7 +2701,7 @@ bool SkPathPriv::CheapComputeFirstDirection(const SkPath& path, FirstDirection*
// We don't want to pay the cost for computing convexity if it is unknown,
// so we call getConvexityOrUnknown() instead of isConvex().
if (path.getConvexityOrUnknown() == SkPath::kConvex_Convexity) {
if (path.getConvexityTypeOrUnknown() == SkPathConvexityType::kConvex) {
SkASSERT(path.getFirstDirection() == kUnknown_FirstDirection);
*dir = static_cast<FirstDirection>(path.getFirstDirection());
return false;
@ -3294,7 +3294,7 @@ int SkPath::ConvertConicToQuads(const SkPoint& p0, const SkPoint& p1, const SkPo
return conic.chopIntoQuadsPOW2(pts, pow2);
}
bool SkPathPriv::IsSimpleClosedRect(const SkPath& path, SkRect* rect, SkPath::Direction* direction,
bool SkPathPriv::IsSimpleClosedRect(const SkPath& path, SkRect* rect, SkPathDirection* direction,
unsigned* start) {
if (path.getSegmentMasks() != SkPath::kLine_SegmentMask) {
return false;
@ -3364,22 +3364,22 @@ bool SkPathPriv::IsSimpleClosedRect(const SkPath& path, SkRect* rect, SkPath::Di
switch (sortFlags) {
case 0b00:
rect->setLTRB(rectPts[0].fX, rectPts[0].fY, rectPts[2].fX, rectPts[2].fY);
*direction = vec03IsVertical ? SkPath::kCW_Direction : SkPath::kCCW_Direction;
*direction = vec03IsVertical ? SkPathDirection::kCW : SkPathDirection::kCCW;
*start = 0;
break;
case 0b01:
rect->setLTRB(rectPts[2].fX, rectPts[0].fY, rectPts[0].fX, rectPts[2].fY);
*direction = vec03IsVertical ? SkPath::kCCW_Direction : SkPath::kCW_Direction;
*direction = vec03IsVertical ? SkPathDirection::kCCW : SkPathDirection::kCW;
*start = 1;
break;
case 0b10:
rect->setLTRB(rectPts[0].fX, rectPts[2].fY, rectPts[2].fX, rectPts[0].fY);
*direction = vec03IsVertical ? SkPath::kCCW_Direction : SkPath::kCW_Direction;
*direction = vec03IsVertical ? SkPathDirection::kCCW : SkPathDirection::kCW;
*start = 3;
break;
case 0b11:
rect->setLTRB(rectPts[2].fX, rectPts[2].fY, rectPts[0].fX, rectPts[0].fY);
*direction = vec03IsVertical ? SkPath::kCW_Direction : SkPath::kCCW_Direction;
*direction = vec03IsVertical ? SkPathDirection::kCW : SkPathDirection::kCCW;
*start = 2;
break;
}
@ -3441,7 +3441,7 @@ void SkPathPriv::CreateDrawArcPath(SkPath* path, const SkRect& oval, SkScalar st
if (useCenter) {
path->close();
}
path->setConvexity(convex ? SkPath::kConvex_Convexity : SkPath::kConcave_Convexity);
path->setConvexityType(convex ? SkPathConvexityType::kConvex : SkPathConvexityType::kConcave);
path->setFirstDirection(firstDir);
}
@ -3560,7 +3560,7 @@ bool SkPath::IsCubicDegenerate(const SkPoint& p1, const SkPoint& p2,
//////////////////////////////////////////////////////////////////////////////////////////////////
bool SkPathPriv::IsRectContour(const SkPath& path, bool allowPartial, int* currVerb,
const SkPoint** ptsPtr, bool* isClosed, SkPath::Direction* direction,
const SkPoint** ptsPtr, bool* isClosed, SkPathDirection* direction,
SkRect* rect) {
int corners = 0;
SkPoint closeXY; // used to determine if final line falls on a diagonal
@ -3693,17 +3693,17 @@ bool SkPathPriv::IsRectContour(const SkPath& path, bool allowPartial, int* currV
}
if (direction) {
*direction = directions[0] == ((directions[1] + 1) & 3) ?
SkPath::kCW_Direction : SkPath::kCCW_Direction;
SkPathDirection::kCW : SkPathDirection::kCCW;
}
return true;
}
bool SkPathPriv::IsNestedFillRects(const SkPath& path, SkRect rects[2], SkPath::Direction dirs[2]) {
bool SkPathPriv::IsNestedFillRects(const SkPath& path, SkRect rects[2], SkPathDirection dirs[2]) {
SkDEBUGCODE(path.validate();)
int currVerb = 0;
const SkPoint* pts = path.fPathRef->points();
SkPath::Direction testDirs[2];
SkPathDirection testDirs[2];
SkRect testRects[2];
if (!IsRectContour(path, true, &currVerb, &pts, nullptr, &testDirs[0], &testRects[0])) {
return false;

View File

@ -8,15 +8,15 @@
#ifndef SkPathMakers_DEFINED
#define SkPathMakers_DEFINED
#include "include/core/SkPath.h" // just for direction
#include "include/core/SkPathTypes.h"
#include "include/core/SkPoint.h"
#include "include/core/SkRRect.h"
template <unsigned N> class SkPath_PointIterator {
public:
SkPath_PointIterator(SkPath::Direction dir, unsigned startIndex)
SkPath_PointIterator(SkPathDirection dir, unsigned startIndex)
: fCurrent(startIndex % N)
, fAdvance(dir == SkPath::kCW_Direction ? 1 : N - 1) { }
, fAdvance(dir == SkPathDirection::kCW ? 1 : N - 1) { }
const SkPoint& current() const {
SkASSERT(fCurrent < N);
@ -38,7 +38,7 @@ public:
class SkPath_RectPointIterator : public SkPath_PointIterator<4> {
public:
SkPath_RectPointIterator(const SkRect& rect, SkPath::Direction dir, unsigned startIndex)
SkPath_RectPointIterator(const SkRect& rect, SkPathDirection dir, unsigned startIndex)
: SkPath_PointIterator(dir, startIndex) {
fPts[0] = SkPoint::Make(rect.fLeft, rect.fTop);
@ -50,7 +50,7 @@ public:
class SkPath_OvalPointIterator : public SkPath_PointIterator<4> {
public:
SkPath_OvalPointIterator(const SkRect& oval, SkPath::Direction dir, unsigned startIndex)
SkPath_OvalPointIterator(const SkRect& oval, SkPathDirection dir, unsigned startIndex)
: SkPath_PointIterator(dir, startIndex) {
const SkScalar cx = oval.centerX();
@ -65,7 +65,7 @@ public:
class SkPath_RRectPointIterator : public SkPath_PointIterator<8> {
public:
SkPath_RRectPointIterator(const SkRRect& rrect, SkPath::Direction dir, unsigned startIndex)
SkPath_RRectPointIterator(const SkRRect& rrect, SkPathDirection dir, unsigned startIndex)
: SkPath_PointIterator(dir, startIndex) {
const SkRect& bounds = rrect.getBounds();

View File

@ -10,6 +10,11 @@
#include "include/core/SkPath.h"
static_assert(0 == static_cast<int>(SkPathFillType::kWinding), "fill_type_mismatch");
static_assert(1 == static_cast<int>(SkPathFillType::kEvenOdd), "fill_type_mismatch");
static_assert(2 == static_cast<int>(SkPathFillType::kInverseWinding), "fill_type_mismatch");
static_assert(3 == static_cast<int>(SkPathFillType::kInverseEvenOdd), "fill_type_mismatch");
class SkPathPriv {
public:
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
@ -19,12 +24,12 @@ public:
#endif
enum FirstDirection : int {
kCW_FirstDirection, // == SkPath::kCW_Direction
kCCW_FirstDirection, // == SkPath::kCCW_Direction
kCW_FirstDirection, // == SkPathDirection::kCW
kCCW_FirstDirection, // == SkPathDirection::kCCW
kUnknown_FirstDirection,
};
static FirstDirection AsFirstDirection(SkPath::Direction dir) {
static FirstDirection AsFirstDirection(SkPathDirection dir) {
// since we agree numerically for the values in Direction, we can just cast.
return (FirstDirection)dir;
}
@ -96,7 +101,7 @@ public:
* followed by four lines or a move followed by 3 lines and a close. None of the parameters are
* optional. This does not permit degenerate line or point rectangles.
*/
static bool IsSimpleClosedRect(const SkPath& path, SkRect* rect, SkPath::Direction* direction,
static bool IsSimpleClosedRect(const SkPath& path, SkRect* rect, SkPathDirection* direction,
unsigned* start);
/**
@ -179,7 +184,7 @@ public:
return true though SkPath draws oval.
rect receives bounds of oval.
dir receives SkPath::Direction of oval: kCW_Direction if clockwise, kCCW_Direction if
dir receives SkPathDirection of oval: kCW_Direction if clockwise, kCCW_Direction if
counterclockwise.
start receives start of oval: 0 for top, 1 for right, 2 for bottom, 3 for left.
@ -188,15 +193,15 @@ public:
Triggers performance optimizations on some GPU surface implementations.
@param rect storage for bounding SkRect of oval; may be nullptr
@param dir storage for SkPath::Direction; may be nullptr
@param dir storage for SkPathDirection; may be nullptr
@param start storage for start of oval; may be nullptr
@return true if SkPath was constructed by method that reduces to oval
*/
static bool IsOval(const SkPath& path, SkRect* rect, SkPath::Direction* dir, unsigned* start) {
static bool IsOval(const SkPath& path, SkRect* rect, SkPathDirection* dir, unsigned* start) {
bool isCCW = false;
bool result = path.fPathRef->isOval(rect, &isCCW, start);
if (dir && result) {
*dir = isCCW ? SkPath::kCCW_Direction : SkPath::kCW_Direction;
*dir = isCCW ? SkPathDirection::kCCW : SkPathDirection::kCW;
}
return result;
}
@ -206,7 +211,7 @@ public:
will not return true though SkPath draws SkRRect.
rrect receives bounds of SkRRect.
dir receives SkPath::Direction of oval: kCW_Direction if clockwise, kCCW_Direction if
dir receives SkPathDirection of oval: kCW_Direction if clockwise, kCCW_Direction if
counterclockwise.
start receives start of SkRRect: 0 for top, 1 for right, 2 for bottom, 3 for left.
@ -215,16 +220,16 @@ public:
Triggers performance optimizations on some GPU surface implementations.
@param rrect storage for bounding SkRect of SkRRect; may be nullptr
@param dir storage for SkPath::Direction; may be nullptr
@param dir storage for SkPathDirection; may be nullptr
@param start storage for start of SkRRect; may be nullptr
@return true if SkPath contains only SkRRect
*/
static bool IsRRect(const SkPath& path, SkRRect* rrect, SkPath::Direction* dir,
static bool IsRRect(const SkPath& path, SkRRect* rrect, SkPathDirection* dir,
unsigned* start) {
bool isCCW = false;
bool result = path.fPathRef->isRRect(rrect, &isCCW, start);
if (dir && result) {
*dir = isCCW ? SkPath::kCCW_Direction : SkPath::kCW_Direction;
*dir = isCCW ? SkPathDirection::kCCW : SkPathDirection::kCW;
}
return result;
}
@ -282,22 +287,37 @@ public:
}
static bool IsRectContour(const SkPath&, bool allowPartial, int* currVerb,
const SkPoint** ptsPtr, bool* isClosed, SkPath::Direction* direction,
const SkPoint** ptsPtr, bool* isClosed, SkPathDirection* direction,
SkRect* rect);
/** Returns true if SkPath is equivalent to nested SkRect pair when filled.
If false, rect and dirs are unchanged.
If true, rect and dirs are written to if not nullptr:
setting rect[0] to outer SkRect, and rect[1] to inner SkRect;
setting dirs[0] to SkPath::Direction of outer SkRect, and dirs[1] to SkPath::Direction of
setting dirs[0] to SkPathDirection of outer SkRect, and dirs[1] to SkPathDirection of
inner SkRect.
@param rect storage for SkRect pair; may be nullptr
@param dirs storage for SkPath::Direction pair; may be nullptr
@param dirs storage for SkPathDirection pair; may be nullptr
@return true if SkPath contains nested SkRect pair
*/
static bool IsNestedFillRects(const SkPath&, SkRect rect[2],
SkPath::Direction dirs[2] = nullptr);
SkPathDirection dirs[2] = nullptr);
static bool IsInverseFillType(SkPathFillType fill) {
return (static_cast<int>(fill) & 2) != 0;
}
/** Returns equivalent SkPath::FillType representing SkPath fill inside its bounds.
.
@param fill one of: kWinding_FillType, kEvenOdd_FillType,
kInverseWinding_FillType, kInverseEvenOdd_FillType
@return fill, or kWinding_FillType or kEvenOdd_FillType if fill is inverted
*/
static SkPathFillType ConvertToNonInverseFillType(SkPathFillType fill) {
return (SkPathFillType)(static_cast<int>(fill) & 1);
}
};
// Lightweight variant of SkPath::Iter that only returns segments (e.g. lines/conics).

View File

@ -169,15 +169,15 @@ size_t SkPath::readAsRRect(const void* storage, size_t length) {
uint8_t dir = (packed >> kDirection_SerializationShift) & 0x3;
FillType fillType = extract_filltype(packed);
Direction rrectDir;
SkPathDirection rrectDir;
SkRRect rrect;
int32_t start;
switch (dir) {
case SkPathPriv::kCW_FirstDirection:
rrectDir = kCW_Direction;
rrectDir = SkPathDirection::kCW;
break;
case SkPathPriv::kCCW_FirstDirection:
rrectDir = kCCW_Direction;
rrectDir = SkPathDirection::kCCW;
break;
default:
return 0;

View File

@ -1391,7 +1391,7 @@ void SkStroke::strokePath(const SkPath& src, SkPath* dst) const {
{
SkRect rect;
bool isClosed = false;
SkPath::Direction dir;
SkPathDirection dir;
if (src.isRect(&rect, &isClosed, &dir) && isClosed) {
this->strokeRect(rect, dst, dir);
// our answer should preserve the inverseness of the src
@ -1498,15 +1498,15 @@ DONE:
}
}
static SkPath::Direction reverse_direction(SkPath::Direction dir) {
static const SkPath::Direction gOpposite[] = { SkPath::kCCW_Direction, SkPath::kCW_Direction };
return gOpposite[dir];
static SkPathDirection reverse_direction(SkPathDirection dir) {
static const SkPathDirection gOpposite[] = { SkPathDirection::kCCW, SkPathDirection::kCW };
return gOpposite[(int)dir];
}
static void addBevel(SkPath* path, const SkRect& r, const SkRect& outer, SkPath::Direction dir) {
static void addBevel(SkPath* path, const SkRect& r, const SkRect& outer, SkPathDirection dir) {
SkPoint pts[8];
if (SkPath::kCW_Direction == dir) {
if (SkPathDirection::kCW == dir) {
pts[0].set(r.fLeft, outer.fTop);
pts[1].set(r.fRight, outer.fTop);
pts[2].set(outer.fRight, r.fTop);
@ -1529,7 +1529,7 @@ static void addBevel(SkPath* path, const SkRect& r, const SkRect& outer, SkPath:
}
void SkStroke::strokeRect(const SkRect& origRect, SkPath* dst,
SkPath::Direction dir) const {
SkPathDirection dir) const {
SkASSERT(dst != nullptr);
dst->reset();

View File

@ -62,7 +62,7 @@ public:
* Stroke the specified rect, winding it in the specified direction..
*/
void strokeRect(const SkRect& rect, SkPath* result,
SkPath::Direction = SkPath::kCW_Direction) const;
SkPathDirection = SkPathDirection::kCW) const;
void strokePath(const SkPath& path, SkPath*) const;
////////////////////////////////////////////////////////////////

View File

@ -1447,7 +1447,7 @@ void GrRenderTargetContext::drawOval(const GrClip& clip,
assert_alive(paint);
this->drawShapeUsingPathRenderer(
clip, std::move(paint), aa, viewMatrix,
GrShape(SkRRect::MakeOval(oval), SkPath::kCW_Direction, 2, false, style));
GrShape(SkRRect::MakeOval(oval), SkPathDirection::kCW, 2, false, style));
}
void GrRenderTargetContext::drawArc(const GrClip& clip,

View File

@ -232,7 +232,7 @@ const SkPath& TestPathConvex(SkRandom* random) {
gPath[2].lineTo(-50.0f, 31.0f);
for (size_t i = 0; i < SK_ARRAY_COUNT(gPath); i++) {
SkASSERT(SkPath::kConvex_Convexity == gPath[i].getConvexity());
SkASSERT(SkPathConvexityType::kConvex == gPath[i].getConvexityType());
}
}

View File

@ -273,7 +273,7 @@ void GrShape::writeUnstyledKey(uint32_t* key) const {
case Type::kRRect:
fRRectData.fRRect.writeToMemory(key);
key += SkRRect::kSizeInMemory / sizeof(uint32_t);
*key = (fRRectData.fDir == SkPath::kCCW_Direction) ? (1 << 31) : 0;
*key = (fRRectData.fDir == SkPathDirection::kCCW) ? (1 << 31) : 0;
*key |= fRRectData.fInverted ? (1 << 30) : 0;
*key++ |= fRRectData.fStart;
SkASSERT(fRRectData.fStart < 8);
@ -507,7 +507,7 @@ GrShape::GrShape(const GrShape& parent, GrStyle::Apply apply, SkScalar scale) {
void GrShape::attemptToSimplifyPath() {
SkRect rect;
SkRRect rrect;
SkPath::Direction rrectDir;
SkPathDirection rrectDir;
unsigned rrectStart;
bool inverted = this->path().isInverseFillType();
SkPoint pts[2];

View File

@ -61,7 +61,7 @@ public:
this->attemptToSimplifyRRect();
}
GrShape(const SkRRect& rrect, SkPath::Direction dir, unsigned start, bool inverted,
GrShape(const SkRRect& rrect, SkPathDirection dir, unsigned start, bool inverted,
const GrStyle& style)
: fStyle(style) {
this->initType(Type::kRRect);
@ -160,7 +160,7 @@ public:
}
/** Returns the unstyled geometry as a rrect if possible. */
bool asRRect(SkRRect* rrect, SkPath::Direction* dir, unsigned* start, bool* inverted) const {
bool asRRect(SkRRect* rrect, SkPathDirection* dir, unsigned* start, bool* inverted) const {
if (Type::kRRect != fType) {
return false;
}
@ -255,7 +255,7 @@ public:
return false;
}
SkPath::Direction dirs[2];
SkPathDirection dirs[2];
if (!SkPathPriv::IsNestedFillRects(this->path(), rects, dirs)) {
return false;
}
@ -554,11 +554,11 @@ private:
static constexpr SkPath::FillType kDefaultPathInverseFillType =
SkPath::kInverseEvenOdd_FillType;
static constexpr SkPath::Direction kDefaultRRectDir = SkPath::kCW_Direction;
static constexpr SkPathDirection kDefaultRRectDir = SkPathDirection::kCW;
static constexpr unsigned kDefaultRRectStart = 0;
static unsigned DefaultRectDirAndStartIndex(const SkRect& rect, bool hasPathEffect,
SkPath::Direction* dir) {
SkPathDirection* dir) {
*dir = kDefaultRRectDir;
// This comes from SkPath's interface. The default for adding a SkRect is counter clockwise
// beginning at index 0 (which happens to correspond to rrect index 0 or 7).
@ -575,11 +575,11 @@ private:
// 0 becomes start index 2 and times 2 to convert from rect the rrect indices.
return 2 * 2;
} else if (swapX) {
*dir = SkPath::kCCW_Direction;
*dir = SkPathDirection::kCCW;
// 0 becomes start index 1 and times 2 to convert from rect the rrect indices.
return 2 * 1;
} else if (swapY) {
*dir = SkPath::kCCW_Direction;
*dir = SkPathDirection::kCCW;
// 0 becomes start index 3 and times 2 to convert from rect the rrect indices.
return 2 * 3;
}
@ -587,7 +587,7 @@ private:
}
static unsigned DefaultRRectDirAndStartIndex(const SkRRect& rrect, bool hasPathEffect,
SkPath::Direction* dir) {
SkPathDirection* dir) {
// This comes from SkPath's interface. The default for adding a SkRRect to a path is
// clockwise beginning at starting index 6.
static constexpr unsigned kPathRRectStartIdx = 6;
@ -602,7 +602,7 @@ private:
union {
struct {
SkRRect fRRect;
SkPath::Direction fDir;
SkPathDirection fDir;
unsigned fStart;
bool fInverted;
} fRRectData;

View File

@ -377,7 +377,7 @@ bool GrAAConvexTessellator::computePtAlongBisector(int startIdx,
}
bool GrAAConvexTessellator::extractFromPath(const SkMatrix& m, const SkPath& path) {
SkASSERT(SkPath::kConvex_Convexity == path.getConvexity());
SkASSERT(SkPathConvexityType::kConvex == path.getConvexityType());
SkRect bounds = path.getBounds();
m.mapRect(&bounds);

View File

@ -13,7 +13,7 @@
using std::vector;
struct Contour {
enum class Direction { // SkPath::Direction doesn't have 'none' state
enum class Direction { // SkPathDirection doesn't have 'none' state
kCCW = -1,
kNone,
kCW,

View File

@ -2914,15 +2914,15 @@ void SkPathOpsDebug::ShowOnePath(const SkPath& path, const char* name, bool incl
int rectCount = path.isRectContours() ? path.rectContours(nullptr, nullptr) : 0;
if (rectCount > 0) {
SkTDArray<SkRect> rects;
SkTDArray<SkPath::Direction> directions;
SkTDArray<SkPathDirection> directions;
rects.setCount(rectCount);
directions.setCount(rectCount);
path.rectContours(rects.begin(), directions.begin());
for (int contour = 0; contour < rectCount; ++contour) {
const SkRect& rect = rects[contour];
SkDebugf("path.addRect(%1.9g, %1.9g, %1.9g, %1.9g, %s);\n", rect.fLeft, rect.fTop,
rect.fRight, rect.fBottom, directions[contour] == SkPath::kCCW_Direction
? "SkPath::kCCW_Direction" : "SkPath::kCW_Direction");
rect.fRight, rect.fBottom, directions[contour] == SkPathDirection::kCCW
? "SkPathDirection::kCCW" : "SkPathDirection::kCW");
}
return;
}

View File

@ -128,10 +128,10 @@ void SkPDFUtils::EmitPath(const SkPath& path, SkPaint::Style paintStyle,
SkRect rect;
bool isClosed; // Both closure and direction need to be checked.
SkPath::Direction direction;
SkPathDirection direction;
if (path.isRect(&rect, &isClosed, &direction) &&
isClosed &&
(SkPath::kCW_Direction == direction ||
(SkPathDirection::kCW == direction ||
SkPath::kEvenOdd_FillType == path.getFillType()))
{
SkPDFUtils::AppendRectangle(rect, content);

View File

@ -425,7 +425,7 @@ bool SkDashPath::InternalFilter(SkPath* dst, const SkPath& src, SkStrokeRec* rec
} while (meas.nextContour());
if (segCount > 1) {
dst->setConvexity(SkPath::kConcave_Convexity);
dst->setConvexityType(SkPathConvexityType::kConcave);
}
return true;

View File

@ -1310,7 +1310,7 @@ static int lpath_getSegmentTypes(lua_State* L) {
}
static int lpath_isConvex(lua_State* L) {
bool isConvex = SkPath::kConvex_Convexity == get_obj<SkPath>(L, 1)->getConvexity();
bool isConvex = get_obj<SkPath>(L, 1)->isConvex();
SkLua(L).pushBool(isConvex);
return 1;
}

View File

@ -175,7 +175,7 @@ bool SkParsePath::FromSVGString(const char data[], SkPath* result) {
&& (data = skip_sep(data))
&& (data = find_points(data, &points[0], 1, relative, &c))) {
path.arcTo(radii, angle, (SkPath::ArcSize) SkToBool(largeArc),
(SkPath::Direction) !SkToBool(sweep), points[0]);
(SkPathDirection) !SkToBool(sweep), points[0]);
path.getLastPt(&c);
}
} break;

View File

@ -55,8 +55,8 @@ static SkBitmap read_back(GrRenderTargetContext* rtc, int width, int height) {
static SkPath make_path(const SkRect& outer, int inset, SkPath::FillType fill) {
SkPath p;
p.addRect(outer, SkPath::kCW_Direction);
p.addRect(outer.makeInset(inset, inset), SkPath::kCCW_Direction);
p.addRect(outer, SkPathDirection::kCW);
p.addRect(outer.makeInset(inset, inset), SkPathDirection::kCCW);
p.setFillType(fill);
return p;
}

View File

@ -65,8 +65,8 @@ static void test_drawSameRectOvals(skiatest::Reporter*, SkCanvas* canvas) {
SkPath oval1, oval2;
const SkRect rect = SkRect::MakeWH(100, 50);
oval1.addOval(rect, SkPath::kCW_Direction);
oval2.addOval(rect, SkPath::kCCW_Direction);
oval1.addOval(rect, SkPathDirection::kCW);
oval2.addOval(rect, SkPathDirection::kCCW);
fill_and_stroke(canvas, oval1, oval2, nullptr);

View File

@ -119,7 +119,7 @@ static void check_equivalence(skiatest::Reporter* r, const GrShape& a, const GrS
// The asRRect() output params are all initialized just to silence compiler warnings about
// uninitialized variables.
SkRRect rrectA = SkRRect::MakeEmpty(), rrectB = SkRRect::MakeEmpty();
SkPath::Direction dirA = SkPath::kCW_Direction, dirB = SkPath::kCW_Direction;
SkPathDirection dirA = SkPathDirection::kCW, dirB = SkPathDirection::kCW;
unsigned startA = ~0U, startB = ~0U;
bool invertedA = true, invertedB = true;
@ -457,7 +457,7 @@ public:
}
SkRect rect;
unsigned start;
SkPath::Direction dir;
SkPathDirection dir;
if (SkPathPriv::IsSimpleClosedRect(fPath, &rect, &dir, &start)) {
return RectGeo(rect).strokeAndFillIsConvertedToFill(paint);
}
@ -1577,7 +1577,7 @@ DEF_TEST(GrShape_empty_shape, reporter) {
dashAndStrokeEmptyRRectCase.compare(reporter, fillEmptyCase,
TestCase::kAllSame_ComparisonExpecation);
static constexpr SkPath::Direction kDir = SkPath::kCCW_Direction;
static constexpr SkPathDirection kDir = SkPathDirection::kCCW;
static constexpr int kStart = 0;
TestCase fillInvertedEmptyRRectCase(reporter, emptyRRect, kDir, kStart, true, GrStyle(fill));
@ -1646,21 +1646,21 @@ void test_rrect(skiatest::Reporter* r, const SkRRect& rrect) {
static constexpr Style kStyleCnt = static_cast<Style>(SK_ARRAY_COUNT(strokeRecs));
auto index = [](bool inverted,
SkPath::Direction dir,
SkPathDirection dir,
unsigned start,
Style style,
bool dash) -> int {
return inverted * (2 * 8 * kStyleCnt * 2) +
dir * ( 8 * kStyleCnt * 2) +
(int)dir * ( 8 * kStyleCnt * 2) +
start * ( kStyleCnt * 2) +
style * ( 2) +
dash;
};
static const SkPath::Direction kSecondDirection = static_cast<SkPath::Direction>(1);
static const SkPathDirection kSecondDirection = static_cast<SkPathDirection>(1);
const int cnt = index(true, kSecondDirection, 7, static_cast<Style>(kStyleCnt - 1), true) + 1;
SkAutoTArray<GrShape> shapes(cnt);
for (bool inverted : {false, true}) {
for (SkPath::Direction dir : {SkPath::kCW_Direction, SkPath::kCCW_Direction}) {
for (SkPathDirection dir : {SkPathDirection::kCW, SkPathDirection::kCCW}) {
for (unsigned start = 0; start < 8; ++start) {
for (Style style : {kFill, kStroke, kHairline, kStrokeAndFill}) {
for (bool dash : {false, true}) {
@ -1676,7 +1676,7 @@ void test_rrect(skiatest::Reporter* r, const SkRRect& rrect) {
// Get the keys for some example shape instances that we'll use for comparision against the
// rest.
static constexpr SkPath::Direction kExamplesDir = SkPath::kCW_Direction;
static constexpr SkPathDirection kExamplesDir = SkPathDirection::kCW;
static constexpr unsigned kExamplesStart = 0;
const GrShape& exampleFillCase = shapes[index(false, kExamplesDir, kExamplesStart, kFill,
false)];
@ -1720,61 +1720,61 @@ void test_rrect(skiatest::Reporter* r, const SkRRect& rrect) {
// These are dummy initializations to suppress warnings.
SkRRect queryRR = SkRRect::MakeEmpty();
SkPath::Direction queryDir = SkPath::kCW_Direction;
SkPathDirection queryDir = SkPathDirection::kCW;
unsigned queryStart = ~0U;
bool queryInverted = true;
REPORTER_ASSERT(r, exampleFillCase.asRRect(&queryRR, &queryDir, &queryStart, &queryInverted));
REPORTER_ASSERT(r, queryRR == rrect);
REPORTER_ASSERT(r, SkPath::kCW_Direction == queryDir);
REPORTER_ASSERT(r, SkPathDirection::kCW == queryDir);
REPORTER_ASSERT(r, 0 == queryStart);
REPORTER_ASSERT(r, !queryInverted);
REPORTER_ASSERT(r, exampleInvFillCase.asRRect(&queryRR, &queryDir, &queryStart,
&queryInverted));
REPORTER_ASSERT(r, queryRR == rrect);
REPORTER_ASSERT(r, SkPath::kCW_Direction == queryDir);
REPORTER_ASSERT(r, SkPathDirection::kCW == queryDir);
REPORTER_ASSERT(r, 0 == queryStart);
REPORTER_ASSERT(r, queryInverted);
REPORTER_ASSERT(r, exampleStrokeAndFillCase.asRRect(&queryRR, &queryDir, &queryStart,
&queryInverted));
REPORTER_ASSERT(r, queryRR == rrect);
REPORTER_ASSERT(r, SkPath::kCW_Direction == queryDir);
REPORTER_ASSERT(r, SkPathDirection::kCW == queryDir);
REPORTER_ASSERT(r, 0 == queryStart);
REPORTER_ASSERT(r, !queryInverted);
REPORTER_ASSERT(r, exampleInvStrokeAndFillCase.asRRect(&queryRR, &queryDir, &queryStart,
&queryInverted));
REPORTER_ASSERT(r, queryRR == rrect);
REPORTER_ASSERT(r, SkPath::kCW_Direction == queryDir);
REPORTER_ASSERT(r, SkPathDirection::kCW == queryDir);
REPORTER_ASSERT(r, 0 == queryStart);
REPORTER_ASSERT(r, queryInverted);
REPORTER_ASSERT(r, exampleHairlineCase.asRRect(&queryRR, &queryDir, &queryStart,
&queryInverted));
REPORTER_ASSERT(r, queryRR == rrect);
REPORTER_ASSERT(r, SkPath::kCW_Direction == queryDir);
REPORTER_ASSERT(r, SkPathDirection::kCW == queryDir);
REPORTER_ASSERT(r, 0 == queryStart);
REPORTER_ASSERT(r, !queryInverted);
REPORTER_ASSERT(r, exampleInvHairlineCase.asRRect(&queryRR, &queryDir, &queryStart,
&queryInverted));
REPORTER_ASSERT(r, queryRR == rrect);
REPORTER_ASSERT(r, SkPath::kCW_Direction == queryDir);
REPORTER_ASSERT(r, SkPathDirection::kCW == queryDir);
REPORTER_ASSERT(r, 0 == queryStart);
REPORTER_ASSERT(r, queryInverted);
REPORTER_ASSERT(r, exampleStrokeCase.asRRect(&queryRR, &queryDir, &queryStart, &queryInverted));
REPORTER_ASSERT(r, queryRR == rrect);
REPORTER_ASSERT(r, SkPath::kCW_Direction == queryDir);
REPORTER_ASSERT(r, SkPathDirection::kCW == queryDir);
REPORTER_ASSERT(r, 0 == queryStart);
REPORTER_ASSERT(r, !queryInverted);
REPORTER_ASSERT(r, exampleInvStrokeCase.asRRect(&queryRR, &queryDir, &queryStart,
&queryInverted));
REPORTER_ASSERT(r, queryRR == rrect);
REPORTER_ASSERT(r, SkPath::kCW_Direction == queryDir);
REPORTER_ASSERT(r, SkPathDirection::kCW == queryDir);
REPORTER_ASSERT(r, 0 == queryStart);
REPORTER_ASSERT(r, queryInverted);
@ -1791,7 +1791,7 @@ void test_rrect(skiatest::Reporter* r, const SkRRect& rrect) {
REPORTER_ASSERT(r, exampleInvStrokeAndFillCaseKey == exampleInvHairlineCaseKey);
for (bool inverted : {false, true}) {
for (SkPath::Direction dir : {SkPath::kCW_Direction, SkPath::kCCW_Direction}) {
for (SkPathDirection dir : {SkPathDirection::kCW, SkPathDirection::kCCW}) {
for (unsigned start = 0; start < 8; ++start) {
for (bool dash : {false, true}) {
const GrShape& fillCase = shapes[index(inverted, dir, start, kFill, dash)];
@ -1846,7 +1846,7 @@ void test_rrect(skiatest::Reporter* r, const SkRRect& rrect) {
// The pre-style case for the dash will match the non-dash example iff the
// dir and start match (dir=cw, start=0).
if (0 == expectedStart && SkPath::kCW_Direction == dir) {
if (0 == expectedStart && SkPathDirection::kCW == dir) {
e.compare(r, f, TestCase::kSameUpToPE_ComparisonExpecation);
g.compare(r, h, TestCase::kSameUpToPE_ComparisonExpecation);
} else {

View File

@ -9,9 +9,9 @@
#include "tests/PathOpsThreadedCommon.h"
#include "tests/Test.h"
static SkPath build_squircle(SkPath::Verb verb, const SkRect& rect, SkPath::Direction dir) {
static SkPath build_squircle(SkPath::Verb verb, const SkRect& rect, SkPathDirection dir) {
SkPath path;
bool reverse = SkPath::kCCW_Direction == dir;
bool reverse = SkPathDirection::kCCW == dir;
switch (verb) {
case SkPath::kLine_Verb:
path.addRect(rect, dir);
@ -119,8 +119,8 @@ DEF_TEST(PathOpsAsWinding, reporter) {
const std::initializer_list<SkPoint> revBccw = {{1, 2}, {2, 2}, {2, 1}, {1, 1}};
const std::initializer_list<SkPoint> revBcw = {{2, 1}, {2, 2}, {1, 2}, {1, 1}};
for (bool aFirst : {false, true}) {
for (auto dirA : {SkPath::kCW_Direction, SkPath::kCCW_Direction}) {
for (auto dirB : {SkPath::kCW_Direction, SkPath::kCCW_Direction}) {
for (auto dirA : {SkPathDirection::kCW, SkPathDirection::kCCW}) {
for (auto dirB : {SkPathDirection::kCW, SkPathDirection::kCCW}) {
test.reset();
test.setFillType(SkPath::kEvenOdd_FillType);
if (aFirst) {
@ -140,7 +140,7 @@ DEF_TEST(PathOpsAsWinding, reporter) {
if (dirA != dirB) {
test.addRect(rectB, dirB);
} else {
test.addPoly(SkPath::kCW_Direction == dirA ? revBccw : revBcw, true);
test.addPoly(SkPathDirection::kCW == dirA ? revBccw : revBcw, true);
}
if (!aFirst) {
test.addRect(rectA, dirA);
@ -156,8 +156,8 @@ DEF_TEST(PathOpsAsWinding, reporter) {
// Test curve types with donuts. Create a donut with outer and hole in all directions.
// After converting to winding, all donuts should have a hole in the middle.
for (bool aFirst : {false, true}) {
for (auto dirA : {SkPath::kCW_Direction, SkPath::kCCW_Direction}) {
for (auto dirB : {SkPath::kCW_Direction, SkPath::kCCW_Direction}) {
for (auto dirA : {SkPathDirection::kCW, SkPathDirection::kCCW}) {
for (auto dirB : {SkPathDirection::kCW, SkPathDirection::kCCW}) {
for (auto curveA : { SkPath::kLine_Verb, SkPath::kQuad_Verb,
SkPath::kConic_Verb, SkPath::kCubic_Verb } ) {
SkPath pathA = build_squircle(curveA, rectA, dirA);

View File

@ -26,25 +26,25 @@ DEF_TEST(PathOpsBuilder, reporter) {
SkPath rectPath;
rectPath.setFillType(SkPath::kEvenOdd_FillType);
rectPath.addRect(0, 1, 2, 3, SkPath::kCW_Direction);
rectPath.addRect(0, 1, 2, 3, SkPathDirection::kCW);
builder.add(rectPath, kUnion_SkPathOp);
REPORTER_ASSERT(reporter, builder.resolve(&result));
bool closed;
SkPath::Direction dir;
SkPathDirection dir;
REPORTER_ASSERT(reporter, result.isRect(nullptr, &closed, &dir));
REPORTER_ASSERT(reporter, closed);
REPORTER_ASSERT(reporter, dir == SkPath::kCCW_Direction);
REPORTER_ASSERT(reporter, dir == SkPathDirection::kCCW);
int pixelDiff = comparePaths(reporter, __FUNCTION__, rectPath, result);
REPORTER_ASSERT(reporter, pixelDiff == 0);
rectPath.reset();
rectPath.setFillType(SkPath::kEvenOdd_FillType);
rectPath.addRect(0, 1, 2, 3, SkPath::kCCW_Direction);
rectPath.addRect(0, 1, 2, 3, SkPathDirection::kCCW);
builder.add(rectPath, kUnion_SkPathOp);
REPORTER_ASSERT(reporter, builder.resolve(&result));
REPORTER_ASSERT(reporter, result.isRect(nullptr, &closed, &dir));
REPORTER_ASSERT(reporter, closed);
REPORTER_ASSERT(reporter, dir == SkPath::kCCW_Direction);
REPORTER_ASSERT(reporter, dir == SkPathDirection::kCCW);
REPORTER_ASSERT(reporter, rectPath == result);
builder.add(rectPath, kDifference_SkPathOp);
@ -52,8 +52,8 @@ DEF_TEST(PathOpsBuilder, reporter) {
REPORTER_ASSERT(reporter, result.isEmpty());
SkPath rect2, rect3;
rect2.addRect(2, 1, 4, 3, SkPath::kCW_Direction);
rect3.addRect(4, 1, 5, 3, SkPath::kCCW_Direction);
rect2.addRect(2, 1, 4, 3, SkPathDirection::kCW);
rect3.addRect(4, 1, 5, 3, SkPathDirection::kCCW);
builder.add(rectPath, kUnion_SkPathOp);
builder.add(rect2, kUnion_SkPathOp);
builder.add(rect3, kUnion_SkPathOp);
@ -65,9 +65,9 @@ DEF_TEST(PathOpsBuilder, reporter) {
REPORTER_ASSERT(reporter, result.getBounds() == expected);
SkPath circle1, circle2, circle3;
circle1.addCircle(5, 6, 4, SkPath::kCW_Direction);
circle2.addCircle(7, 4, 8, SkPath::kCCW_Direction);
circle3.addCircle(6, 5, 6, SkPath::kCW_Direction);
circle1.addCircle(5, 6, 4, SkPathDirection::kCW);
circle2.addCircle(7, 4, 8, SkPathDirection::kCCW);
circle3.addCircle(6, 5, 6, SkPathDirection::kCW);
SkPath opCompare;
Op(circle1, circle2, kUnion_SkPathOp, &opCompare);
Op(opCompare, circle3, kDifference_SkPathOp, &opCompare);
@ -139,11 +139,11 @@ DEF_TEST(BuilderIssue3838_3, reporter) {
DEF_TEST(BuilderIssue502792_2, reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
path.addRect(2, 2, 3, 3, SkPath::kCW_Direction);
path.addRect(0, 0, 1, 1, SkPathDirection::kCW);
path.addRect(2, 2, 3, 3, SkPathDirection::kCW);
pathB.setFillType(SkPath::kEvenOdd_FillType);
pathB.addRect(3, 3, 4, 4, SkPath::kCW_Direction);
pathB.addRect(3, 3, 4, 4, SkPath::kCW_Direction);
pathB.addRect(3, 3, 4, 4, SkPathDirection::kCW);
pathB.addRect(3, 3, 4, 4, SkPathDirection::kCW);
SkOpBuilder builder;
builder.add(path, kUnion_SkPathOp);
builder.add(pathB, kDifference_SkPathOp);

View File

@ -7,22 +7,22 @@
#include "tests/PathOpsExtendedTest.h"
DEF_TEST(PathOpsInverse, reporter) {
const SkPathDirection dirs[] = {SkPathDirection::kCW, SkPathDirection::kCCW};
SkPath one, two;
int testCount = 0;
for (int op = kDifference_SkPathOp; op <= kReverseDifference_SkPathOp; ++op) {
for (int oneFill = SkPath::kWinding_FillType; oneFill <= SkPath::kInverseEvenOdd_FillType;
++oneFill) {
for (int oneDir = SkPath::kCW_Direction; oneDir != SkPath::kCCW_Direction; ++oneDir) {
for (auto oneDir : dirs) {
one.reset();
one.setFillType((SkPath::FillType) oneFill);
one.addRect(0, 0, 6, 6, (SkPath::Direction) oneDir);
one.addRect(0, 0, 6, 6, oneDir);
for (int twoFill = SkPath::kWinding_FillType;
twoFill <= SkPath::kInverseEvenOdd_FillType; ++twoFill) {
for (int twoDir = SkPath::kCW_Direction; twoDir != SkPath::kCCW_Direction;
++twoDir) {
for (auto twoDir : dirs) {
two.reset();
two.setFillType((SkPath::FillType) twoFill);
two.addRect(3, 3, 9, 9, (SkPath::Direction) twoDir);
two.addRect(3, 3, 9, 9, twoDir);
SkString testName;
testName.printf("inverseTest%d", ++testCount);
testPathOp(reporter, one, two, (SkPathOp) op, testName.c_str());

View File

@ -27,10 +27,10 @@ static void testOpCirclesMain(PathOpsThreadState* data) {
SkPath pathA, pathB;
pathA.setFillType((SkPath::FillType) e);
pathA.addCircle(SkIntToScalar(state.fA), SkIntToScalar(state.fB), SkIntToScalar(state.fC),
state.fD ? SkPath::kCW_Direction : SkPath::kCCW_Direction);
state.fD ? SkPathDirection::kCW : SkPathDirection::kCCW);
pathB.setFillType((SkPath::FillType) f);
pathB.addCircle(SkIntToScalar(a), SkIntToScalar(b), SkIntToScalar(c),
d ? SkPath::kCW_Direction : SkPath::kCCW_Direction);
d ? SkPathDirection::kCW : SkPathDirection::kCCW);
for (int op = 0 ; op <= kXOR_SkPathOp; ++op) {
if (state.fReporter->verbose()) {
pathStr.printf("static void circlesOp%d(skiatest::Reporter* reporter,"
@ -40,12 +40,12 @@ static void testOpCirclesMain(PathOpsThreadState* data) {
e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType
? "EvenOdd" : "?UNDEFINED");
pathStr.appendf(" path.addCircle(%d, %d, %d, %s);\n", state.fA, state.fB,
state.fC, state.fD ? "SkPath::kCW_Direction" : "SkPath::kCCW_Direction");
state.fC, state.fD ? "SkPathDirection::kCW" : "SkPathDirection::kCCW");
pathStr.appendf(" pathB.setFillType(SkPath::k%s_FillType);\n",
f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType
? "EvenOdd" : "?UNDEFINED");
pathStr.appendf(" pathB.addCircle(%d, %d, %d, %s);\n", a, b,
c, d ? "SkPath::kCW_Direction" : "SkPath::kCCW_Direction");
c, d ? "SkPathDirection::kCW" : "SkPathDirection::kCCW");
pathStr.appendf(" testPathOp(reporter, path, pathB, %s, filename);\n",
SkPathOpsDebug::OpStr((SkPathOp) op));
pathStr.appendf("}\n");

View File

@ -34,15 +34,15 @@ static void testPathOpsRectsMain(PathOpsThreadState* data)
SkPath pathA, pathB;
pathA.setFillType((SkPath::FillType) e);
pathA.addRect(SkIntToScalar(state.fA), SkIntToScalar(state.fA), SkIntToScalar(state.fB),
SkIntToScalar(state.fB), SkPath::kCW_Direction);
SkIntToScalar(state.fB), SkPathDirection::kCW);
pathA.addRect(SkIntToScalar(state.fC), SkIntToScalar(state.fC), SkIntToScalar(state.fD),
SkIntToScalar(state.fD), SkPath::kCW_Direction);
SkIntToScalar(state.fD), SkPathDirection::kCW);
pathA.close();
pathB.setFillType((SkPath::FillType) f);
pathB.addRect(SkIntToScalar(a), SkIntToScalar(a), SkIntToScalar(b),
SkIntToScalar(b), SkPath::kCW_Direction);
SkIntToScalar(b), SkPathDirection::kCW);
pathB.addRect(SkIntToScalar(c), SkIntToScalar(c), SkIntToScalar(d),
SkIntToScalar(d), SkPath::kCW_Direction);
SkIntToScalar(d), SkPathDirection::kCW);
pathB.close();
for (int op = 0 ; op <= kXOR_SkPathOp; ++op) {
if (state.fReporter->verbose()) {
@ -54,16 +54,16 @@ static void testPathOpsRectsMain(PathOpsThreadState* data)
e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType
? "EvenOdd" : "?UNDEFINED");
pathStr.appendf(" path.addRect(%d, %d, %d, %d,"
" SkPath::kCW_Direction);\n", state.fA, state.fA, state.fB, state.fB);
" SkPathDirection::kCW);\n", state.fA, state.fA, state.fB, state.fB);
pathStr.appendf(" path.addRect(%d, %d, %d, %d,"
" SkPath::kCW_Direction);\n", state.fC, state.fC, state.fD, state.fD);
" SkPathDirection::kCW);\n", state.fC, state.fC, state.fD, state.fD);
pathStr.appendf(" pathB.setFillType(SkPath::k%s_FillType);\n",
f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType
? "EvenOdd" : "?UNDEFINED");
pathStr.appendf(" pathB.addRect(%d, %d, %d, %d,"
" SkPath::kCW_Direction);\n", a, a, b, b);
" SkPathDirection::kCW);\n", a, a, b, b);
pathStr.appendf(" pathB.addRect(%d, %d, %d, %d,"
" SkPath::kCW_Direction);\n", c, c, d, d);
" SkPathDirection::kCW);\n", c, c, d, d);
pathStr.appendf(" testPathOp(reporter, path, pathB, %s, filename);\n",
SkPathOpsDebug::OpStr((SkPathOp) op));
pathStr.appendf("}\n\n");
@ -124,13 +124,13 @@ static void testPathOpsFastMain(PathOpsThreadState* data)
pathA.setFillType((SkPath::FillType) e);
if (a) {
pathA.addRect(SkIntToScalar(state.fA), SkIntToScalar(state.fA), SkIntToScalar(state.fB) + c,
SkIntToScalar(state.fB), SkPath::kCW_Direction);
SkIntToScalar(state.fB), SkPathDirection::kCW);
}
pathA.close();
pathB.setFillType((SkPath::FillType) f);
if (b) {
pathB.addRect(SkIntToScalar(state.fC), SkIntToScalar(state.fC), SkIntToScalar(state.fD) + d,
SkIntToScalar(state.fD), SkPath::kCW_Direction);
SkIntToScalar(state.fD), SkPathDirection::kCW);
}
pathB.close();
const char* fillTypeStr[] = { "Winding", "EvenOdd", "InverseWinding", "InverseEvenOdd" };
@ -143,12 +143,12 @@ static void testPathOpsFastMain(PathOpsThreadState* data)
pathStr.appendf(" path.setFillType(SkPath::k%s_FillType);\n", fillTypeStr[e]);
if (a) {
pathStr.appendf(" path.addRect(%d, %d, %d, %d,"
" SkPath::kCW_Direction);\n", state.fA, state.fA, state.fB + c, state.fB);
" SkPathDirection::kCW);\n", state.fA, state.fA, state.fB + c, state.fB);
}
pathStr.appendf(" path.setFillType(SkPath::k%s_FillType);\n", fillTypeStr[f]);
if (b) {
pathStr.appendf(" path.addRect(%d, %d, %d, %d,"
" SkPath::kCW_Direction);\n", state.fC, state.fC, state.fD + d, state.fD);
" SkPathDirection::kCW);\n", state.fC, state.fC, state.fD + d, state.fD);
}
pathStr.appendf(" testPathOp(reporter, path, pathB, %s, filename);\n",
SkPathOpsDebug::OpStr((SkPathOp) op));

View File

@ -378,156 +378,156 @@ static void cubicOp24d(skiatest::Reporter* reporter, const char* filename) {
static void testIntersect1(skiatest::Reporter* reporter, const char* filename) {
SkPath one, two;
one.addRect(0, 0, 6, 6, SkPath::kCW_Direction);
two.addRect(3, 3, 9, 9, SkPath::kCW_Direction);
one.addRect(0, 0, 6, 6, SkPathDirection::kCW);
two.addRect(3, 3, 9, 9, SkPathDirection::kCW);
testPathOp(reporter, one, two, kIntersect_SkPathOp, filename);
}
static void testUnion1(skiatest::Reporter* reporter, const char* filename) {
SkPath one, two;
one.addRect(0, 0, 6, 6, SkPath::kCW_Direction);
two.addRect(3, 3, 9, 9, SkPath::kCW_Direction);
one.addRect(0, 0, 6, 6, SkPathDirection::kCW);
two.addRect(3, 3, 9, 9, SkPathDirection::kCW);
testPathOp(reporter, one, two, kUnion_SkPathOp, filename);
}
static void testDiff1(skiatest::Reporter* reporter, const char* filename) {
SkPath one, two;
one.addRect(0, 0, 6, 6, SkPath::kCW_Direction);
two.addRect(3, 3, 9, 9, SkPath::kCW_Direction);
one.addRect(0, 0, 6, 6, SkPathDirection::kCW);
two.addRect(3, 3, 9, 9, SkPathDirection::kCW);
testPathOp(reporter, one, two, kDifference_SkPathOp, filename);
}
static void testXor1(skiatest::Reporter* reporter, const char* filename) {
SkPath one, two;
one.addRect(0, 0, 6, 6, SkPath::kCW_Direction);
two.addRect(3, 3, 9, 9, SkPath::kCW_Direction);
one.addRect(0, 0, 6, 6, SkPathDirection::kCW);
two.addRect(3, 3, 9, 9, SkPathDirection::kCW);
testPathOp(reporter, one, two, kXOR_SkPathOp, filename);
}
static void testIntersect2(skiatest::Reporter* reporter, const char* filename) {
SkPath one, two;
one.addRect(0, 0, 6, 6, SkPath::kCW_Direction);
two.addRect(0, 3, 9, 9, SkPath::kCW_Direction);
one.addRect(0, 0, 6, 6, SkPathDirection::kCW);
two.addRect(0, 3, 9, 9, SkPathDirection::kCW);
testPathOp(reporter, one, two, kIntersect_SkPathOp, filename);
}
static void testUnion2(skiatest::Reporter* reporter, const char* filename) {
SkPath one, two;
one.addRect(0, 0, 6, 6, SkPath::kCW_Direction);
two.addRect(0, 3, 9, 9, SkPath::kCW_Direction);
one.addRect(0, 0, 6, 6, SkPathDirection::kCW);
two.addRect(0, 3, 9, 9, SkPathDirection::kCW);
testPathOp(reporter, one, two, kUnion_SkPathOp, filename);
}
static void testDiff2(skiatest::Reporter* reporter, const char* filename) {
SkPath one, two;
one.addRect(0, 0, 6, 6, SkPath::kCW_Direction);
two.addRect(0, 3, 9, 9, SkPath::kCW_Direction);
one.addRect(0, 0, 6, 6, SkPathDirection::kCW);
two.addRect(0, 3, 9, 9, SkPathDirection::kCW);
testPathOp(reporter, one, two, kDifference_SkPathOp, filename);
}
static void testXor2(skiatest::Reporter* reporter, const char* filename) {
SkPath one, two;
one.addRect(0, 0, 6, 6, SkPath::kCW_Direction);
two.addRect(0, 3, 9, 9, SkPath::kCW_Direction);
one.addRect(0, 0, 6, 6, SkPathDirection::kCW);
two.addRect(0, 3, 9, 9, SkPathDirection::kCW);
testPathOp(reporter, one, two, kXOR_SkPathOp, filename);
}
static void testOp1d(skiatest::Reporter* reporter, const char* filename) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
path.addRect(0, 0, 2, 2, SkPath::kCW_Direction);
path.addRect(0, 0, 1, 1, SkPathDirection::kCW);
path.addRect(0, 0, 2, 2, SkPathDirection::kCW);
pathB.setFillType(SkPath::kWinding_FillType);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
pathB.addRect(0, 0, 1, 1, SkPathDirection::kCW);
pathB.addRect(0, 0, 1, 1, SkPathDirection::kCW);
testPathOp(reporter, path, pathB, kDifference_SkPathOp, filename);
}
static void testOp2d(skiatest::Reporter* reporter, const char* filename) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
path.addRect(0, 0, 2, 2, SkPath::kCW_Direction);
path.addRect(0, 0, 1, 1, SkPathDirection::kCW);
path.addRect(0, 0, 2, 2, SkPathDirection::kCW);
pathB.setFillType(SkPath::kEvenOdd_FillType);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
pathB.addRect(0, 0, 1, 1, SkPathDirection::kCW);
pathB.addRect(0, 0, 1, 1, SkPathDirection::kCW);
testPathOp(reporter, path, pathB, kDifference_SkPathOp, filename);
}
static void testOp3d(skiatest::Reporter* reporter, const char* filename) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
path.addRect(1, 1, 2, 2, SkPath::kCW_Direction);
path.addRect(0, 0, 1, 1, SkPathDirection::kCW);
path.addRect(1, 1, 2, 2, SkPathDirection::kCW);
pathB.setFillType(SkPath::kWinding_FillType);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
pathB.addRect(0, 0, 1, 1, SkPathDirection::kCW);
pathB.addRect(0, 0, 1, 1, SkPathDirection::kCW);
testPathOp(reporter, path, pathB, kDifference_SkPathOp, filename);
}
static void testOp1u(skiatest::Reporter* reporter, const char* filename) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
path.addRect(0, 0, 3, 3, SkPath::kCW_Direction);
path.addRect(0, 0, 1, 1, SkPathDirection::kCW);
path.addRect(0, 0, 3, 3, SkPathDirection::kCW);
pathB.setFillType(SkPath::kWinding_FillType);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
pathB.addRect(0, 0, 1, 1, SkPathDirection::kCW);
pathB.addRect(0, 0, 1, 1, SkPathDirection::kCW);
testPathOp(reporter, path, pathB, kUnion_SkPathOp, filename);
}
static void testOp4d(skiatest::Reporter* reporter, const char* filename) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
path.addRect(2, 2, 4, 4, SkPath::kCW_Direction);
path.addRect(0, 0, 1, 1, SkPathDirection::kCW);
path.addRect(2, 2, 4, 4, SkPathDirection::kCW);
pathB.setFillType(SkPath::kWinding_FillType);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
pathB.addRect(0, 0, 1, 1, SkPathDirection::kCW);
pathB.addRect(0, 0, 1, 1, SkPathDirection::kCW);
testPathOp(reporter, path, pathB, kDifference_SkPathOp, filename);
}
static void testOp5d(skiatest::Reporter* reporter, const char* filename) {
SkPath path, pathB;
path.setFillType(SkPath::kEvenOdd_FillType);
path.addRect(0, 0, 2, 2, SkPath::kCW_Direction);
path.addRect(0, 0, 3, 3, SkPath::kCW_Direction);
path.addRect(0, 0, 2, 2, SkPathDirection::kCW);
path.addRect(0, 0, 3, 3, SkPathDirection::kCW);
pathB.setFillType(SkPath::kEvenOdd_FillType);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
pathB.addRect(0, 0, 1, 1, SkPathDirection::kCW);
pathB.addRect(0, 0, 1, 1, SkPathDirection::kCW);
testPathOp(reporter, path, pathB, kDifference_SkPathOp, filename);
}
static void testOp6d(skiatest::Reporter* reporter, const char* filename) {
SkPath path, pathB;
path.setFillType(SkPath::kEvenOdd_FillType);
path.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
path.addRect(0, 0, 3, 3, SkPath::kCW_Direction);
path.addRect(0, 0, 1, 1, SkPathDirection::kCW);
path.addRect(0, 0, 3, 3, SkPathDirection::kCW);
pathB.setFillType(SkPath::kWinding_FillType);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
pathB.addRect(0, 0, 1, 1, SkPathDirection::kCW);
pathB.addRect(0, 0, 1, 1, SkPathDirection::kCW);
testPathOp(reporter, path, pathB, kDifference_SkPathOp, filename);
}
static void testOp7d(skiatest::Reporter* reporter, const char* filename) {
SkPath path, pathB;
path.setFillType(SkPath::kEvenOdd_FillType);
path.addRect(0, 0, 2, 2, SkPath::kCW_Direction);
path.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
path.addRect(0, 0, 2, 2, SkPathDirection::kCW);
path.addRect(0, 0, 1, 1, SkPathDirection::kCW);
pathB.setFillType(SkPath::kEvenOdd_FillType);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
pathB.addRect(0, 0, 1, 1, SkPathDirection::kCW);
pathB.addRect(0, 0, 1, 1, SkPathDirection::kCW);
testPathOp(reporter, path, pathB, kDifference_SkPathOp, filename);
}
static void testOp2u(skiatest::Reporter* reporter, const char* filename) {
SkPath path, pathB;
path.setFillType(SkPath::kEvenOdd_FillType);
path.addRect(0, 0, 2, 2, SkPath::kCW_Direction);
path.addRect(0, 0, 2, 2, SkPath::kCW_Direction);
path.addRect(0, 0, 2, 2, SkPathDirection::kCW);
path.addRect(0, 0, 2, 2, SkPathDirection::kCW);
pathB.setFillType(SkPath::kWinding_FillType);
pathB.addRect(0, 0, 3, 3, SkPath::kCW_Direction);
pathB.addRect(1, 1, 2, 2, SkPath::kCW_Direction);
pathB.addRect(0, 0, 3, 3, SkPathDirection::kCW);
pathB.addRect(1, 1, 2, 2, SkPathDirection::kCW);
testPathOp(reporter, path, pathB, kUnion_SkPathOp, filename);
}
@ -2025,22 +2025,22 @@ static void issue1418b(skiatest::Reporter* reporter, const char* filename) {
static void rectOp1i(skiatest::Reporter* reporter, const char* filename) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
path.addRect(2, 2, 4, 4, SkPath::kCW_Direction);
path.addRect(0, 0, 1, 1, SkPathDirection::kCW);
path.addRect(2, 2, 4, 4, SkPathDirection::kCW);
pathB.setFillType(SkPath::kWinding_FillType);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
pathB.addRect(0, 0, 2, 2, SkPath::kCW_Direction);
pathB.addRect(0, 0, 1, 1, SkPathDirection::kCW);
pathB.addRect(0, 0, 2, 2, SkPathDirection::kCW);
testPathOp(reporter, path, pathB, kIntersect_SkPathOp, filename);
}
static void rectOp2i(skiatest::Reporter* reporter, const char* filename) {
SkPath path, pathB;
path.setFillType(SkPath::kEvenOdd_FillType);
path.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
path.addRect(0, 0, 3, 3, SkPath::kCW_Direction);
path.addRect(0, 0, 1, 1, SkPathDirection::kCW);
path.addRect(0, 0, 3, 3, SkPathDirection::kCW);
pathB.setFillType(SkPath::kWinding_FillType);
pathB.addRect(0, 0, 2, 2, SkPath::kCW_Direction);
pathB.addRect(0, 0, 2, 2, SkPath::kCW_Direction);
pathB.addRect(0, 0, 2, 2, SkPathDirection::kCW);
pathB.addRect(0, 0, 2, 2, SkPathDirection::kCW);
testPathOp(reporter, path, pathB, kIntersect_SkPathOp, filename);
}
@ -3173,11 +3173,11 @@ static void cubicOp109(skiatest::Reporter* reporter, const char* filename) {
static void cubicOp110(skiatest::Reporter* reporter, const char* filename) {
SkPath path, pathB;
path.setFillType(SkPath::kEvenOdd_FillType);
path.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
path.addRect(0, 0, 4, 4, SkPath::kCW_Direction);
path.addRect(0, 0, 1, 1, SkPathDirection::kCW);
path.addRect(0, 0, 4, 4, SkPathDirection::kCW);
pathB.setFillType(SkPath::kEvenOdd_FillType);
pathB.addRect(0, 0, 2, 2, SkPath::kCW_Direction);
pathB.addRect(0, 0, 2, 2, SkPath::kCW_Direction);
pathB.addRect(0, 0, 2, 2, SkPathDirection::kCW);
pathB.addRect(0, 0, 2, 2, SkPathDirection::kCW);
testPathOp(reporter, path, pathB, kIntersect_SkPathOp, filename);
}
@ -3439,22 +3439,22 @@ static void rects2(skiatest::Reporter* reporter, const char* filename) {
static void rects3(skiatest::Reporter* reporter, const char* filename) {
SkPath path, pathB;
path.setFillType(SkPath::kEvenOdd_FillType);
path.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
path.addRect(0, 0, 4, 4, SkPath::kCW_Direction);
path.addRect(0, 0, 1, 1, SkPathDirection::kCW);
path.addRect(0, 0, 4, 4, SkPathDirection::kCW);
pathB.setFillType(SkPath::kWinding_FillType);
pathB.addRect(0, 0, 2, 2, SkPath::kCW_Direction);
pathB.addRect(0, 0, 2, 2, SkPath::kCW_Direction);
pathB.addRect(0, 0, 2, 2, SkPathDirection::kCW);
pathB.addRect(0, 0, 2, 2, SkPathDirection::kCW);
testPathOp(reporter, path, pathB, kDifference_SkPathOp, filename);
}
static void rects4(skiatest::Reporter* reporter, const char* filename) {
SkPath path, pathB;
path.setFillType(SkPath::kEvenOdd_FillType);
path.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
path.addRect(0, 0, 2, 2, SkPath::kCW_Direction);
path.addRect(0, 0, 1, 1, SkPathDirection::kCW);
path.addRect(0, 0, 2, 2, SkPathDirection::kCW);
pathB.setFillType(SkPath::kWinding_FillType);
pathB.addRect(0, 0, 2, 2, SkPath::kCW_Direction);
pathB.addRect(0, 0, 3, 3, SkPath::kCW_Direction);
pathB.addRect(0, 0, 2, 2, SkPathDirection::kCW);
pathB.addRect(0, 0, 3, 3, SkPathDirection::kCW);
testPathOp(reporter, path, pathB, kDifference_SkPathOp, filename);
}
@ -3522,21 +3522,21 @@ static void cubicOp115(skiatest::Reporter* reporter, const char* filename) {
static void testRect1(skiatest::Reporter* reporter, const char* filename) {
SkPath path, path2;
path.addRect(0, 0, 60, 60, SkPath::kCCW_Direction);
path.addRect(30, 20, 50, 50, SkPath::kCCW_Direction);
path.addRect(24, 20, 36, 30, SkPath::kCCW_Direction);
// path.addRect(32, 24, 36, 41, SkPath::kCCW_Direction);
path.addRect(0, 0, 60, 60, SkPathDirection::kCCW);
path.addRect(30, 20, 50, 50, SkPathDirection::kCCW);
path.addRect(24, 20, 36, 30, SkPathDirection::kCCW);
// path.addRect(32, 24, 36, 41, SkPathDirection::kCCW);
testPathOp(reporter, path, path2, kUnion_SkPathOp, filename);
}
static void testRect2(skiatest::Reporter* reporter, const char* filename) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
path.addRect(4, 4, 5, 5, SkPath::kCW_Direction);
path.addRect(0, 0, 1, 1, SkPathDirection::kCW);
path.addRect(4, 4, 5, 5, SkPathDirection::kCW);
pathB.setFillType(SkPath::kEvenOdd_FillType);
pathB.addRect(0, 0, 2, 2, SkPath::kCW_Direction);
pathB.addRect(0, 0, 6, 6, SkPath::kCW_Direction);
pathB.addRect(0, 0, 2, 2, SkPathDirection::kCW);
pathB.addRect(0, 0, 6, 6, SkPathDirection::kCW);
testPathOp(reporter, path, pathB, kDifference_SkPathOp, filename);
}
@ -3898,18 +3898,18 @@ static void cubicOp131(skiatest::Reporter* reporter, const char* filename) {
static void circlesOp1(skiatest::Reporter* reporter, const char* filename) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.addCircle(0, 1, 2, SkPath::kCCW_Direction);
path.addCircle(0, 1, 2, SkPathDirection::kCCW);
pathB.setFillType(SkPath::kWinding_FillType);
pathB.addCircle(0, 1, 1, SkPath::kCW_Direction);
pathB.addCircle(0, 1, 1, SkPathDirection::kCW);
testPathOp(reporter, path, pathB, kDifference_SkPathOp, filename);
}
static void circlesOp2(skiatest::Reporter* reporter, const char* filename) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.addCircle(0, 1, 4, SkPath::kCCW_Direction);
path.addCircle(0, 1, 4, SkPathDirection::kCCW);
pathB.setFillType(SkPath::kWinding_FillType);
pathB.addCircle(0, 4, 3, SkPath::kCW_Direction);
pathB.addCircle(0, 4, 3, SkPathDirection::kCW);
testPathOp(reporter, path, pathB, kIntersect_SkPathOp, filename);
}
@ -3971,11 +3971,11 @@ static void loop7(skiatest::Reporter* reporter, const char* filename) {
static void rects5(skiatest::Reporter* reporter, const char* filename) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.addRect(5, 5, 6, 6, SkPath::kCW_Direction);
path.addRect(5, 5, 6, 6, SkPath::kCW_Direction);
path.addRect(5, 5, 6, 6, SkPathDirection::kCW);
path.addRect(5, 5, 6, 6, SkPathDirection::kCW);
pathB.setFillType(SkPath::kEvenOdd_FillType);
pathB.addRect(0, 0, 6, 6, SkPath::kCW_Direction);
pathB.addRect(5, 5, 6, 6, SkPath::kCW_Direction);
pathB.addRect(0, 0, 6, 6, SkPathDirection::kCW);
pathB.addRect(5, 5, 6, 6, SkPathDirection::kCW);
testPathOp(reporter, path, pathB, kDifference_SkPathOp, filename);
}
@ -4004,9 +4004,9 @@ static void loop9(skiatest::Reporter* reporter, const char* filename) {
static void circlesOp3(skiatest::Reporter* reporter, const char* filename) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.addCircle(0, 1, 2, SkPath::kCCW_Direction);
path.addCircle(0, 1, 2, SkPathDirection::kCCW);
pathB.setFillType(SkPath::kWinding_FillType);
pathB.addCircle(3, 5, 3, SkPath::kCW_Direction);
pathB.addCircle(3, 5, 3, SkPathDirection::kCW);
testPathOp(reporter, path, pathB, kDifference_SkPathOp, filename);
}
@ -5399,9 +5399,9 @@ static void loop17(skiatest::Reporter* reporter, const char* filename) {
static void circlesOp4(skiatest::Reporter* reporter, const char* filename) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.addCircle(0, 1, 5, SkPath::kCW_Direction);
path.addCircle(0, 1, 5, SkPathDirection::kCW);
pathB.setFillType(SkPath::kWinding_FillType);
pathB.addCircle(0, 1, 0, SkPath::kCW_Direction);
pathB.addCircle(0, 1, 0, SkPathDirection::kCW);
testPathOp(reporter, path, pathB, kDifference_SkPathOp, filename);
}

View File

@ -22,13 +22,13 @@ static void testSimplify4x4RectsMain(PathOpsThreadState* data)
SkASSERT(data);
PathOpsThreadState& state = *data;
int aShape = state.fA & 0x03;
SkPath::Direction aCW = state.fA >> 2 ? SkPath::kCCW_Direction : SkPath::kCW_Direction;
SkPathDirection aCW = state.fA >> 2 ? SkPathDirection::kCCW : SkPathDirection::kCW;
int bShape = state.fB & 0x03;
SkPath::Direction bCW = state.fB >> 2 ? SkPath::kCCW_Direction : SkPath::kCW_Direction;
SkPathDirection bCW = state.fB >> 2 ? SkPathDirection::kCCW : SkPathDirection::kCW;
int cShape = state.fC & 0x03;
SkPath::Direction cCW = state.fC >> 2 ? SkPath::kCCW_Direction : SkPath::kCW_Direction;
SkPathDirection cCW = state.fC >> 2 ? SkPathDirection::kCCW : SkPathDirection::kCW;
int dShape = state.fD & 0x03;
SkPath::Direction dCW = state.fD >> 2 ? SkPath::kCCW_Direction : SkPath::kCW_Direction;
SkPathDirection dCW = state.fD >> 2 ? SkPathDirection::kCCW : SkPathDirection::kCW;
for (int aXAlign = 0; aXAlign < 5; ++aXAlign) {
for (int aYAlign = 0; aYAlign < 5; ++aYAlign) {
for (int bXAlign = 0; bXAlign < 5; ++bXAlign) {
@ -67,7 +67,8 @@ static void testSimplify4x4RectsMain(PathOpsThreadState* data)
aCW);
if (state.fReporter->verbose()) {
pathStr.appendf(" path.addRect(%d, %d, %d, %d,"
" SkPath::kC%sW_Direction);\n", l, t, r, b, aCW ? "C" : "");
" SkPathDirection::kC%sW);\n", l, t, r, b,
aCW == SkPathDirection::kCCW ? "C" : "");
}
} else {
aXAlign = 5;
@ -98,7 +99,8 @@ static void testSimplify4x4RectsMain(PathOpsThreadState* data)
bCW);
if (state.fReporter->verbose()) {
pathStr.appendf(" path.addRect(%d, %d, %d, %d,"
" SkPath::kC%sW_Direction);\n", l, t, r, b, bCW ? "C" : "");
" SkPathDirection::kC%sW);\n", l, t, r, b,
bCW == SkPathDirection::kCCW ? "C" : "");
}
} else {
bXAlign = 5;
@ -129,7 +131,8 @@ static void testSimplify4x4RectsMain(PathOpsThreadState* data)
cCW);
if (state.fReporter->verbose()) {
pathStr.appendf(" path.addRect(%d, %d, %d, %d,"
" SkPath::kC%sW_Direction);\n", l, t, r, b, cCW ? "C" : "");
" SkPathDirection::kC%sW);\n", l, t, r, b,
cCW == SkPathDirection::kCCW ? "C" : "");
}
} else {
cXAlign = 5;
@ -160,7 +163,8 @@ static void testSimplify4x4RectsMain(PathOpsThreadState* data)
dCW);
if (state.fReporter->verbose()) {
pathStr.appendf(" path.addRect(%d, %d, %d, %d,"
" SkPath::kC%sW_Direction);\n", l, t, r, b, dCW ? "C" : "");
" SkPathDirection::kC%sW);\n", l, t, r, b,
dCW == SkPathDirection::kCCW ? "C" : "");
}
} else {
dXAlign = 5;

File diff suppressed because it is too large Load Diff

View File

@ -1129,13 +1129,13 @@ static void test_direction(skiatest::Reporter* reporter) {
// Test two donuts, each wound a different direction. Only the outer contour
// determines the cheap direction
path.reset();
path.addCircle(0, 0, SkIntToScalar(2), SkPath::kCW_Direction);
path.addCircle(0, 0, SkIntToScalar(1), SkPath::kCCW_Direction);
path.addCircle(0, 0, SkIntToScalar(2), SkPathDirection::kCW);
path.addCircle(0, 0, SkIntToScalar(1), SkPathDirection::kCCW);
check_direction(reporter, path, SkPathPriv::kCW_FirstDirection);
path.reset();
path.addCircle(0, 0, SkIntToScalar(1), SkPath::kCW_Direction);
path.addCircle(0, 0, SkIntToScalar(2), SkPath::kCCW_Direction);
path.addCircle(0, 0, SkIntToScalar(1), SkPathDirection::kCW);
path.addCircle(0, 0, SkIntToScalar(2), SkPathDirection::kCCW);
check_direction(reporter, path, SkPathPriv::kCCW_FirstDirection);
// triangle with one point really far from the origin.
@ -1155,7 +1155,7 @@ static void test_direction(skiatest::Reporter* reporter) {
path.lineTo(1, 1e7f);
path.lineTo(1e7f, 2e7f);
path.close();
REPORTER_ASSERT(reporter, SkPath::kConvex_Convexity == path.getConvexity());
REPORTER_ASSERT(reporter, path.isConvex());
check_direction(reporter, path, SkPathPriv::kCCW_FirstDirection);
}
@ -1317,9 +1317,9 @@ static void test_close(skiatest::Reporter* reporter) {
}
static void check_convexity(skiatest::Reporter* reporter, const SkPath& path,
SkPath::Convexity expected) {
SkPathConvexityType expected) {
SkPath copy(path); // we make a copy so that we don't cache the result on the passed in path.
SkPath::Convexity c = copy.getConvexity();
SkPathConvexityType c = copy.getConvexityType();
REPORTER_ASSERT(reporter, c == expected);
#ifndef SK_LEGACY_PATH_CONVEXITY
// test points-by-array interface
@ -1335,7 +1335,7 @@ static void check_convexity(skiatest::Reporter* reporter, const SkPath& path,
(void) path.getPoints(&points.front(), points.size());
int skip = initialMoves - 1;
bool isConvex = SkPathPriv::IsConvex(&points.front() + skip, points.size() - skip);
REPORTER_ASSERT(reporter, isConvex == (SkPath::kConvex_Convexity == expected));
REPORTER_ASSERT(reporter, isConvex == (SkPathConvexityType::kConvex == expected));
}
#endif
}
@ -1347,10 +1347,10 @@ static void test_path_crbug389050(skiatest::Reporter* reporter) {
tinyConvexPolygon.lineTo(600.148962f, 800.142338f);
tinyConvexPolygon.lineTo(600.134891f, 800.137724f);
tinyConvexPolygon.close();
tinyConvexPolygon.getConvexity();
tinyConvexPolygon.getConvexityType();
// This is convex, but so small that it fails many of our checks, and the three "backwards"
// bends convince the checker that it's concave. That's okay though, we draw it correctly.
check_convexity(reporter, tinyConvexPolygon, SkPath::kConcave_Convexity);
check_convexity(reporter, tinyConvexPolygon, SkPathConvexityType::kConcave);
check_direction(reporter, tinyConvexPolygon, SkPathPriv::kCW_FirstDirection);
SkPath platTriangle;
@ -1358,7 +1358,7 @@ static void test_path_crbug389050(skiatest::Reporter* reporter) {
platTriangle.lineTo(200, 0);
platTriangle.lineTo(100, 0.04f);
platTriangle.close();
platTriangle.getConvexity();
platTriangle.getConvexityType();
check_direction(reporter, platTriangle, SkPathPriv::kCW_FirstDirection);
platTriangle.reset();
@ -1366,7 +1366,7 @@ static void test_path_crbug389050(skiatest::Reporter* reporter) {
platTriangle.lineTo(200, 0);
platTriangle.lineTo(100, 0.03f);
platTriangle.close();
platTriangle.getConvexity();
platTriangle.getConvexityType();
check_direction(reporter, platTriangle, SkPathPriv::kCW_FirstDirection);
}
@ -1374,14 +1374,14 @@ static void test_convexity2(skiatest::Reporter* reporter) {
SkPath pt;
pt.moveTo(0, 0);
pt.close();
check_convexity(reporter, pt, SkPath::kConvex_Convexity);
check_convexity(reporter, pt, SkPathConvexityType::kConvex);
check_direction(reporter, pt, SkPathPriv::kUnknown_FirstDirection);
SkPath line;
line.moveTo(12*SK_Scalar1, 20*SK_Scalar1);
line.lineTo(-12*SK_Scalar1, -20*SK_Scalar1);
line.close();
check_convexity(reporter, line, SkPath::kConvex_Convexity);
check_convexity(reporter, line, SkPathConvexityType::kConvex);
check_direction(reporter, line, SkPathPriv::kUnknown_FirstDirection);
SkPath triLeft;
@ -1389,7 +1389,7 @@ static void test_convexity2(skiatest::Reporter* reporter) {
triLeft.lineTo(SK_Scalar1, 0);
triLeft.lineTo(SK_Scalar1, SK_Scalar1);
triLeft.close();
check_convexity(reporter, triLeft, SkPath::kConvex_Convexity);
check_convexity(reporter, triLeft, SkPathConvexityType::kConvex);
check_direction(reporter, triLeft, SkPathPriv::kCW_FirstDirection);
SkPath triRight;
@ -1397,7 +1397,7 @@ static void test_convexity2(skiatest::Reporter* reporter) {
triRight.lineTo(-SK_Scalar1, 0);
triRight.lineTo(SK_Scalar1, SK_Scalar1);
triRight.close();
check_convexity(reporter, triRight, SkPath::kConvex_Convexity);
check_convexity(reporter, triRight, SkPathConvexityType::kConvex);
check_direction(reporter, triRight, SkPathPriv::kCCW_FirstDirection);
SkPath square;
@ -1406,7 +1406,7 @@ static void test_convexity2(skiatest::Reporter* reporter) {
square.lineTo(SK_Scalar1, SK_Scalar1);
square.lineTo(0, SK_Scalar1);
square.close();
check_convexity(reporter, square, SkPath::kConvex_Convexity);
check_convexity(reporter, square, SkPathConvexityType::kConvex);
check_direction(reporter, square, SkPathPriv::kCW_FirstDirection);
SkPath redundantSquare;
@ -1423,7 +1423,7 @@ static void test_convexity2(skiatest::Reporter* reporter) {
redundantSquare.lineTo(0, SK_Scalar1);
redundantSquare.lineTo(0, SK_Scalar1);
redundantSquare.close();
check_convexity(reporter, redundantSquare, SkPath::kConvex_Convexity);
check_convexity(reporter, redundantSquare, SkPathConvexityType::kConvex);
check_direction(reporter, redundantSquare, SkPathPriv::kCW_FirstDirection);
SkPath bowTie;
@ -1440,7 +1440,7 @@ static void test_convexity2(skiatest::Reporter* reporter) {
bowTie.lineTo(0, SK_Scalar1);
bowTie.lineTo(0, SK_Scalar1);
bowTie.close();
check_convexity(reporter, bowTie, SkPath::kConcave_Convexity);
check_convexity(reporter, bowTie, SkPathConvexityType::kConcave);
check_direction(reporter, bowTie, kDontCheckDir);
SkPath spiral;
@ -1452,7 +1452,7 @@ static void test_convexity2(skiatest::Reporter* reporter) {
spiral.lineTo(50*SK_Scalar1, 50*SK_Scalar1);
spiral.lineTo(50*SK_Scalar1, 75*SK_Scalar1);
spiral.close();
check_convexity(reporter, spiral, SkPath::kConcave_Convexity);
check_convexity(reporter, spiral, SkPathConvexityType::kConcave);
check_direction(reporter, spiral, kDontCheckDir);
SkPath dent;
@ -1462,7 +1462,7 @@ static void test_convexity2(skiatest::Reporter* reporter) {
dent.lineTo(-50*SK_Scalar1, 200*SK_Scalar1);
dent.lineTo(-200*SK_Scalar1, 100*SK_Scalar1);
dent.close();
check_convexity(reporter, dent, SkPath::kConcave_Convexity);
check_convexity(reporter, dent, SkPathConvexityType::kConcave);
check_direction(reporter, dent, SkPathPriv::kCW_FirstDirection);
// https://bug.skia.org/2235
@ -1479,7 +1479,7 @@ static void test_convexity2(skiatest::Reporter* reporter) {
SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle);
stroke.setStrokeStyle(2 * SK_Scalar1);
stroke.applyToPath(&strokedSin, strokedSin);
check_convexity(reporter, strokedSin, SkPath::kConcave_Convexity);
check_convexity(reporter, strokedSin, SkPathConvexityType::kConcave);
check_direction(reporter, strokedSin, kDontCheckDir);
// http://crbug.com/412640
@ -1490,7 +1490,7 @@ static void test_convexity2(skiatest::Reporter* reporter) {
degenerateConcave.lineTo(41.446522f, 376.25f);
degenerateConcave.lineTo(-55.971577f, 460.0f);
degenerateConcave.lineTo(41.446522f, 376.25f);
check_convexity(reporter, degenerateConcave, SkPath::kConcave_Convexity);
check_convexity(reporter, degenerateConcave, SkPathConvexityType::kConcave);
check_direction(reporter, degenerateConcave, SkPathPriv::kUnknown_FirstDirection);
// http://crbug.com/433683
@ -1505,7 +1505,7 @@ static void test_convexity2(skiatest::Reporter* reporter) {
badFirstVector.lineTo(504.912292f, 316.389648f);
badFirstVector.lineTo(501.087708f, 319.610352f);
badFirstVector.close();
check_convexity(reporter, badFirstVector, SkPath::kConcave_Convexity);
check_convexity(reporter, badFirstVector, SkPathConvexityType::kConcave);
// http://crbug.com/993330
SkPath falseBackEdge;
@ -1520,30 +1520,30 @@ static void test_convexity2(skiatest::Reporter* reporter) {
-151.46727226799754f, -419.98027663161537f,
-217.83430557928145f, -382.14948768484857f);
falseBackEdge.close();
check_convexity(reporter, falseBackEdge, SkPath::kConcave_Convexity);
check_convexity(reporter, falseBackEdge, SkPathConvexityType::kConcave);
}
static void test_convexity_doubleback(skiatest::Reporter* reporter) {
SkPath doubleback;
doubleback.lineTo(1, 1);
check_convexity(reporter, doubleback, SkPath::kConvex_Convexity);
check_convexity(reporter, doubleback, SkPathConvexityType::kConvex);
doubleback.lineTo(2, 2);
check_convexity(reporter, doubleback, SkPath::kConvex_Convexity);
check_convexity(reporter, doubleback, SkPathConvexityType::kConvex);
doubleback.reset();
doubleback.lineTo(1, 0);
check_convexity(reporter, doubleback, SkPath::kConvex_Convexity);
check_convexity(reporter, doubleback, SkPathConvexityType::kConvex);
doubleback.lineTo(2, 0);
check_convexity(reporter, doubleback, SkPath::kConvex_Convexity);
check_convexity(reporter, doubleback, SkPathConvexityType::kConvex);
doubleback.lineTo(1, 0);
check_convexity(reporter, doubleback, SkPath::kConvex_Convexity);
check_convexity(reporter, doubleback, SkPathConvexityType::kConvex);
doubleback.reset();
doubleback.quadTo(1, 1, 2, 2);
check_convexity(reporter, doubleback, SkPath::kConvex_Convexity);
check_convexity(reporter, doubleback, SkPathConvexityType::kConvex);
doubleback.reset();
doubleback.quadTo(1, 0, 2, 0);
check_convexity(reporter, doubleback, SkPath::kConvex_Convexity);
check_convexity(reporter, doubleback, SkPathConvexityType::kConvex);
doubleback.quadTo(1, 0, 0, 0);
check_convexity(reporter, doubleback, SkPath::kConvex_Convexity);
check_convexity(reporter, doubleback, SkPathConvexityType::kConvex);
}
static void check_convex_bounds(skiatest::Reporter* reporter, const SkPath& p,
@ -1583,39 +1583,39 @@ static void setFromString(SkPath* path, const char str[]) {
static void test_convexity(skiatest::Reporter* reporter) {
SkPath path;
check_convexity(reporter, path, SkPath::kConvex_Convexity);
check_convexity(reporter, path, SkPathConvexityType::kConvex);
path.addCircle(0, 0, SkIntToScalar(10));
check_convexity(reporter, path, SkPath::kConvex_Convexity);
check_convexity(reporter, path, SkPathConvexityType::kConvex);
path.addCircle(0, 0, SkIntToScalar(10)); // 2nd circle
check_convexity(reporter, path, SkPath::kConcave_Convexity);
check_convexity(reporter, path, SkPathConvexityType::kConcave);
path.reset();
path.addRect(0, 0, SkIntToScalar(10), SkIntToScalar(10), SkPath::kCCW_Direction);
check_convexity(reporter, path, SkPath::kConvex_Convexity);
path.addRect(0, 0, SkIntToScalar(10), SkIntToScalar(10), SkPathDirection::kCCW);
check_convexity(reporter, path, SkPathConvexityType::kConvex);
REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(path, SkPathPriv::kCCW_FirstDirection));
path.reset();
path.addRect(0, 0, SkIntToScalar(10), SkIntToScalar(10), SkPath::kCW_Direction);
check_convexity(reporter, path, SkPath::kConvex_Convexity);
path.addRect(0, 0, SkIntToScalar(10), SkIntToScalar(10), SkPathDirection::kCW);
check_convexity(reporter, path, SkPathConvexityType::kConvex);
REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(path, SkPathPriv::kCW_FirstDirection));
path.reset();
path.quadTo(100, 100, 50, 50); // This from GM:convexpaths
check_convexity(reporter, path, SkPath::kConvex_Convexity);
check_convexity(reporter, path, SkPathConvexityType::kConvex);
static const struct {
const char* fPathStr;
SkPath::Convexity fExpectedConvexity;
SkPathConvexityType fExpectedConvexity;
SkPathPriv::FirstDirection fExpectedDirection;
} gRec[] = {
{ "", SkPath::kConvex_Convexity, SkPathPriv::kUnknown_FirstDirection },
{ "0 0", SkPath::kConvex_Convexity, SkPathPriv::kUnknown_FirstDirection },
{ "0 0 10 10", SkPath::kConvex_Convexity, SkPathPriv::kUnknown_FirstDirection },
{ "0 0 10 10 20 20 0 0 10 10", SkPath::kConcave_Convexity, SkPathPriv::kUnknown_FirstDirection },
{ "0 0 10 10 10 20", SkPath::kConvex_Convexity, SkPathPriv::kCW_FirstDirection },
{ "0 0 10 10 10 0", SkPath::kConvex_Convexity, SkPathPriv::kCCW_FirstDirection },
{ "0 0 10 10 10 0 0 10", SkPath::kConcave_Convexity, kDontCheckDir },
{ "0 0 10 0 0 10 -10 -10", SkPath::kConcave_Convexity, SkPathPriv::kCW_FirstDirection },
{ "", SkPathConvexityType::kConvex, SkPathPriv::kUnknown_FirstDirection },
{ "0 0", SkPathConvexityType::kConvex, SkPathPriv::kUnknown_FirstDirection },
{ "0 0 10 10", SkPathConvexityType::kConvex, SkPathPriv::kUnknown_FirstDirection },
{ "0 0 10 10 20 20 0 0 10 10", SkPathConvexityType::kConcave, SkPathPriv::kUnknown_FirstDirection },
{ "0 0 10 10 10 20", SkPathConvexityType::kConvex, SkPathPriv::kCW_FirstDirection },
{ "0 0 10 10 10 0", SkPathConvexityType::kConvex, SkPathPriv::kCCW_FirstDirection },
{ "0 0 10 10 10 0 0 10", SkPathConvexityType::kConcave, kDontCheckDir },
{ "0 0 10 0 0 10 -10 -10", SkPathConvexityType::kConcave, SkPathPriv::kCW_FirstDirection },
};
for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) {
@ -1633,7 +1633,7 @@ static void test_convexity(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, !foundDir || gRec[i].fExpectedDirection == dir);
check_convexity(reporter, copy, gRec[i].fExpectedConvexity);
}
REPORTER_ASSERT(reporter, gRec[i].fExpectedConvexity == path.getConvexity());
REPORTER_ASSERT(reporter, gRec[i].fExpectedConvexity == path.getConvexityType());
check_direction(reporter, path, gRec[i].fExpectedDirection);
}
@ -1682,7 +1682,7 @@ static void test_convexity(skiatest::Reporter* reporter) {
case 11: path.cubicTo(nonFinitePts[i], axisAlignedPts[f], axisAlignedPts[g]); break;
case 12: path.moveTo(nonFinitePts[i]); break;
}
check_convexity(reporter, path, SkPath::kUnknown_Convexity);
check_convexity(reporter, path, SkPathConvexityType::kUnknown);
}
for (int index = 0; index < (int) (11 * axisAlignedPtsCount); ++index) {
@ -1704,12 +1704,12 @@ static void test_convexity(skiatest::Reporter* reporter) {
case 10: path.cubicTo(axisAlignedPts[g], axisAlignedPts[f], axisAlignedPts[g]); break;
}
if (curveSelect == 0 || curveSelect == 1 || curveSelect == 2 || curveSelect == 5) {
check_convexity(reporter, path, SkPath::kConvex_Convexity);
check_convexity(reporter, path, SkPathConvexityType::kConvex);
} else {
SkPath copy(path); // we make a copy so that we don't cache the result on the passed in path.
SkPath::Convexity c = copy.getConvexity();
REPORTER_ASSERT(reporter, SkPath::kUnknown_Convexity == c
|| SkPath::kConcave_Convexity == c);
SkPathConvexityType c = copy.getConvexityType();
REPORTER_ASSERT(reporter, SkPathConvexityType::kUnknown == c
|| SkPathConvexityType::kConcave == c);
}
}
@ -1739,12 +1739,12 @@ static void test_convexity(skiatest::Reporter* reporter) {
case 10: path.cubicTo(diagonalPts[g], axisAlignedPts[f], diagonalPts[g]); break;
}
if (curveSelect == 0) {
check_convexity(reporter, path, SkPath::kConvex_Convexity);
check_convexity(reporter, path, SkPathConvexityType::kConvex);
} else {
SkPath copy(path); // we make a copy so that we don't cache the result on the passed in path.
SkPath::Convexity c = copy.getConvexity();
REPORTER_ASSERT(reporter, SkPath::kUnknown_Convexity == c
|| SkPath::kConcave_Convexity == c);
SkPathConvexityType c = copy.getConvexityType();
REPORTER_ASSERT(reporter, SkPathConvexityType::kUnknown == c
|| SkPathConvexityType::kConcave == c);
}
}
@ -1757,7 +1757,7 @@ static void test_convexity(skiatest::Reporter* reporter) {
path.lineTo(SkBits2Float(0xbe917378), SkBits2Float(0xbd7ee1a9)); // -0.284084f, -0.0622269f
path.lineTo(SkBits2Float(0xbe9171db), SkBits2Float(0xbd7eeb5d)); // -0.284072f, -0.0622362f
path.close();
check_convexity(reporter, path, SkPath::kConcave_Convexity);
check_convexity(reporter, path, SkPathConvexityType::kConcave);
}
@ -1913,7 +1913,7 @@ static void test_conservativelyContains(skiatest::Reporter* reporter) {
swap(qRect.fTop, qRect.fBottom);
}
for (int d = 0; d < 2; ++d) {
SkPath::Direction dir = d ? SkPath::kCCW_Direction : SkPath::kCW_Direction;
SkPathDirection dir = d ? SkPathDirection::kCCW : SkPathDirection::kCW;
path.reset();
path.addRect(kBaseRect, dir);
REPORTER_ASSERT(reporter, kQueries[q].fInRect ==
@ -2157,7 +2157,7 @@ static void test_isRect(skiatest::Reporter* reporter) {
if (tests[testIndex].fIsRect) {
SkRect computed, expected;
bool isClosed;
SkPath::Direction direction;
SkPathDirection direction;
SkPathPriv::FirstDirection cheapDirection;
int pointCount = tests[testIndex].fPointCount - (d2 == tests[testIndex].fPoints);
expected.setBounds(tests[testIndex].fPoints, pointCount);
@ -2170,9 +2170,9 @@ static void test_isRect(skiatest::Reporter* reporter) {
SkRect computed;
computed.setLTRB(123, 456, 789, 1011);
for (auto c : {true, false})
for (auto d : {SkPath::kCW_Direction, SkPath::kCCW_Direction}) {
for (auto d : {SkPathDirection::kCW, SkPathDirection::kCCW}) {
bool isClosed = c;
SkPath::Direction direction = d;
SkPathDirection direction = d;
REPORTER_ASSERT(reporter, !path.isRect(&computed, &isClosed, &direction));
REPORTER_ASSERT(reporter, computed.fLeft == 123 && computed.fTop == 456);
REPORTER_ASSERT(reporter, computed.fRight == 789 && computed.fBottom == 1011);
@ -2239,9 +2239,9 @@ static void test_isRect(skiatest::Reporter* reporter) {
}
static void check_simple_closed_rect(skiatest::Reporter* reporter, const SkPath& path,
const SkRect& rect, SkPath::Direction dir, unsigned start) {
const SkRect& rect, SkPathDirection dir, unsigned start) {
SkRect r = SkRect::MakeEmpty();
SkPath::Direction d = SkPath::kCCW_Direction;
SkPathDirection d = SkPathDirection::kCCW;
unsigned s = ~0U;
REPORTER_ASSERT(reporter, SkPathPriv::IsSimpleClosedRect(path, &r, &d, &s));
@ -2253,14 +2253,14 @@ static void check_simple_closed_rect(skiatest::Reporter* reporter, const SkPath&
static void test_is_simple_closed_rect(skiatest::Reporter* reporter) {
using std::swap;
SkRect r = SkRect::MakeEmpty();
SkPath::Direction d = SkPath::kCCW_Direction;
SkPathDirection d = SkPathDirection::kCCW;
unsigned s = ~0U;
const SkRect testRect = SkRect::MakeXYWH(10, 10, 50, 70);
const SkRect emptyRect = SkRect::MakeEmpty();
SkPath path;
for (int start = 0; start < 4; ++start) {
for (auto dir : {SkPath::kCCW_Direction, SkPath::kCW_Direction}) {
for (auto dir : {SkPathDirection::kCCW, SkPathDirection::kCW}) {
SkPath path;
path.addRect(testRect, dir, start);
check_simple_closed_rect(reporter, path, testRect, dir, start);
@ -2317,9 +2317,9 @@ static void test_is_simple_closed_rect(skiatest::Reporter* reporter) {
path2.addRect(degenRect, dir, start);
REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path2, &r, &d, &s));
// An inverted rect makes a rect path, but changes the winding dir and start point.
SkPath::Direction swapDir = (dir == SkPath::kCW_Direction)
? SkPath::kCCW_Direction
: SkPath::kCW_Direction;
SkPathDirection swapDir = (dir == SkPathDirection::kCW)
? SkPathDirection::kCCW
: SkPathDirection::kCW;
static constexpr unsigned kXSwapStarts[] = { 1, 0, 3, 2 };
static constexpr unsigned kYSwapStarts[] = { 3, 2, 1, 0 };
SkRect swapRect = testRect;
@ -2341,7 +2341,7 @@ static void test_is_simple_closed_rect(skiatest::Reporter* reporter) {
path.lineTo(1, 1);
path.lineTo(0, 1);
SkRect rect;
SkPath::Direction dir;
SkPathDirection dir;
unsigned start;
path.close();
REPORTER_ASSERT(reporter, !SkPathPriv::IsSimpleClosedRect(path, &rect, &dir, &start));
@ -2444,7 +2444,7 @@ static void test_isNestedFillRects(skiatest::Reporter* reporter) {
for (size_t testIndex = 0; testIndex < testCount; ++testIndex) {
SkPath path;
if (rectFirst) {
path.addRect(-1, -1, 2, 2, SkPath::kCW_Direction);
path.addRect(-1, -1, 2, 2, SkPathDirection::kCW);
}
path.moveTo(tests[testIndex].fPoints[0].fX, tests[testIndex].fPoints[0].fY);
for (index = 1; index < tests[testIndex].fPointCount; ++index) {
@ -2454,14 +2454,14 @@ static void test_isNestedFillRects(skiatest::Reporter* reporter) {
path.close();
}
if (!rectFirst) {
path.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction);
path.addRect(-1, -1, 2, 2, SkPathDirection::kCCW);
}
REPORTER_ASSERT(reporter,
tests[testIndex].fIsNestedRect == SkPathPriv::IsNestedFillRects(path, nullptr));
if (tests[testIndex].fIsNestedRect) {
SkRect expected[2], computed[2];
SkPathPriv::FirstDirection expectedDirs[2];
SkPath::Direction computedDirs[2];
SkPathDirection computedDirs[2];
SkRect testBounds;
testBounds.setBounds(tests[testIndex].fPoints, tests[testIndex].fPointCount);
expected[0] = SkRect::MakeLTRB(-1, -1, 2, 2);
@ -2483,7 +2483,7 @@ static void test_isNestedFillRects(skiatest::Reporter* reporter) {
// fail, close then line
SkPath path1;
if (rectFirst) {
path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction);
path1.addRect(-1, -1, 2, 2, SkPathDirection::kCW);
}
path1.moveTo(r1[0].fX, r1[0].fY);
for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) {
@ -2492,14 +2492,14 @@ static void test_isNestedFillRects(skiatest::Reporter* reporter) {
path1.close();
path1.lineTo(1, 0);
if (!rectFirst) {
path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction);
path1.addRect(-1, -1, 2, 2, SkPathDirection::kCCW);
}
REPORTER_ASSERT(reporter, !SkPathPriv::IsNestedFillRects(path1, nullptr));
// fail, move in the middle
path1.reset();
if (rectFirst) {
path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction);
path1.addRect(-1, -1, 2, 2, SkPathDirection::kCW);
}
path1.moveTo(r1[0].fX, r1[0].fY);
for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) {
@ -2510,14 +2510,14 @@ static void test_isNestedFillRects(skiatest::Reporter* reporter) {
}
path1.close();
if (!rectFirst) {
path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction);
path1.addRect(-1, -1, 2, 2, SkPathDirection::kCCW);
}
REPORTER_ASSERT(reporter, !SkPathPriv::IsNestedFillRects(path1, nullptr));
// fail, move on the edge
path1.reset();
if (rectFirst) {
path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction);
path1.addRect(-1, -1, 2, 2, SkPathDirection::kCW);
}
for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) {
path1.moveTo(r1[index - 1].fX, r1[index - 1].fY);
@ -2525,14 +2525,14 @@ static void test_isNestedFillRects(skiatest::Reporter* reporter) {
}
path1.close();
if (!rectFirst) {
path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction);
path1.addRect(-1, -1, 2, 2, SkPathDirection::kCCW);
}
REPORTER_ASSERT(reporter, !SkPathPriv::IsNestedFillRects(path1, nullptr));
// fail, quad
path1.reset();
if (rectFirst) {
path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction);
path1.addRect(-1, -1, 2, 2, SkPathDirection::kCW);
}
path1.moveTo(r1[0].fX, r1[0].fY);
for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) {
@ -2543,14 +2543,14 @@ static void test_isNestedFillRects(skiatest::Reporter* reporter) {
}
path1.close();
if (!rectFirst) {
path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction);
path1.addRect(-1, -1, 2, 2, SkPathDirection::kCCW);
}
REPORTER_ASSERT(reporter, !SkPathPriv::IsNestedFillRects(path1, nullptr));
// fail, cubic
path1.reset();
if (rectFirst) {
path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction);
path1.addRect(-1, -1, 2, 2, SkPathDirection::kCW);
}
path1.moveTo(r1[0].fX, r1[0].fY);
for (index = 1; index < SkToInt(SK_ARRAY_COUNT(r1)); ++index) {
@ -2561,14 +2561,14 @@ static void test_isNestedFillRects(skiatest::Reporter* reporter) {
}
path1.close();
if (!rectFirst) {
path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction);
path1.addRect(-1, -1, 2, 2, SkPathDirection::kCCW);
}
REPORTER_ASSERT(reporter, !SkPathPriv::IsNestedFillRects(path1, nullptr));
// fail, not nested
path1.reset();
path1.addRect(1, 1, 3, 3, SkPath::kCW_Direction);
path1.addRect(2, 2, 4, 4, SkPath::kCW_Direction);
path1.addRect(1, 1, 3, 3, SkPathDirection::kCW);
path1.addRect(2, 2, 4, 4, SkPathDirection::kCW);
REPORTER_ASSERT(reporter, !SkPathPriv::IsNestedFillRects(path1, nullptr));
}
@ -2588,7 +2588,7 @@ static void test_isNestedFillRects(skiatest::Reporter* reporter) {
// pass, stroke rect
SkPath src, dst;
src.addRect(1, 1, 7, 7, SkPath::kCW_Direction);
src.addRect(1, 1, 7, 7, SkPathDirection::kCW);
SkPaint strokePaint;
strokePaint.setStyle(SkPaint::kStroke_Style);
strokePaint.setStrokeWidth(2);
@ -2610,11 +2610,11 @@ static void write_and_read_back(skiatest::Reporter* reporter,
reader.readPath(&readBack);
REPORTER_ASSERT(reporter, readBack == p);
REPORTER_ASSERT(reporter, readBack.getConvexityOrUnknown() ==
p.getConvexityOrUnknown());
REPORTER_ASSERT(reporter, readBack.getConvexityTypeOrUnknown() ==
p.getConvexityTypeOrUnknown());
SkRect oval0, oval1;
SkPath::Direction dir0, dir1;
SkPathDirection dir0, dir1;
unsigned start0, start1;
REPORTER_ASSERT(reporter, readBack.isOval(nullptr) == p.isOval(nullptr));
if (SkPathPriv::IsOval(p, &oval0, &dir0, &start0) &&
@ -2756,7 +2756,7 @@ static void test_transform(skiatest::Reporter* reporter) {
}
p.reset();
p.addCircle(0, 0, 1, SkPath::kCW_Direction);
p.addCircle(0, 0, 1, SkPathDirection::kCW);
{
SkMatrix matrix;
@ -3286,7 +3286,7 @@ static void check_for_circle(skiatest::Reporter* reporter,
SkPathPriv::FirstDirection expectedDir) {
SkRect rect = SkRect::MakeEmpty();
REPORTER_ASSERT(reporter, path.isOval(&rect) == expectedCircle);
SkPath::Direction isOvalDir;
SkPathDirection isOvalDir;
unsigned isOvalStart;
if (SkPathPriv::IsOval(path, &rect, &isOvalDir, &isOvalStart)) {
REPORTER_ASSERT(reporter, rect.height() == rect.width());
@ -3406,7 +3406,7 @@ static void test_circle_mirror_xy(skiatest::Reporter* reporter,
}
static void test_circle_with_direction(skiatest::Reporter* reporter,
SkPath::Direction inDir) {
SkPathDirection inDir) {
const SkPathPriv::FirstDirection dir = SkPathPriv::AsFirstDirection(inDir);
SkPath path;
@ -3453,12 +3453,12 @@ static void test_circle_with_add_paths(skiatest::Reporter* reporter) {
SkPath rect;
SkPath empty;
const SkPath::Direction kCircleDir = SkPath::kCW_Direction;
const SkPath::Direction kCircleDirOpposite = SkPath::kCCW_Direction;
const SkPathDirection kCircleDir = SkPathDirection::kCW;
const SkPathDirection kCircleDirOpposite = SkPathDirection::kCCW;
circle.addCircle(0, 0, SkIntToScalar(10), kCircleDir);
rect.addRect(SkIntToScalar(5), SkIntToScalar(5),
SkIntToScalar(20), SkIntToScalar(20), SkPath::kCW_Direction);
SkIntToScalar(20), SkIntToScalar(20), SkPathDirection::kCW);
SkMatrix translate;
translate.setTranslate(SkIntToScalar(12), SkIntToScalar(12));
@ -3484,24 +3484,24 @@ static void test_circle_with_add_paths(skiatest::Reporter* reporter) {
}
static void test_circle(skiatest::Reporter* reporter) {
test_circle_with_direction(reporter, SkPath::kCW_Direction);
test_circle_with_direction(reporter, SkPath::kCCW_Direction);
test_circle_with_direction(reporter, SkPathDirection::kCW);
test_circle_with_direction(reporter, SkPathDirection::kCCW);
// multiple addCircle()
SkPath path;
path.addCircle(0, 0, SkIntToScalar(10), SkPath::kCW_Direction);
path.addCircle(0, 0, SkIntToScalar(20), SkPath::kCW_Direction);
path.addCircle(0, 0, SkIntToScalar(10), SkPathDirection::kCW);
path.addCircle(0, 0, SkIntToScalar(20), SkPathDirection::kCW);
check_for_circle(reporter, path, false, SkPathPriv::kCW_FirstDirection);
// some extra lineTo() would make isOval() fail
path.reset();
path.addCircle(0, 0, SkIntToScalar(10), SkPath::kCW_Direction);
path.addCircle(0, 0, SkIntToScalar(10), SkPathDirection::kCW);
path.lineTo(0, 0);
check_for_circle(reporter, path, false, SkPathPriv::kCW_FirstDirection);
// not back to the original point
path.reset();
path.addCircle(0, 0, SkIntToScalar(10), SkPath::kCW_Direction);
path.addCircle(0, 0, SkIntToScalar(10), SkPathDirection::kCW);
path.setLastPt(SkIntToScalar(5), SkIntToScalar(5));
check_for_circle(reporter, path, false, SkPathPriv::kCW_FirstDirection);
@ -3509,7 +3509,7 @@ static void test_circle(skiatest::Reporter* reporter) {
// test negative radius
path.reset();
path.addCircle(0, 0, -1, SkPath::kCW_Direction);
path.addCircle(0, 0, -1, SkPathDirection::kCW);
REPORTER_ASSERT(reporter, path.isEmpty());
}
@ -3518,7 +3518,7 @@ static void test_oval(skiatest::Reporter* reporter) {
SkMatrix m;
SkPath path;
unsigned start = 0;
SkPath::Direction dir = SkPath::kCCW_Direction;
SkPathDirection dir = SkPathDirection::kCCW;
rect = SkRect::MakeWH(SkIntToScalar(30), SkIntToScalar(50));
path.addOval(rect);
@ -3533,7 +3533,7 @@ static void test_oval(skiatest::Reporter* reporter) {
// is unchanged.
REPORTER_ASSERT(reporter, SkPathPriv::IsOval(tmp, nullptr, &dir, &start));
REPORTER_ASSERT(reporter, 2 == start);
REPORTER_ASSERT(reporter, SkPath::kCW_Direction == dir);
REPORTER_ASSERT(reporter, SkPathDirection::kCW == dir);
m.reset();
m.setRotate(SkIntToScalar(30));
@ -3572,7 +3572,7 @@ static void test_oval(skiatest::Reporter* reporter) {
tmp.addOval(rect);
path = tmp;
REPORTER_ASSERT(reporter, SkPathPriv::IsOval(path, nullptr, &dir, &start));
REPORTER_ASSERT(reporter, SkPath::kCW_Direction == dir);
REPORTER_ASSERT(reporter, SkPathDirection::kCW == dir);
REPORTER_ASSERT(reporter, 1 == start);
}
@ -3591,20 +3591,20 @@ static void test_empty(skiatest::Reporter* reporter, const SkPath& p) {
}
static void test_rrect_is_convex(skiatest::Reporter* reporter, SkPath* path,
SkPath::Direction dir) {
SkPathDirection dir) {
REPORTER_ASSERT(reporter, path->isConvex());
REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(*path, SkPathPriv::AsFirstDirection(dir)));
path->setConvexity(SkPath::kUnknown_Convexity);
path->setConvexityType(SkPathConvexityType::kUnknown);
REPORTER_ASSERT(reporter, path->isConvex());
path->reset();
}
static void test_rrect_convexity_is_unknown(skiatest::Reporter* reporter, SkPath* path,
SkPath::Direction dir) {
SkPathDirection dir) {
REPORTER_ASSERT(reporter, path->isConvex());
REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(*path, SkPathPriv::AsFirstDirection(dir)));
path->setConvexity(SkPath::kUnknown_Convexity);
REPORTER_ASSERT(reporter, path->getConvexity() == SkPath::kConcave_Convexity);
path->setConvexityType(SkPathConvexityType::kUnknown);
REPORTER_ASSERT(reporter, path->getConvexityType() == SkPathConvexityType::kConcave);
path->reset();
}
@ -3615,45 +3615,45 @@ static void test_rrect(skiatest::Reporter* reporter) {
SkRect r = {10, 20, 30, 40};
rr.setRectRadii(r, radii);
p.addRRect(rr);
test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction);
p.addRRect(rr, SkPath::kCCW_Direction);
test_rrect_is_convex(reporter, &p, SkPath::kCCW_Direction);
test_rrect_is_convex(reporter, &p, SkPathDirection::kCW);
p.addRRect(rr, SkPathDirection::kCCW);
test_rrect_is_convex(reporter, &p, SkPathDirection::kCCW);
p.addRoundRect(r, &radii[0].fX);
test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction);
p.addRoundRect(r, &radii[0].fX, SkPath::kCCW_Direction);
test_rrect_is_convex(reporter, &p, SkPath::kCCW_Direction);
test_rrect_is_convex(reporter, &p, SkPathDirection::kCW);
p.addRoundRect(r, &radii[0].fX, SkPathDirection::kCCW);
test_rrect_is_convex(reporter, &p, SkPathDirection::kCCW);
p.addRoundRect(r, radii[1].fX, radii[1].fY);
test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction);
p.addRoundRect(r, radii[1].fX, radii[1].fY, SkPath::kCCW_Direction);
test_rrect_is_convex(reporter, &p, SkPath::kCCW_Direction);
test_rrect_is_convex(reporter, &p, SkPathDirection::kCW);
p.addRoundRect(r, radii[1].fX, radii[1].fY, SkPathDirection::kCCW);
test_rrect_is_convex(reporter, &p, SkPathDirection::kCCW);
for (size_t i = 0; i < SK_ARRAY_COUNT(radii); ++i) {
SkVector save = radii[i];
radii[i].set(0, 0);
rr.setRectRadii(r, radii);
p.addRRect(rr);
test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction);
test_rrect_is_convex(reporter, &p, SkPathDirection::kCW);
radii[i] = save;
}
p.addRoundRect(r, 0, 0);
SkRect returnedRect;
REPORTER_ASSERT(reporter, p.isRect(&returnedRect));
REPORTER_ASSERT(reporter, returnedRect == r);
test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction);
test_rrect_is_convex(reporter, &p, SkPathDirection::kCW);
SkVector zeroRadii[] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}};
rr.setRectRadii(r, zeroRadii);
p.addRRect(rr);
bool closed;
SkPath::Direction dir;
SkPathDirection dir;
REPORTER_ASSERT(reporter, p.isRect(nullptr, &closed, &dir));
REPORTER_ASSERT(reporter, closed);
REPORTER_ASSERT(reporter, SkPath::kCW_Direction == dir);
test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction);
p.addRRect(rr, SkPath::kCW_Direction);
p.addRRect(rr, SkPath::kCW_Direction);
REPORTER_ASSERT(reporter, SkPathDirection::kCW == dir);
test_rrect_is_convex(reporter, &p, SkPathDirection::kCW);
p.addRRect(rr, SkPathDirection::kCW);
p.addRRect(rr, SkPathDirection::kCW);
REPORTER_ASSERT(reporter, !p.isConvex());
p.reset();
p.addRRect(rr, SkPath::kCCW_Direction);
p.addRRect(rr, SkPath::kCCW_Direction);
p.addRRect(rr, SkPathDirection::kCCW);
p.addRRect(rr, SkPathDirection::kCCW);
REPORTER_ASSERT(reporter, !p.isConvex());
p.reset();
SkRect emptyR = {10, 20, 10, 30};
@ -3666,7 +3666,7 @@ static void test_rrect(skiatest::Reporter* reporter) {
SkRect largeR = {0, 0, SK_ScalarMax, SK_ScalarMax};
rr.setRectRadii(largeR, radii);
p.addRRect(rr);
test_rrect_convexity_is_unknown(reporter, &p, SkPath::kCW_Direction);
test_rrect_convexity_is_unknown(reporter, &p, SkPathDirection::kCW);
// we check for non-finites
SkRect infR = {0, 0, SK_ScalarMax, SK_ScalarInfinity};
@ -3676,7 +3676,7 @@ static void test_rrect(skiatest::Reporter* reporter) {
// We consider any path with very small (numerically unstable) edges to be concave.
SkRect tinyR = {0, 0, 1e-9f, 1e-9f};
p.addRoundRect(tinyR, 5e-11f, 5e-11f);
test_rrect_convexity_is_unknown(reporter, &p, SkPath::kCW_Direction);
test_rrect_convexity_is_unknown(reporter, &p, SkPathDirection::kCW);
}
static void test_arc(skiatest::Reporter* reporter) {
@ -3696,7 +3696,7 @@ static void test_arc(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, p == cwOval);
p.reset();
SkPath ccwOval;
ccwOval.addOval(oval, SkPath::kCCW_Direction);
ccwOval.addOval(oval, SkPathDirection::kCCW);
p.addArc(oval, 0, -360);
REPORTER_ASSERT(reporter, p == ccwOval);
p.reset();
@ -3704,10 +3704,10 @@ static void test_arc(skiatest::Reporter* reporter) {
// diagonal colinear points make arc convex
// TODO: one way to keep it concave would be to introduce interpolated on curve points
// between control points and computing the on curve point at scan conversion time
REPORTER_ASSERT(reporter, p.getConvexity() == SkPath::kConvex_Convexity);
REPORTER_ASSERT(reporter, p.getConvexityType() == SkPathConvexityType::kConvex);
REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(p, SkPathPriv::kCW_FirstDirection));
p.setConvexity(SkPath::kUnknown_Convexity);
REPORTER_ASSERT(reporter, p.getConvexity() == SkPath::kConvex_Convexity);
p.setConvexityType(SkPathConvexityType::kUnknown);
REPORTER_ASSERT(reporter, p.getConvexityType() == SkPathConvexityType::kConvex);
}
static inline SkScalar oval_start_index_to_angle(unsigned start) {
@ -3738,7 +3738,7 @@ static inline SkScalar canonical_start_angle(float angle) {
static void check_oval_arc(skiatest::Reporter* reporter, SkScalar start, SkScalar sweep,
const SkPath& path) {
SkRect r = SkRect::MakeEmpty();
SkPath::Direction d = SkPath::kCCW_Direction;
SkPathDirection d = SkPathDirection::kCCW;
unsigned s = ~0U;
bool isOval = SkPathPriv::IsOval(path, &r, &d, &s);
REPORTER_ASSERT(reporter, isOval);
@ -3746,7 +3746,7 @@ static void check_oval_arc(skiatest::Reporter* reporter, SkScalar start, SkScala
recreatedPath.addOval(r, d, s);
REPORTER_ASSERT(reporter, path == recreatedPath);
REPORTER_ASSERT(reporter, oval_start_index_to_angle(s) == canonical_start_angle(start));
REPORTER_ASSERT(reporter, (SkPath::kCW_Direction == d) == (sweep > 0.f));
REPORTER_ASSERT(reporter, (SkPathDirection::kCW == d) == (sweep > 0.f));
}
static void test_arc_ovals(skiatest::Reporter* reporter) {
@ -5488,8 +5488,8 @@ struct Xforms {
};
static bool conditional_convex(const SkPath& path, bool is_convex) {
SkPath::Convexity c = path.getConvexityOrUnknown();
return is_convex ? (c == SkPath::kConvex_Convexity) : (c != SkPath::kConvex_Convexity);
SkPathConvexityType c = path.getConvexityTypeOrUnknown();
return is_convex ? (c == SkPathConvexityType::kConvex) : (c != SkPathConvexityType::kConvex);
}
// expect axis-aligned shape to survive assignment, identity and scale/translate matrices
@ -5498,22 +5498,22 @@ void survive(SkPath* path, const Xforms& x, bool isAxisAligned, skiatest::Report
ISA isa_proc) {
REPORTER_ASSERT(reporter, isa_proc(*path));
// force the issue (computing convexity) the first time.
REPORTER_ASSERT(reporter, path->getConvexity() == SkPath::kConvex_Convexity);
REPORTER_ASSERT(reporter, path->getConvexityType() == SkPathConvexityType::kConvex);
SkPath path2;
// a path's isa and convexity should survive assignment
path2 = *path;
REPORTER_ASSERT(reporter, isa_proc(path2));
REPORTER_ASSERT(reporter, path2.getConvexityOrUnknown() == SkPath::kConvex_Convexity);
REPORTER_ASSERT(reporter, path2.getConvexityTypeOrUnknown() == SkPathConvexityType::kConvex);
// a path's isa and convexity should identity transform
path->transform(x.fIM, &path2);
path->transform(x.fIM);
REPORTER_ASSERT(reporter, isa_proc(path2));
REPORTER_ASSERT(reporter, path2.getConvexityOrUnknown() == SkPath::kConvex_Convexity);
REPORTER_ASSERT(reporter, path2.getConvexityTypeOrUnknown() == SkPathConvexityType::kConvex);
REPORTER_ASSERT(reporter, isa_proc(*path));
REPORTER_ASSERT(reporter, path->getConvexityOrUnknown() == SkPath::kConvex_Convexity);
REPORTER_ASSERT(reporter, path->getConvexityTypeOrUnknown() == SkPathConvexityType::kConvex);
// a path's isa should survive translation, convexity depends on axis alignment
path->transform(x.fTM, &path2);
@ -5533,15 +5533,15 @@ void survive(SkPath* path, const Xforms& x, bool isAxisAligned, skiatest::Report
// For security, post-rotation, we can't assume we're still convex. It might prove to be,
// in fact, still be convex, be we can't have cached that setting, hence the call to
// getConvexityOrUnknown() instead of getConvexity().
// getConvexityTypeOrUnknown() instead of getConvexityType().
path->transform(x.fRM, &path2);
path->transform(x.fRM);
if (isAxisAligned) {
REPORTER_ASSERT(reporter, !isa_proc(path2));
REPORTER_ASSERT(reporter, !isa_proc(*path));
}
REPORTER_ASSERT(reporter, path2.getConvexityOrUnknown() != SkPath::kConvex_Convexity);
REPORTER_ASSERT(reporter, path->getConvexityOrUnknown() != SkPath::kConvex_Convexity);
REPORTER_ASSERT(reporter, path2.getConvexityTypeOrUnknown() != SkPathConvexityType::kConvex);
REPORTER_ASSERT(reporter, path->getConvexityTypeOrUnknown() != SkPathConvexityType::kConvex);
}
DEF_TEST(Path_survive_transform, r) {
@ -5562,7 +5562,7 @@ DEF_TEST(Path_survive_transform, r) {
// make a trapazoid; definitely convex, but not marked as axis-aligned (e.g. oval, rrect)
path.reset();
path.moveTo(0, 0).lineTo(100, 0).lineTo(70, 100).lineTo(30, 100);
REPORTER_ASSERT(r, path.getConvexity() == SkPath::kConvex_Convexity);
REPORTER_ASSERT(r, path.getConvexityType() == SkPathConvexityType::kConvex);
survive(&path, x, false, r, [](const SkPath& p) { return true; });
}

View File

@ -12,7 +12,7 @@
#include "tests/Test.h"
static SkRRect path_contains_rrect(skiatest::Reporter* reporter, const SkPath& path,
SkPath::Direction* dir, unsigned* start) {
SkPathDirection* dir, unsigned* start) {
SkRRect out;
REPORTER_ASSERT(reporter, SkPathPriv::IsRRect(path, &out, dir, start));
SkPath recreatedPath;
@ -30,7 +30,7 @@ static SkRRect path_contains_rrect(skiatest::Reporter* reporter, const SkPath& p
SkPath xformed;
path.transform(m, &xformed);
SkRRect xrr = SkRRect::MakeRect(SkRect::MakeEmpty());
SkPath::Direction xd = SkPath::kCCW_Direction;
SkPathDirection xd = SkPathDirection::kCCW;
unsigned xs = ~0U;
REPORTER_ASSERT(reporter, SkPathPriv::IsRRect(xformed, &xrr, &xd, &xs));
recreatedPath.reset();
@ -41,7 +41,7 @@ static SkRRect path_contains_rrect(skiatest::Reporter* reporter, const SkPath& p
}
static SkRRect inner_path_contains_rrect(skiatest::Reporter* reporter, const SkRRect& in,
SkPath::Direction dir, unsigned start) {
SkPathDirection dir, unsigned start) {
switch (in.getType()) {
case SkRRect::kEmpty_Type:
case SkRRect::kRect_Type:
@ -52,7 +52,7 @@ static SkRRect inner_path_contains_rrect(skiatest::Reporter* reporter, const SkR
}
SkPath path;
path.addRRect(in, dir, start);
SkPath::Direction outDir;
SkPathDirection outDir;
unsigned outStart;
SkRRect rrect = path_contains_rrect(reporter, path, &outDir, &outStart);
REPORTER_ASSERT(reporter, outDir == dir && outStart == start);
@ -60,7 +60,7 @@ static SkRRect inner_path_contains_rrect(skiatest::Reporter* reporter, const SkR
}
static void path_contains_rrect_check(skiatest::Reporter* reporter, const SkRRect& in,
SkPath::Direction dir, unsigned start) {
SkPathDirection dir, unsigned start) {
SkRRect out = inner_path_contains_rrect(reporter, in, dir, start);
if (in != out) {
SkDebugf("");
@ -69,7 +69,7 @@ static void path_contains_rrect_check(skiatest::Reporter* reporter, const SkRRec
}
static void path_contains_rrect_nocheck(skiatest::Reporter* reporter, const SkRRect& in,
SkPath::Direction dir, unsigned start) {
SkPathDirection dir, unsigned start) {
SkRRect out = inner_path_contains_rrect(reporter, in, dir, start);
if (in == out) {
SkDebugf("");
@ -77,7 +77,7 @@ static void path_contains_rrect_nocheck(skiatest::Reporter* reporter, const SkRR
}
static void path_contains_rrect_check(skiatest::Reporter* reporter, const SkRect& r,
SkVector v[4], SkPath::Direction dir, unsigned start) {
SkVector v[4], SkPathDirection dir, unsigned start) {
SkRRect rrect;
rrect.setRectRadii(r, v);
path_contains_rrect_check(reporter, rrect, dir, start);
@ -85,15 +85,15 @@ static void path_contains_rrect_check(skiatest::Reporter* reporter, const SkRect
class ForceIsRRect_Private {
public:
ForceIsRRect_Private(SkPath* path, SkPath::Direction dir, unsigned start) {
path->fPathRef->setIsRRect(true, dir == SkPath::kCCW_Direction, start);
ForceIsRRect_Private(SkPath* path, SkPathDirection dir, unsigned start) {
path->fPathRef->setIsRRect(true, dir == SkPathDirection::kCCW, start);
}
};
static void force_path_contains_rrect(skiatest::Reporter* reporter, SkPath& path,
SkPath::Direction dir, unsigned start) {
SkPathDirection dir, unsigned start) {
ForceIsRRect_Private force_rrect(&path, dir, start);
SkPath::Direction outDir;
SkPathDirection outDir;
unsigned outStart;
path_contains_rrect(reporter, path, &outDir, &outStart);
REPORTER_ASSERT(reporter, outDir == dir && outStart == start);
@ -124,7 +124,7 @@ static void test_undetected_paths(skiatest::Reporter* reporter) {
path.lineTo(3.5f, 66);
path.conicTo(0, 66, 0, 62.5, weight);
path.close();
force_path_contains_rrect(reporter, path, SkPath::kCW_Direction, 6);
force_path_contains_rrect(reporter, path, SkPathDirection::kCW, 6);
path.reset();
path.moveTo(0, 81.5f);
@ -137,7 +137,7 @@ static void test_undetected_paths(skiatest::Reporter* reporter) {
path.lineTo(3.5f, 85);
path.conicTo(0, 85, 0, 81.5f, weight);
path.close();
force_path_contains_rrect(reporter, path, SkPath::kCW_Direction, 6);
force_path_contains_rrect(reporter, path, SkPathDirection::kCW, 6);
path.reset();
path.moveTo(14, 1189);
@ -150,7 +150,7 @@ static void test_undetected_paths(skiatest::Reporter* reporter) {
path.lineTo(21, 1196);
path.conicTo(14, 1196, 14, 1189, weight);
path.close();
force_path_contains_rrect(reporter, path, SkPath::kCW_Direction, 6);
force_path_contains_rrect(reporter, path, SkPathDirection::kCW, 6);
path.reset();
path.moveTo(14, 1743);
@ -163,14 +163,14 @@ static void test_undetected_paths(skiatest::Reporter* reporter) {
path.lineTo(21, 1750);
path.conicTo(14, 1750, 14, 1743, weight);
path.close();
force_path_contains_rrect(reporter, path, SkPath::kCW_Direction, 6);
force_path_contains_rrect(reporter, path, SkPathDirection::kCW, 6);
}
static const SkScalar kWidth = 100.0f;
static const SkScalar kHeight = 100.0f;
static void test_tricky_radii(skiatest::Reporter* reporter) {
for (auto dir : {SkPath::kCW_Direction, SkPath::kCCW_Direction}) {
for (auto dir : {SkPathDirection::kCW, SkPathDirection::kCCW}) {
for (int start = 0; start < 8; ++start) {
{
// crbug.com/458522
@ -197,7 +197,7 @@ static void test_tricky_radii(skiatest::Reporter* reporter) {
}
static void test_empty_crbug_458524(skiatest::Reporter* reporter) {
for (auto dir : {SkPath::kCW_Direction, SkPath::kCCW_Direction}) {
for (auto dir : {SkPathDirection::kCW, SkPathDirection::kCCW}) {
for (int start = 0; start < 8; ++start) {
SkRRect rr;
const SkRect bounds = { 3709, 3709, 3709 + 7402, 3709 + 29825 };
@ -215,7 +215,7 @@ static void test_empty_crbug_458524(skiatest::Reporter* reporter) {
}
static void test_inset(skiatest::Reporter* reporter) {
for (auto dir : {SkPath::kCW_Direction, SkPath::kCCW_Direction}) {
for (auto dir : {SkPathDirection::kCW, SkPathDirection::kCCW}) {
for (int start = 0; start < 8; ++start) {
SkRRect rr, rr2;
SkRect r = { 0, 0, 100, 100 };
@ -244,7 +244,7 @@ static void test_9patch_rrect(skiatest::Reporter* reporter,
const SkRect& rect,
SkScalar l, SkScalar t, SkScalar r, SkScalar b,
bool checkRadii) {
for (auto dir : {SkPath::kCW_Direction, SkPath::kCCW_Direction}) {
for (auto dir : {SkPathDirection::kCW, SkPathDirection::kCCW}) {
for (int start = 0; start < 8; ++start) {
SkRRect rr;
rr.setNinePatch(rect, l, t, r, b);
@ -268,7 +268,7 @@ static void test_9patch_rrect(skiatest::Reporter* reporter,
// Test out the basic API entry points
static void test_round_rect_basic(skiatest::Reporter* reporter) {
for (auto dir : {SkPath::kCW_Direction, SkPath::kCCW_Direction}) {
for (auto dir : {SkPathDirection::kCW, SkPathDirection::kCCW}) {
for (int start = 0; start < 8; ++start) {
//----
SkRect rect = SkRect::MakeLTRB(0, 0, kWidth, kHeight);
@ -342,7 +342,7 @@ static void test_round_rect_basic(skiatest::Reporter* reporter) {
// Test out the cases when the RR degenerates to a rect
static void test_round_rect_rects(skiatest::Reporter* reporter) {
for (auto dir : {SkPath::kCW_Direction, SkPath::kCCW_Direction}) {
for (auto dir : {SkPathDirection::kCW, SkPathDirection::kCCW}) {
for (int start = 0; start < 8; ++start) {
//----
SkRect rect = SkRect::MakeLTRB(0, 0, kWidth, kHeight);
@ -371,7 +371,7 @@ static void test_round_rect_rects(skiatest::Reporter* reporter) {
// Test out the cases when the RR degenerates to an oval
static void test_round_rect_ovals(skiatest::Reporter* reporter) {
for (auto dir : {SkPath::kCW_Direction, SkPath::kCCW_Direction}) {
for (auto dir : {SkPathDirection::kCW, SkPathDirection::kCCW}) {
for (int start = 0; start < 8; ++start) {
//----
SkRect rect = SkRect::MakeLTRB(0, 0, kWidth, kHeight);
@ -385,7 +385,7 @@ static void test_round_rect_ovals(skiatest::Reporter* reporter) {
// Test out the non-degenerate RR cases
static void test_round_rect_general(skiatest::Reporter* reporter) {
for (auto dir : {SkPath::kCW_Direction, SkPath::kCCW_Direction}) {
for (auto dir : {SkPathDirection::kCW, SkPathDirection::kCCW}) {
for (int start = 0; start < 8; ++start) {
//----
SkRect rect = SkRect::MakeLTRB(0, 0, kWidth, kHeight);
@ -406,7 +406,7 @@ static void test_round_rect_general(skiatest::Reporter* reporter) {
}
static void test_round_rect_iffy_parameters(skiatest::Reporter* reporter) {
for (auto dir : {SkPath::kCW_Direction, SkPath::kCCW_Direction}) {
for (auto dir : {SkPathDirection::kCW, SkPathDirection::kCCW}) {
for (int start = 0; start < 8; ++start) {
SkRect rect = SkRect::MakeLTRB(0, 0, kWidth, kHeight);
SkPoint radii[4] = { { 50, 100 }, { 100, 50 }, { 50, 100 }, { 100, 50 } };
@ -432,7 +432,7 @@ static void test_skbug_3239(skiatest::Reporter* reporter) {
const SkRect rectx = SkRect::MakeLTRB(min, min, max, big);
const SkRect recty = SkRect::MakeLTRB(min, min, big, max);
for (auto dir : {SkPath::kCW_Direction, SkPath::kCCW_Direction}) {
for (auto dir : {SkPathDirection::kCW, SkPathDirection::kCCW}) {
for (int start = 0; start < 8; ++start) {
SkVector radii[4];
for (int i = 0; i < 4; ++i) {
@ -445,7 +445,7 @@ static void test_skbug_3239(skiatest::Reporter* reporter) {
}
static void test_mix(skiatest::Reporter* reporter) {
for (auto dir : {SkPath::kCW_Direction, SkPath::kCCW_Direction}) {
for (auto dir : {SkPathDirection::kCW, SkPathDirection::kCCW}) {
for (int start = 0; start < 8; ++start) {
// Test out mixed degenerate and non-degenerate geometry with Conics
const SkVector radii[4] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 100, 100 } };