From 1792b19485cacb0c950a3c0ea0aab763a8d43176 Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Thu, 21 Nov 2019 17:13:54 -0500 Subject: [PATCH] Revert "Revert "Use flat version of path-direction enum"" This reverts commit 0dacc6b7d3027e8181311a61f7ca798be52a0250. Change-Id: Ie103e9f36b07e4ee256a3688a4decf3a6dd74314 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/255832 Auto-Submit: Mike Reed Reviewed-by: Mike Reed Commit-Queue: Mike Reed --- bench/BlurRectsBench.cpp | 4 +- bench/GeometryBench.cpp | 2 +- bench/PathBench.cpp | 4 +- docs/examples/Arc.cpp | 2 +- docs/examples/Path_ArcSize.cpp | 4 +- docs/examples/Path_Direction.cpp | 4 +- docs/examples/Path_FillType_a.cpp | 8 +- docs/examples/Path_FillType_b.cpp | 4 +- docs/examples/Path_addCircle.cpp | 2 +- docs/examples/Path_addOval_2.cpp | 4 +- docs/examples/Path_addPath_2.cpp | 2 +- docs/examples/Path_addPath_3.cpp | 2 +- docs/examples/Path_addRRect_2.cpp | 2 +- docs/examples/Path_addRect.cpp | 4 +- docs/examples/Path_addRect_2.cpp | 2 +- docs/examples/Path_addRect_3.cpp | 2 +- docs/examples/Path_arcTo_4.cpp | 4 +- docs/examples/Path_getConvexity.cpp | 4 +- docs/examples/Path_getConvexityOrUnknown.cpp | 8 +- docs/examples/Path_isRect.cpp | 4 +- docs/examples/Path_notequal_operator.cpp | 4 +- docs/examples/Path_rArcTo.cpp | 2 +- docs/examples/Path_rMoveTo.cpp | 2 +- docs/examples/Path_setConvexity.cpp | 8 +- docs/examples/RRect_setRectRadii.cpp | 4 +- fuzz/FuzzCommon.cpp | 18 +- gm/aaa.cpp | 2 +- gm/arcto.cpp | 8 +- gm/bigblurs.cpp | 2 +- gm/blurs.cpp | 8 +- gm/circularclips.cpp | 4 +- gm/convex_all_line_paths.cpp | 8 +- gm/convexpaths.cpp | 14 +- gm/drawatlas.cpp | 4 +- gm/inversepaths.cpp | 2 +- gm/nested.cpp | 6 +- gm/pathcontourstart.cpp | 20 +- gm/patheffects.cpp | 4 +- gm/pathinterior.cpp | 4 +- gm/polygonoffset.cpp | 18 +- gm/strokefill.cpp | 24 +- gm/strokes.cpp | 24 +- gn/flutter_defines.gni | 1 + include/core/SkPath.h | 177 ++-- modules/canvaskit/canvaskit_bindings.cpp | 13 +- modules/skottie/src/layers/ShapeLayer.cpp | 8 +- modules/sksg/include/SkSGRect.h | 22 +- samplecode/SampleAndroidShadows.cpp | 2 +- samplecode/SampleClock.cpp | 8 +- samplecode/SampleQuadStroker.cpp | 4 +- samplecode/SampleRegion.cpp | 2 +- samplecode/SampleSlides.cpp | 4 +- samplecode/SampleStrokePath.cpp | 4 +- src/c/sk_surface.cpp | 12 +- src/core/SkPath.cpp | 148 +-- src/core/SkPathMakers.h | 12 +- src/core/SkPathPriv.h | 52 +- src/core/SkPath_serial.cpp | 6 +- src/core/SkStroke.cpp | 14 +- src/core/SkStroke.h | 2 +- src/gpu/GrRenderTargetContext.cpp | 2 +- src/gpu/GrTestUtils.cpp | 2 +- src/gpu/geometry/GrShape.cpp | 4 +- src/gpu/geometry/GrShape.h | 18 +- src/gpu/ops/GrAAConvexTessellator.cpp | 2 +- src/pathops/SkPathOpsAsWinding.cpp | 2 +- src/pathops/SkPathOpsDebug.cpp | 6 +- src/pdf/SkPDFUtils.cpp | 4 +- src/utils/SkDashPath.cpp | 2 +- src/utils/SkLua.cpp | 2 +- src/utils/SkParsePath.cpp | 2 +- tests/DefaultPathRendererTest.cpp | 4 +- tests/GpuDrawPathTest.cpp | 4 +- tests/GrShapeTest.cpp | 38 +- tests/PathOpsAsWindingTest.cpp | 14 +- tests/PathOpsBuilderTest.cpp | 28 +- tests/PathOpsInverseTest.cpp | 10 +- tests/PathOpsOpCircleThreadedTest.cpp | 8 +- tests/PathOpsOpRectThreadedTest.cpp | 24 +- tests/PathOpsOpTest.cpp | 184 ++-- tests/PathOpsSimplifyRectThreadedTest.cpp | 20 +- tests/PathOpsSimplifyTest.cpp | 988 +++++++++---------- tests/PathTest.cpp | 298 +++--- tests/RRectInPathTest.cpp | 52 +- 84 files changed, 1272 insertions(+), 1199 deletions(-) diff --git a/bench/BlurRectsBench.cpp b/bench/BlurRectsBench.cpp index ed2b254e56..df1775c5cd 100644 --- a/bench/BlurRectsBench.cpp +++ b/bench/BlurRectsBench.cpp @@ -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); diff --git a/bench/GeometryBench.cpp b/bench/GeometryBench.cpp index 457151d155..abaf678a76 100644 --- a/bench/GeometryBench.cpp +++ b/bench/GeometryBench.cpp @@ -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(); } } diff --git a/bench/PathBench.cpp b/bench/PathBench.cpp index eb4d4a3fea..c92e88dea6 100644 --- a/bench/PathBench.cpp +++ b/bench/PathBench.cpp @@ -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()); diff --git a/docs/examples/Arc.cpp b/docs/examples/Arc.cpp index 7b6daafabd..bb96907762 100644 --- a/docs/examples/Arc.cpp +++ b/docs/examples/Arc.cpp @@ -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); diff --git a/docs/examples/Path_ArcSize.cpp b/docs/examples/Path_ArcSize.cpp index b99a2371cb..1c7b6839ed 100644 --- a/docs/examples/Path_ArcSize.cpp +++ b/docs/examples/Path_ArcSize.cpp @@ -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); } diff --git a/docs/examples/Path_Direction.cpp b/docs/examples/Path_Direction.cpp index dab6ba913b..bbc74a2dd6 100644 --- a/docs/examples/Path_Direction.cpp +++ b/docs/examples/Path_Direction.cpp @@ -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); } diff --git a/docs/examples/Path_FillType_a.cpp b/docs/examples/Path_FillType_a.cpp index 5931cabc4d..caed39a4a6 100644 --- a/docs/examples/Path_FillType_a.cpp +++ b/docs/examples/Path_FillType_a.cpp @@ -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}; diff --git a/docs/examples/Path_FillType_b.cpp b/docs/examples/Path_FillType_b.cpp index 6064fe0d74..110117ef6f 100644 --- a/docs/examples/Path_FillType_b.cpp +++ b/docs/examples/Path_FillType_b.cpp @@ -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}; diff --git a/docs/examples/Path_addCircle.cpp b/docs/examples/Path_addCircle.cpp index dbea5b7676..73cca566f9 100644 --- a/docs/examples/Path_addCircle.cpp +++ b/docs/examples/Path_addCircle.cpp @@ -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); } } diff --git a/docs/examples/Path_addOval_2.cpp b/docs/examples/Path_addOval_2.cpp index ba07e545fd..1af997788c 100644 --- a/docs/examples/Path_addOval_2.cpp +++ b/docs/examples/Path_addOval_2.cpp @@ -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); } } diff --git a/docs/examples/Path_addPath_2.cpp b/docs/examples/Path_addPath_2.cpp index e00ff7c412..8d724046a3 100644 --- a/docs/examples/Path_addPath_2.cpp +++ b/docs/examples/Path_addPath_2.cpp @@ -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); diff --git a/docs/examples/Path_addPath_3.cpp b/docs/examples/Path_addPath_3.cpp index 2fb476130b..b865d2bb88 100644 --- a/docs/examples/Path_addPath_3.cpp +++ b/docs/examples/Path_addPath_3.cpp @@ -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(); diff --git a/docs/examples/Path_addRRect_2.cpp b/docs/examples/Path_addRRect_2.cpp index 2f14659ea4..43f7c8711d 100644 --- a/docs/examples/Path_addRRect_2.cpp +++ b/docs/examples/Path_addRRect_2.cpp @@ -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; diff --git a/docs/examples/Path_addRect.cpp b/docs/examples/Path_addRect.cpp index e51b8ef7ce..694e420d07 100644 --- a/docs/examples/Path_addRect.cpp +++ b/docs/examples/Path_addRect.cpp @@ -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 diff --git a/docs/examples/Path_addRect_2.cpp b/docs/examples/Path_addRect_2.cpp index 39d1044883..798eaae6b5 100644 --- a/docs/examples/Path_addRect_2.cpp +++ b/docs/examples/Path_addRect_2.cpp @@ -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); diff --git a/docs/examples/Path_addRect_3.cpp b/docs/examples/Path_addRect_3.cpp index 1022328590..b5bb877a5d 100644 --- a/docs/examples/Path_addRect_3.cpp +++ b/docs/examples/Path_addRect_3.cpp @@ -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); diff --git a/docs/examples/Path_arcTo_4.cpp b/docs/examples/Path_arcTo_4.cpp index 8de4927804..37395d7cb6 100644 --- a/docs/examples/Path_arcTo_4.cpp +++ b/docs/examples/Path_arcTo_4.cpp @@ -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); } diff --git a/docs/examples/Path_getConvexity.cpp b/docs/examples/Path_getConvexity.cpp index ef09116705..9f5987b95d 100644 --- a/docs/examples/Path_getConvexity.cpp +++ b/docs/examples/Path_getConvexity.cpp @@ -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); diff --git a/docs/examples/Path_getConvexityOrUnknown.cpp b/docs/examples/Path_getConvexityOrUnknown.cpp index b03c8b4b1b..4aca799eb8 100644 --- a/docs/examples/Path_getConvexityOrUnknown.cpp +++ b/docs/examples/Path_getConvexityOrUnknown.cpp @@ -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 diff --git a/docs/examples/Path_isRect.cpp b/docs/examples/Path_isRect.cpp index 9d9a6215cc..c099bb9739 100644 --- a/docs/examples/Path_isRect.cpp +++ b/docs/examples/Path_isRect.cpp @@ -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; diff --git a/docs/examples/Path_notequal_operator.cpp b/docs/examples/Path_notequal_operator.cpp index dfba8c2242..dcd56ef329 100644 --- a/docs/examples/Path_notequal_operator.cpp +++ b/docs/examples/Path_notequal_operator.cpp @@ -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 diff --git a/docs/examples/Path_rArcTo.cpp b/docs/examples/Path_rArcTo.cpp index 8244674b34..8eccb5b285 100644 --- a/docs/examples/Path_rArcTo.cpp +++ b/docs/examples/Path_rArcTo.cpp @@ -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); } diff --git a/docs/examples/Path_rMoveTo.cpp b/docs/examples/Path_rMoveTo.cpp index fd4e06dc1c..f59b579345 100644 --- a/docs/examples/Path_rMoveTo.cpp +++ b/docs/examples/Path_rMoveTo.cpp @@ -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) { diff --git a/docs/examples/Path_setConvexity.cpp b/docs/examples/Path_setConvexity.cpp index 16e5c9f308..7fe5cee172 100644 --- a/docs/examples/Path_setConvexity.cpp +++ b/docs/examples/Path_setConvexity.cpp @@ -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 diff --git a/docs/examples/RRect_setRectRadii.cpp b/docs/examples/RRect_setRectRadii.cpp index 2004e5f52f..86f35c7bca 100644 --- a/docs/examples/RRect_setRectRadii.cpp +++ b/docs/examples/RRect_setRectRadii.cpp @@ -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); } diff --git a/fuzz/FuzzCommon.cpp b/fuzz/FuzzCommon.cpp index 3a2108e9bf..0de7ce0f74 100644 --- a/fuzz/FuzzCommon.cpp +++ b/fuzz/FuzzCommon.cpp @@ -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(ui); + dir = static_cast(ui); path->addRect(r, dir); break; case 14: fuzz->nextRange(&ui, 0, 1); - dir = static_cast(ui); + dir = static_cast(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(ui); + dir = static_cast(ui); fuzz_nice_rect(fuzz, &r); path->addOval(r, dir); break; case 16: fuzz->nextRange(&ui, 0, 1); - dir = static_cast(ui); + dir = static_cast(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(ui); + dir = static_cast(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(ui); + dir = static_cast(ui); path->addRoundRect(r, a, b, dir); break; case 20: FuzzNiceRRect(fuzz, &rr); fuzz->nextRange(&ui, 0, 1); - dir = static_cast(ui); + dir = static_cast(ui); path->addRRect(rr, dir); break; case 21: fuzz->nextRange(&ui, 0, 1); - dir = static_cast(ui); + dir = static_cast(ui); FuzzNiceRRect(fuzz, &rr); path->addRRect(rr, dir, ui); break; diff --git a/gm/aaa.cpp b/gm/aaa.cpp index d056b0b53a..4ebd25ef65 100644 --- a/gm/aaa.cpp +++ b/gm/aaa.cpp @@ -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 diff --git a/gm/arcto.cpp b/gm/arcto.cpp index f28d86cbee..03942fe1cd 100644 --- a/gm/arcto.cpp +++ b/gm/arcto.cpp @@ -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); } diff --git a/gm/bigblurs.cpp b/gm/bigblurs.cpp index ff12b6bef0..6436c85322 100644 --- a/gm/bigblurs.cpp +++ b/gm/bigblurs.cpp @@ -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 diff --git a/gm/blurs.cpp b/gm/blurs.cpp index 3aef01776d..e6f69103f5 100644 --- a/gm/blurs.cpp +++ b/gm/blurs.cpp @@ -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; diff --git a/gm/circularclips.cpp b/gm/circularclips.cpp index 025b693888..b2138385f1 100644 --- a/gm/circularclips.cpp +++ b/gm/circularclips.cpp @@ -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); } diff --git a/gm/convex_all_line_paths.cpp b/gm/convex_all_line_paths.cpp index 2fa2adf047..1936dfc580 100644 --- a/gm/convex_all_line_paths.cpp +++ b/gm/convex_all_line_paths.cpp @@ -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 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, diff --git a/gm/convexpaths.cpp b/gm/convexpaths.cpp index a92508fdc8..0fa0e34e35 100644 --- a/gm/convexpaths.cpp +++ b/gm/convexpaths.cpp @@ -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 { diff --git a/gm/drawatlas.cpp b/gm/drawatlas.cpp index 132fd5b8c2..e349bbff9e 100644 --- a/gm/drawatlas.cpp +++ b/gm/drawatlas.cpp @@ -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(); diff --git a/gm/inversepaths.cpp b/gm/inversepaths.cpp index 07269836f2..7ddf088e6f 100644 --- a/gm/inversepaths.cpp +++ b/gm/inversepaths.cpp @@ -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; } diff --git a/gm/nested.cpp b/gm/nested.cpp index 859077f3f8..9c1370c569 100644 --- a/gm/nested.cpp +++ b/gm/nested.cpp @@ -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) { diff --git a/gm/pathcontourstart.cpp b/gm/pathcontourstart.cpp index 430e59bcff..7d3ff4842d 100644 --- a/gm/pathcontourstart.cpp +++ b/gm/pathcontourstart.cpp @@ -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) { diff --git a/gm/patheffects.cpp b/gm/patheffects.cpp index 33a6841ce6..37715f1b36 100644 --- a/gm/patheffects.cpp +++ b/gm/patheffects.cpp @@ -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++) { diff --git a/gm/pathinterior.cpp b/gm/pathinterior.cpp index b152f72f6e..8480b225cc 100644 --- a/gm/pathinterior.cpp +++ b/gm/pathinterior.cpp @@ -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) { diff --git a/gm/polygonoffset.cpp b/gm/polygonoffset.cpp index 9cdd9ea5a3..9f906ac829 100644 --- a/gm/polygonoffset.cpp +++ b/gm/polygonoffset.cpp @@ -23,12 +23,12 @@ #include #include -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* 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* 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 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, diff --git a/gm/strokefill.cpp b/gm/strokefill.cpp index 9b0bb04db8..0533024b9d 100644 --- a/gm/strokefill.cpp +++ b/gm/strokefill.cpp @@ -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); diff --git a/gm/strokes.cpp b/gm/strokes.cpp index a2e7bfd972..9b3b1a4638 100644 --- a/gm/strokes.cpp +++ b/gm/strokes.cpp @@ -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"); } diff --git a/gn/flutter_defines.gni b/gn/flutter_defines.gni index 97be7d8d66..4ab268c77c 100644 --- a/gn/flutter_defines.gni +++ b/gn/flutter_defines.gni @@ -13,6 +13,7 @@ flutter_defines = [ "SK_DISABLE_AAA", # API staging + "SK_SUPPORT_LEGACY_PATH_DIRECTION_ENUM", # Flutter doesn't deserialize anything. "SK_DISABLE_READBUFFER", diff --git a/include/core/SkPath.h b/include/core/SkPath.h index 8f69d0ec1d..da5bda1d34 100644 --- a/include/core/SkPath.h +++ b/include/core/SkPath.h @@ -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(SkPathDirection::kCW), kCCW_Direction = static_cast(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(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 fPathRef; int fLastMoveToIndex; - mutable std::atomic fConvexity; + mutable std::atomic fConvexity; // SkPathConvexityType mutable std::atomic 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; diff --git a/modules/canvaskit/canvaskit_bindings.cpp b/modules/canvaskit/canvaskit_bindings.cpp index 962538a028..fb5aed6a79 100644 --- a/modules/canvaskit/canvaskit_bindings.cpp +++ b/modules/canvaskit/canvaskit_bindings.cpp @@ -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(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); } diff --git a/modules/skottie/src/layers/ShapeLayer.cpp b/modules/skottie/src/layers/ShapeLayer.cpp index 7396696cda..97a96da9da 100644 --- a/modules/skottie/src/layers/ShapeLayer.cpp +++ b/modules/skottie/src/layers/ShapeLayer.cpp @@ -41,8 +41,8 @@ sk_sp AttachPathGeometry(const skjson::ObjectValue& jpath, sk_sp 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(rect_node); @@ -70,8 +70,8 @@ sk_sp AttachRRectGeometry(const skjson::ObjectValue& jrect, sk_sp 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(rect_node); diff --git a/modules/sksg/include/SkSGRect.h b/modules/sksg/include/SkSGRect.h index 29456a0439..fa39a8fe02 100644 --- a/modules/sksg/include/SkSGRect.h +++ b/modules/sksg/include/SkSGRect.h @@ -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(fDirection); + SkPathDirection getDirection() const { + return static_cast(fDirection); } - void setDirection(SkPath::Direction dir) { fDirection = SkTo(dir); } + void setDirection(SkPathDirection dir) { fDirection = SkTo(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(fDirection); + SkPathDirection getDirection() const { + return static_cast(fDirection); } - void setDirection(SkPath::Direction dir) { fDirection = SkTo(dir); } + void setDirection(SkPathDirection dir) { fDirection = SkTo(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; }; diff --git a/samplecode/SampleAndroidShadows.cpp b/samplecode/SampleAndroidShadows.cpp index 71eb22affb..a4518f2356 100644 --- a/samplecode/SampleAndroidShadows.cpp +++ b/samplecode/SampleAndroidShadows.cpp @@ -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); diff --git a/samplecode/SampleClock.cpp b/samplecode/SampleClock.cpp index a90ecf1663..f7332cec3c 100644 --- a/samplecode/SampleClock.cpp +++ b/samplecode/SampleClock.cpp @@ -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 diff --git a/samplecode/SampleQuadStroker.cpp b/samplecode/SampleQuadStroker.cpp index 72dfabc9dd..53bf5eb1fc 100644 --- a/samplecode/SampleQuadStroker.cpp +++ b/samplecode/SampleQuadStroker.cpp @@ -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); diff --git a/samplecode/SampleRegion.cpp b/samplecode/SampleRegion.cpp index 58ad5e020c..7c16c01166 100644 --- a/samplecode/SampleRegion.cpp +++ b/samplecode/SampleRegion.cpp @@ -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); diff --git a/samplecode/SampleSlides.cpp b/samplecode/SampleSlides.cpp index 09cb87cc90..d58f4f13a9 100644 --- a/samplecode/SampleSlides.cpp +++ b/samplecode/SampleSlides.cpp @@ -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++) { diff --git a/samplecode/SampleStrokePath.cpp b/samplecode/SampleStrokePath.cpp index 4963f97677..3ab8bf4184 100644 --- a/samplecode/SampleStrokePath.cpp +++ b/samplecode/SampleStrokePath.cpp @@ -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); diff --git a/src/c/sk_surface.cpp b/src/c/sk_surface.cpp index b3f203fc24..65fe20959c 100644 --- a/src/c/sk_surface.cpp +++ b/src/c/sk_surface.cpp @@ -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; } diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp index 0847ea5910..a79481c73b 100644 --- a/src/core/SkPath.cpp +++ b/src/core/SkPath.cpp @@ -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(¤tPoint); 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(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; diff --git a/src/core/SkPathMakers.h b/src/core/SkPathMakers.h index a4ef7e1215..8e668e5378 100644 --- a/src/core/SkPathMakers.h +++ b/src/core/SkPathMakers.h @@ -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 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(); diff --git a/src/core/SkPathPriv.h b/src/core/SkPathPriv.h index 0df94eb000..67b4b5f2d8 100644 --- a/src/core/SkPathPriv.h +++ b/src/core/SkPathPriv.h @@ -10,6 +10,11 @@ #include "include/core/SkPath.h" +static_assert(0 == static_cast(SkPathFillType::kWinding), "fill_type_mismatch"); +static_assert(1 == static_cast(SkPathFillType::kEvenOdd), "fill_type_mismatch"); +static_assert(2 == static_cast(SkPathFillType::kInverseWinding), "fill_type_mismatch"); +static_assert(3 == static_cast(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(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(fill) & 1); + } }; // Lightweight variant of SkPath::Iter that only returns segments (e.g. lines/conics). diff --git a/src/core/SkPath_serial.cpp b/src/core/SkPath_serial.cpp index 44fd146bac..5c94c04f0c 100644 --- a/src/core/SkPath_serial.cpp +++ b/src/core/SkPath_serial.cpp @@ -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; diff --git a/src/core/SkStroke.cpp b/src/core/SkStroke.cpp index a734efad84..1c32900a33 100644 --- a/src/core/SkStroke.cpp +++ b/src/core/SkStroke.cpp @@ -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(); diff --git a/src/core/SkStroke.h b/src/core/SkStroke.h index 66edf3d92f..b0458d3869 100644 --- a/src/core/SkStroke.h +++ b/src/core/SkStroke.h @@ -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; //////////////////////////////////////////////////////////////// diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp index 0a1ed18fdf..244b39b600 100644 --- a/src/gpu/GrRenderTargetContext.cpp +++ b/src/gpu/GrRenderTargetContext.cpp @@ -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, diff --git a/src/gpu/GrTestUtils.cpp b/src/gpu/GrTestUtils.cpp index 42aba5ef53..b348c78ce3 100644 --- a/src/gpu/GrTestUtils.cpp +++ b/src/gpu/GrTestUtils.cpp @@ -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()); } } diff --git a/src/gpu/geometry/GrShape.cpp b/src/gpu/geometry/GrShape.cpp index 4fc3472ffb..bb4f92b8ad 100644 --- a/src/gpu/geometry/GrShape.cpp +++ b/src/gpu/geometry/GrShape.cpp @@ -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]; diff --git a/src/gpu/geometry/GrShape.h b/src/gpu/geometry/GrShape.h index 37f38f8844..08146df153 100644 --- a/src/gpu/geometry/GrShape.h +++ b/src/gpu/geometry/GrShape.h @@ -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; diff --git a/src/gpu/ops/GrAAConvexTessellator.cpp b/src/gpu/ops/GrAAConvexTessellator.cpp index c345c333b6..86aa54ca30 100644 --- a/src/gpu/ops/GrAAConvexTessellator.cpp +++ b/src/gpu/ops/GrAAConvexTessellator.cpp @@ -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); diff --git a/src/pathops/SkPathOpsAsWinding.cpp b/src/pathops/SkPathOpsAsWinding.cpp index 3dfae2fd5a..b3d92a9eb9 100644 --- a/src/pathops/SkPathOpsAsWinding.cpp +++ b/src/pathops/SkPathOpsAsWinding.cpp @@ -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, diff --git a/src/pathops/SkPathOpsDebug.cpp b/src/pathops/SkPathOpsDebug.cpp index 7ee44deb9d..da4e76b750 100644 --- a/src/pathops/SkPathOpsDebug.cpp +++ b/src/pathops/SkPathOpsDebug.cpp @@ -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 rects; - SkTDArray directions; + SkTDArray 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; } diff --git a/src/pdf/SkPDFUtils.cpp b/src/pdf/SkPDFUtils.cpp index 9beedfb5ab..0564b0f36c 100644 --- a/src/pdf/SkPDFUtils.cpp +++ b/src/pdf/SkPDFUtils.cpp @@ -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); diff --git a/src/utils/SkDashPath.cpp b/src/utils/SkDashPath.cpp index 92e4bdbda8..f94df30b3e 100644 --- a/src/utils/SkDashPath.cpp +++ b/src/utils/SkDashPath.cpp @@ -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; diff --git a/src/utils/SkLua.cpp b/src/utils/SkLua.cpp index 03318bb282..2f1482e5cf 100644 --- a/src/utils/SkLua.cpp +++ b/src/utils/SkLua.cpp @@ -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(L, 1)->getConvexity(); + bool isConvex = get_obj(L, 1)->isConvex(); SkLua(L).pushBool(isConvex); return 1; } diff --git a/src/utils/SkParsePath.cpp b/src/utils/SkParsePath.cpp index 8c9469b98f..688daae33b 100644 --- a/src/utils/SkParsePath.cpp +++ b/src/utils/SkParsePath.cpp @@ -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; diff --git a/tests/DefaultPathRendererTest.cpp b/tests/DefaultPathRendererTest.cpp index 7b5f9032c0..c4498a2d41 100644 --- a/tests/DefaultPathRendererTest.cpp +++ b/tests/DefaultPathRendererTest.cpp @@ -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; } diff --git a/tests/GpuDrawPathTest.cpp b/tests/GpuDrawPathTest.cpp index 22fecd7a58..5431aaa39c 100644 --- a/tests/GpuDrawPathTest.cpp +++ b/tests/GpuDrawPathTest.cpp @@ -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); diff --git a/tests/GrShapeTest.cpp b/tests/GrShapeTest.cpp index 548bd0423f..44d43be631 100644 --- a/tests/GrShapeTest.cpp +++ b/tests/GrShapeTest.cpp @@ -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