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 <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2020-08-29 17:46:51 -04:00 committed by Skia Commit-Bot
parent d5961b33e8
commit 3872c98951
25 changed files with 297 additions and 295 deletions

View File

@ -1243,7 +1243,7 @@ public:
fPath.addRRect(SkRRect::MakeRectXY(r, w/8.0f, h/8.0f)); fPath.addRRect(SkRRect::MakeRectXY(r, w/8.0f, h/8.0f));
if (forceConcave) { if (forceConcave) {
SkPathPriv::SetConvexityType(fPath, SkPathConvexityType::kConcave); SkPathPriv::SetConvexity(fPath, SkPathConvexity::kConcave);
SkASSERT(!fPath.isConvex()); SkASSERT(!fPath.isConvex());
} else { } else {
SkASSERT(fPath.isConvex()); SkASSERT(fPath.isConvex());

View File

@ -12,6 +12,7 @@
#include "include/core/SkPathBuilder.h" #include "include/core/SkPathBuilder.h"
#include "include/core/SkScalar.h" #include "include/core/SkScalar.h"
#include "include/private/SkFloatBits.h" #include "include/private/SkFloatBits.h"
#include "include/private/SkPathRef.h"
#include "src/core/SkPathPriv.h" #include "src/core/SkPathPriv.h"
#define W 800 #define W 800
@ -64,7 +65,7 @@ DEF_SIMPLE_GM(analytic_antialias_convex, canvas, W, H) {
SkBits2Float(0x4344f079), SkBits2Float(0x4397e900), SkBits2Float(0x3f3504f3)); SkBits2Float(0x4344f079), SkBits2Float(0x4397e900), SkBits2Float(0x3f3504f3));
path.close(); path.close();
// Manually setting convexity is required. Otherwise, this path will be considered concave. // 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); canvas->drawPath(path.detach(), p);
// skbug.com/7573 // skbug.com/7573

View File

@ -258,7 +258,7 @@ protected:
// of the GMs rows. // of the GMs rows.
SkASSERT(path.isConvex()); SkASSERT(path.isConvex());
SkASSERT(SkPath::kLine_SegmentMask == path.getSegmentMasks()); SkASSERT(SkPath::kLine_SegmentMask == path.getSegmentMasks());
SkPathPriv::FirstDirection actualDir; SkPathFirstDirection actualDir;
SkASSERT(SkPathPriv::CheapComputeFirstDirection(path, &actualDir)); SkASSERT(SkPathPriv::CheapComputeFirstDirection(path, &actualDir));
SkASSERT(SkPathPriv::AsFirstDirection(dir) == actualDir); SkASSERT(SkPathPriv::AsFirstDirection(dir) == actualDir);
SkRect bounds = path.getBounds(); SkRect bounds = path.getBounds();

View File

@ -303,12 +303,12 @@ DEF_SIMPLE_GM_BG_NAME(strokefill, canvas, 640, 480, SK_ColorWHITE,
path2.reset(); path2.reset();
path2.addCircle(x + SkIntToScalar(240), y + SkIntToScalar(200), SkIntToScalar(50), SkPathDirection::kCCW); path2.addCircle(x + SkIntToScalar(240), y + SkIntToScalar(200), SkIntToScalar(50), SkPathDirection::kCCW);
canvas->drawPath(path2, paint); canvas->drawPath(path2, paint);
SkASSERT(SkPathPriv::CheapIsFirstDirection(path2, SkPathPriv::kCCW_FirstDirection)); SkASSERT(SkPathPriv::CheapIsFirstDirection(path2, SkPathFirstDirection::kCCW));
path2.reset(); path2.reset();
SkASSERT(!SkPathPriv::CheapComputeFirstDirection(path2, nullptr)); SkASSERT(!SkPathPriv::CheapComputeFirstDirection(path2, nullptr));
path2.addCircle(x + SkIntToScalar(360), y + SkIntToScalar(200), SkIntToScalar(50), SkPathDirection::kCW); 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); canvas->drawPath(path2, paint);
SkRect r = SkRect::MakeXYWH(x - SkIntToScalar(50), y + SkIntToScalar(280), 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(); path4.reset();
SkASSERT(!SkPathPriv::CheapComputeFirstDirection(path4, nullptr)); SkASSERT(!SkPathPriv::CheapComputeFirstDirection(path4, nullptr));
path4.addRect(r, SkPathDirection::kCCW); 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 path4.moveTo(0, 0); // test for crbug.com/247770
canvas->drawPath(path4, paint); canvas->drawPath(path4, paint);
@ -343,7 +343,7 @@ DEF_SIMPLE_GM_BG_NAME(strokefill, canvas, 640, 480, SK_ColorWHITE,
path4.reset(); path4.reset();
SkASSERT(!SkPathPriv::CheapComputeFirstDirection(path4, nullptr)); SkASSERT(!SkPathPriv::CheapComputeFirstDirection(path4, nullptr));
path4.addRect(r, SkPathDirection::kCW); 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 path4.moveTo(0, 0); // test for crbug.com/247770
canvas->drawPath(path4, paint); canvas->drawPath(path4, paint);
} }

View File

@ -227,7 +227,7 @@ public:
/** Returns true if the path is convex. If necessary, it will first compute the convexity. /** Returns true if the path is convex. If necessary, it will first compute the convexity.
*/ */
bool isConvex() const { 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. /** 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(); } bool isValid() const { return this->isValidImpl() && fPathRef->isValid(); }
private: private:
SkPath(sk_sp<SkPathRef>, SkPathFillType, bool isVolatile, SkPathConvexityType, SkPath(sk_sp<SkPathRef>, SkPathFillType, bool isVolatile, SkPathConvexity,
uint8_t firstDirection); SkPathFirstDirection firstDirection);
sk_sp<SkPathRef> fPathRef; sk_sp<SkPathRef> fPathRef;
int fLastMoveToIndex; int fLastMoveToIndex;
mutable std::atomic<uint8_t> fConvexity; // SkPathConvexityType mutable std::atomic<uint8_t> fConvexity; // SkPathConvexity
mutable std::atomic<uint8_t> fFirstDirection; // really an SkPathPriv::FirstDirection mutable std::atomic<uint8_t> fFirstDirection; // SkPathFirstDirection
uint8_t fFillType : 2; uint8_t fFillType : 2;
uint8_t fIsVolatile : 1; uint8_t fIsVolatile : 1;
@ -1846,7 +1846,7 @@ private:
inline bool hasOnlyMoveTos() const; inline bool hasOnlyMoveTos() const;
SkPathConvexityType computeConvexity() const; SkPathConvexity computeConvexity() const;
/** Asserts if SkPath data is inconsistent. /** Asserts if SkPath data is inconsistent.
Debugging check intended for internal use only. Debugging check intended for internal use only.
@ -1880,31 +1880,32 @@ private:
// Bottlenecks for working with fConvexity and fFirstDirection. // Bottlenecks for working with fConvexity and fFirstDirection.
// Notice the setters are const... these are mutable atomic fields. // Notice the setters are const... these are mutable atomic fields.
void setConvexityType(SkPathConvexityType) const; void setConvexity(SkPathConvexity) const;
void setFirstDirection(uint8_t) const;
uint8_t getFirstDirection() const; void setFirstDirection(SkPathFirstDirection) const;
SkPathFirstDirection getFirstDirection() const;
/** Returns the comvexity type, computing if needed. Never returns kUnknown. /** Returns the comvexity type, computing if needed. Never returns kUnknown.
@return path's convexity type (convex or concave) @return path's convexity type (convex or concave)
*/ */
SkPathConvexityType getConvexityType() const { SkPathConvexity getConvexity() const {
SkPathConvexityType convexity = this->getConvexityTypeOrUnknown(); SkPathConvexity convexity = this->getConvexityOrUnknown();
if (convexity == SkPathConvexityType::kUnknown) { if (convexity == SkPathConvexity::kUnknown) {
convexity = this->computeConvexity(); convexity = this->computeConvexity();
} }
SkASSERT(convexity != SkPathConvexityType::kUnknown); SkASSERT(convexity != SkPathConvexity::kUnknown);
return convexity; return convexity;
} }
SkPathConvexityType getConvexityTypeOrUnknown() const { SkPathConvexity getConvexityOrUnknown() const {
return (SkPathConvexityType)fConvexity.load(std::memory_order_relaxed); return (SkPathConvexity)fConvexity.load(std::memory_order_relaxed);
} }
/** Stores a convexity type for this path. This is what will be returned if /** 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. * is called, the real convexity will be computed.
* *
* example: https://fiddle.skia.org/c/@Path_setConvexity * example: https://fiddle.skia.org/c/@Path_setConvexity
*/ */
void setConvexityType(SkPathConvexityType convexity); void setConvexity(SkPathConvexity convexity);
friend class SkAutoPathBoundsUpdate; friend class SkAutoPathBoundsUpdate;
friend class SkAutoDisableOvalCheck; friend class SkAutoDisableOvalCheck;

View File

@ -230,7 +230,7 @@ private:
bool fIsACCW = false; // tracks direction iff fIsA is not unknown bool fIsACCW = false; // tracks direction iff fIsA is not unknown
// for testing // for testing
SkPathConvexityType fOverrideConvexity = SkPathConvexityType::kUnknown; SkPathConvexity fOverrideConvexity = SkPathConvexity::kUnknown;
int countVerbs() const { return fVerbs.count(); } int countVerbs() const { return fVerbs.count(); }
@ -247,7 +247,7 @@ private:
SkPathBuilder& privateReverseAddPath(const SkPath&); SkPathBuilder& privateReverseAddPath(const SkPath&);
// For testing // For testing
void privateSetConvexityType(SkPathConvexityType c) { fOverrideConvexity = c; } void privateSetConvexity(SkPathConvexity c) { fOverrideConvexity = c; }
friend class SkPathPriv; friend class SkPathPriv;
}; };

View File

@ -33,12 +33,6 @@ static inline SkPathFillType SkPathFillType_ConvertToNonInverse(SkPathFillType f
return static_cast<SkPathFillType>(static_cast<int>(ft) & 1); return static_cast<SkPathFillType>(static_cast<int>(ft) & 1);
} }
enum class SkPathConvexityType {
kUnknown,
kConvex,
kConcave
};
enum class SkPathDirection { enum class SkPathDirection {
/** clockwise direction for adding closed contours */ /** clockwise direction for adding closed contours */
kCW, kCW,

View File

@ -28,6 +28,18 @@ struct SkPathView;
class SkRBuffer; class SkRBuffer;
class SkWBuffer; 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 * 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 * modify the contents. To modify or append to the verbs/points wrap the SkPathRef in an
@ -338,7 +350,7 @@ public:
bool isValid() const; bool isValid() const;
SkDEBUGCODE(void validate() const { SkASSERT(this->isValid()); } ) SkDEBUGCODE(void validate() const { SkASSERT(this->isValid()); } )
SkPathView view(SkPathFillType, SkPathConvexityType) const; SkPathView view(SkPathFillType, SkPathConvexity) const;
private: private:
enum SerializationOffsets { enum SerializationOffsets {

View File

@ -67,7 +67,7 @@ static bool is_degenerate(const SkPath& path) {
class SkAutoDisableDirectionCheck { class SkAutoDisableDirectionCheck {
public: public:
SkAutoDisableDirectionCheck(SkPath* path) : fPath(path) { SkAutoDisableDirectionCheck(SkPath* path) : fPath(path) {
fSaved = static_cast<SkPathPriv::FirstDirection>(fPath->getFirstDirection()); fSaved = static_cast<SkPathFirstDirection>(fPath->getFirstDirection());
} }
~SkAutoDisableDirectionCheck() { ~SkAutoDisableDirectionCheck() {
@ -76,7 +76,7 @@ public:
private: private:
SkPath* fPath; SkPath* fPath;
SkPathPriv::FirstDirection fSaved; SkPathFirstDirection fSaved;
}; };
/* This class's constructor/destructor bracket a path editing operation. It is /* This class's constructor/destructor bracket a path editing operation. It is
@ -107,8 +107,8 @@ public:
} }
~SkAutoPathBoundsUpdate() { ~SkAutoPathBoundsUpdate() {
fPath->setConvexityType(fDegenerate ? SkPathConvexityType::kConvex fPath->setConvexity(fDegenerate ? SkPathConvexity::kConvex
: SkPathConvexityType::kUnknown); : SkPathConvexity::kUnknown);
if ((fEmpty || fHasValidBounds) && fRect.isFinite()) { if ((fEmpty || fHasValidBounds) && fRect.isFinite()) {
fPath->setBounds(fRect); fPath->setBounds(fRect);
} }
@ -147,12 +147,12 @@ SkPath::SkPath()
fIsVolatile = false; fIsVolatile = false;
} }
SkPath::SkPath(sk_sp<SkPathRef> pr, SkPathFillType ft, bool isVolatile, SkPathConvexityType ct, SkPath::SkPath(sk_sp<SkPathRef> pr, SkPathFillType ft, bool isVolatile, SkPathConvexity ct,
uint8_t firstDirection) SkPathFirstDirection firstDirection)
: fPathRef(std::move(pr)) : fPathRef(std::move(pr))
, fLastMoveToIndex(INITIAL_LASTMOVETOINDEX_VALUE) , fLastMoveToIndex(INITIAL_LASTMOVETOINDEX_VALUE)
, fConvexity((uint8_t)ct) , fConvexity((uint8_t)ct)
, fFirstDirection(firstDirection) , fFirstDirection((uint8_t)firstDirection)
, fFillType((unsigned)ft) , fFillType((unsigned)ft)
, fIsVolatile(isVolatile) , fIsVolatile(isVolatile)
{} {}
@ -161,8 +161,8 @@ void SkPath::resetFields() {
//fPathRef is assumed to have been emptied by the caller. //fPathRef is assumed to have been emptied by the caller.
fLastMoveToIndex = INITIAL_LASTMOVETOINDEX_VALUE; fLastMoveToIndex = INITIAL_LASTMOVETOINDEX_VALUE;
fFillType = SkToU8(SkPathFillType::kWinding); fFillType = SkToU8(SkPathFillType::kWinding);
this->setConvexityType(SkPathConvexityType::kUnknown); this->setConvexity(SkPathConvexity::kUnknown);
this->setFirstDirection(SkPathPriv::kUnknown_FirstDirection); this->setFirstDirection(SkPathFirstDirection::kUnknown);
// We don't touch Android's fSourcePath. It's used to track texture garbage collection, so we // 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. // 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; fIsVolatile = that.fIsVolatile;
// Non-atomic assignment of atomic values. // Non-atomic assignment of atomic values.
this->setConvexityType(that.getConvexityTypeOrUnknown()); this->setConvexity(that.getConvexityOrUnknown());
this->setFirstDirection(that.getFirstDirection()); this->setFirstDirection(that.getFirstDirection());
} }
@ -221,18 +221,18 @@ void SkPath::swap(SkPath& that) {
that.fIsVolatile = iv; that.fIsVolatile = iv;
// Non-atomic swaps of atomic values. // Non-atomic swaps of atomic values.
SkPathConvexityType c = this->getConvexityTypeOrUnknown(); SkPathConvexity c = this->getConvexityOrUnknown();
this->setConvexityType(that.getConvexityTypeOrUnknown()); this->setConvexity(that.getConvexityOrUnknown());
that.setConvexityType(c); that.setConvexity(c);
uint8_t fd = this->getFirstDirection(); SkPathFirstDirection fd = this->getFirstDirection();
this->setFirstDirection(that.getFirstDirection()); this->setFirstDirection(that.getFirstDirection());
that.setFirstDirection(fd); that.setFirstDirection(fd);
} }
} }
SkPathView SkPath::view() const { 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, static inline bool check_edge_against_rect(const SkPoint& p0,
const SkPoint& p1, const SkPoint& p1,
const SkRect& rect, const SkRect& rect,
SkPathPriv::FirstDirection dir) { SkPathFirstDirection dir) {
const SkPoint* edgeBegin; const SkPoint* edgeBegin;
SkVector v; SkVector v;
if (SkPathPriv::kCW_FirstDirection == dir) { if (SkPathFirstDirection::kCW == dir) {
v = p1 - p0; v = p1 - p0;
edgeBegin = &p0; edgeBegin = &p0;
} else { } else {
@ -290,7 +290,7 @@ bool SkPath::conservativelyContainsRect(const SkRect& rect) const {
return false; return false;
} }
SkPathPriv::FirstDirection direction; SkPathFirstDirection direction;
if (!SkPathPriv::CheapComputeFirstDirection(*this, &direction)) { if (!SkPathPriv::CheapComputeFirstDirection(*this, &direction)) {
return false; return false;
} }
@ -574,27 +574,27 @@ void SkPath::setLastPt(SkScalar x, SkScalar y) {
} }
// This is the public-facing non-const setConvexity(). // 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); fConvexity.store((uint8_t)c, std::memory_order_relaxed);
} }
// Const hooks for working with fConvexity and fFirstDirection from const methods. // 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); fConvexity.store((uint8_t)c, std::memory_order_relaxed);
} }
void SkPath::setFirstDirection(uint8_t d) const { void SkPath::setFirstDirection(SkPathFirstDirection d) const {
fFirstDirection.store(d, std::memory_order_relaxed); fFirstDirection.store((uint8_t)d, std::memory_order_relaxed);
} }
uint8_t SkPath::getFirstDirection() const { SkPathFirstDirection SkPath::getFirstDirection() const {
return fFirstDirection.load(std::memory_order_relaxed); return (SkPathFirstDirection)fFirstDirection.load(std::memory_order_relaxed);
} }
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// Construction methods // Construction methods
SkPath& SkPath::dirtyAfterEdit() { SkPath& SkPath::dirtyAfterEdit() {
this->setConvexityType(SkPathConvexityType::kUnknown); this->setConvexity(SkPathConvexity::kUnknown);
this->setFirstDirection(SkPathPriv::kUnknown_FirstDirection); this->setFirstDirection(SkPathFirstDirection::kUnknown);
return *this; 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) { SkPath& SkPath::addRect(const SkRect &rect, SkPathDirection dir, unsigned startIndex) {
assert_known_direction(dir); assert_known_direction(dir);
this->setFirstDirection(this->hasOnlyMoveTos() ? (SkPathPriv::FirstDirection)dir this->setFirstDirection(this->hasOnlyMoveTos() ? (SkPathFirstDirection)dir
: SkPathPriv::kUnknown_FirstDirection); : SkPathFirstDirection::kUnknown);
SkAutoDisableDirectionCheck addc(this); SkAutoDisableDirectionCheck addc(this);
SkAutoPathBoundsUpdate apbu(this, rect); SkAutoPathBoundsUpdate apbu(this, rect);
@ -938,8 +938,8 @@ SkPath& SkPath::addRRect(const SkRRect &rrect, SkPathDirection dir, unsigned sta
// degenerate(oval) => line points are collapsing // degenerate(oval) => line points are collapsing
this->addOval(bounds, dir, startIndex / 2); this->addOval(bounds, dir, startIndex / 2);
} else { } else {
this->setFirstDirection(this->hasOnlyMoveTos() ? (SkPathPriv::FirstDirection)dir this->setFirstDirection(this->hasOnlyMoveTos() ? (SkPathFirstDirection)dir
: SkPathPriv::kUnknown_FirstDirection); : SkPathFirstDirection::kUnknown);
SkAutoPathBoundsUpdate apbu(this, bounds); SkAutoPathBoundsUpdate apbu(this, bounds);
SkAutoDisableDirectionCheck addc(this); SkAutoDisableDirectionCheck addc(this);
@ -1045,9 +1045,9 @@ SkPath& SkPath::addOval(const SkRect &oval, SkPathDirection dir, unsigned startP
*/ */
bool isOval = hasOnlyMoveTos(); bool isOval = hasOnlyMoveTos();
if (isOval) { if (isOval) {
this->setFirstDirection((SkPathPriv::FirstDirection)dir); this->setFirstDirection((SkPathFirstDirection)dir);
} else { } else {
this->setFirstDirection(SkPathPriv::kUnknown_FirstDirection); this->setFirstDirection(SkPathFirstDirection::kUnknown);
} }
SkAutoDisableDirectionCheck addc(this); SkAutoDisableDirectionCheck addc(this);
@ -1617,9 +1617,9 @@ void SkPath::transform(const SkMatrix& matrix, SkPath* dst, SkApplyPerspectiveCl
dst->swap(tmp); dst->swap(tmp);
SkPathRef::Editor ed(&dst->fPathRef); SkPathRef::Editor ed(&dst->fPathRef);
matrix.mapPoints(ed.writablePoints(), ed.pathRef()->countPoints()); matrix.mapPoints(ed.writablePoints(), ed.pathRef()->countPoints());
dst->setFirstDirection(SkPathPriv::kUnknown_FirstDirection); dst->setFirstDirection(SkPathFirstDirection::kUnknown);
} else { } else {
SkPathConvexityType convexity = this->getConvexityTypeOrUnknown(); SkPathConvexity convexity = this->getConvexityOrUnknown();
SkPathRef::CreateTransformedCopy(&dst->fPathRef, *fPathRef, matrix); 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... // check, and keep convex paths marked as such after a general transform...
// //
if (matrix.isScaleTranslate() && SkPathPriv::IsAxisAligned(*this)) { if (matrix.isScaleTranslate() && SkPathPriv::IsAxisAligned(*this)) {
dst->setConvexityType(convexity); dst->setConvexity(convexity);
} else { } else {
dst->setConvexityType(SkPathConvexityType::kUnknown); dst->setConvexity(SkPathConvexity::kUnknown);
} }
if (this->getFirstDirection() == SkPathPriv::kUnknown_FirstDirection) { if (this->getFirstDirection() == SkPathFirstDirection::kUnknown) {
dst->setFirstDirection(SkPathPriv::kUnknown_FirstDirection); dst->setFirstDirection(SkPathFirstDirection::kUnknown);
} else { } else {
SkScalar det2x2 = SkScalar det2x2 =
matrix.get(SkMatrix::kMScaleX) * matrix.get(SkMatrix::kMScaleY) - matrix.get(SkMatrix::kMScaleX) * matrix.get(SkMatrix::kMScaleY) -
@ -1653,11 +1653,11 @@ void SkPath::transform(const SkMatrix& matrix, SkPath* dst, SkApplyPerspectiveCl
if (det2x2 < 0) { if (det2x2 < 0) {
dst->setFirstDirection( dst->setFirstDirection(
SkPathPriv::OppositeFirstDirection( SkPathPriv::OppositeFirstDirection(
(SkPathPriv::FirstDirection)this->getFirstDirection())); (SkPathFirstDirection)this->getFirstDirection()));
} else if (det2x2 > 0) { } else if (det2x2 > 0) {
dst->setFirstDirection(this->getFirstDirection()); dst->setFirstDirection(this->getFirstDirection());
} else { } else {
dst->setFirstDirection(SkPathPriv::kUnknown_FirstDirection); dst->setFirstDirection(SkPathFirstDirection::kUnknown);
} }
} }
@ -2040,7 +2040,7 @@ static bool almost_equal(SkScalar compA, SkScalar compB) {
struct Convexicator { struct Convexicator {
/** The direction returned is only valid if the path is determined convex */ /** 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) { void setMovePt(const SkPoint& pt) {
fPriorPt = fLastPt = fCurrPt = pt; fPriorPt = fLastPt = fCurrPt = pt;
@ -2062,7 +2062,7 @@ struct Convexicator {
return true; return true;
} }
static SkPathConvexityType BySign(const SkPoint points[], int count) { static SkPathConvexity BySign(const SkPoint points[], int count) {
const SkPoint* last = points + count; const SkPoint* last = points + count;
SkPoint currPt = *points++; SkPoint currPt = *points++;
SkPoint firstPt = currPt; SkPoint firstPt = currPt;
@ -2076,14 +2076,14 @@ struct Convexicator {
if (!vec.isZero()) { if (!vec.isZero()) {
// give up if vector construction failed // give up if vector construction failed
if (!vec.isFinite()) { if (!vec.isFinite()) {
return SkPathConvexityType::kUnknown; return SkPathConvexity::kUnknown;
} }
int sx = sign(vec.fX); int sx = sign(vec.fX);
int sy = sign(vec.fY); int sy = sign(vec.fY);
dxes += (sx != lastSx); dxes += (sx != lastSx);
dyes += (sy != lastSy); dyes += (sy != lastSy);
if (dxes > 3 || dyes > 3) { if (dxes > 3 || dyes > 3) {
return SkPathConvexityType::kConcave; return SkPathConvexity::kConcave;
} }
lastSx = sx; lastSx = sx;
lastSy = sy; lastSy = sy;
@ -2095,7 +2095,7 @@ struct Convexicator {
} }
points = &firstPt; 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() { bool close() {
@ -2138,10 +2138,10 @@ private:
case kRight_DirChange: case kRight_DirChange:
if (kInvalid_DirChange == fExpectedDir) { if (kInvalid_DirChange == fExpectedDir) {
fExpectedDir = dir; fExpectedDir = dir;
fFirstDirection = (kRight_DirChange == dir) ? SkPathPriv::kCW_FirstDirection fFirstDirection = (kRight_DirChange == dir) ? SkPathFirstDirection::kCW
: SkPathPriv::kCCW_FirstDirection; : SkPathFirstDirection::kCCW;
} else if (dir != fExpectedDir) { } else if (dir != fExpectedDir) {
fFirstDirection = SkPathPriv::kUnknown_FirstDirection; fFirstDirection = SkPathFirstDirection::kUnknown;
return false; return false;
} }
fLastVec = curVec; fLastVec = curVec;
@ -2170,24 +2170,24 @@ private:
SkPoint fCurrPt {0, 0}; SkPoint fCurrPt {0, 0};
SkVector fLastVec {0, 0}; SkVector fLastVec {0, 0};
DirChange fExpectedDir { kInvalid_DirChange }; DirChange fExpectedDir { kInvalid_DirChange };
SkPathPriv::FirstDirection fFirstDirection { SkPathPriv::kUnknown_FirstDirection }; SkPathFirstDirection fFirstDirection { SkPathFirstDirection::kUnknown };
int fReversals { 0 }; int fReversals { 0 };
bool fIsFinite { true }; bool fIsFinite { true };
}; };
SkPathConvexityType SkPath::computeConvexity() const { SkPathConvexity SkPath::computeConvexity() const {
SkPoint pts[4]; SkPoint pts[4];
SkPath::Verb verb; SkPath::Verb verb;
SkPath::Iter iter(*this, true); SkPath::Iter iter(*this, true);
auto setComputedConvexity = [=](SkPathConvexityType convexity){ auto setComputedConvexity = [=](SkPathConvexity convexity){
SkASSERT(SkPathConvexityType::kUnknown != convexity); SkASSERT(SkPathConvexity::kUnknown != convexity);
this->setConvexityType(convexity); this->setConvexity(convexity);
return convexity; return convexity;
}; };
auto setFail = [=](){ 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 // 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;
} }
--points; --points;
SkPathConvexityType convexity = Convexicator::BySign(points, (int) (last - points)); SkPathConvexity convexity = Convexicator::BySign(points, (int) (last - points));
if (SkPathConvexityType::kConvex != convexity) { if (SkPathConvexity::kConvex != convexity) {
return setComputedConvexity(SkPathConvexityType::kConcave); return setComputedConvexity(SkPathConvexity::kConcave);
} }
iter.setPath(*this, true); iter.setPath(*this, true);
} else if (!this->isFinite()) { } else if (!this->isFinite()) {
@ -2221,7 +2221,7 @@ SkPathConvexityType SkPath::computeConvexity() const {
switch (verb) { switch (verb) {
case kMove_Verb: case kMove_Verb:
if (++contourCount > 1) { if (++contourCount > 1) {
return setComputedConvexity(SkPathConvexityType::kConcave); return setComputedConvexity(SkPathConvexity::kConcave);
} }
state.setMovePt(pts[0]); state.setMovePt(pts[0]);
count = 0; count = 0;
@ -2245,7 +2245,7 @@ SkPathConvexityType SkPath::computeConvexity() const {
break; break;
default: default:
SkDEBUGFAIL("bad verb"); SkDEBUGFAIL("bad verb");
return setComputedConvexity(SkPathConvexityType::kConcave); return setComputedConvexity(SkPathConvexity::kConcave);
} }
for (int i = 1; i <= count; i++) { for (int i = 1; i <= count; i++) {
if (!state.addPt(pts[i])) { if (!state.addPt(pts[i])) {
@ -2254,20 +2254,20 @@ SkPathConvexityType SkPath::computeConvexity() const {
} }
} }
if (this->getFirstDirection() == SkPathPriv::kUnknown_FirstDirection) { if (this->getFirstDirection() == SkPathFirstDirection::kUnknown) {
if (state.getFirstDirection() == SkPathPriv::kUnknown_FirstDirection if (state.getFirstDirection() == SkPathFirstDirection::kUnknown
&& !this->getBounds().isEmpty()) { && !this->getBounds().isEmpty()) {
return setComputedConvexity(state.reversals() < 3 ? return setComputedConvexity(state.reversals() < 3 ?
SkPathConvexityType::kConvex : SkPathConvexityType::kConcave); SkPathConvexity::kConvex : SkPathConvexity::kConcave);
} }
this->setFirstDirection(state.getFirstDirection()); this->setFirstDirection(state.getFirstDirection());
} }
return setComputedConvexity(SkPathConvexityType::kConvex); return setComputedConvexity(SkPathConvexity::kConvex);
} }
bool SkPathPriv::IsConvex(const SkPoint points[], int count) { bool SkPathPriv::IsConvex(const SkPoint points[], int count) {
SkPathConvexityType convexity = Convexicator::BySign(points, count); SkPathConvexity convexity = Convexicator::BySign(points, count);
if (SkPathConvexityType::kConvex != convexity) { if (SkPathConvexity::kConvex != convexity) {
return false; return false;
} }
Convexicator state; Convexicator state;
@ -2283,7 +2283,7 @@ bool SkPathPriv::IsConvex(const SkPoint points[], int count) {
if (!state.close()) { if (!state.close()) {
return false; return false;
} }
return state.getFirstDirection() != SkPathPriv::kUnknown_FirstDirection return state.getFirstDirection() != SkPathFirstDirection::kUnknown
|| state.reversals() < 3; || state.reversals() < 3;
} }
@ -2443,8 +2443,8 @@ static int find_min_max_x_at_y(const SkPoint pts[], int index, int n,
return minIndex; return minIndex;
} }
static void crossToDir(SkScalar cross, SkPathPriv::FirstDirection* dir) { static void crossToDir(SkScalar cross, SkPathFirstDirection* dir) {
*dir = cross > 0 ? SkPathPriv::kCW_FirstDirection : SkPathPriv::kCCW_FirstDirection; *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 * that is outer most (or at least has the global y-max) before we can consider
* its cross product. * its cross product.
*/ */
bool SkPathPriv::CheapComputeFirstDirection(const SkPath& path, FirstDirection* dir) { bool SkPathPriv::CheapComputeFirstDirection(const SkPath& path, SkPathFirstDirection* dir) {
auto d = path.getFirstDirection(); auto d = path.getFirstDirection();
if (d != kUnknown_FirstDirection) { if (d != SkPathFirstDirection::kUnknown) {
*dir = static_cast<FirstDirection>(d); *dir = d;
return true; return true;
} }
// We don't want to pay the cost for computing convexity if it is unknown, // We don't want to pay the cost for computing convexity if it is unknown,
// so we call getConvexityOrUnknown() instead of isConvex(). // so we call getConvexityOrUnknown() instead of isConvex().
if (path.getConvexityTypeOrUnknown() == SkPathConvexityType::kConvex) { if (path.getConvexityOrUnknown() == SkPathConvexity::kConvex) {
SkASSERT(path.getFirstDirection() == kUnknown_FirstDirection); SkASSERT(path.getFirstDirection() == SkPathFirstDirection::kUnknown);
*dir = static_cast<FirstDirection>(path.getFirstDirection()); *dir = path.getFirstDirection();
return false; return false;
} }
@ -3179,7 +3179,7 @@ void SkPathPriv::CreateDrawArcPath(SkPath* path, const SkRect& oval, SkScalar st
path->moveTo(oval.centerX(), oval.centerY()); path->moveTo(oval.centerX(), oval.centerY());
} }
auto firstDir = auto firstDir =
sweepAngle > 0 ? SkPathPriv::kCW_FirstDirection : SkPathPriv::kCCW_FirstDirection; sweepAngle > 0 ? SkPathFirstDirection::kCW : SkPathFirstDirection::kCCW;
bool convex = DrawArcIsConvex(sweepAngle, useCenter, isFillNoPathEffect); bool convex = DrawArcIsConvex(sweepAngle, useCenter, isFillNoPathEffect);
// Arc to mods at 360 and drawArc is not supposed to. // Arc to mods at 360 and drawArc is not supposed to.
bool forceMoveTo = !useCenter; bool forceMoveTo = !useCenter;
@ -3203,7 +3203,7 @@ void SkPathPriv::CreateDrawArcPath(SkPath* path, const SkRect& oval, SkScalar st
if (useCenter) { if (useCenter) {
path->close(); path->close();
} }
path->setConvexityType(convex ? SkPathConvexityType::kConvex : SkPathConvexityType::kConcave); path->setConvexity(convex ? SkPathConvexity::kConvex : SkPathConvexity::kConcave);
path->setFirstDirection(firstDir); path->setFirstDirection(firstDir);
} }
@ -3385,7 +3385,7 @@ SkPath SkPath::Make(const SkPoint pts[], int pointCount,
SkTDArray<uint8_t>(vbs, verbCount), SkTDArray<uint8_t>(vbs, verbCount),
SkTDArray<SkScalar>(ws, info.weights), SkTDArray<SkScalar>(ws, info.weights),
info.segmentMask)), 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) { SkPath SkPath::Rect(const SkRect& r, SkPathDirection dir, unsigned startIndex) {

View File

@ -35,7 +35,7 @@ SkPathBuilder& SkPathBuilder::reset() {
fNeedsMoveVerb = true; fNeedsMoveVerb = true;
// testing // testing
fOverrideConvexity = SkPathConvexityType::kUnknown; fOverrideConvexity = SkPathConvexity::kUnknown;
return *this; return *this;
} }
@ -49,7 +49,7 @@ void SkPathBuilder::incReserve(int extraPtCount, int extraVbCount) {
* Some old behavior in SkPath -- should we keep it? * Some old behavior in SkPath -- should we keep it?
* *
* After each edit (i.e. adding a verb) * After each edit (i.e. adding a verb)
this->setConvexityType(SkPathConvexityType::kUnknown); this->setConvexityType(SkPathConvexity::kUnknown);
this->setFirstDirection(SkPathPriv::kUnknown_FirstDirection); this->setFirstDirection(SkPathPriv::kUnknown_FirstDirection);
*/ */
@ -150,24 +150,24 @@ SkPathBuilder& SkPathBuilder::rCubicTo(SkPoint p1, SkPoint p2, SkPoint p3) {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
SkPath SkPathBuilder::make(sk_sp<SkPathRef> pr) const { SkPath SkPathBuilder::make(sk_sp<SkPathRef> pr) const {
auto convexity = SkPathConvexityType::kUnknown; auto convexity = SkPathConvexity::kUnknown;
SkPathPriv::FirstDirection dir = SkPathPriv::kUnknown_FirstDirection; SkPathFirstDirection dir = SkPathFirstDirection::kUnknown;
switch (fIsA) { switch (fIsA) {
case kIsA_Oval: case kIsA_Oval:
pr->setIsOval( true, fIsACCW, fIsAStart); pr->setIsOval( true, fIsACCW, fIsAStart);
convexity = SkPathConvexityType::kConvex; convexity = SkPathConvexity::kConvex;
dir = fIsACCW ? SkPathPriv::kCCW_FirstDirection : SkPathPriv::kCW_FirstDirection; dir = fIsACCW ? SkPathFirstDirection::kCCW : SkPathFirstDirection::kCW;
break; break;
case kIsA_RRect: case kIsA_RRect:
pr->setIsRRect(true, fIsACCW, fIsAStart); pr->setIsRRect(true, fIsACCW, fIsAStart);
convexity = SkPathConvexityType::kConvex; convexity = SkPathConvexity::kConvex;
dir = fIsACCW ? SkPathPriv::kCCW_FirstDirection : SkPathPriv::kCW_FirstDirection; dir = fIsACCW ? SkPathFirstDirection::kCCW : SkPathFirstDirection::kCW;
break; break;
default: break; default: break;
} }
if (fOverrideConvexity != SkPathConvexityType::kUnknown) { if (fOverrideConvexity != SkPathConvexity::kUnknown) {
convexity = fOverrideConvexity; convexity = fOverrideConvexity;
} }

View File

@ -27,26 +27,20 @@ public:
static constexpr SkScalar kW0PlaneDistance = 0.05f; static constexpr SkScalar kW0PlaneDistance = 0.05f;
enum FirstDirection : int { static SkPathFirstDirection AsFirstDirection(SkPathDirection dir) {
kCW_FirstDirection, // == SkPathDirection::kCW
kCCW_FirstDirection, // == SkPathDirection::kCCW
kUnknown_FirstDirection,
};
static FirstDirection AsFirstDirection(SkPathDirection dir) {
// since we agree numerically for the values in Direction, we can just cast. // 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 * Return the opposite of the specified direction. kUnknown is its own
* opposite. * opposite.
*/ */
static FirstDirection OppositeFirstDirection(FirstDirection dir) { static SkPathFirstDirection OppositeFirstDirection(SkPathFirstDirection dir) {
static const FirstDirection gOppositeDir[] = { static const SkPathFirstDirection gOppositeDir[] = {
kCCW_FirstDirection, kCW_FirstDirection, kUnknown_FirstDirection, 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 * the dir parameter. If the direction was determined, it is cached to make
* subsequent calls return quickly. * 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 * 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 * specified direction. If dir is kUnknown, returns true if the direction
* cannot be computed. * cannot be computed.
*/ */
static bool CheapIsFirstDirection(const SkPath& path, FirstDirection dir) { static bool CheapIsFirstDirection(const SkPath& path, SkPathFirstDirection dir) {
FirstDirection computedDir = kUnknown_FirstDirection; SkPathFirstDirection computedDir = SkPathFirstDirection::kUnknown;
(void)CheapComputeFirstDirection(path, &computedDir); (void)CheapComputeFirstDirection(path, &computedDir);
return computedDir == dir; return computedDir == dir;
} }
@ -415,20 +409,20 @@ public:
path->dirtyAfterEdit(); path->dirtyAfterEdit();
} }
static SkPathConvexityType GetConvexityType(const SkPath& path) { static SkPathConvexity GetConvexity(const SkPath& path) {
return path.getConvexityType(); return path.getConvexity();
} }
static SkPathConvexityType GetConvexityTypeOrUnknown(const SkPath& path) { static SkPathConvexity GetConvexityOrUnknown(const SkPath& path) {
return path.getConvexityTypeOrUnknown(); return path.getConvexityOrUnknown();
} }
static void SetConvexityType(const SkPath& path, SkPathConvexityType c) { static void SetConvexity(const SkPath& path, SkPathConvexity c) {
path.setConvexityType(c); path.setConvexity(c);
} }
static void SetConvexityType(SkPathBuilder* builder, SkPathConvexityType c) { static void SetConvexity(SkPathBuilder* builder, SkPathConvexity c) {
builder->privateSetConvexityType(c); builder->privateSetConvexity(c);
} }
static void ForceComputeConvexity(const SkPath& path) { static void ForceComputeConvexity(const SkPath& path) {
path.setConvexityType(SkPathConvexityType::kUnknown); path.setConvexity(SkPathConvexity::kUnknown);
(void)path.isConvex(); (void)path.isConvex();
} }

View File

@ -686,7 +686,7 @@ bool SkPathRef::isValid() const {
#include "src/core/SkPathView.h" #include "src/core/SkPathView.h"
SkPathView SkPathRef::view(SkPathFillType ft, SkPathConvexityType ct) const { SkPathView SkPathRef::view(SkPathFillType ft, SkPathConvexity ct) const {
return { return {
{ fPoints.begin(), fPoints.size() }, { fPoints.begin(), fPoints.size() },
{ fVerbs.begin(), fVerbs.size() }, { fVerbs.begin(), fVerbs.size() },

View File

@ -10,11 +10,12 @@
#include "include/core/SkPathTypes.h" #include "include/core/SkPathTypes.h"
#include "include/core/SkPoint.h" #include "include/core/SkPoint.h"
#include "include/core/SkRect.h" #include "include/core/SkRect.h"
#include "include/private/SkPathRef.h"
#include "src/core/SkSpan.h" #include "src/core/SkSpan.h"
struct SkPathView { struct SkPathView {
SkPathView(SkSpan<const SkPoint> points, SkSpan<const uint8_t> verbs, SkSpan<const float> weights, SkPathView(SkSpan<const SkPoint> points, SkSpan<const uint8_t> verbs, SkSpan<const float> weights,
SkPathFillType ft, SkPathConvexityType ct, const SkRect& bounds, unsigned segmentMask, SkPathFillType ft, SkPathConvexity ct, const SkRect& bounds, unsigned segmentMask,
bool isFinite) bool isFinite)
: fPoints(points) : fPoints(points)
, fVerbs(verbs) , fVerbs(verbs)
@ -29,7 +30,7 @@ struct SkPathView {
} }
bool isInverseFillType() const { return SkPathFillType_IsInverse(fFillType); } 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; } bool isEmpty() const { return fPoints.size() == 0; }
@ -43,7 +44,7 @@ struct SkPathView {
SkRect fBounds; SkRect fBounds;
SkPathFillType fFillType; SkPathFillType fFillType;
SkPathConvexityType fConvexity; SkPathConvexity fConvexity;
uint8_t fSegmentMask; uint8_t fSegmentMask;
bool fIsFinite; bool fIsFinite;
@ -61,7 +62,7 @@ static inline SkPathView SkPathView_triangle(const SkPoint pts[3], const SkRect&
(uint8_t)SkPathVerb::kLine, (uint8_t)SkPathVerb::kLine,
}; };
return SkPathView({pts, 3}, SkMakeSpan(verbs), {}, return SkPathView({pts, 3}, SkMakeSpan(verbs), {},
SkPathFillType::kWinding, SkPathConvexityType::kConvex, SkPathFillType::kWinding, SkPathConvexity::kConvex,
bounds, kLine_SkPathSegmentMask, true); bounds, kLine_SkPathSegmentMask, true);
} }
@ -73,6 +74,6 @@ static inline SkPathView SkPathView_quad(const SkPoint pts[4], const SkRect& bou
(uint8_t)SkPathVerb::kLine, (uint8_t)SkPathVerb::kLine,
}; };
return SkPathView({pts, 4}, SkMakeSpan(verbs), {}, return SkPathView({pts, 4}, SkMakeSpan(verbs), {},
SkPathFillType::kWinding, SkPathConvexityType::kConvex, SkPathFillType::kWinding, SkPathConvexity::kConvex,
bounds, kLine_SkPathSegmentMask, true); bounds, kLine_SkPathSegmentMask, true);
}; };

View File

@ -73,7 +73,7 @@ size_t SkPath::writeToMemoryAsRRect(void* storage) const {
return sizeNeeded; 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) | int32_t packed = (fFillType << kFillType_SerializationShift) |
(firstDir << kDirection_SerializationShift) | (firstDir << kDirection_SerializationShift) |
(SerializationType::kRRect << kType_SerializationShift) | (SerializationType::kRRect << kType_SerializationShift) |
@ -173,10 +173,10 @@ size_t SkPath::readAsRRect(const void* storage, size_t length) {
SkRRect rrect; SkRRect rrect;
int32_t start; int32_t start;
switch (dir) { switch (dir) {
case SkPathPriv::kCW_FirstDirection: case (int)SkPathFirstDirection::kCW:
rrectDir = SkPathDirection::kCW; rrectDir = SkPathDirection::kCW;
break; break;
case SkPathPriv::kCCW_FirstDirection: case (int)SkPathFirstDirection::kCCW:
rrectDir = SkPathDirection::kCCW; rrectDir = SkPathDirection::kCCW;
break; break;
default: default:

View File

@ -1504,7 +1504,7 @@ DONE:
stroker.done(dst, lastSegment == SkPath::kLine_Verb); stroker.done(dst, lastSegment == SkPath::kLine_Verb);
if (fDoFill && !ignoreCenter) { if (fDoFill && !ignoreCenter) {
if (SkPathPriv::CheapIsFirstDirection(src, SkPathPriv::kCCW_FirstDirection)) { if (SkPathPriv::CheapIsFirstDirection(src, SkPathFirstDirection::kCCW)) {
dst->reverseAddPath(src); dst->reverseAddPath(src);
} else { } else {
dst->addPath(src); dst->addPath(src);

View File

@ -134,16 +134,16 @@ sk_sp<SkPathEffect> SkStrokeAndFillPathEffect::Make() {
void SkStrokeAndFillPE::flatten(SkWriteBuffer&) const {} void SkStrokeAndFillPE::flatten(SkWriteBuffer&) const {}
static bool known_to_be_opposite_directions(const SkPath& a, const SkPath& b) { static bool known_to_be_opposite_directions(const SkPath& a, const SkPath& b) {
auto a_dir = SkPathPriv::kUnknown_FirstDirection, auto a_dir = SkPathFirstDirection::kUnknown,
b_dir = SkPathPriv::kUnknown_FirstDirection; b_dir = SkPathFirstDirection::kUnknown;
(void)SkPathPriv::CheapComputeFirstDirection(a, &a_dir); (void)SkPathPriv::CheapComputeFirstDirection(a, &a_dir);
(void)SkPathPriv::CheapComputeFirstDirection(b, &b_dir); (void)SkPathPriv::CheapComputeFirstDirection(b, &b_dir);
return (a_dir == SkPathPriv::kCCW_FirstDirection && return (a_dir == SkPathFirstDirection::kCCW &&
b_dir == SkPathPriv::kCW_FirstDirection) b_dir == SkPathFirstDirection::kCW)
|| ||
(a_dir == SkPathPriv::kCW_FirstDirection && (a_dir == SkPathFirstDirection::kCW &&
b_dir == SkPathPriv::kCCW_FirstDirection); b_dir == SkPathFirstDirection::kCCW);
} }
bool SkStrokeAndFillPE::onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec, bool SkStrokeAndFillPE::onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec,

View File

@ -97,7 +97,7 @@ GrFPResult GrConvexPolyEffect::Make(std::unique_ptr<GrFragmentProcessor> inputFP
return GrFPFailure(std::move(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 // 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 // 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. // skip the draw or omit the clip element.
@ -138,7 +138,7 @@ GrFPResult GrConvexPolyEffect::Make(std::unique_ptr<GrFragmentProcessor> inputFP
if (pts[0] != pts[1]) { if (pts[0] != pts[1]) {
SkVector v = pts[1] - pts[0]; SkVector v = pts[1] - pts[0];
v.normalize(); v.normalize();
if (SkPathPriv::kCCW_FirstDirection == dir) { if (SkPathFirstDirection::kCCW == dir) {
edges[3 * n] = v.fY; edges[3 * n] = v.fY;
edges[3 * n + 1] = -v.fX; edges[3 * n + 1] = -v.fX;
} else { } else {

View File

@ -366,16 +366,16 @@ bool is_point_within_cubic_tangents(const SkPoint& a,
const SkVector& ab, const SkVector& ab,
const SkVector& dc, const SkVector& dc,
const SkPoint& d, const SkPoint& d,
SkPathPriv::FirstDirection dir, SkPathFirstDirection dir,
const SkPoint p) { const SkPoint p) {
SkVector ap = p - a; SkVector ap = p - a;
SkScalar apXab = ap.cross(ab); SkScalar apXab = ap.cross(ab);
if (SkPathPriv::kCW_FirstDirection == dir) { if (SkPathFirstDirection::kCW == dir) {
if (apXab > 0) { if (apXab > 0) {
return false; return false;
} }
} else { } else {
SkASSERT(SkPathPriv::kCCW_FirstDirection == dir); SkASSERT(SkPathFirstDirection::kCCW == dir);
if (apXab < 0) { if (apXab < 0) {
return false; return false;
} }
@ -383,12 +383,12 @@ bool is_point_within_cubic_tangents(const SkPoint& a,
SkVector dp = p - d; SkVector dp = p - d;
SkScalar dpXdc = dp.cross(dc); SkScalar dpXdc = dp.cross(dc);
if (SkPathPriv::kCW_FirstDirection == dir) { if (SkPathFirstDirection::kCW == dir) {
if (dpXdc < 0) { if (dpXdc < 0) {
return false; return false;
} }
} else { } else {
SkASSERT(SkPathPriv::kCCW_FirstDirection == dir); SkASSERT(SkPathFirstDirection::kCCW == dir);
if (dpXdc > 0) { if (dpXdc > 0) {
return false; 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], void convert_noninflect_cubic_to_quads_with_constraint(const SkPoint p[4],
SkScalar toleranceSqd, SkScalar toleranceSqd,
SkPathPriv::FirstDirection dir, SkPathFirstDirection dir,
SkTArray<SkPoint, true>* quads, SkTArray<SkPoint, true>* quads,
int sublevel = 0) { 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 // 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], void GrPathUtils::convertCubicToQuadsConstrainToTangents(const SkPoint p[4],
SkScalar tolScale, SkScalar tolScale,
SkPathPriv::FirstDirection dir, SkPathFirstDirection dir,
SkTArray<SkPoint, true>* quads) { SkTArray<SkPoint, true>* quads) {
if (!p[0].isFinite() || !p[1].isFinite() || !p[2].isFinite() || !p[3].isFinite()) { if (!p[0].isFinite() || !p[1].isFinite() || !p[2].isFinite() || !p[3].isFinite()) {
return; return;

View File

@ -117,7 +117,7 @@ namespace GrPathUtils {
// must specify the orientation of the contour containing the cubic. // must specify the orientation of the contour containing the cubic.
void convertCubicToQuadsConstrainToTangents(const SkPoint p[4], void convertCubicToQuadsConstrainToTangents(const SkPoint p[4],
SkScalar tolScale, SkScalar tolScale,
SkPathPriv::FirstDirection dir, SkPathFirstDirection dir,
SkTArray<SkPoint, true>* quads); SkTArray<SkPoint, true>* quads);
enum class ExcludedTerm { enum class ExcludedTerm {

View File

@ -178,8 +178,7 @@ public:
// Assuming this is called after knownToBeConvex(), this should just be relying on // Assuming this is called after knownToBeConvex(), this should just be relying on
// cached convexity and direction and will be cheap. // cached convexity and direction and will be cheap.
return !fShape.isPath() || return !fShape.isPath() ||
!SkPathPriv::CheapIsFirstDirection(fShape.path(), !SkPathPriv::CheapIsFirstDirection(fShape.path(), SkPathFirstDirection::kUnknown);
SkPathPriv::kUnknown_FirstDirection);
} }
/** Is the pre-styled geometry inverse filled? */ /** Is the pre-styled geometry inverse filled? */

View File

@ -117,7 +117,7 @@ static bool center_of_mass(const SegmentArray& segments, SkPoint* c) {
static bool compute_vectors(SegmentArray* segments, static bool compute_vectors(SegmentArray* segments,
SkPoint* fanPt, SkPoint* fanPt,
SkPathPriv::FirstDirection dir, SkPathFirstDirection dir,
int* vCount, int* vCount,
int* iCount) { int* iCount) {
if (!center_of_mass(*segments, fanPt)) { if (!center_of_mass(*segments, fanPt)) {
@ -127,7 +127,7 @@ static bool compute_vectors(SegmentArray* segments,
// Make the normals point towards the outside // Make the normals point towards the outside
SkPointPriv::Side normSide; SkPointPriv::Side normSide;
if (dir == SkPathPriv::kCCW_FirstDirection) { if (dir == SkPathFirstDirection::kCCW) {
normSide = SkPointPriv::kRight_Side; normSide = SkPointPriv::kRight_Side;
} else { } else {
normSide = SkPointPriv::kLeft_Side; 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, 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 // 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. // 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 // 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], static inline void add_cubic_segments(const SkPoint pts[4],
SkPathPriv::FirstDirection dir, SkPathFirstDirection dir,
SegmentArray* segments) { SegmentArray* segments) {
SkSTArray<15, SkPoint, true> quads; SkSTArray<15, SkPoint, true> quads;
GrPathUtils::convertCubicToQuadsConstrainToTangents(pts, SK_Scalar1, dir, &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 // line paths. We detect paths that are very close to a line (zero area) and
// draw nothing. // draw nothing.
DegenerateTestData degenerateData; DegenerateTestData degenerateData;
SkPathPriv::FirstDirection dir; SkPathFirstDirection dir;
if (!get_direction(path, m, &dir)) { if (!get_direction(path, m, &dir)) {
return false; return false;
} }

View File

@ -42,9 +42,9 @@ bool SkOpBuilder::FixWinding(SkPath* path) {
} else if (fillType == SkPathFillType::kEvenOdd) { } else if (fillType == SkPathFillType::kEvenOdd) {
fillType = SkPathFillType::kWinding; fillType = SkPathFillType::kWinding;
} }
SkPathPriv::FirstDirection dir; SkPathFirstDirection dir;
if (one_contour(*path) && SkPathPriv::CheapComputeFirstDirection(*path, &dir)) { if (one_contour(*path) && SkPathPriv::CheapComputeFirstDirection(*path, &dir)) {
if (dir != SkPathPriv::kCCW_FirstDirection) { if (dir != SkPathFirstDirection::kCCW) {
ReversePath(path); ReversePath(path);
} }
path->setFillType(fillType); path->setFillType(fillType);
@ -127,7 +127,7 @@ bool SkOpBuilder::resolve(SkPath* result) {
SkPath original = *result; SkPath original = *result;
int count = fOps.count(); int count = fOps.count();
bool allUnion = true; bool allUnion = true;
SkPathPriv::FirstDirection firstDir = SkPathPriv::kUnknown_FirstDirection; SkPathFirstDirection firstDir = SkPathFirstDirection::kUnknown;
for (int index = 0; index < count; ++index) { for (int index = 0; index < count; ++index) {
SkPath* test = &fPathRefs[index]; SkPath* test = &fPathRefs[index];
if (kUnion_SkPathOp != fOps[index] || test->isInverseFillType()) { 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 all paths are convex, track direction, reversing as needed.
if (test->isConvex()) { if (test->isConvex()) {
SkPathPriv::FirstDirection dir; SkPathFirstDirection dir;
if (!SkPathPriv::CheapComputeFirstDirection(*test, &dir)) { if (!SkPathPriv::CheapComputeFirstDirection(*test, &dir)) {
allUnion = false; allUnion = false;
break; break;
} }
if (firstDir == SkPathPriv::kUnknown_FirstDirection) { if (firstDir == SkPathFirstDirection::kUnknown) {
firstDir = dir; firstDir = dir;
} else if (firstDir != dir) { } else if (firstDir != dir) {
ReversePath(test); ReversePath(test);

View File

@ -427,7 +427,7 @@ bool SkDashPath::InternalFilter(SkPath* dst, const SkPath& src, SkStrokeRec* rec
// TODO: do we still need this? // TODO: do we still need this?
if (segCount > 1) { if (segCount > 1) {
SkPathPriv::SetConvexityType(*dst, SkPathConvexityType::kConcave); SkPathPriv::SetConvexity(*dst, SkPathConvexity::kConcave);
} }
return true; return true;

View File

@ -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 // 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. // to trigger computing it, so this is the stronger test for equality.
{ {
SkPathConvexityType ca = SkPathPriv::GetConvexityTypeOrUnknown(a), SkPathConvexity ca = SkPathPriv::GetConvexityOrUnknown(a),
cb = SkPathPriv::GetConvexityTypeOrUnknown(b); cb = SkPathPriv::GetConvexityOrUnknown(b);
if (ca != cb) { if (ca != cb) {
return false; return false;
} }

View File

@ -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. // Set this for paths that don't have a consistent direction such as a bowtie.
// (cheapComputeDirection is not expected to catch these.) // (cheapComputeDirection is not expected to catch these.)
// Legal values are CW (0), CCW (1) and Unknown (2), leaving 3 as a convenient sentinel. // Legal values are CW (0), CCW (1) and Unknown (2), leaving 3 as a convenient sentinel.
const SkPathPriv::FirstDirection kDontCheckDir = static_cast<SkPathPriv::FirstDirection>(3); const SkPathFirstDirection kDontCheckDir = static_cast<SkPathFirstDirection>(3);
static void check_direction(skiatest::Reporter* reporter, const SkPath& path, static void check_direction(skiatest::Reporter* reporter, const SkPath& path,
SkPathPriv::FirstDirection expected) { SkPathFirstDirection expected) {
if (expected == kDontCheckDir) { if (expected == kDontCheckDir) {
return; return;
} }
// We make a copy so that we don't cache the result on the passed in path. // 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) SkPath copy(path); // NOLINT(performance-unnecessary-copy-initialization)
SkPathPriv::FirstDirection dir; SkPathFirstDirection dir;
if (SkPathPriv::CheapComputeFirstDirection(copy, &dir)) { if (SkPathPriv::CheapComputeFirstDirection(copy, &dir)) {
REPORTER_ASSERT(reporter, dir == expected); REPORTER_ASSERT(reporter, dir == expected);
} else { } 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; size_t i;
SkPath path; SkPath path;
REPORTER_ASSERT(reporter, !SkPathPriv::CheapComputeFirstDirection(path, nullptr)); REPORTER_ASSERT(reporter, !SkPathPriv::CheapComputeFirstDirection(path, nullptr));
REPORTER_ASSERT(reporter, !SkPathPriv::CheapIsFirstDirection(path, SkPathPriv::kCW_FirstDirection)); REPORTER_ASSERT(reporter, !SkPathPriv::CheapIsFirstDirection(path, SkPathFirstDirection::kCW));
REPORTER_ASSERT(reporter, !SkPathPriv::CheapIsFirstDirection(path, SkPathPriv::kCCW_FirstDirection)); REPORTER_ASSERT(reporter, !SkPathPriv::CheapIsFirstDirection(path, SkPathFirstDirection::kCCW));
REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(path, SkPathPriv::kUnknown_FirstDirection)); REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(path, SkPathFirstDirection::kUnknown));
static const char* gDegen[] = { static const char* gDegen[] = {
"M 10 10", "M 10 10",
@ -1103,7 +1103,7 @@ static void test_direction(skiatest::Reporter* reporter) {
path.reset(); path.reset();
bool valid = SkParsePath::FromSVGString(gCW[i], &path); bool valid = SkParsePath::FromSVGString(gCW[i], &path);
REPORTER_ASSERT(reporter, valid); REPORTER_ASSERT(reporter, valid);
check_direction(reporter, path, SkPathPriv::kCW_FirstDirection); check_direction(reporter, path, SkPathFirstDirection::kCW);
} }
static const char* gCCW[] = { static const char* gCCW[] = {
@ -1119,7 +1119,7 @@ static void test_direction(skiatest::Reporter* reporter) {
path.reset(); path.reset();
bool valid = SkParsePath::FromSVGString(gCCW[i], &path); bool valid = SkParsePath::FromSVGString(gCCW[i], &path);
REPORTER_ASSERT(reporter, valid); 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 // 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.reset();
path.addCircle(0, 0, SkIntToScalar(2), SkPathDirection::kCW); path.addCircle(0, 0, SkIntToScalar(2), SkPathDirection::kCW);
path.addCircle(0, 0, SkIntToScalar(1), SkPathDirection::kCCW); path.addCircle(0, 0, SkIntToScalar(1), SkPathDirection::kCCW);
check_direction(reporter, path, SkPathPriv::kCW_FirstDirection); check_direction(reporter, path, SkPathFirstDirection::kCW);
path.reset(); path.reset();
path.addCircle(0, 0, SkIntToScalar(1), SkPathDirection::kCW); path.addCircle(0, 0, SkIntToScalar(1), SkPathDirection::kCW);
path.addCircle(0, 0, SkIntToScalar(2), SkPathDirection::kCCW); 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. // triangle with one point really far from the origin.
path.reset(); path.reset();
@ -1140,19 +1140,19 @@ static void test_direction(skiatest::Reporter* reporter) {
path.moveTo(SkBits2Float(0x501c7652), SkBits2Float(0x501c7652)); path.moveTo(SkBits2Float(0x501c7652), SkBits2Float(0x501c7652));
path.lineTo(110 * SK_Scalar1, -10 * SK_Scalar1); path.lineTo(110 * SK_Scalar1, -10 * SK_Scalar1);
path.lineTo(-10 * SK_Scalar1, 60 * 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.reset();
path.conicTo(20, 0, 20, 20, 0.5f); path.conicTo(20, 0, 20, 20, 0.5f);
path.close(); path.close();
check_direction(reporter, path, SkPathPriv::kCW_FirstDirection); check_direction(reporter, path, SkPathFirstDirection::kCW);
path.reset(); path.reset();
path.lineTo(1, 1e7f); path.lineTo(1, 1e7f);
path.lineTo(1e7f, 2e7f); path.lineTo(1e7f, 2e7f);
path.close(); path.close();
REPORTER_ASSERT(reporter, path.isConvex()); 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) { 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" // 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. // bends convince the checker that it's concave. That's okay though, we draw it correctly.
check_convexity(reporter, tinyConvexPolygon, false); check_convexity(reporter, tinyConvexPolygon, false);
check_direction(reporter, tinyConvexPolygon, SkPathPriv::kCW_FirstDirection); check_direction(reporter, tinyConvexPolygon, SkPathFirstDirection::kCW);
SkPath platTriangle; SkPath platTriangle;
platTriangle.moveTo(0, 0); platTriangle.moveTo(0, 0);
@ -1355,7 +1355,7 @@ static void test_path_crbug389050(skiatest::Reporter* reporter) {
platTriangle.lineTo(100, 0.04f); platTriangle.lineTo(100, 0.04f);
platTriangle.close(); platTriangle.close();
platTriangle.isConvex(); platTriangle.isConvex();
check_direction(reporter, platTriangle, SkPathPriv::kCW_FirstDirection); check_direction(reporter, platTriangle, SkPathFirstDirection::kCW);
platTriangle.reset(); platTriangle.reset();
platTriangle.moveTo(0, 0); platTriangle.moveTo(0, 0);
@ -1363,7 +1363,7 @@ static void test_path_crbug389050(skiatest::Reporter* reporter) {
platTriangle.lineTo(100, 0.03f); platTriangle.lineTo(100, 0.03f);
platTriangle.close(); platTriangle.close();
platTriangle.isConvex(); platTriangle.isConvex();
check_direction(reporter, platTriangle, SkPathPriv::kCW_FirstDirection); check_direction(reporter, platTriangle, SkPathFirstDirection::kCW);
} }
static void test_convexity2(skiatest::Reporter* reporter) { static void test_convexity2(skiatest::Reporter* reporter) {
@ -1371,14 +1371,14 @@ static void test_convexity2(skiatest::Reporter* reporter) {
pt.moveTo(0, 0); pt.moveTo(0, 0);
pt.close(); pt.close();
check_convexity(reporter, pt, true); check_convexity(reporter, pt, true);
check_direction(reporter, pt, SkPathPriv::kUnknown_FirstDirection); check_direction(reporter, pt, SkPathFirstDirection::kUnknown);
SkPath line; SkPath line;
line.moveTo(12*SK_Scalar1, 20*SK_Scalar1); line.moveTo(12*SK_Scalar1, 20*SK_Scalar1);
line.lineTo(-12*SK_Scalar1, -20*SK_Scalar1); line.lineTo(-12*SK_Scalar1, -20*SK_Scalar1);
line.close(); line.close();
check_convexity(reporter, line, true); check_convexity(reporter, line, true);
check_direction(reporter, line, SkPathPriv::kUnknown_FirstDirection); check_direction(reporter, line, SkPathFirstDirection::kUnknown);
SkPath triLeft; SkPath triLeft;
triLeft.moveTo(0, 0); triLeft.moveTo(0, 0);
@ -1386,7 +1386,7 @@ static void test_convexity2(skiatest::Reporter* reporter) {
triLeft.lineTo(SK_Scalar1, SK_Scalar1); triLeft.lineTo(SK_Scalar1, SK_Scalar1);
triLeft.close(); triLeft.close();
check_convexity(reporter, triLeft, true); check_convexity(reporter, triLeft, true);
check_direction(reporter, triLeft, SkPathPriv::kCW_FirstDirection); check_direction(reporter, triLeft, SkPathFirstDirection::kCW);
SkPath triRight; SkPath triRight;
triRight.moveTo(0, 0); triRight.moveTo(0, 0);
@ -1394,7 +1394,7 @@ static void test_convexity2(skiatest::Reporter* reporter) {
triRight.lineTo(SK_Scalar1, SK_Scalar1); triRight.lineTo(SK_Scalar1, SK_Scalar1);
triRight.close(); triRight.close();
check_convexity(reporter, triRight, true); check_convexity(reporter, triRight, true);
check_direction(reporter, triRight, SkPathPriv::kCCW_FirstDirection); check_direction(reporter, triRight, SkPathFirstDirection::kCCW);
SkPath square; SkPath square;
square.moveTo(0, 0); square.moveTo(0, 0);
@ -1403,7 +1403,7 @@ static void test_convexity2(skiatest::Reporter* reporter) {
square.lineTo(0, SK_Scalar1); square.lineTo(0, SK_Scalar1);
square.close(); square.close();
check_convexity(reporter, square, true); check_convexity(reporter, square, true);
check_direction(reporter, square, SkPathPriv::kCW_FirstDirection); check_direction(reporter, square, SkPathFirstDirection::kCW);
SkPath redundantSquare; SkPath redundantSquare;
redundantSquare.moveTo(0, 0); redundantSquare.moveTo(0, 0);
@ -1420,7 +1420,7 @@ static void test_convexity2(skiatest::Reporter* reporter) {
redundantSquare.lineTo(0, SK_Scalar1); redundantSquare.lineTo(0, SK_Scalar1);
redundantSquare.close(); redundantSquare.close();
check_convexity(reporter, redundantSquare, true); check_convexity(reporter, redundantSquare, true);
check_direction(reporter, redundantSquare, SkPathPriv::kCW_FirstDirection); check_direction(reporter, redundantSquare, SkPathFirstDirection::kCW);
SkPath bowTie; SkPath bowTie;
bowTie.moveTo(0, 0); bowTie.moveTo(0, 0);
@ -1459,7 +1459,7 @@ static void test_convexity2(skiatest::Reporter* reporter) {
dent.lineTo(-200*SK_Scalar1, 100*SK_Scalar1); dent.lineTo(-200*SK_Scalar1, 100*SK_Scalar1);
dent.close(); dent.close();
check_convexity(reporter, dent, false); check_convexity(reporter, dent, false);
check_direction(reporter, dent, SkPathPriv::kCW_FirstDirection); check_direction(reporter, dent, SkPathFirstDirection::kCW);
// https://bug.skia.org/2235 // https://bug.skia.org/2235
SkPath strokedSin; SkPath strokedSin;
@ -1487,7 +1487,7 @@ static void test_convexity2(skiatest::Reporter* reporter) {
degenerateConcave.lineTo(-55.971577f, 460.0f); degenerateConcave.lineTo(-55.971577f, 460.0f);
degenerateConcave.lineTo(41.446522f, 376.25f); degenerateConcave.lineTo(41.446522f, 376.25f);
check_convexity(reporter, degenerateConcave, false); check_convexity(reporter, degenerateConcave, false);
check_direction(reporter, degenerateConcave, SkPathPriv::kUnknown_FirstDirection); check_direction(reporter, degenerateConcave, SkPathFirstDirection::kUnknown);
// http://crbug.com/433683 // http://crbug.com/433683
SkPath badFirstVector; SkPath badFirstVector;
@ -1588,12 +1588,12 @@ static void test_convexity(skiatest::Reporter* reporter) {
path.reset(); path.reset();
path.addRect(0, 0, SkIntToScalar(10), SkIntToScalar(10), SkPathDirection::kCCW); path.addRect(0, 0, SkIntToScalar(10), SkIntToScalar(10), SkPathDirection::kCCW);
check_convexity(reporter, path, true); 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.reset();
path.addRect(0, 0, SkIntToScalar(10), SkIntToScalar(10), SkPathDirection::kCW); path.addRect(0, 0, SkIntToScalar(10), SkIntToScalar(10), SkPathDirection::kCW);
check_convexity(reporter, path, true); 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.reset();
path.quadTo(100, 100, 50, 50); // This from GM:convexpaths path.quadTo(100, 100, 50, 50); // This from GM:convexpaths
@ -1602,16 +1602,16 @@ static void test_convexity(skiatest::Reporter* reporter) {
static const struct { static const struct {
const char* fPathStr; const char* fPathStr;
bool fExpectedIsConvex; bool fExpectedIsConvex;
SkPathPriv::FirstDirection fExpectedDirection; SkPathFirstDirection fExpectedDirection;
} gRec[] = { } gRec[] = {
{ "", true, SkPathPriv::kUnknown_FirstDirection }, { "", true, SkPathFirstDirection::kUnknown },
{ "0 0", true, SkPathPriv::kUnknown_FirstDirection }, { "0 0", true, SkPathFirstDirection::kUnknown },
{ "0 0 10 10", true, SkPathPriv::kUnknown_FirstDirection }, { "0 0 10 10", true, SkPathFirstDirection::kUnknown },
{ "0 0 10 10 20 20 0 0 10 10", false, SkPathPriv::kUnknown_FirstDirection }, { "0 0 10 10 20 20 0 0 10 10", false, SkPathFirstDirection::kUnknown },
{ "0 0 10 10 10 20", true, SkPathPriv::kCW_FirstDirection }, { "0 0 10 10 10 20", true, SkPathFirstDirection::kCW },
{ "0 0 10 10 10 0", true, SkPathPriv::kCCW_FirstDirection }, { "0 0 10 10 10 0", true, SkPathFirstDirection::kCCW },
{ "0 0 10 10 10 0 0 10", false, kDontCheckDir }, { "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) { 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) { if (kDontCheckDir != gRec[i].fExpectedDirection) {
// We make a copy so that we don't cache the result on the passed in path. // 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) SkPath copy(path); // NOLINT(performance-unnecessary-copy-initialization)
SkPathPriv::FirstDirection dir; SkPathFirstDirection dir;
bool foundDir = SkPathPriv::CheapComputeFirstDirection(copy, &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); ^ foundDir);
REPORTER_ASSERT(reporter, !foundDir || gRec[i].fExpectedDirection == dir); REPORTER_ASSERT(reporter, !foundDir || gRec[i].fExpectedDirection == dir);
check_convexity(reporter, copy, gRec[i].fExpectedIsConvex); 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; case 12: path.moveTo(nonFinitePts[i]); break;
} }
REPORTER_ASSERT(reporter, REPORTER_ASSERT(reporter,
SkPathPriv::GetConvexityTypeOrUnknown(path) == SkPathConvexityType::kUnknown); SkPathPriv::GetConvexityOrUnknown(path) == SkPathConvexity::kUnknown);
} }
for (int index = 0; index < (int) (11 * axisAlignedPtsCount); ++index) { for (int index = 0; index < (int) (11 * axisAlignedPtsCount); ++index) {
@ -2154,7 +2154,7 @@ static void test_isRect(skiatest::Reporter* reporter) {
SkRect computed, expected; SkRect computed, expected;
bool isClosed; bool isClosed;
SkPathDirection direction; SkPathDirection direction;
SkPathPriv::FirstDirection cheapDirection; SkPathFirstDirection cheapDirection;
int pointCount = tests[testIndex].fPointCount - (d2 == tests[testIndex].fPoints); int pointCount = tests[testIndex].fPointCount - (d2 == tests[testIndex].fPoints);
expected.setBounds(tests[testIndex].fPoints, pointCount); expected.setBounds(tests[testIndex].fPoints, pointCount);
REPORTER_ASSERT(reporter, SkPathPriv::CheapComputeFirstDirection(path, &cheapDirection)); REPORTER_ASSERT(reporter, SkPathPriv::CheapComputeFirstDirection(path, &cheapDirection));
@ -2399,36 +2399,36 @@ static void test_isNestedFillRects(skiatest::Reporter* reporter) {
struct IsNestedRectTest { struct IsNestedRectTest {
SkPoint *fPoints; SkPoint *fPoints;
int fPointCount; int fPointCount;
SkPathPriv::FirstDirection fDirection; SkPathFirstDirection fDirection;
bool fClose; bool fClose;
bool fIsNestedRect; // nests with path.addRect(-1, -1, 2, 2); bool fIsNestedRect; // nests with path.addRect(-1, -1, 2, 2);
} tests[] = { } tests[] = {
{ r1, SK_ARRAY_COUNT(r1), SkPathPriv::kCW_FirstDirection , true, true }, { r1, SK_ARRAY_COUNT(r1), SkPathFirstDirection::kCW , true, true },
{ r2, SK_ARRAY_COUNT(r2), SkPathPriv::kCW_FirstDirection , true, true }, { r2, SK_ARRAY_COUNT(r2), SkPathFirstDirection::kCW , true, true },
{ r3, SK_ARRAY_COUNT(r3), SkPathPriv::kCW_FirstDirection , true, true }, { r3, SK_ARRAY_COUNT(r3), SkPathFirstDirection::kCW , true, true },
{ r4, SK_ARRAY_COUNT(r4), SkPathPriv::kCW_FirstDirection , true, true }, { r4, SK_ARRAY_COUNT(r4), SkPathFirstDirection::kCW , true, true },
{ r5, SK_ARRAY_COUNT(r5), SkPathPriv::kCCW_FirstDirection, true, true }, { r5, SK_ARRAY_COUNT(r5), SkPathFirstDirection::kCCW, true, true },
{ r6, SK_ARRAY_COUNT(r6), SkPathPriv::kCCW_FirstDirection, true, true }, { r6, SK_ARRAY_COUNT(r6), SkPathFirstDirection::kCCW, true, true },
{ r7, SK_ARRAY_COUNT(r7), SkPathPriv::kCCW_FirstDirection, true, true }, { r7, SK_ARRAY_COUNT(r7), SkPathFirstDirection::kCCW, true, true },
{ r8, SK_ARRAY_COUNT(r8), SkPathPriv::kCCW_FirstDirection, true, true }, { r8, SK_ARRAY_COUNT(r8), SkPathFirstDirection::kCCW, true, true },
{ r9, SK_ARRAY_COUNT(r9), SkPathPriv::kCCW_FirstDirection, true, true }, { r9, SK_ARRAY_COUNT(r9), SkPathFirstDirection::kCCW, true, true },
{ ra, SK_ARRAY_COUNT(ra), SkPathPriv::kCCW_FirstDirection, true, true }, { ra, SK_ARRAY_COUNT(ra), SkPathFirstDirection::kCCW, true, true },
{ rb, SK_ARRAY_COUNT(rb), SkPathPriv::kCW_FirstDirection, true, true }, { rb, SK_ARRAY_COUNT(rb), SkPathFirstDirection::kCW, true, true },
{ rc, SK_ARRAY_COUNT(rc), SkPathPriv::kCW_FirstDirection, true, true }, { rc, SK_ARRAY_COUNT(rc), SkPathFirstDirection::kCW, true, true },
{ rd, SK_ARRAY_COUNT(rd), SkPathPriv::kCCW_FirstDirection, true, true }, { rd, SK_ARRAY_COUNT(rd), SkPathFirstDirection::kCCW, true, true },
{ re, SK_ARRAY_COUNT(re), SkPathPriv::kCW_FirstDirection, true, true }, { re, SK_ARRAY_COUNT(re), SkPathFirstDirection::kCW, true, true },
{ f1, SK_ARRAY_COUNT(f1), SkPathPriv::kUnknown_FirstDirection, true, false }, { f1, SK_ARRAY_COUNT(f1), SkPathFirstDirection::kUnknown, true, false },
{ f2, SK_ARRAY_COUNT(f2), SkPathPriv::kUnknown_FirstDirection, true, false }, { f2, SK_ARRAY_COUNT(f2), SkPathFirstDirection::kUnknown, true, false },
{ f3, SK_ARRAY_COUNT(f3), SkPathPriv::kUnknown_FirstDirection, true, false }, { f3, SK_ARRAY_COUNT(f3), SkPathFirstDirection::kUnknown, true, false },
{ f4, SK_ARRAY_COUNT(f4), SkPathPriv::kUnknown_FirstDirection, true, false }, { f4, SK_ARRAY_COUNT(f4), SkPathFirstDirection::kUnknown, true, false },
{ f5, SK_ARRAY_COUNT(f5), SkPathPriv::kUnknown_FirstDirection, true, false }, { f5, SK_ARRAY_COUNT(f5), SkPathFirstDirection::kUnknown, true, false },
{ f6, SK_ARRAY_COUNT(f6), SkPathPriv::kUnknown_FirstDirection, true, false }, { f6, SK_ARRAY_COUNT(f6), SkPathFirstDirection::kUnknown, true, false },
{ f7, SK_ARRAY_COUNT(f7), SkPathPriv::kUnknown_FirstDirection, true, false }, { f7, SK_ARRAY_COUNT(f7), SkPathFirstDirection::kUnknown, true, false },
{ f8, SK_ARRAY_COUNT(f8), SkPathPriv::kUnknown_FirstDirection, true, false }, { f8, SK_ARRAY_COUNT(f8), SkPathFirstDirection::kUnknown, true, false },
{ c1, SK_ARRAY_COUNT(c1), SkPathPriv::kCW_FirstDirection, false, true }, { c1, SK_ARRAY_COUNT(c1), SkPathFirstDirection::kCW, false, true },
{ c2, SK_ARRAY_COUNT(c2), SkPathPriv::kCW_FirstDirection, false, true }, { c2, SK_ARRAY_COUNT(c2), SkPathFirstDirection::kCW, false, true },
}; };
const size_t testCount = SK_ARRAY_COUNT(tests); 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)); tests[testIndex].fIsNestedRect == SkPathPriv::IsNestedFillRects(path, nullptr));
if (tests[testIndex].fIsNestedRect) { if (tests[testIndex].fIsNestedRect) {
SkRect expected[2], computed[2]; SkRect expected[2], computed[2];
SkPathPriv::FirstDirection expectedDirs[2]; SkPathFirstDirection expectedDirs[2];
SkPathDirection computedDirs[2]; SkPathDirection computedDirs[2];
SkRect testBounds; SkRect testBounds;
testBounds.setBounds(tests[testIndex].fPoints, tests[testIndex].fPointCount); testBounds.setBounds(tests[testIndex].fPoints, tests[testIndex].fPointCount);
expected[0] = SkRect::MakeLTRB(-1, -1, 2, 2); expected[0] = SkRect::MakeLTRB(-1, -1, 2, 2);
expected[1] = testBounds; expected[1] = testBounds;
if (rectFirst) { if (rectFirst) {
expectedDirs[0] = SkPathPriv::kCW_FirstDirection; expectedDirs[0] = SkPathFirstDirection::kCW;
} else { } else {
expectedDirs[0] = SkPathPriv::kCCW_FirstDirection; expectedDirs[0] = SkPathFirstDirection::kCCW;
} }
expectedDirs[1] = tests[testIndex].fDirection; expectedDirs[1] = tests[testIndex].fDirection;
REPORTER_ASSERT(reporter, SkPathPriv::IsNestedFillRects(path, computed, computedDirs)); REPORTER_ASSERT(reporter, SkPathPriv::IsNestedFillRects(path, computed, computedDirs));
@ -2603,8 +2603,8 @@ static void write_and_read_back(skiatest::Reporter* reporter,
reader.readPath(&readBack); reader.readPath(&readBack);
REPORTER_ASSERT(reporter, readBack == p); REPORTER_ASSERT(reporter, readBack == p);
REPORTER_ASSERT(reporter, SkPathPriv::GetConvexityTypeOrUnknown(readBack) == REPORTER_ASSERT(reporter, SkPathPriv::GetConvexityOrUnknown(readBack) ==
SkPathPriv::GetConvexityTypeOrUnknown(p)); SkPathPriv::GetConvexityOrUnknown(p));
SkRect oval0, oval1; SkRect oval0, oval1;
SkPathDirection dir0, dir1; SkPathDirection dir0, dir1;
@ -2758,7 +2758,7 @@ static void test_transform(skiatest::Reporter* reporter) {
p1.moveTo(SkPoint::Make(0, 0)); p1.moveTo(SkPoint::Make(0, 0));
p.transform(matrix, &p1); 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) p1.moveTo(SkPoint::Make(0, 0)); // Make p1 unique (i.e., not empty path)
p.transform(matrix, &p1); 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) p1.moveTo(SkPoint::Make(0, 0)); // Make p1 unique (i.e., not empty path)
p.transform(matrix, &p1); 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, static void check_for_circle(skiatest::Reporter* reporter,
const SkPath& path, const SkPath& path,
bool expectedCircle, bool expectedCircle,
SkPathPriv::FirstDirection expectedDir) { SkPathFirstDirection expectedDir) {
SkRect rect = SkRect::MakeEmpty(); SkRect rect = SkRect::MakeEmpty();
REPORTER_ASSERT(reporter, path.isOval(&rect) == expectedCircle); REPORTER_ASSERT(reporter, path.isOval(&rect) == expectedCircle);
SkPathDirection isOvalDir; SkPathDirection isOvalDir;
@ -3320,25 +3320,25 @@ static void check_for_circle(skiatest::Reporter* reporter,
static void test_circle_skew(skiatest::Reporter* reporter, static void test_circle_skew(skiatest::Reporter* reporter,
const SkPath& path, const SkPath& path,
SkPathPriv::FirstDirection dir) { SkPathFirstDirection dir) {
SkPath tmp; SkPath tmp;
SkMatrix m; SkMatrix m;
m.setSkew(SkIntToScalar(3), SkIntToScalar(5)); m.setSkew(SkIntToScalar(3), SkIntToScalar(5));
path.transform(m, &tmp); path.transform(m, &tmp);
// this matrix reverses the direction. // this matrix reverses the direction.
if (SkPathPriv::kCCW_FirstDirection == dir) { if (SkPathFirstDirection::kCCW == dir) {
dir = SkPathPriv::kCW_FirstDirection; dir = SkPathFirstDirection::kCW;
} else { } else {
REPORTER_ASSERT(reporter, SkPathPriv::kCW_FirstDirection == dir); REPORTER_ASSERT(reporter, SkPathFirstDirection::kCW == dir);
dir = SkPathPriv::kCCW_FirstDirection; dir = SkPathFirstDirection::kCCW;
} }
check_for_circle(reporter, tmp, false, dir); check_for_circle(reporter, tmp, false, dir);
} }
static void test_circle_translate(skiatest::Reporter* reporter, static void test_circle_translate(skiatest::Reporter* reporter,
const SkPath& path, const SkPath& path,
SkPathPriv::FirstDirection dir) { SkPathFirstDirection dir) {
SkPath tmp; SkPath tmp;
// translate at small offset // translate at small offset
@ -3358,7 +3358,7 @@ static void test_circle_translate(skiatest::Reporter* reporter,
static void test_circle_rotate(skiatest::Reporter* reporter, static void test_circle_rotate(skiatest::Reporter* reporter,
const SkPath& path, const SkPath& path,
SkPathPriv::FirstDirection dir) { SkPathFirstDirection dir) {
for (int angle = 0; angle < 360; ++angle) { for (int angle = 0; angle < 360; ++angle) {
SkPath tmp; SkPath tmp;
SkMatrix m; SkMatrix m;
@ -3378,35 +3378,35 @@ static void test_circle_rotate(skiatest::Reporter* reporter,
static void test_circle_mirror_x(skiatest::Reporter* reporter, static void test_circle_mirror_x(skiatest::Reporter* reporter,
const SkPath& path, const SkPath& path,
SkPathPriv::FirstDirection dir) { SkPathFirstDirection dir) {
SkPath tmp; SkPath tmp;
SkMatrix m; SkMatrix m;
m.reset(); m.reset();
m.setScaleX(-SK_Scalar1); m.setScaleX(-SK_Scalar1);
path.transform(m, &tmp); path.transform(m, &tmp);
if (SkPathPriv::kCW_FirstDirection == dir) { if (SkPathFirstDirection::kCW == dir) {
dir = SkPathPriv::kCCW_FirstDirection; dir = SkPathFirstDirection::kCCW;
} else { } else {
REPORTER_ASSERT(reporter, SkPathPriv::kCCW_FirstDirection == dir); REPORTER_ASSERT(reporter, SkPathFirstDirection::kCCW == dir);
dir = SkPathPriv::kCW_FirstDirection; dir = SkPathFirstDirection::kCW;
} }
check_for_circle(reporter, tmp, true, dir); check_for_circle(reporter, tmp, true, dir);
} }
static void test_circle_mirror_y(skiatest::Reporter* reporter, static void test_circle_mirror_y(skiatest::Reporter* reporter,
const SkPath& path, const SkPath& path,
SkPathPriv::FirstDirection dir) { SkPathFirstDirection dir) {
SkPath tmp; SkPath tmp;
SkMatrix m; SkMatrix m;
m.reset(); m.reset();
m.setScaleY(-SK_Scalar1); m.setScaleY(-SK_Scalar1);
path.transform(m, &tmp); path.transform(m, &tmp);
if (SkPathPriv::kCW_FirstDirection == dir) { if (SkPathFirstDirection::kCW == dir) {
dir = SkPathPriv::kCCW_FirstDirection; dir = SkPathFirstDirection::kCCW;
} else { } else {
REPORTER_ASSERT(reporter, SkPathPriv::kCCW_FirstDirection == dir); REPORTER_ASSERT(reporter, SkPathFirstDirection::kCCW == dir);
dir = SkPathPriv::kCW_FirstDirection; dir = SkPathFirstDirection::kCW;
} }
check_for_circle(reporter, tmp, true, dir); 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, static void test_circle_mirror_xy(skiatest::Reporter* reporter,
const SkPath& path, const SkPath& path,
SkPathPriv::FirstDirection dir) { SkPathFirstDirection dir) {
SkPath tmp; SkPath tmp;
SkMatrix m; SkMatrix m;
m.reset(); m.reset();
@ -3427,7 +3427,7 @@ static void test_circle_mirror_xy(skiatest::Reporter* reporter,
static void test_circle_with_direction(skiatest::Reporter* reporter, static void test_circle_with_direction(skiatest::Reporter* reporter,
SkPathDirection inDir) { SkPathDirection inDir) {
const SkPathPriv::FirstDirection dir = SkPathPriv::AsFirstDirection(inDir); const SkPathFirstDirection dir = SkPathPriv::AsFirstDirection(inDir);
SkPath path; SkPath path;
// circle at origin // circle at origin
@ -3511,19 +3511,19 @@ static void test_circle(skiatest::Reporter* reporter) {
SkPath path; SkPath path;
path.addCircle(0, 0, SkIntToScalar(10), SkPathDirection::kCW); path.addCircle(0, 0, SkIntToScalar(10), SkPathDirection::kCW);
path.addCircle(0, 0, SkIntToScalar(20), 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 // some extra lineTo() would make isOval() fail
path.reset(); path.reset();
path.addCircle(0, 0, SkIntToScalar(10), SkPathDirection::kCW); path.addCircle(0, 0, SkIntToScalar(10), SkPathDirection::kCW);
path.lineTo(0, 0); 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 // not back to the original point
path.reset(); path.reset();
path.addCircle(0, 0, SkIntToScalar(10), SkPathDirection::kCW); path.addCircle(0, 0, SkIntToScalar(10), SkPathDirection::kCW);
path.setLastPt(SkIntToScalar(5), SkIntToScalar(5)); 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); 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 // 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 // between control points and computing the on curve point at scan conversion time
REPORTER_ASSERT(reporter, p.isConvex()); 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); SkPathPriv::ForceComputeConvexity(p);
REPORTER_ASSERT(reporter, p.isConvex()); REPORTER_ASSERT(reporter, p.isConvex());
} }
@ -5509,8 +5509,8 @@ struct Xforms {
}; };
static bool conditional_convex(const SkPath& path, bool is_convex) { static bool conditional_convex(const SkPath& path, bool is_convex) {
SkPathConvexityType c = SkPathPriv::GetConvexityTypeOrUnknown(path); SkPathConvexity c = SkPathPriv::GetConvexityOrUnknown(path);
return is_convex ? (c == SkPathConvexityType::kConvex) : (c != SkPathConvexityType::kConvex); return is_convex ? (c == SkPathConvexity::kConvex) : (c != SkPathConvexity::kConvex);
} }
// expect axis-aligned shape to survive assignment, identity and scale/translate matrices // 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 // a path's isa and convexity should survive assignment
path2 = *path; path2 = *path;
REPORTER_ASSERT(reporter, isa_proc(path2)); 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 // a path's isa and convexity should identity transform
path->transform(x.fIM, &path2); path->transform(x.fIM, &path2);
path->transform(x.fIM); path->transform(x.fIM);
REPORTER_ASSERT(reporter, isa_proc(path2)); 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, 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 // a path's isa should survive translation, convexity depends on axis alignment
path->transform(x.fTM, &path2); 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, // 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 // 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, &path2);
path->transform(x.fRM); path->transform(x.fRM);
REPORTER_ASSERT(reporter, SkPathPriv::GetConvexityTypeOrUnknown(path2) != SkPathConvexityType::kConvex); REPORTER_ASSERT(reporter, SkPathPriv::GetConvexityOrUnknown(path2) != SkPathConvexity::kConvex);
REPORTER_ASSERT(reporter, SkPathPriv::GetConvexityTypeOrUnknown(*path) != SkPathConvexityType::kConvex); REPORTER_ASSERT(reporter, SkPathPriv::GetConvexityOrUnknown(*path) != SkPathConvexity::kConvex);
if (isAxisAligned) { if (isAxisAligned) {
REPORTER_ASSERT(reporter, !isa_proc(path2)); REPORTER_ASSERT(reporter, !isa_proc(path2));