From 3872c989512c203a3966fd2ab40251c6af581750 Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Sat, 29 Aug 2020 17:46:51 -0400 Subject: [PATCH] Move convexity enum out of public Also, move first-direction into SkPathRef.h so it can be referenced by name in SkPath (instead of using uint8_t) No functional change expected. Change-Id: Ica4a8357a8156fd9a516118f23599a965b0fdd47 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/313980 Reviewed-by: Mike Reed Commit-Queue: Mike Reed --- bench/PathBench.cpp | 2 +- gm/aaa.cpp | 3 +- gm/convex_all_line_paths.cpp | 2 +- gm/strokefill.cpp | 8 +- include/core/SkPath.h | 35 ++-- include/core/SkPathBuilder.h | 4 +- include/core/SkPathTypes.h | 6 - include/private/SkPathRef.h | 14 +- src/core/SkPath.cpp | 156 +++++++++--------- src/core/SkPathBuilder.cpp | 18 +-- src/core/SkPathPriv.h | 42 +++-- src/core/SkPathRef.cpp | 2 +- src/core/SkPathView.h | 19 +-- src/core/SkPath_serial.cpp | 6 +- src/core/SkStroke.cpp | 2 +- src/effects/SkOpPathEffect.cpp | 12 +- src/gpu/effects/GrConvexPolyEffect.cpp | 4 +- src/gpu/geometry/GrPathUtils.cpp | 14 +- src/gpu/geometry/GrPathUtils.h | 2 +- src/gpu/geometry/GrStyledShape.h | 3 +- src/gpu/ops/GrAAConvexPathRenderer.cpp | 10 +- src/pathops/SkOpBuilder.cpp | 10 +- src/utils/SkDashPath.cpp | 2 +- tests/PathBuilderTest.cpp | 4 +- tests/PathTest.cpp | 212 ++++++++++++------------- 25 files changed, 297 insertions(+), 295 deletions(-) diff --git a/bench/PathBench.cpp b/bench/PathBench.cpp index 10d24b438e..6ae31520e6 100644 --- a/bench/PathBench.cpp +++ b/bench/PathBench.cpp @@ -1243,7 +1243,7 @@ public: fPath.addRRect(SkRRect::MakeRectXY(r, w/8.0f, h/8.0f)); if (forceConcave) { - SkPathPriv::SetConvexityType(fPath, SkPathConvexityType::kConcave); + SkPathPriv::SetConvexity(fPath, SkPathConvexity::kConcave); SkASSERT(!fPath.isConvex()); } else { SkASSERT(fPath.isConvex()); diff --git a/gm/aaa.cpp b/gm/aaa.cpp index edb77e97f3..67fe3538a0 100644 --- a/gm/aaa.cpp +++ b/gm/aaa.cpp @@ -12,6 +12,7 @@ #include "include/core/SkPathBuilder.h" #include "include/core/SkScalar.h" #include "include/private/SkFloatBits.h" +#include "include/private/SkPathRef.h" #include "src/core/SkPathPriv.h" #define W 800 @@ -64,7 +65,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. - SkPathPriv::SetConvexityType(&path, SkPathConvexityType::kConvex); + SkPathPriv::SetConvexity(&path, SkPathConvexity::kConvex); canvas->drawPath(path.detach(), p); // skbug.com/7573 diff --git a/gm/convex_all_line_paths.cpp b/gm/convex_all_line_paths.cpp index 2568c61684..3273bdac05 100644 --- a/gm/convex_all_line_paths.cpp +++ b/gm/convex_all_line_paths.cpp @@ -258,7 +258,7 @@ protected: // of the GMs rows. SkASSERT(path.isConvex()); SkASSERT(SkPath::kLine_SegmentMask == path.getSegmentMasks()); - SkPathPriv::FirstDirection actualDir; + SkPathFirstDirection actualDir; SkASSERT(SkPathPriv::CheapComputeFirstDirection(path, &actualDir)); SkASSERT(SkPathPriv::AsFirstDirection(dir) == actualDir); SkRect bounds = path.getBounds(); diff --git a/gm/strokefill.cpp b/gm/strokefill.cpp index 0357ef2ffb..f034ce8042 100644 --- a/gm/strokefill.cpp +++ b/gm/strokefill.cpp @@ -303,12 +303,12 @@ DEF_SIMPLE_GM_BG_NAME(strokefill, canvas, 640, 480, SK_ColorWHITE, path2.reset(); path2.addCircle(x + SkIntToScalar(240), y + SkIntToScalar(200), SkIntToScalar(50), SkPathDirection::kCCW); canvas->drawPath(path2, paint); - SkASSERT(SkPathPriv::CheapIsFirstDirection(path2, SkPathPriv::kCCW_FirstDirection)); + SkASSERT(SkPathPriv::CheapIsFirstDirection(path2, SkPathFirstDirection::kCCW)); path2.reset(); SkASSERT(!SkPathPriv::CheapComputeFirstDirection(path2, nullptr)); path2.addCircle(x + SkIntToScalar(360), y + SkIntToScalar(200), SkIntToScalar(50), SkPathDirection::kCW); - SkASSERT(SkPathPriv::CheapIsFirstDirection(path2, SkPathPriv::kCW_FirstDirection)); + SkASSERT(SkPathPriv::CheapIsFirstDirection(path2, SkPathFirstDirection::kCW)); canvas->drawPath(path2, paint); SkRect r = SkRect::MakeXYWH(x - SkIntToScalar(50), y + SkIntToScalar(280), @@ -334,7 +334,7 @@ DEF_SIMPLE_GM_BG_NAME(strokefill, canvas, 640, 480, SK_ColorWHITE, path4.reset(); SkASSERT(!SkPathPriv::CheapComputeFirstDirection(path4, nullptr)); path4.addRect(r, SkPathDirection::kCCW); - SkASSERT(SkPathPriv::CheapIsFirstDirection(path4, SkPathPriv::kCCW_FirstDirection)); + SkASSERT(SkPathPriv::CheapIsFirstDirection(path4, SkPathFirstDirection::kCCW)); path4.moveTo(0, 0); // test for crbug.com/247770 canvas->drawPath(path4, paint); @@ -343,7 +343,7 @@ DEF_SIMPLE_GM_BG_NAME(strokefill, canvas, 640, 480, SK_ColorWHITE, path4.reset(); SkASSERT(!SkPathPriv::CheapComputeFirstDirection(path4, nullptr)); path4.addRect(r, SkPathDirection::kCW); - SkASSERT(SkPathPriv::CheapIsFirstDirection(path4, SkPathPriv::kCW_FirstDirection)); + SkASSERT(SkPathPriv::CheapIsFirstDirection(path4, SkPathFirstDirection::kCW)); path4.moveTo(0, 0); // test for crbug.com/247770 canvas->drawPath(path4, paint); } diff --git a/include/core/SkPath.h b/include/core/SkPath.h index 7cb80c9f4b..d826b21699 100644 --- a/include/core/SkPath.h +++ b/include/core/SkPath.h @@ -227,7 +227,7 @@ public: /** Returns true if the path is convex. If necessary, it will first compute the convexity. */ bool isConvex() const { - return SkPathConvexityType::kConvex == this->getConvexityType(); + return SkPathConvexity::kConvex == this->getConvexity(); } /** Returns true if this path is recognized as an oval or circle. @@ -1800,13 +1800,13 @@ public: bool isValid() const { return this->isValidImpl() && fPathRef->isValid(); } private: - SkPath(sk_sp, SkPathFillType, bool isVolatile, SkPathConvexityType, - uint8_t firstDirection); + SkPath(sk_sp, SkPathFillType, bool isVolatile, SkPathConvexity, + SkPathFirstDirection firstDirection); sk_sp fPathRef; int fLastMoveToIndex; - mutable std::atomic fConvexity; // SkPathConvexityType - mutable std::atomic fFirstDirection; // really an SkPathPriv::FirstDirection + mutable std::atomic fConvexity; // SkPathConvexity + mutable std::atomic fFirstDirection; // SkPathFirstDirection uint8_t fFillType : 2; uint8_t fIsVolatile : 1; @@ -1846,7 +1846,7 @@ private: inline bool hasOnlyMoveTos() const; - SkPathConvexityType computeConvexity() const; + SkPathConvexity computeConvexity() const; /** Asserts if SkPath data is inconsistent. Debugging check intended for internal use only. @@ -1880,31 +1880,32 @@ private: // Bottlenecks for working with fConvexity and fFirstDirection. // Notice the setters are const... these are mutable atomic fields. - void setConvexityType(SkPathConvexityType) const; - void setFirstDirection(uint8_t) const; - uint8_t getFirstDirection() const; + void setConvexity(SkPathConvexity) const; + + void setFirstDirection(SkPathFirstDirection) const; + SkPathFirstDirection getFirstDirection() const; /** 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) { + SkPathConvexity getConvexity() const { + SkPathConvexity convexity = this->getConvexityOrUnknown(); + if (convexity == SkPathConvexity::kUnknown) { convexity = this->computeConvexity(); } - SkASSERT(convexity != SkPathConvexityType::kUnknown); + SkASSERT(convexity != SkPathConvexity::kUnknown); return convexity; } - SkPathConvexityType getConvexityTypeOrUnknown() const { - return (SkPathConvexityType)fConvexity.load(std::memory_order_relaxed); + SkPathConvexity getConvexityOrUnknown() const { + return (SkPathConvexity)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() + * getConvexityOrUnknown() is called. If you pass kUnknown, then if getContexityType() * is called, the real convexity will be computed. * * example: https://fiddle.skia.org/c/@Path_setConvexity */ - void setConvexityType(SkPathConvexityType convexity); + void setConvexity(SkPathConvexity convexity); friend class SkAutoPathBoundsUpdate; friend class SkAutoDisableOvalCheck; diff --git a/include/core/SkPathBuilder.h b/include/core/SkPathBuilder.h index 2fa87aa75b..7994195772 100644 --- a/include/core/SkPathBuilder.h +++ b/include/core/SkPathBuilder.h @@ -230,7 +230,7 @@ private: bool fIsACCW = false; // tracks direction iff fIsA is not unknown // for testing - SkPathConvexityType fOverrideConvexity = SkPathConvexityType::kUnknown; + SkPathConvexity fOverrideConvexity = SkPathConvexity::kUnknown; int countVerbs() const { return fVerbs.count(); } @@ -247,7 +247,7 @@ private: SkPathBuilder& privateReverseAddPath(const SkPath&); // For testing - void privateSetConvexityType(SkPathConvexityType c) { fOverrideConvexity = c; } + void privateSetConvexity(SkPathConvexity c) { fOverrideConvexity = c; } friend class SkPathPriv; }; diff --git a/include/core/SkPathTypes.h b/include/core/SkPathTypes.h index daa68f886a..f589ea46ce 100644 --- a/include/core/SkPathTypes.h +++ b/include/core/SkPathTypes.h @@ -33,12 +33,6 @@ static inline SkPathFillType SkPathFillType_ConvertToNonInverse(SkPathFillType f return static_cast(static_cast(ft) & 1); } -enum class SkPathConvexityType { - kUnknown, - kConvex, - kConcave -}; - enum class SkPathDirection { /** clockwise direction for adding closed contours */ kCW, diff --git a/include/private/SkPathRef.h b/include/private/SkPathRef.h index 871787ffd7..96d3a49aca 100644 --- a/include/private/SkPathRef.h +++ b/include/private/SkPathRef.h @@ -28,6 +28,18 @@ struct SkPathView; class SkRBuffer; class SkWBuffer; +enum class SkPathConvexity { + kConvex, + kConcave, + kUnknown, +}; + +enum class SkPathFirstDirection { + kCW, // == SkPathDirection::kCW + kCCW, // == SkPathDirection::kCCW + kUnknown, +}; + /** * Holds the path verbs and points. It is versioned by a generation ID. None of its public methods * modify the contents. To modify or append to the verbs/points wrap the SkPathRef in an @@ -338,7 +350,7 @@ public: bool isValid() const; SkDEBUGCODE(void validate() const { SkASSERT(this->isValid()); } ) - SkPathView view(SkPathFillType, SkPathConvexityType) const; + SkPathView view(SkPathFillType, SkPathConvexity) const; private: enum SerializationOffsets { diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp index dbc27c0457..be3c08dc45 100644 --- a/src/core/SkPath.cpp +++ b/src/core/SkPath.cpp @@ -67,7 +67,7 @@ static bool is_degenerate(const SkPath& path) { class SkAutoDisableDirectionCheck { public: SkAutoDisableDirectionCheck(SkPath* path) : fPath(path) { - fSaved = static_cast(fPath->getFirstDirection()); + fSaved = static_cast(fPath->getFirstDirection()); } ~SkAutoDisableDirectionCheck() { @@ -75,8 +75,8 @@ public: } private: - SkPath* fPath; - SkPathPriv::FirstDirection fSaved; + SkPath* fPath; + SkPathFirstDirection fSaved; }; /* This class's constructor/destructor bracket a path editing operation. It is @@ -107,8 +107,8 @@ public: } ~SkAutoPathBoundsUpdate() { - fPath->setConvexityType(fDegenerate ? SkPathConvexityType::kConvex - : SkPathConvexityType::kUnknown); + fPath->setConvexity(fDegenerate ? SkPathConvexity::kConvex + : SkPathConvexity::kUnknown); if ((fEmpty || fHasValidBounds) && fRect.isFinite()) { fPath->setBounds(fRect); } @@ -147,12 +147,12 @@ SkPath::SkPath() fIsVolatile = false; } -SkPath::SkPath(sk_sp pr, SkPathFillType ft, bool isVolatile, SkPathConvexityType ct, - uint8_t firstDirection) +SkPath::SkPath(sk_sp pr, SkPathFillType ft, bool isVolatile, SkPathConvexity ct, + SkPathFirstDirection firstDirection) : fPathRef(std::move(pr)) , fLastMoveToIndex(INITIAL_LASTMOVETOINDEX_VALUE) , fConvexity((uint8_t)ct) - , fFirstDirection(firstDirection) + , fFirstDirection((uint8_t)firstDirection) , fFillType((unsigned)ft) , fIsVolatile(isVolatile) {} @@ -161,8 +161,8 @@ void SkPath::resetFields() { //fPathRef is assumed to have been emptied by the caller. fLastMoveToIndex = INITIAL_LASTMOVETOINDEX_VALUE; fFillType = SkToU8(SkPathFillType::kWinding); - this->setConvexityType(SkPathConvexityType::kUnknown); - this->setFirstDirection(SkPathPriv::kUnknown_FirstDirection); + this->setConvexity(SkPathConvexity::kUnknown); + this->setFirstDirection(SkPathFirstDirection::kUnknown); // We don't touch Android's fSourcePath. It's used to track texture garbage collection, so we // don't want to muck with it if it's been set to something non-nullptr. @@ -196,7 +196,7 @@ void SkPath::copyFields(const SkPath& that) { fIsVolatile = that.fIsVolatile; // Non-atomic assignment of atomic values. - this->setConvexityType(that.getConvexityTypeOrUnknown()); + this->setConvexity(that.getConvexityOrUnknown()); this->setFirstDirection(that.getFirstDirection()); } @@ -221,18 +221,18 @@ void SkPath::swap(SkPath& that) { that.fIsVolatile = iv; // Non-atomic swaps of atomic values. - SkPathConvexityType c = this->getConvexityTypeOrUnknown(); - this->setConvexityType(that.getConvexityTypeOrUnknown()); - that.setConvexityType(c); + SkPathConvexity c = this->getConvexityOrUnknown(); + this->setConvexity(that.getConvexityOrUnknown()); + that.setConvexity(c); - uint8_t fd = this->getFirstDirection(); + SkPathFirstDirection fd = this->getFirstDirection(); this->setFirstDirection(that.getFirstDirection()); that.setFirstDirection(fd); } } SkPathView SkPath::view() const { - return fPathRef->view(this->getFillType(), this->getConvexityType()); + return fPathRef->view(this->getFillType(), this->getConvexity()); } /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -261,10 +261,10 @@ bool SkPath::interpolate(const SkPath& ending, SkScalar weight, SkPath* out) con static inline bool check_edge_against_rect(const SkPoint& p0, const SkPoint& p1, const SkRect& rect, - SkPathPriv::FirstDirection dir) { + SkPathFirstDirection dir) { const SkPoint* edgeBegin; SkVector v; - if (SkPathPriv::kCW_FirstDirection == dir) { + if (SkPathFirstDirection::kCW == dir) { v = p1 - p0; edgeBegin = &p0; } else { @@ -290,7 +290,7 @@ bool SkPath::conservativelyContainsRect(const SkRect& rect) const { return false; } - SkPathPriv::FirstDirection direction; + SkPathFirstDirection direction; if (!SkPathPriv::CheapComputeFirstDirection(*this, &direction)) { return false; } @@ -574,27 +574,27 @@ void SkPath::setLastPt(SkScalar x, SkScalar y) { } // This is the public-facing non-const setConvexity(). -void SkPath::setConvexityType(SkPathConvexityType c) { +void SkPath::setConvexity(SkPathConvexity c) { fConvexity.store((uint8_t)c, std::memory_order_relaxed); } // Const hooks for working with fConvexity and fFirstDirection from const methods. -void SkPath::setConvexityType(SkPathConvexityType c) const { +void SkPath::setConvexity(SkPathConvexity 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); +void SkPath::setFirstDirection(SkPathFirstDirection d) const { + fFirstDirection.store((uint8_t)d, std::memory_order_relaxed); } -uint8_t SkPath::getFirstDirection() const { - return fFirstDirection.load(std::memory_order_relaxed); +SkPathFirstDirection SkPath::getFirstDirection() const { + return (SkPathFirstDirection)fFirstDirection.load(std::memory_order_relaxed); } ////////////////////////////////////////////////////////////////////////////// // Construction methods SkPath& SkPath::dirtyAfterEdit() { - this->setConvexityType(SkPathConvexityType::kUnknown); - this->setFirstDirection(SkPathPriv::kUnknown_FirstDirection); + this->setConvexity(SkPathConvexity::kUnknown); + this->setFirstDirection(SkPathFirstDirection::kUnknown); return *this; } @@ -786,8 +786,8 @@ SkPath& SkPath::addRect(SkScalar left, SkScalar top, SkScalar right, SkPath& SkPath::addRect(const SkRect &rect, SkPathDirection dir, unsigned startIndex) { assert_known_direction(dir); - this->setFirstDirection(this->hasOnlyMoveTos() ? (SkPathPriv::FirstDirection)dir - : SkPathPriv::kUnknown_FirstDirection); + this->setFirstDirection(this->hasOnlyMoveTos() ? (SkPathFirstDirection)dir + : SkPathFirstDirection::kUnknown); SkAutoDisableDirectionCheck addc(this); SkAutoPathBoundsUpdate apbu(this, rect); @@ -938,8 +938,8 @@ SkPath& SkPath::addRRect(const SkRRect &rrect, SkPathDirection dir, unsigned sta // degenerate(oval) => line points are collapsing this->addOval(bounds, dir, startIndex / 2); } else { - this->setFirstDirection(this->hasOnlyMoveTos() ? (SkPathPriv::FirstDirection)dir - : SkPathPriv::kUnknown_FirstDirection); + this->setFirstDirection(this->hasOnlyMoveTos() ? (SkPathFirstDirection)dir + : SkPathFirstDirection::kUnknown); SkAutoPathBoundsUpdate apbu(this, bounds); SkAutoDisableDirectionCheck addc(this); @@ -1045,9 +1045,9 @@ SkPath& SkPath::addOval(const SkRect &oval, SkPathDirection dir, unsigned startP */ bool isOval = hasOnlyMoveTos(); if (isOval) { - this->setFirstDirection((SkPathPriv::FirstDirection)dir); + this->setFirstDirection((SkPathFirstDirection)dir); } else { - this->setFirstDirection(SkPathPriv::kUnknown_FirstDirection); + this->setFirstDirection(SkPathFirstDirection::kUnknown); } SkAutoDisableDirectionCheck addc(this); @@ -1617,9 +1617,9 @@ void SkPath::transform(const SkMatrix& matrix, SkPath* dst, SkApplyPerspectiveCl dst->swap(tmp); SkPathRef::Editor ed(&dst->fPathRef); matrix.mapPoints(ed.writablePoints(), ed.pathRef()->countPoints()); - dst->setFirstDirection(SkPathPriv::kUnknown_FirstDirection); + dst->setFirstDirection(SkPathFirstDirection::kUnknown); } else { - SkPathConvexityType convexity = this->getConvexityTypeOrUnknown(); + SkPathConvexity convexity = this->getConvexityOrUnknown(); SkPathRef::CreateTransformedCopy(&dst->fPathRef, *fPathRef, matrix); @@ -1639,13 +1639,13 @@ void SkPath::transform(const SkMatrix& matrix, SkPath* dst, SkApplyPerspectiveCl // check, and keep convex paths marked as such after a general transform... // if (matrix.isScaleTranslate() && SkPathPriv::IsAxisAligned(*this)) { - dst->setConvexityType(convexity); + dst->setConvexity(convexity); } else { - dst->setConvexityType(SkPathConvexityType::kUnknown); + dst->setConvexity(SkPathConvexity::kUnknown); } - if (this->getFirstDirection() == SkPathPriv::kUnknown_FirstDirection) { - dst->setFirstDirection(SkPathPriv::kUnknown_FirstDirection); + if (this->getFirstDirection() == SkPathFirstDirection::kUnknown) { + dst->setFirstDirection(SkPathFirstDirection::kUnknown); } else { SkScalar det2x2 = matrix.get(SkMatrix::kMScaleX) * matrix.get(SkMatrix::kMScaleY) - @@ -1653,11 +1653,11 @@ void SkPath::transform(const SkMatrix& matrix, SkPath* dst, SkApplyPerspectiveCl if (det2x2 < 0) { dst->setFirstDirection( SkPathPriv::OppositeFirstDirection( - (SkPathPriv::FirstDirection)this->getFirstDirection())); + (SkPathFirstDirection)this->getFirstDirection())); } else if (det2x2 > 0) { dst->setFirstDirection(this->getFirstDirection()); } else { - dst->setFirstDirection(SkPathPriv::kUnknown_FirstDirection); + dst->setFirstDirection(SkPathFirstDirection::kUnknown); } } @@ -2040,7 +2040,7 @@ static bool almost_equal(SkScalar compA, SkScalar compB) { struct Convexicator { /** The direction returned is only valid if the path is determined convex */ - SkPathPriv::FirstDirection getFirstDirection() const { return fFirstDirection; } + SkPathFirstDirection getFirstDirection() const { return fFirstDirection; } void setMovePt(const SkPoint& pt) { fPriorPt = fLastPt = fCurrPt = pt; @@ -2062,7 +2062,7 @@ struct Convexicator { return true; } - static SkPathConvexityType BySign(const SkPoint points[], int count) { + static SkPathConvexity BySign(const SkPoint points[], int count) { const SkPoint* last = points + count; SkPoint currPt = *points++; SkPoint firstPt = currPt; @@ -2076,14 +2076,14 @@ struct Convexicator { if (!vec.isZero()) { // give up if vector construction failed if (!vec.isFinite()) { - return SkPathConvexityType::kUnknown; + return SkPathConvexity::kUnknown; } int sx = sign(vec.fX); int sy = sign(vec.fY); dxes += (sx != lastSx); dyes += (sy != lastSy); if (dxes > 3 || dyes > 3) { - return SkPathConvexityType::kConcave; + return SkPathConvexity::kConcave; } lastSx = sx; lastSy = sy; @@ -2095,7 +2095,7 @@ struct Convexicator { } points = &firstPt; } - return SkPathConvexityType::kConvex; // that is, it may be convex, don't know yet + return SkPathConvexity::kConvex; // that is, it may be convex, don't know yet } bool close() { @@ -2138,10 +2138,10 @@ private: case kRight_DirChange: if (kInvalid_DirChange == fExpectedDir) { fExpectedDir = dir; - fFirstDirection = (kRight_DirChange == dir) ? SkPathPriv::kCW_FirstDirection - : SkPathPriv::kCCW_FirstDirection; + fFirstDirection = (kRight_DirChange == dir) ? SkPathFirstDirection::kCW + : SkPathFirstDirection::kCCW; } else if (dir != fExpectedDir) { - fFirstDirection = SkPathPriv::kUnknown_FirstDirection; + fFirstDirection = SkPathFirstDirection::kUnknown; return false; } fLastVec = curVec; @@ -2170,24 +2170,24 @@ private: SkPoint fCurrPt {0, 0}; SkVector fLastVec {0, 0}; DirChange fExpectedDir { kInvalid_DirChange }; - SkPathPriv::FirstDirection fFirstDirection { SkPathPriv::kUnknown_FirstDirection }; + SkPathFirstDirection fFirstDirection { SkPathFirstDirection::kUnknown }; int fReversals { 0 }; bool fIsFinite { true }; }; -SkPathConvexityType SkPath::computeConvexity() const { +SkPathConvexity SkPath::computeConvexity() const { SkPoint pts[4]; SkPath::Verb verb; SkPath::Iter iter(*this, true); - auto setComputedConvexity = [=](SkPathConvexityType convexity){ - SkASSERT(SkPathConvexityType::kUnknown != convexity); - this->setConvexityType(convexity); + auto setComputedConvexity = [=](SkPathConvexity convexity){ + SkASSERT(SkPathConvexity::kUnknown != convexity); + this->setConvexity(convexity); return convexity; }; auto setFail = [=](){ - return setComputedConvexity(SkPathConvexityType::kConcave); + return setComputedConvexity(SkPathConvexity::kConcave); }; // Check to see if path changes direction more than three times as quick concave test @@ -2204,9 +2204,9 @@ SkPathConvexityType SkPath::computeConvexity() const { ++points; } --points; - SkPathConvexityType convexity = Convexicator::BySign(points, (int) (last - points)); - if (SkPathConvexityType::kConvex != convexity) { - return setComputedConvexity(SkPathConvexityType::kConcave); + SkPathConvexity convexity = Convexicator::BySign(points, (int) (last - points)); + if (SkPathConvexity::kConvex != convexity) { + return setComputedConvexity(SkPathConvexity::kConcave); } iter.setPath(*this, true); } else if (!this->isFinite()) { @@ -2221,7 +2221,7 @@ SkPathConvexityType SkPath::computeConvexity() const { switch (verb) { case kMove_Verb: if (++contourCount > 1) { - return setComputedConvexity(SkPathConvexityType::kConcave); + return setComputedConvexity(SkPathConvexity::kConcave); } state.setMovePt(pts[0]); count = 0; @@ -2245,7 +2245,7 @@ SkPathConvexityType SkPath::computeConvexity() const { break; default: SkDEBUGFAIL("bad verb"); - return setComputedConvexity(SkPathConvexityType::kConcave); + return setComputedConvexity(SkPathConvexity::kConcave); } for (int i = 1; i <= count; i++) { if (!state.addPt(pts[i])) { @@ -2254,20 +2254,20 @@ SkPathConvexityType SkPath::computeConvexity() const { } } - if (this->getFirstDirection() == SkPathPriv::kUnknown_FirstDirection) { - if (state.getFirstDirection() == SkPathPriv::kUnknown_FirstDirection + if (this->getFirstDirection() == SkPathFirstDirection::kUnknown) { + if (state.getFirstDirection() == SkPathFirstDirection::kUnknown && !this->getBounds().isEmpty()) { return setComputedConvexity(state.reversals() < 3 ? - SkPathConvexityType::kConvex : SkPathConvexityType::kConcave); + SkPathConvexity::kConvex : SkPathConvexity::kConcave); } this->setFirstDirection(state.getFirstDirection()); } - return setComputedConvexity(SkPathConvexityType::kConvex); + return setComputedConvexity(SkPathConvexity::kConvex); } bool SkPathPriv::IsConvex(const SkPoint points[], int count) { - SkPathConvexityType convexity = Convexicator::BySign(points, count); - if (SkPathConvexityType::kConvex != convexity) { + SkPathConvexity convexity = Convexicator::BySign(points, count); + if (SkPathConvexity::kConvex != convexity) { return false; } Convexicator state; @@ -2283,7 +2283,7 @@ bool SkPathPriv::IsConvex(const SkPoint points[], int count) { if (!state.close()) { return false; } - return state.getFirstDirection() != SkPathPriv::kUnknown_FirstDirection + return state.getFirstDirection() != SkPathFirstDirection::kUnknown || state.reversals() < 3; } @@ -2443,8 +2443,8 @@ static int find_min_max_x_at_y(const SkPoint pts[], int index, int n, return minIndex; } -static void crossToDir(SkScalar cross, SkPathPriv::FirstDirection* dir) { - *dir = cross > 0 ? SkPathPriv::kCW_FirstDirection : SkPathPriv::kCCW_FirstDirection; +static void crossToDir(SkScalar cross, SkPathFirstDirection* dir) { + *dir = cross > 0 ? SkPathFirstDirection::kCW : SkPathFirstDirection::kCCW; } /* @@ -2455,18 +2455,18 @@ static void crossToDir(SkScalar cross, SkPathPriv::FirstDirection* dir) { * that is outer most (or at least has the global y-max) before we can consider * its cross product. */ -bool SkPathPriv::CheapComputeFirstDirection(const SkPath& path, FirstDirection* dir) { +bool SkPathPriv::CheapComputeFirstDirection(const SkPath& path, SkPathFirstDirection* dir) { auto d = path.getFirstDirection(); - if (d != kUnknown_FirstDirection) { - *dir = static_cast(d); + if (d != SkPathFirstDirection::kUnknown) { + *dir = d; return true; } // We don't want to pay the cost for computing convexity if it is unknown, // so we call getConvexityOrUnknown() instead of isConvex(). - if (path.getConvexityTypeOrUnknown() == SkPathConvexityType::kConvex) { - SkASSERT(path.getFirstDirection() == kUnknown_FirstDirection); - *dir = static_cast(path.getFirstDirection()); + if (path.getConvexityOrUnknown() == SkPathConvexity::kConvex) { + SkASSERT(path.getFirstDirection() == SkPathFirstDirection::kUnknown); + *dir = path.getFirstDirection(); return false; } @@ -3179,7 +3179,7 @@ void SkPathPriv::CreateDrawArcPath(SkPath* path, const SkRect& oval, SkScalar st path->moveTo(oval.centerX(), oval.centerY()); } auto firstDir = - sweepAngle > 0 ? SkPathPriv::kCW_FirstDirection : SkPathPriv::kCCW_FirstDirection; + sweepAngle > 0 ? SkPathFirstDirection::kCW : SkPathFirstDirection::kCCW; bool convex = DrawArcIsConvex(sweepAngle, useCenter, isFillNoPathEffect); // Arc to mods at 360 and drawArc is not supposed to. bool forceMoveTo = !useCenter; @@ -3203,7 +3203,7 @@ void SkPathPriv::CreateDrawArcPath(SkPath* path, const SkRect& oval, SkScalar st if (useCenter) { path->close(); } - path->setConvexityType(convex ? SkPathConvexityType::kConvex : SkPathConvexityType::kConcave); + path->setConvexity(convex ? SkPathConvexity::kConvex : SkPathConvexity::kConcave); path->setFirstDirection(firstDir); } @@ -3385,7 +3385,7 @@ SkPath SkPath::Make(const SkPoint pts[], int pointCount, SkTDArray(vbs, verbCount), SkTDArray(ws, info.weights), info.segmentMask)), - ft, isVolatile, SkPathConvexityType::kUnknown, SkPathPriv::kUnknown_FirstDirection); + ft, isVolatile, SkPathConvexity::kUnknown, SkPathFirstDirection::kUnknown); } SkPath SkPath::Rect(const SkRect& r, SkPathDirection dir, unsigned startIndex) { diff --git a/src/core/SkPathBuilder.cpp b/src/core/SkPathBuilder.cpp index ad7026f6ec..9d442dbab3 100644 --- a/src/core/SkPathBuilder.cpp +++ b/src/core/SkPathBuilder.cpp @@ -35,7 +35,7 @@ SkPathBuilder& SkPathBuilder::reset() { fNeedsMoveVerb = true; // testing - fOverrideConvexity = SkPathConvexityType::kUnknown; + fOverrideConvexity = SkPathConvexity::kUnknown; return *this; } @@ -49,7 +49,7 @@ void SkPathBuilder::incReserve(int extraPtCount, int extraVbCount) { * Some old behavior in SkPath -- should we keep it? * * After each edit (i.e. adding a verb) - this->setConvexityType(SkPathConvexityType::kUnknown); + this->setConvexityType(SkPathConvexity::kUnknown); this->setFirstDirection(SkPathPriv::kUnknown_FirstDirection); */ @@ -150,24 +150,24 @@ SkPathBuilder& SkPathBuilder::rCubicTo(SkPoint p1, SkPoint p2, SkPoint p3) { /////////////////////////////////////////////////////////////////////////////////////////// SkPath SkPathBuilder::make(sk_sp pr) const { - auto convexity = SkPathConvexityType::kUnknown; - SkPathPriv::FirstDirection dir = SkPathPriv::kUnknown_FirstDirection; + auto convexity = SkPathConvexity::kUnknown; + SkPathFirstDirection dir = SkPathFirstDirection::kUnknown; switch (fIsA) { case kIsA_Oval: pr->setIsOval( true, fIsACCW, fIsAStart); - convexity = SkPathConvexityType::kConvex; - dir = fIsACCW ? SkPathPriv::kCCW_FirstDirection : SkPathPriv::kCW_FirstDirection; + convexity = SkPathConvexity::kConvex; + dir = fIsACCW ? SkPathFirstDirection::kCCW : SkPathFirstDirection::kCW; break; case kIsA_RRect: pr->setIsRRect(true, fIsACCW, fIsAStart); - convexity = SkPathConvexityType::kConvex; - dir = fIsACCW ? SkPathPriv::kCCW_FirstDirection : SkPathPriv::kCW_FirstDirection; + convexity = SkPathConvexity::kConvex; + dir = fIsACCW ? SkPathFirstDirection::kCCW : SkPathFirstDirection::kCW; break; default: break; } - if (fOverrideConvexity != SkPathConvexityType::kUnknown) { + if (fOverrideConvexity != SkPathConvexity::kUnknown) { convexity = fOverrideConvexity; } diff --git a/src/core/SkPathPriv.h b/src/core/SkPathPriv.h index 9258ce51e9..6b9e68524c 100644 --- a/src/core/SkPathPriv.h +++ b/src/core/SkPathPriv.h @@ -27,26 +27,20 @@ public: static constexpr SkScalar kW0PlaneDistance = 0.05f; - enum FirstDirection : int { - kCW_FirstDirection, // == SkPathDirection::kCW - kCCW_FirstDirection, // == SkPathDirection::kCCW - kUnknown_FirstDirection, - }; - - static FirstDirection AsFirstDirection(SkPathDirection dir) { + static SkPathFirstDirection AsFirstDirection(SkPathDirection dir) { // since we agree numerically for the values in Direction, we can just cast. - return (FirstDirection)dir; + return (SkPathFirstDirection)dir; } /** * Return the opposite of the specified direction. kUnknown is its own * opposite. */ - static FirstDirection OppositeFirstDirection(FirstDirection dir) { - static const FirstDirection gOppositeDir[] = { - kCCW_FirstDirection, kCW_FirstDirection, kUnknown_FirstDirection, + static SkPathFirstDirection OppositeFirstDirection(SkPathFirstDirection dir) { + static const SkPathFirstDirection gOppositeDir[] = { + SkPathFirstDirection::kCCW, SkPathFirstDirection::kCW, SkPathFirstDirection::kUnknown, }; - return gOppositeDir[dir]; + return gOppositeDir[(unsigned)dir]; } /** @@ -56,7 +50,7 @@ public: * the dir parameter. If the direction was determined, it is cached to make * subsequent calls return quickly. */ - static bool CheapComputeFirstDirection(const SkPath&, FirstDirection* dir); + static bool CheapComputeFirstDirection(const SkPath&, SkPathFirstDirection* dir); /** * Returns true if the path's direction can be computed via @@ -64,8 +58,8 @@ public: * specified direction. If dir is kUnknown, returns true if the direction * cannot be computed. */ - static bool CheapIsFirstDirection(const SkPath& path, FirstDirection dir) { - FirstDirection computedDir = kUnknown_FirstDirection; + static bool CheapIsFirstDirection(const SkPath& path, SkPathFirstDirection dir) { + SkPathFirstDirection computedDir = SkPathFirstDirection::kUnknown; (void)CheapComputeFirstDirection(path, &computedDir); return computedDir == dir; } @@ -415,20 +409,20 @@ public: path->dirtyAfterEdit(); } - static SkPathConvexityType GetConvexityType(const SkPath& path) { - return path.getConvexityType(); + static SkPathConvexity GetConvexity(const SkPath& path) { + return path.getConvexity(); } - static SkPathConvexityType GetConvexityTypeOrUnknown(const SkPath& path) { - return path.getConvexityTypeOrUnknown(); + static SkPathConvexity GetConvexityOrUnknown(const SkPath& path) { + return path.getConvexityOrUnknown(); } - static void SetConvexityType(const SkPath& path, SkPathConvexityType c) { - path.setConvexityType(c); + static void SetConvexity(const SkPath& path, SkPathConvexity c) { + path.setConvexity(c); } - static void SetConvexityType(SkPathBuilder* builder, SkPathConvexityType c) { - builder->privateSetConvexityType(c); + static void SetConvexity(SkPathBuilder* builder, SkPathConvexity c) { + builder->privateSetConvexity(c); } static void ForceComputeConvexity(const SkPath& path) { - path.setConvexityType(SkPathConvexityType::kUnknown); + path.setConvexity(SkPathConvexity::kUnknown); (void)path.isConvex(); } diff --git a/src/core/SkPathRef.cpp b/src/core/SkPathRef.cpp index 02f184ee30..83771c3027 100644 --- a/src/core/SkPathRef.cpp +++ b/src/core/SkPathRef.cpp @@ -686,7 +686,7 @@ bool SkPathRef::isValid() const { #include "src/core/SkPathView.h" -SkPathView SkPathRef::view(SkPathFillType ft, SkPathConvexityType ct) const { +SkPathView SkPathRef::view(SkPathFillType ft, SkPathConvexity ct) const { return { { fPoints.begin(), fPoints.size() }, { fVerbs.begin(), fVerbs.size() }, diff --git a/src/core/SkPathView.h b/src/core/SkPathView.h index 5154890250..fcb75869b9 100644 --- a/src/core/SkPathView.h +++ b/src/core/SkPathView.h @@ -10,12 +10,13 @@ #include "include/core/SkPathTypes.h" #include "include/core/SkPoint.h" #include "include/core/SkRect.h" +#include "include/private/SkPathRef.h" #include "src/core/SkSpan.h" struct SkPathView { SkPathView(SkSpan points, SkSpan verbs, SkSpan weights, - SkPathFillType ft, SkPathConvexityType ct, const SkRect& bounds, unsigned segmentMask, - bool isFinite) + SkPathFillType ft, SkPathConvexity ct, const SkRect& bounds, unsigned segmentMask, + bool isFinite) : fPoints(points) , fVerbs(verbs) , fWeights(weights) @@ -29,7 +30,7 @@ struct SkPathView { } bool isInverseFillType() const { return SkPathFillType_IsInverse(fFillType); } - bool isConvex() const { return fConvexity == SkPathConvexityType::kConvex; } + bool isConvex() const { return fConvexity == SkPathConvexity::kConvex; } bool isEmpty() const { return fPoints.size() == 0; } @@ -42,10 +43,10 @@ struct SkPathView { SkRect fBounds; - SkPathFillType fFillType; - SkPathConvexityType fConvexity; - uint8_t fSegmentMask; - bool fIsFinite; + SkPathFillType fFillType; + SkPathConvexity fConvexity; + uint8_t fSegmentMask; + bool fIsFinite; #ifdef SK_DEBUG void validate() const; @@ -61,7 +62,7 @@ static inline SkPathView SkPathView_triangle(const SkPoint pts[3], const SkRect& (uint8_t)SkPathVerb::kLine, }; return SkPathView({pts, 3}, SkMakeSpan(verbs), {}, - SkPathFillType::kWinding, SkPathConvexityType::kConvex, + SkPathFillType::kWinding, SkPathConvexity::kConvex, bounds, kLine_SkPathSegmentMask, true); } @@ -73,6 +74,6 @@ static inline SkPathView SkPathView_quad(const SkPoint pts[4], const SkRect& bou (uint8_t)SkPathVerb::kLine, }; return SkPathView({pts, 4}, SkMakeSpan(verbs), {}, - SkPathFillType::kWinding, SkPathConvexityType::kConvex, + SkPathFillType::kWinding, SkPathConvexity::kConvex, bounds, kLine_SkPathSegmentMask, true); }; diff --git a/src/core/SkPath_serial.cpp b/src/core/SkPath_serial.cpp index 694ce77315..499ff82f66 100644 --- a/src/core/SkPath_serial.cpp +++ b/src/core/SkPath_serial.cpp @@ -73,7 +73,7 @@ size_t SkPath::writeToMemoryAsRRect(void* storage) const { return sizeNeeded; } - int firstDir = isCCW ? SkPathPriv::kCCW_FirstDirection : SkPathPriv::kCW_FirstDirection; + int firstDir = isCCW ? (int)SkPathFirstDirection::kCCW : (int)SkPathFirstDirection::kCW; int32_t packed = (fFillType << kFillType_SerializationShift) | (firstDir << kDirection_SerializationShift) | (SerializationType::kRRect << kType_SerializationShift) | @@ -173,10 +173,10 @@ size_t SkPath::readAsRRect(const void* storage, size_t length) { SkRRect rrect; int32_t start; switch (dir) { - case SkPathPriv::kCW_FirstDirection: + case (int)SkPathFirstDirection::kCW: rrectDir = SkPathDirection::kCW; break; - case SkPathPriv::kCCW_FirstDirection: + case (int)SkPathFirstDirection::kCCW: rrectDir = SkPathDirection::kCCW; break; default: diff --git a/src/core/SkStroke.cpp b/src/core/SkStroke.cpp index b1e67d6801..2a4471fab6 100644 --- a/src/core/SkStroke.cpp +++ b/src/core/SkStroke.cpp @@ -1504,7 +1504,7 @@ DONE: stroker.done(dst, lastSegment == SkPath::kLine_Verb); if (fDoFill && !ignoreCenter) { - if (SkPathPriv::CheapIsFirstDirection(src, SkPathPriv::kCCW_FirstDirection)) { + if (SkPathPriv::CheapIsFirstDirection(src, SkPathFirstDirection::kCCW)) { dst->reverseAddPath(src); } else { dst->addPath(src); diff --git a/src/effects/SkOpPathEffect.cpp b/src/effects/SkOpPathEffect.cpp index 91d89532b0..4bf242dcec 100644 --- a/src/effects/SkOpPathEffect.cpp +++ b/src/effects/SkOpPathEffect.cpp @@ -134,16 +134,16 @@ sk_sp SkStrokeAndFillPathEffect::Make() { void SkStrokeAndFillPE::flatten(SkWriteBuffer&) const {} static bool known_to_be_opposite_directions(const SkPath& a, const SkPath& b) { - auto a_dir = SkPathPriv::kUnknown_FirstDirection, - b_dir = SkPathPriv::kUnknown_FirstDirection; + auto a_dir = SkPathFirstDirection::kUnknown, + b_dir = SkPathFirstDirection::kUnknown; (void)SkPathPriv::CheapComputeFirstDirection(a, &a_dir); (void)SkPathPriv::CheapComputeFirstDirection(b, &b_dir); - return (a_dir == SkPathPriv::kCCW_FirstDirection && - b_dir == SkPathPriv::kCW_FirstDirection) + return (a_dir == SkPathFirstDirection::kCCW && + b_dir == SkPathFirstDirection::kCW) || - (a_dir == SkPathPriv::kCW_FirstDirection && - b_dir == SkPathPriv::kCCW_FirstDirection); + (a_dir == SkPathFirstDirection::kCW && + b_dir == SkPathFirstDirection::kCCW); } bool SkStrokeAndFillPE::onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec, diff --git a/src/gpu/effects/GrConvexPolyEffect.cpp b/src/gpu/effects/GrConvexPolyEffect.cpp index 53a2ce918f..6d94e257fc 100644 --- a/src/gpu/effects/GrConvexPolyEffect.cpp +++ b/src/gpu/effects/GrConvexPolyEffect.cpp @@ -97,7 +97,7 @@ GrFPResult GrConvexPolyEffect::Make(std::unique_ptr inputFP return GrFPFailure(std::move(inputFP)); } - SkPathPriv::FirstDirection dir; + SkPathFirstDirection dir; // The only way this should fail is if the clip is effectively a infinitely thin line. In that // case nothing is inside the clip. It'd be nice to detect this at a higher level and either // skip the draw or omit the clip element. @@ -138,7 +138,7 @@ GrFPResult GrConvexPolyEffect::Make(std::unique_ptr inputFP if (pts[0] != pts[1]) { SkVector v = pts[1] - pts[0]; v.normalize(); - if (SkPathPriv::kCCW_FirstDirection == dir) { + if (SkPathFirstDirection::kCCW == dir) { edges[3 * n] = v.fY; edges[3 * n + 1] = -v.fX; } else { diff --git a/src/gpu/geometry/GrPathUtils.cpp b/src/gpu/geometry/GrPathUtils.cpp index 9ee165a500..3b5fc012a4 100644 --- a/src/gpu/geometry/GrPathUtils.cpp +++ b/src/gpu/geometry/GrPathUtils.cpp @@ -366,16 +366,16 @@ bool is_point_within_cubic_tangents(const SkPoint& a, const SkVector& ab, const SkVector& dc, const SkPoint& d, - SkPathPriv::FirstDirection dir, + SkPathFirstDirection dir, const SkPoint p) { SkVector ap = p - a; SkScalar apXab = ap.cross(ab); - if (SkPathPriv::kCW_FirstDirection == dir) { + if (SkPathFirstDirection::kCW == dir) { if (apXab > 0) { return false; } } else { - SkASSERT(SkPathPriv::kCCW_FirstDirection == dir); + SkASSERT(SkPathFirstDirection::kCCW == dir); if (apXab < 0) { return false; } @@ -383,12 +383,12 @@ bool is_point_within_cubic_tangents(const SkPoint& a, SkVector dp = p - d; SkScalar dpXdc = dp.cross(dc); - if (SkPathPriv::kCW_FirstDirection == dir) { + if (SkPathFirstDirection::kCW == dir) { if (dpXdc < 0) { return false; } } else { - SkASSERT(SkPathPriv::kCCW_FirstDirection == dir); + SkASSERT(SkPathFirstDirection::kCCW == dir); if (dpXdc > 0) { return false; } @@ -463,7 +463,7 @@ void convert_noninflect_cubic_to_quads(const SkPoint p[4], void convert_noninflect_cubic_to_quads_with_constraint(const SkPoint p[4], SkScalar toleranceSqd, - SkPathPriv::FirstDirection dir, + SkPathFirstDirection dir, SkTArray* quads, int sublevel = 0) { // Notation: Point a is always p[0]. Point b is p[1] unless p[1] == p[0], in which case it is @@ -613,7 +613,7 @@ void GrPathUtils::convertCubicToQuads(const SkPoint p[4], void GrPathUtils::convertCubicToQuadsConstrainToTangents(const SkPoint p[4], SkScalar tolScale, - SkPathPriv::FirstDirection dir, + SkPathFirstDirection dir, SkTArray* quads) { if (!p[0].isFinite() || !p[1].isFinite() || !p[2].isFinite() || !p[3].isFinite()) { return; diff --git a/src/gpu/geometry/GrPathUtils.h b/src/gpu/geometry/GrPathUtils.h index 35e6738727..48f537dee3 100644 --- a/src/gpu/geometry/GrPathUtils.h +++ b/src/gpu/geometry/GrPathUtils.h @@ -117,7 +117,7 @@ namespace GrPathUtils { // must specify the orientation of the contour containing the cubic. void convertCubicToQuadsConstrainToTangents(const SkPoint p[4], SkScalar tolScale, - SkPathPriv::FirstDirection dir, + SkPathFirstDirection dir, SkTArray* quads); enum class ExcludedTerm { diff --git a/src/gpu/geometry/GrStyledShape.h b/src/gpu/geometry/GrStyledShape.h index 39adad22bc..db79744ccd 100644 --- a/src/gpu/geometry/GrStyledShape.h +++ b/src/gpu/geometry/GrStyledShape.h @@ -178,8 +178,7 @@ public: // Assuming this is called after knownToBeConvex(), this should just be relying on // cached convexity and direction and will be cheap. return !fShape.isPath() || - !SkPathPriv::CheapIsFirstDirection(fShape.path(), - SkPathPriv::kUnknown_FirstDirection); + !SkPathPriv::CheapIsFirstDirection(fShape.path(), SkPathFirstDirection::kUnknown); } /** Is the pre-styled geometry inverse filled? */ diff --git a/src/gpu/ops/GrAAConvexPathRenderer.cpp b/src/gpu/ops/GrAAConvexPathRenderer.cpp index 9bc2f88862..1f6151e077 100644 --- a/src/gpu/ops/GrAAConvexPathRenderer.cpp +++ b/src/gpu/ops/GrAAConvexPathRenderer.cpp @@ -117,7 +117,7 @@ static bool center_of_mass(const SegmentArray& segments, SkPoint* c) { static bool compute_vectors(SegmentArray* segments, SkPoint* fanPt, - SkPathPriv::FirstDirection dir, + SkPathFirstDirection dir, int* vCount, int* iCount) { if (!center_of_mass(*segments, fanPt)) { @@ -127,7 +127,7 @@ static bool compute_vectors(SegmentArray* segments, // Make the normals point towards the outside SkPointPriv::Side normSide; - if (dir == SkPathPriv::kCCW_FirstDirection) { + if (dir == SkPathFirstDirection::kCCW) { normSide = SkPointPriv::kRight_Side; } else { normSide = SkPointPriv::kLeft_Side; @@ -223,7 +223,7 @@ static void update_degenerate_test(DegenerateTestData* data, const SkPoint& pt) } static inline bool get_direction(const SkPath& path, const SkMatrix& m, - SkPathPriv::FirstDirection* dir) { + SkPathFirstDirection* dir) { // At this point, we've already returned true from canDraw(), which checked that the path's // direction could be determined, so this should just be fetching the cached direction. // However, if perspective is involved, we're operating on a transformed path, which may no @@ -265,7 +265,7 @@ static inline void add_quad_segment(const SkPoint pts[3], } static inline void add_cubic_segments(const SkPoint pts[4], - SkPathPriv::FirstDirection dir, + SkPathFirstDirection dir, SegmentArray* segments) { SkSTArray<15, SkPoint, true> quads; GrPathUtils::convertCubicToQuadsConstrainToTangents(pts, SK_Scalar1, dir, &quads); @@ -290,7 +290,7 @@ static bool get_segments(const SkPath& path, // line paths. We detect paths that are very close to a line (zero area) and // draw nothing. DegenerateTestData degenerateData; - SkPathPriv::FirstDirection dir; + SkPathFirstDirection dir; if (!get_direction(path, m, &dir)) { return false; } diff --git a/src/pathops/SkOpBuilder.cpp b/src/pathops/SkOpBuilder.cpp index b14baff4b8..595553a283 100644 --- a/src/pathops/SkOpBuilder.cpp +++ b/src/pathops/SkOpBuilder.cpp @@ -42,9 +42,9 @@ bool SkOpBuilder::FixWinding(SkPath* path) { } else if (fillType == SkPathFillType::kEvenOdd) { fillType = SkPathFillType::kWinding; } - SkPathPriv::FirstDirection dir; + SkPathFirstDirection dir; if (one_contour(*path) && SkPathPriv::CheapComputeFirstDirection(*path, &dir)) { - if (dir != SkPathPriv::kCCW_FirstDirection) { + if (dir != SkPathFirstDirection::kCCW) { ReversePath(path); } path->setFillType(fillType); @@ -127,7 +127,7 @@ bool SkOpBuilder::resolve(SkPath* result) { SkPath original = *result; int count = fOps.count(); bool allUnion = true; - SkPathPriv::FirstDirection firstDir = SkPathPriv::kUnknown_FirstDirection; + SkPathFirstDirection firstDir = SkPathFirstDirection::kUnknown; for (int index = 0; index < count; ++index) { SkPath* test = &fPathRefs[index]; if (kUnion_SkPathOp != fOps[index] || test->isInverseFillType()) { @@ -136,12 +136,12 @@ bool SkOpBuilder::resolve(SkPath* result) { } // If all paths are convex, track direction, reversing as needed. if (test->isConvex()) { - SkPathPriv::FirstDirection dir; + SkPathFirstDirection dir; if (!SkPathPriv::CheapComputeFirstDirection(*test, &dir)) { allUnion = false; break; } - if (firstDir == SkPathPriv::kUnknown_FirstDirection) { + if (firstDir == SkPathFirstDirection::kUnknown) { firstDir = dir; } else if (firstDir != dir) { ReversePath(test); diff --git a/src/utils/SkDashPath.cpp b/src/utils/SkDashPath.cpp index 7c8e75105a..f8612f44b6 100644 --- a/src/utils/SkDashPath.cpp +++ b/src/utils/SkDashPath.cpp @@ -427,7 +427,7 @@ bool SkDashPath::InternalFilter(SkPath* dst, const SkPath& src, SkStrokeRec* rec // TODO: do we still need this? if (segCount > 1) { - SkPathPriv::SetConvexityType(*dst, SkPathConvexityType::kConcave); + SkPathPriv::SetConvexity(*dst, SkPathConvexity::kConcave); } return true; diff --git a/tests/PathBuilderTest.cpp b/tests/PathBuilderTest.cpp index 27b5a86349..0fecb4eb69 100644 --- a/tests/PathBuilderTest.cpp +++ b/tests/PathBuilderTest.cpp @@ -150,8 +150,8 @@ static bool is_eq(const SkPath& a, const SkPath& b) { // getConvextity() should be sufficient to test, but internally we sometimes don't want // to trigger computing it, so this is the stronger test for equality. { - SkPathConvexityType ca = SkPathPriv::GetConvexityTypeOrUnknown(a), - cb = SkPathPriv::GetConvexityTypeOrUnknown(b); + SkPathConvexity ca = SkPathPriv::GetConvexityOrUnknown(a), + cb = SkPathPriv::GetConvexityOrUnknown(b); if (ca != cb) { return false; } diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp index c62ee236ef..e81ab5d4e3 100644 --- a/tests/PathTest.cpp +++ b/tests/PathTest.cpp @@ -1049,21 +1049,21 @@ static void test_strokerec(skiatest::Reporter* reporter) { // Set this for paths that don't have a consistent direction such as a bowtie. // (cheapComputeDirection is not expected to catch these.) // Legal values are CW (0), CCW (1) and Unknown (2), leaving 3 as a convenient sentinel. -const SkPathPriv::FirstDirection kDontCheckDir = static_cast(3); +const SkPathFirstDirection kDontCheckDir = static_cast(3); static void check_direction(skiatest::Reporter* reporter, const SkPath& path, - SkPathPriv::FirstDirection expected) { + SkPathFirstDirection expected) { if (expected == kDontCheckDir) { return; } // We make a copy so that we don't cache the result on the passed in path. SkPath copy(path); // NOLINT(performance-unnecessary-copy-initialization) - SkPathPriv::FirstDirection dir; + SkPathFirstDirection dir; if (SkPathPriv::CheapComputeFirstDirection(copy, &dir)) { REPORTER_ASSERT(reporter, dir == expected); } else { - REPORTER_ASSERT(reporter, SkPathPriv::kUnknown_FirstDirection == expected); + REPORTER_ASSERT(reporter, SkPathFirstDirection::kUnknown == expected); } } @@ -1071,9 +1071,9 @@ static void test_direction(skiatest::Reporter* reporter) { size_t i; SkPath path; REPORTER_ASSERT(reporter, !SkPathPriv::CheapComputeFirstDirection(path, nullptr)); - REPORTER_ASSERT(reporter, !SkPathPriv::CheapIsFirstDirection(path, SkPathPriv::kCW_FirstDirection)); - REPORTER_ASSERT(reporter, !SkPathPriv::CheapIsFirstDirection(path, SkPathPriv::kCCW_FirstDirection)); - REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(path, SkPathPriv::kUnknown_FirstDirection)); + REPORTER_ASSERT(reporter, !SkPathPriv::CheapIsFirstDirection(path, SkPathFirstDirection::kCW)); + REPORTER_ASSERT(reporter, !SkPathPriv::CheapIsFirstDirection(path, SkPathFirstDirection::kCCW)); + REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(path, SkPathFirstDirection::kUnknown)); static const char* gDegen[] = { "M 10 10", @@ -1103,7 +1103,7 @@ static void test_direction(skiatest::Reporter* reporter) { path.reset(); bool valid = SkParsePath::FromSVGString(gCW[i], &path); REPORTER_ASSERT(reporter, valid); - check_direction(reporter, path, SkPathPriv::kCW_FirstDirection); + check_direction(reporter, path, SkPathFirstDirection::kCW); } static const char* gCCW[] = { @@ -1119,7 +1119,7 @@ static void test_direction(skiatest::Reporter* reporter) { path.reset(); bool valid = SkParsePath::FromSVGString(gCCW[i], &path); REPORTER_ASSERT(reporter, valid); - check_direction(reporter, path, SkPathPriv::kCCW_FirstDirection); + check_direction(reporter, path, SkPathFirstDirection::kCCW); } // Test two donuts, each wound a different direction. Only the outer contour @@ -1127,12 +1127,12 @@ static void test_direction(skiatest::Reporter* reporter) { path.reset(); path.addCircle(0, 0, SkIntToScalar(2), SkPathDirection::kCW); path.addCircle(0, 0, SkIntToScalar(1), SkPathDirection::kCCW); - check_direction(reporter, path, SkPathPriv::kCW_FirstDirection); + check_direction(reporter, path, SkPathFirstDirection::kCW); path.reset(); path.addCircle(0, 0, SkIntToScalar(1), SkPathDirection::kCW); path.addCircle(0, 0, SkIntToScalar(2), SkPathDirection::kCCW); - check_direction(reporter, path, SkPathPriv::kCCW_FirstDirection); + check_direction(reporter, path, SkPathFirstDirection::kCCW); // triangle with one point really far from the origin. path.reset(); @@ -1140,19 +1140,19 @@ static void test_direction(skiatest::Reporter* reporter) { path.moveTo(SkBits2Float(0x501c7652), SkBits2Float(0x501c7652)); path.lineTo(110 * SK_Scalar1, -10 * SK_Scalar1); path.lineTo(-10 * SK_Scalar1, 60 * SK_Scalar1); - check_direction(reporter, path, SkPathPriv::kCCW_FirstDirection); + check_direction(reporter, path, SkPathFirstDirection::kCCW); path.reset(); path.conicTo(20, 0, 20, 20, 0.5f); path.close(); - check_direction(reporter, path, SkPathPriv::kCW_FirstDirection); + check_direction(reporter, path, SkPathFirstDirection::kCW); path.reset(); path.lineTo(1, 1e7f); path.lineTo(1e7f, 2e7f); path.close(); REPORTER_ASSERT(reporter, path.isConvex()); - check_direction(reporter, path, SkPathPriv::kCCW_FirstDirection); + check_direction(reporter, path, SkPathFirstDirection::kCCW); } static void add_rect(SkPath* path, const SkRect& r) { @@ -1347,7 +1347,7 @@ static void test_path_crbug389050(skiatest::Reporter* reporter) { // This is convex, but so small that it fails many of our checks, and the three "backwards" // bends convince the checker that it's concave. That's okay though, we draw it correctly. check_convexity(reporter, tinyConvexPolygon, false); - check_direction(reporter, tinyConvexPolygon, SkPathPriv::kCW_FirstDirection); + check_direction(reporter, tinyConvexPolygon, SkPathFirstDirection::kCW); SkPath platTriangle; platTriangle.moveTo(0, 0); @@ -1355,7 +1355,7 @@ static void test_path_crbug389050(skiatest::Reporter* reporter) { platTriangle.lineTo(100, 0.04f); platTriangle.close(); platTriangle.isConvex(); - check_direction(reporter, platTriangle, SkPathPriv::kCW_FirstDirection); + check_direction(reporter, platTriangle, SkPathFirstDirection::kCW); platTriangle.reset(); platTriangle.moveTo(0, 0); @@ -1363,7 +1363,7 @@ static void test_path_crbug389050(skiatest::Reporter* reporter) { platTriangle.lineTo(100, 0.03f); platTriangle.close(); platTriangle.isConvex(); - check_direction(reporter, platTriangle, SkPathPriv::kCW_FirstDirection); + check_direction(reporter, platTriangle, SkPathFirstDirection::kCW); } static void test_convexity2(skiatest::Reporter* reporter) { @@ -1371,14 +1371,14 @@ static void test_convexity2(skiatest::Reporter* reporter) { pt.moveTo(0, 0); pt.close(); check_convexity(reporter, pt, true); - check_direction(reporter, pt, SkPathPriv::kUnknown_FirstDirection); + check_direction(reporter, pt, SkPathFirstDirection::kUnknown); SkPath line; line.moveTo(12*SK_Scalar1, 20*SK_Scalar1); line.lineTo(-12*SK_Scalar1, -20*SK_Scalar1); line.close(); check_convexity(reporter, line, true); - check_direction(reporter, line, SkPathPriv::kUnknown_FirstDirection); + check_direction(reporter, line, SkPathFirstDirection::kUnknown); SkPath triLeft; triLeft.moveTo(0, 0); @@ -1386,7 +1386,7 @@ static void test_convexity2(skiatest::Reporter* reporter) { triLeft.lineTo(SK_Scalar1, SK_Scalar1); triLeft.close(); check_convexity(reporter, triLeft, true); - check_direction(reporter, triLeft, SkPathPriv::kCW_FirstDirection); + check_direction(reporter, triLeft, SkPathFirstDirection::kCW); SkPath triRight; triRight.moveTo(0, 0); @@ -1394,7 +1394,7 @@ static void test_convexity2(skiatest::Reporter* reporter) { triRight.lineTo(SK_Scalar1, SK_Scalar1); triRight.close(); check_convexity(reporter, triRight, true); - check_direction(reporter, triRight, SkPathPriv::kCCW_FirstDirection); + check_direction(reporter, triRight, SkPathFirstDirection::kCCW); SkPath square; square.moveTo(0, 0); @@ -1403,7 +1403,7 @@ static void test_convexity2(skiatest::Reporter* reporter) { square.lineTo(0, SK_Scalar1); square.close(); check_convexity(reporter, square, true); - check_direction(reporter, square, SkPathPriv::kCW_FirstDirection); + check_direction(reporter, square, SkPathFirstDirection::kCW); SkPath redundantSquare; redundantSquare.moveTo(0, 0); @@ -1420,7 +1420,7 @@ static void test_convexity2(skiatest::Reporter* reporter) { redundantSquare.lineTo(0, SK_Scalar1); redundantSquare.close(); check_convexity(reporter, redundantSquare, true); - check_direction(reporter, redundantSquare, SkPathPriv::kCW_FirstDirection); + check_direction(reporter, redundantSquare, SkPathFirstDirection::kCW); SkPath bowTie; bowTie.moveTo(0, 0); @@ -1459,7 +1459,7 @@ static void test_convexity2(skiatest::Reporter* reporter) { dent.lineTo(-200*SK_Scalar1, 100*SK_Scalar1); dent.close(); check_convexity(reporter, dent, false); - check_direction(reporter, dent, SkPathPriv::kCW_FirstDirection); + check_direction(reporter, dent, SkPathFirstDirection::kCW); // https://bug.skia.org/2235 SkPath strokedSin; @@ -1487,7 +1487,7 @@ static void test_convexity2(skiatest::Reporter* reporter) { degenerateConcave.lineTo(-55.971577f, 460.0f); degenerateConcave.lineTo(41.446522f, 376.25f); check_convexity(reporter, degenerateConcave, false); - check_direction(reporter, degenerateConcave, SkPathPriv::kUnknown_FirstDirection); + check_direction(reporter, degenerateConcave, SkPathFirstDirection::kUnknown); // http://crbug.com/433683 SkPath badFirstVector; @@ -1588,30 +1588,30 @@ static void test_convexity(skiatest::Reporter* reporter) { path.reset(); path.addRect(0, 0, SkIntToScalar(10), SkIntToScalar(10), SkPathDirection::kCCW); check_convexity(reporter, path, true); - REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(path, SkPathPriv::kCCW_FirstDirection)); + REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(path, SkPathFirstDirection::kCCW)); path.reset(); path.addRect(0, 0, SkIntToScalar(10), SkIntToScalar(10), SkPathDirection::kCW); check_convexity(reporter, path, true); - REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(path, SkPathPriv::kCW_FirstDirection)); + REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(path, SkPathFirstDirection::kCW)); path.reset(); path.quadTo(100, 100, 50, 50); // This from GM:convexpaths check_convexity(reporter, path, true); static const struct { - const char* fPathStr; - bool fExpectedIsConvex; - SkPathPriv::FirstDirection fExpectedDirection; + const char* fPathStr; + bool fExpectedIsConvex; + SkPathFirstDirection fExpectedDirection; } gRec[] = { - { "", true, SkPathPriv::kUnknown_FirstDirection }, - { "0 0", true, SkPathPriv::kUnknown_FirstDirection }, - { "0 0 10 10", true, SkPathPriv::kUnknown_FirstDirection }, - { "0 0 10 10 20 20 0 0 10 10", false, SkPathPriv::kUnknown_FirstDirection }, - { "0 0 10 10 10 20", true, SkPathPriv::kCW_FirstDirection }, - { "0 0 10 10 10 0", true, SkPathPriv::kCCW_FirstDirection }, + { "", true, SkPathFirstDirection::kUnknown }, + { "0 0", true, SkPathFirstDirection::kUnknown }, + { "0 0 10 10", true, SkPathFirstDirection::kUnknown }, + { "0 0 10 10 20 20 0 0 10 10", false, SkPathFirstDirection::kUnknown }, + { "0 0 10 10 10 20", true, SkPathFirstDirection::kCW }, + { "0 0 10 10 10 0", true, SkPathFirstDirection::kCCW }, { "0 0 10 10 10 0 0 10", false, kDontCheckDir }, - { "0 0 10 0 0 10 -10 -10", false, SkPathPriv::kCW_FirstDirection }, + { "0 0 10 0 0 10 -10 -10", false, SkPathFirstDirection::kCW }, }; for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { @@ -1623,9 +1623,9 @@ static void test_convexity(skiatest::Reporter* reporter) { if (kDontCheckDir != gRec[i].fExpectedDirection) { // We make a copy so that we don't cache the result on the passed in path. SkPath copy(path); // NOLINT(performance-unnecessary-copy-initialization) - SkPathPriv::FirstDirection dir; + SkPathFirstDirection dir; bool foundDir = SkPathPriv::CheapComputeFirstDirection(copy, &dir); - REPORTER_ASSERT(reporter, (gRec[i].fExpectedDirection == SkPathPriv::kUnknown_FirstDirection) + REPORTER_ASSERT(reporter, (gRec[i].fExpectedDirection == SkPathFirstDirection::kUnknown) ^ foundDir); REPORTER_ASSERT(reporter, !foundDir || gRec[i].fExpectedDirection == dir); check_convexity(reporter, copy, gRec[i].fExpectedIsConvex); @@ -1680,7 +1680,7 @@ static void test_convexity(skiatest::Reporter* reporter) { case 12: path.moveTo(nonFinitePts[i]); break; } REPORTER_ASSERT(reporter, - SkPathPriv::GetConvexityTypeOrUnknown(path) == SkPathConvexityType::kUnknown); + SkPathPriv::GetConvexityOrUnknown(path) == SkPathConvexity::kUnknown); } for (int index = 0; index < (int) (11 * axisAlignedPtsCount); ++index) { @@ -2154,7 +2154,7 @@ static void test_isRect(skiatest::Reporter* reporter) { SkRect computed, expected; bool isClosed; SkPathDirection direction; - SkPathPriv::FirstDirection cheapDirection; + SkPathFirstDirection cheapDirection; int pointCount = tests[testIndex].fPointCount - (d2 == tests[testIndex].fPoints); expected.setBounds(tests[testIndex].fPoints, pointCount); REPORTER_ASSERT(reporter, SkPathPriv::CheapComputeFirstDirection(path, &cheapDirection)); @@ -2399,36 +2399,36 @@ static void test_isNestedFillRects(skiatest::Reporter* reporter) { struct IsNestedRectTest { SkPoint *fPoints; int fPointCount; - SkPathPriv::FirstDirection fDirection; + SkPathFirstDirection fDirection; bool fClose; bool fIsNestedRect; // nests with path.addRect(-1, -1, 2, 2); } tests[] = { - { r1, SK_ARRAY_COUNT(r1), SkPathPriv::kCW_FirstDirection , true, true }, - { r2, SK_ARRAY_COUNT(r2), SkPathPriv::kCW_FirstDirection , true, true }, - { r3, SK_ARRAY_COUNT(r3), SkPathPriv::kCW_FirstDirection , true, true }, - { r4, SK_ARRAY_COUNT(r4), SkPathPriv::kCW_FirstDirection , true, true }, - { r5, SK_ARRAY_COUNT(r5), SkPathPriv::kCCW_FirstDirection, true, true }, - { r6, SK_ARRAY_COUNT(r6), SkPathPriv::kCCW_FirstDirection, true, true }, - { r7, SK_ARRAY_COUNT(r7), SkPathPriv::kCCW_FirstDirection, true, true }, - { r8, SK_ARRAY_COUNT(r8), SkPathPriv::kCCW_FirstDirection, true, true }, - { r9, SK_ARRAY_COUNT(r9), SkPathPriv::kCCW_FirstDirection, true, true }, - { ra, SK_ARRAY_COUNT(ra), SkPathPriv::kCCW_FirstDirection, true, true }, - { rb, SK_ARRAY_COUNT(rb), SkPathPriv::kCW_FirstDirection, true, true }, - { rc, SK_ARRAY_COUNT(rc), SkPathPriv::kCW_FirstDirection, true, true }, - { rd, SK_ARRAY_COUNT(rd), SkPathPriv::kCCW_FirstDirection, true, true }, - { re, SK_ARRAY_COUNT(re), SkPathPriv::kCW_FirstDirection, true, true }, + { r1, SK_ARRAY_COUNT(r1), SkPathFirstDirection::kCW , true, true }, + { r2, SK_ARRAY_COUNT(r2), SkPathFirstDirection::kCW , true, true }, + { r3, SK_ARRAY_COUNT(r3), SkPathFirstDirection::kCW , true, true }, + { r4, SK_ARRAY_COUNT(r4), SkPathFirstDirection::kCW , true, true }, + { r5, SK_ARRAY_COUNT(r5), SkPathFirstDirection::kCCW, true, true }, + { r6, SK_ARRAY_COUNT(r6), SkPathFirstDirection::kCCW, true, true }, + { r7, SK_ARRAY_COUNT(r7), SkPathFirstDirection::kCCW, true, true }, + { r8, SK_ARRAY_COUNT(r8), SkPathFirstDirection::kCCW, true, true }, + { r9, SK_ARRAY_COUNT(r9), SkPathFirstDirection::kCCW, true, true }, + { ra, SK_ARRAY_COUNT(ra), SkPathFirstDirection::kCCW, true, true }, + { rb, SK_ARRAY_COUNT(rb), SkPathFirstDirection::kCW, true, true }, + { rc, SK_ARRAY_COUNT(rc), SkPathFirstDirection::kCW, true, true }, + { rd, SK_ARRAY_COUNT(rd), SkPathFirstDirection::kCCW, true, true }, + { re, SK_ARRAY_COUNT(re), SkPathFirstDirection::kCW, true, true }, - { f1, SK_ARRAY_COUNT(f1), SkPathPriv::kUnknown_FirstDirection, true, false }, - { f2, SK_ARRAY_COUNT(f2), SkPathPriv::kUnknown_FirstDirection, true, false }, - { f3, SK_ARRAY_COUNT(f3), SkPathPriv::kUnknown_FirstDirection, true, false }, - { f4, SK_ARRAY_COUNT(f4), SkPathPriv::kUnknown_FirstDirection, true, false }, - { f5, SK_ARRAY_COUNT(f5), SkPathPriv::kUnknown_FirstDirection, true, false }, - { f6, SK_ARRAY_COUNT(f6), SkPathPriv::kUnknown_FirstDirection, true, false }, - { f7, SK_ARRAY_COUNT(f7), SkPathPriv::kUnknown_FirstDirection, true, false }, - { f8, SK_ARRAY_COUNT(f8), SkPathPriv::kUnknown_FirstDirection, true, false }, + { f1, SK_ARRAY_COUNT(f1), SkPathFirstDirection::kUnknown, true, false }, + { f2, SK_ARRAY_COUNT(f2), SkPathFirstDirection::kUnknown, true, false }, + { f3, SK_ARRAY_COUNT(f3), SkPathFirstDirection::kUnknown, true, false }, + { f4, SK_ARRAY_COUNT(f4), SkPathFirstDirection::kUnknown, true, false }, + { f5, SK_ARRAY_COUNT(f5), SkPathFirstDirection::kUnknown, true, false }, + { f6, SK_ARRAY_COUNT(f6), SkPathFirstDirection::kUnknown, true, false }, + { f7, SK_ARRAY_COUNT(f7), SkPathFirstDirection::kUnknown, true, false }, + { f8, SK_ARRAY_COUNT(f8), SkPathFirstDirection::kUnknown, true, false }, - { c1, SK_ARRAY_COUNT(c1), SkPathPriv::kCW_FirstDirection, false, true }, - { c2, SK_ARRAY_COUNT(c2), SkPathPriv::kCW_FirstDirection, false, true }, + { c1, SK_ARRAY_COUNT(c1), SkPathFirstDirection::kCW, false, true }, + { c2, SK_ARRAY_COUNT(c2), SkPathFirstDirection::kCW, false, true }, }; const size_t testCount = SK_ARRAY_COUNT(tests); @@ -2453,16 +2453,16 @@ static void test_isNestedFillRects(skiatest::Reporter* reporter) { tests[testIndex].fIsNestedRect == SkPathPriv::IsNestedFillRects(path, nullptr)); if (tests[testIndex].fIsNestedRect) { SkRect expected[2], computed[2]; - SkPathPriv::FirstDirection expectedDirs[2]; + SkPathFirstDirection expectedDirs[2]; SkPathDirection computedDirs[2]; SkRect testBounds; testBounds.setBounds(tests[testIndex].fPoints, tests[testIndex].fPointCount); expected[0] = SkRect::MakeLTRB(-1, -1, 2, 2); expected[1] = testBounds; if (rectFirst) { - expectedDirs[0] = SkPathPriv::kCW_FirstDirection; + expectedDirs[0] = SkPathFirstDirection::kCW; } else { - expectedDirs[0] = SkPathPriv::kCCW_FirstDirection; + expectedDirs[0] = SkPathFirstDirection::kCCW; } expectedDirs[1] = tests[testIndex].fDirection; REPORTER_ASSERT(reporter, SkPathPriv::IsNestedFillRects(path, computed, computedDirs)); @@ -2603,8 +2603,8 @@ static void write_and_read_back(skiatest::Reporter* reporter, reader.readPath(&readBack); REPORTER_ASSERT(reporter, readBack == p); - REPORTER_ASSERT(reporter, SkPathPriv::GetConvexityTypeOrUnknown(readBack) == - SkPathPriv::GetConvexityTypeOrUnknown(p)); + REPORTER_ASSERT(reporter, SkPathPriv::GetConvexityOrUnknown(readBack) == + SkPathPriv::GetConvexityOrUnknown(p)); SkRect oval0, oval1; SkPathDirection dir0, dir1; @@ -2758,7 +2758,7 @@ static void test_transform(skiatest::Reporter* reporter) { p1.moveTo(SkPoint::Make(0, 0)); p.transform(matrix, &p1); - REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(p1, SkPathPriv::kCW_FirstDirection)); + REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(p1, SkPathFirstDirection::kCW)); } @@ -2770,7 +2770,7 @@ static void test_transform(skiatest::Reporter* reporter) { p1.moveTo(SkPoint::Make(0, 0)); // Make p1 unique (i.e., not empty path) p.transform(matrix, &p1); - REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(p1, SkPathPriv::kCCW_FirstDirection)); + REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(p1, SkPathFirstDirection::kCCW)); } { @@ -2780,7 +2780,7 @@ static void test_transform(skiatest::Reporter* reporter) { p1.moveTo(SkPoint::Make(0, 0)); // Make p1 unique (i.e., not empty path) p.transform(matrix, &p1); - REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(p1, SkPathPriv::kUnknown_FirstDirection)); + REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(p1, SkPathFirstDirection::kUnknown)); } { @@ -3303,7 +3303,7 @@ static void test_range_iter(skiatest::Reporter* reporter) { static void check_for_circle(skiatest::Reporter* reporter, const SkPath& path, bool expectedCircle, - SkPathPriv::FirstDirection expectedDir) { + SkPathFirstDirection expectedDir) { SkRect rect = SkRect::MakeEmpty(); REPORTER_ASSERT(reporter, path.isOval(&rect) == expectedCircle); SkPathDirection isOvalDir; @@ -3320,25 +3320,25 @@ static void check_for_circle(skiatest::Reporter* reporter, static void test_circle_skew(skiatest::Reporter* reporter, const SkPath& path, - SkPathPriv::FirstDirection dir) { + SkPathFirstDirection dir) { SkPath tmp; SkMatrix m; m.setSkew(SkIntToScalar(3), SkIntToScalar(5)); path.transform(m, &tmp); // this matrix reverses the direction. - if (SkPathPriv::kCCW_FirstDirection == dir) { - dir = SkPathPriv::kCW_FirstDirection; + if (SkPathFirstDirection::kCCW == dir) { + dir = SkPathFirstDirection::kCW; } else { - REPORTER_ASSERT(reporter, SkPathPriv::kCW_FirstDirection == dir); - dir = SkPathPriv::kCCW_FirstDirection; + REPORTER_ASSERT(reporter, SkPathFirstDirection::kCW == dir); + dir = SkPathFirstDirection::kCCW; } check_for_circle(reporter, tmp, false, dir); } static void test_circle_translate(skiatest::Reporter* reporter, const SkPath& path, - SkPathPriv::FirstDirection dir) { + SkPathFirstDirection dir) { SkPath tmp; // translate at small offset @@ -3358,7 +3358,7 @@ static void test_circle_translate(skiatest::Reporter* reporter, static void test_circle_rotate(skiatest::Reporter* reporter, const SkPath& path, - SkPathPriv::FirstDirection dir) { + SkPathFirstDirection dir) { for (int angle = 0; angle < 360; ++angle) { SkPath tmp; SkMatrix m; @@ -3378,35 +3378,35 @@ static void test_circle_rotate(skiatest::Reporter* reporter, static void test_circle_mirror_x(skiatest::Reporter* reporter, const SkPath& path, - SkPathPriv::FirstDirection dir) { + SkPathFirstDirection dir) { SkPath tmp; SkMatrix m; m.reset(); m.setScaleX(-SK_Scalar1); path.transform(m, &tmp); - if (SkPathPriv::kCW_FirstDirection == dir) { - dir = SkPathPriv::kCCW_FirstDirection; + if (SkPathFirstDirection::kCW == dir) { + dir = SkPathFirstDirection::kCCW; } else { - REPORTER_ASSERT(reporter, SkPathPriv::kCCW_FirstDirection == dir); - dir = SkPathPriv::kCW_FirstDirection; + REPORTER_ASSERT(reporter, SkPathFirstDirection::kCCW == dir); + dir = SkPathFirstDirection::kCW; } check_for_circle(reporter, tmp, true, dir); } static void test_circle_mirror_y(skiatest::Reporter* reporter, const SkPath& path, - SkPathPriv::FirstDirection dir) { + SkPathFirstDirection dir) { SkPath tmp; SkMatrix m; m.reset(); m.setScaleY(-SK_Scalar1); path.transform(m, &tmp); - if (SkPathPriv::kCW_FirstDirection == dir) { - dir = SkPathPriv::kCCW_FirstDirection; + if (SkPathFirstDirection::kCW == dir) { + dir = SkPathFirstDirection::kCCW; } else { - REPORTER_ASSERT(reporter, SkPathPriv::kCCW_FirstDirection == dir); - dir = SkPathPriv::kCW_FirstDirection; + REPORTER_ASSERT(reporter, SkPathFirstDirection::kCCW == dir); + dir = SkPathFirstDirection::kCW; } check_for_circle(reporter, tmp, true, dir); @@ -3414,7 +3414,7 @@ static void test_circle_mirror_y(skiatest::Reporter* reporter, static void test_circle_mirror_xy(skiatest::Reporter* reporter, const SkPath& path, - SkPathPriv::FirstDirection dir) { + SkPathFirstDirection dir) { SkPath tmp; SkMatrix m; m.reset(); @@ -3427,7 +3427,7 @@ static void test_circle_mirror_xy(skiatest::Reporter* reporter, static void test_circle_with_direction(skiatest::Reporter* reporter, SkPathDirection inDir) { - const SkPathPriv::FirstDirection dir = SkPathPriv::AsFirstDirection(inDir); + const SkPathFirstDirection dir = SkPathPriv::AsFirstDirection(inDir); SkPath path; // circle at origin @@ -3511,19 +3511,19 @@ static void test_circle(skiatest::Reporter* reporter) { SkPath path; path.addCircle(0, 0, SkIntToScalar(10), SkPathDirection::kCW); path.addCircle(0, 0, SkIntToScalar(20), SkPathDirection::kCW); - check_for_circle(reporter, path, false, SkPathPriv::kCW_FirstDirection); + check_for_circle(reporter, path, false, SkPathFirstDirection::kCW); // some extra lineTo() would make isOval() fail path.reset(); path.addCircle(0, 0, SkIntToScalar(10), SkPathDirection::kCW); path.lineTo(0, 0); - check_for_circle(reporter, path, false, SkPathPriv::kCW_FirstDirection); + check_for_circle(reporter, path, false, SkPathFirstDirection::kCW); // not back to the original point path.reset(); path.addCircle(0, 0, SkIntToScalar(10), SkPathDirection::kCW); path.setLastPt(SkIntToScalar(5), SkIntToScalar(5)); - check_for_circle(reporter, path, false, SkPathPriv::kCW_FirstDirection); + check_for_circle(reporter, path, false, SkPathFirstDirection::kCW); test_circle_with_add_paths(reporter); @@ -3725,7 +3725,7 @@ static void test_arc(skiatest::Reporter* reporter) { // TODO: one way to keep it concave would be to introduce interpolated on curve points // between control points and computing the on curve point at scan conversion time REPORTER_ASSERT(reporter, p.isConvex()); - REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(p, SkPathPriv::kCW_FirstDirection)); + REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(p, SkPathFirstDirection::kCW)); SkPathPriv::ForceComputeConvexity(p); REPORTER_ASSERT(reporter, p.isConvex()); } @@ -5509,8 +5509,8 @@ struct Xforms { }; static bool conditional_convex(const SkPath& path, bool is_convex) { - SkPathConvexityType c = SkPathPriv::GetConvexityTypeOrUnknown(path); - return is_convex ? (c == SkPathConvexityType::kConvex) : (c != SkPathConvexityType::kConvex); + SkPathConvexity c = SkPathPriv::GetConvexityOrUnknown(path); + return is_convex ? (c == SkPathConvexity::kConvex) : (c != SkPathConvexity::kConvex); } // expect axis-aligned shape to survive assignment, identity and scale/translate matrices @@ -5526,15 +5526,15 @@ void survive(SkPath* path, const Xforms& x, bool isAxisAligned, skiatest::Report // a path's isa and convexity should survive assignment path2 = *path; REPORTER_ASSERT(reporter, isa_proc(path2)); - REPORTER_ASSERT(reporter, SkPathPriv::GetConvexityTypeOrUnknown(path2) == SkPathConvexityType::kConvex); + REPORTER_ASSERT(reporter, SkPathPriv::GetConvexityOrUnknown(path2) == SkPathConvexity::kConvex); // a path's isa and convexity should identity transform path->transform(x.fIM, &path2); path->transform(x.fIM); REPORTER_ASSERT(reporter, isa_proc(path2)); - REPORTER_ASSERT(reporter, SkPathPriv::GetConvexityTypeOrUnknown(path2) == SkPathConvexityType::kConvex); + REPORTER_ASSERT(reporter, SkPathPriv::GetConvexityOrUnknown(path2) == SkPathConvexity::kConvex); REPORTER_ASSERT(reporter, isa_proc(*path)); - REPORTER_ASSERT(reporter, SkPathPriv::GetConvexityTypeOrUnknown(*path) == SkPathConvexityType::kConvex); + REPORTER_ASSERT(reporter, SkPathPriv::GetConvexityOrUnknown(*path) == SkPathConvexity::kConvex); // a path's isa should survive translation, convexity depends on axis alignment path->transform(x.fTM, &path2); @@ -5554,11 +5554,11 @@ void survive(SkPath* path, const Xforms& x, bool isAxisAligned, skiatest::Report // For security, post-rotation, we can't assume we're still convex. It might prove to be, // in fact, still be convex, be we can't have cached that setting, hence the call to - // getConvexityTypeOrUnknown() instead of getConvexityType(). + // getConvexityOrUnknown() instead of getConvexity(). path->transform(x.fRM, &path2); path->transform(x.fRM); - REPORTER_ASSERT(reporter, SkPathPriv::GetConvexityTypeOrUnknown(path2) != SkPathConvexityType::kConvex); - REPORTER_ASSERT(reporter, SkPathPriv::GetConvexityTypeOrUnknown(*path) != SkPathConvexityType::kConvex); + REPORTER_ASSERT(reporter, SkPathPriv::GetConvexityOrUnknown(path2) != SkPathConvexity::kConvex); + REPORTER_ASSERT(reporter, SkPathPriv::GetConvexityOrUnknown(*path) != SkPathConvexity::kConvex); if (isAxisAligned) { REPORTER_ASSERT(reporter, !isa_proc(path2));