Revert "Reland "Revert "Use flat version of path-direction enum"""
This reverts commit 7cda6f37439f69b1e4a9b08147f9c12ddad1bddb.
Reason for revert: legacy convexity code removed -- google3 should be ok
Original change's description:
> Reland "Revert "Use flat version of path-direction enum""
>
> This reverts commit 1792b19485cacb0c950a3c0ea0aab763a8d43176.
>
> Reason for revert: need to update legacy_convexity, still used by google3
>
> Original change's description:
> > Revert "Revert "Use flat version of path-direction enum""
> >
> > This reverts commit 0dacc6b7d3027e8181311a61f7ca798be52a0250.
> >
> > Change-Id: Ie103e9f36b07e4ee256a3688a4decf3a6dd74314
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/255832
> > Auto-Submit: Mike Reed <reed@google.com>
> > Reviewed-by: Mike Reed <reed@google.com>
> > Commit-Queue: Mike Reed <reed@google.com>
>
> TBR=reed@google.com
>
> Change-Id: I0ecea0eb8a237298c6b908cc4bfd1cacdfc5b900
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/255976
> Reviewed-by: Mike Reed <reed@google.com>
> Commit-Queue: Mike Reed <reed@google.com>
TBR=reed@google.com
Change-Id: I3529139bb391c4f62ce5cd0744cdf38a13b71d78
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/255984
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Reed <reed@google.com>
diff --git a/src/c/sk_surface.cpp b/src/c/sk_surface.cpp
index b3f203f..65fe209 100644
--- a/src/c/sk_surface.cpp
+++ b/src/c/sk_surface.cpp
@@ -56,13 +56,13 @@
const struct {
sk_path_direction_t fC;
- SkPath::Direction fSk;
+ SkPathDirection fSk;
} gPathDirMap[] = {
- { CW_SK_PATH_DIRECTION, SkPath::kCW_Direction },
- { CCW_SK_PATH_DIRECTION, SkPath::kCCW_Direction },
+ { CW_SK_PATH_DIRECTION, SkPathDirection::kCW },
+ { CCW_SK_PATH_DIRECTION, SkPathDirection::kCCW },
};
-static bool from_c_path_direction(sk_path_direction_t cdir, SkPath::Direction* dir) {
+static bool from_c_path_direction(sk_path_direction_t cdir, SkPathDirection* dir) {
for (size_t i = 0; i < SK_ARRAY_COUNT(gPathDirMap); ++i) {
if (gPathDirMap[i].fC == cdir) {
if (dir) {
@@ -202,7 +202,7 @@
}
void sk_path_add_rect(sk_path_t* cpath, const sk_rect_t* crect, sk_path_direction_t cdir) {
- SkPath::Direction dir;
+ SkPathDirection dir;
if (!from_c_path_direction(cdir, &dir)) {
return;
}
@@ -210,7 +210,7 @@
}
void sk_path_add_oval(sk_path_t* cpath, const sk_rect_t* crect, sk_path_direction_t cdir) {
- SkPath::Direction dir;
+ SkPathDirection dir;
if (!from_c_path_direction(cdir, &dir)) {
return;
}
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index b955816..2d4d69f 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -107,8 +107,8 @@
}
~SkAutoPathBoundsUpdate() {
- fPath->setConvexity(fDegenerate ? SkPath::kConvex_Convexity
- : SkPath::kUnknown_Convexity);
+ fPath->setConvexityType(fDegenerate ? SkPathConvexityType::kConvex
+ : SkPathConvexityType::kUnknown);
if ((fEmpty || fHasValidBounds) && fRect.isFinite()) {
fPath->setBounds(fRect);
}
@@ -152,7 +152,7 @@
//fPathRef is assumed to have been emptied by the caller.
fLastMoveToIndex = INITIAL_LASTMOVETOINDEX_VALUE;
fFillType = kWinding_FillType;
- this->setConvexity(kUnknown_Convexity);
+ this->setConvexityType(SkPathConvexityType::kUnknown);
this->setFirstDirection(SkPathPriv::kUnknown_FirstDirection);
// We don't touch Android's fSourcePath. It's used to track texture garbage collection, so we
@@ -187,7 +187,7 @@
fIsVolatile = that.fIsVolatile;
// Non-atomic assignment of atomic values.
- this->setConvexity(that.getConvexityOrUnknown());
+ this->setConvexityType(that.getConvexityTypeOrUnknown());
this->setFirstDirection(that.getFirstDirection());
}
@@ -212,9 +212,9 @@
that.fIsVolatile = iv;
// Non-atomic swaps of atomic values.
- Convexity c = this->getConvexityOrUnknown();
- this->setConvexity(that.getConvexityOrUnknown());
- that.setConvexity(c);
+ SkPathConvexityType c = this->getConvexityTypeOrUnknown();
+ this->setConvexityType(that.getConvexityTypeOrUnknown());
+ that.setConvexityType(c);
uint8_t fd = this->getFirstDirection();
this->setFirstDirection(that.getFirstDirection());
@@ -271,7 +271,7 @@
bool SkPath::conservativelyContainsRect(const SkRect& rect) const {
// This only handles non-degenerate convex paths currently.
- if (kConvex_Convexity != this->getConvexity()) {
+ if (!this->isConvex()) {
return false;
}
@@ -455,7 +455,7 @@
return ((0 != dx) << 0) | ((dx > 0 || dy > 0) << 1);
}
-bool SkPath::isRect(SkRect* rect, bool* isClosed, Direction* direction) const {
+bool SkPath::isRect(SkRect* rect, bool* isClosed, SkPathDirection* direction) const {
SkDEBUGCODE(this->validate();)
int currVerb = 0;
const SkPoint* pts = fPathRef->points();
@@ -559,13 +559,13 @@
}
// This is the public-facing non-const setConvexity().
-void SkPath::setConvexity(Convexity c) {
- fConvexity.store(c, std::memory_order_relaxed);
+void SkPath::setConvexityType(SkPathConvexityType c) {
+ fConvexity.store((uint8_t)c, std::memory_order_relaxed);
}
// Const hooks for working with fConvexity and fFirstDirection from const methods.
-void SkPath::setConvexity(Convexity c) const {
- fConvexity.store(c, std::memory_order_relaxed);
+void SkPath::setConvexityType(SkPathConvexityType c) const {
+ fConvexity.store((uint8_t)c, std::memory_order_relaxed);
}
void SkPath::setFirstDirection(uint8_t d) const {
fFirstDirection.store(d, std::memory_order_relaxed);
@@ -579,7 +579,7 @@
#define DIRTY_AFTER_EDIT \
do { \
- this->setConvexity(kUnknown_Convexity); \
+ this->setConvexityType(SkPathConvexityType::kUnknown); \
this->setFirstDirection(SkPathPriv::kUnknown_FirstDirection); \
} while (0)
@@ -760,20 +760,20 @@
///////////////////////////////////////////////////////////////////////////////
-static void assert_known_direction(int dir) {
- SkASSERT(SkPath::kCW_Direction == dir || SkPath::kCCW_Direction == dir);
+static void assert_known_direction(SkPathDirection dir) {
+ SkASSERT(SkPathDirection::kCW == dir || SkPathDirection::kCCW == dir);
}
-SkPath& SkPath::addRect(const SkRect& rect, Direction dir) {
+SkPath& SkPath::addRect(const SkRect& rect, SkPathDirection dir) {
return this->addRect(rect, dir, 0);
}
SkPath& SkPath::addRect(SkScalar left, SkScalar top, SkScalar right,
- SkScalar bottom, Direction dir) {
+ SkScalar bottom, SkPathDirection dir) {
return this->addRect(SkRect::MakeLTRB(left, top, right, bottom), dir, 0);
}
-SkPath& SkPath::addRect(const SkRect &rect, Direction dir, unsigned startIndex) {
+SkPath& SkPath::addRect(const SkRect &rect, SkPathDirection dir, unsigned startIndex) {
assert_known_direction(dir);
this->setFirstDirection(this->hasOnlyMoveTos() ? (SkPathPriv::FirstDirection)dir
: SkPathPriv::kUnknown_FirstDirection);
@@ -903,18 +903,18 @@
}
SkPath& SkPath::addRoundRect(const SkRect& rect, const SkScalar radii[],
- Direction dir) {
+ SkPathDirection dir) {
SkRRect rrect;
rrect.setRectRadii(rect, (const SkVector*) radii);
return this->addRRect(rrect, dir);
}
-SkPath& SkPath::addRRect(const SkRRect& rrect, Direction dir) {
+SkPath& SkPath::addRRect(const SkRRect& rrect, SkPathDirection dir) {
// legacy start indices: 6 (CW) and 7(CCW)
- return this->addRRect(rrect, dir, dir == kCW_Direction ? 6 : 7);
+ return this->addRRect(rrect, dir, dir == SkPathDirection::kCW ? 6 : 7);
}
-SkPath& SkPath::addRRect(const SkRRect &rrect, Direction dir, unsigned startIndex) {
+SkPath& SkPath::addRRect(const SkRRect &rrect, SkPathDirection dir, unsigned startIndex) {
assert_known_direction(dir);
bool isRRect = hasOnlyMoveTos();
@@ -934,7 +934,7 @@
SkAutoDisableDirectionCheck addc(this);
// we start with a conic on odd indices when moving CW vs. even indices when moving CCW
- const bool startsWithConic = ((startIndex & 1) == (dir == kCW_Direction));
+ const bool startsWithConic = ((startIndex & 1) == (dir == SkPathDirection::kCW));
const SkScalar weight = SK_ScalarRoot2Over2;
SkDEBUGCODE(int initialVerbCount = this->countVerbs());
@@ -946,7 +946,7 @@
SkPath_RRectPointIterator rrectIter(rrect, dir, startIndex);
// Corner iterator indices follow the collapsed radii model,
// adjusted such that the start pt is "behind" the radii start pt.
- const unsigned rectStartIndex = startIndex / 2 + (dir == kCW_Direction ? 0 : 1);
+ const unsigned rectStartIndex = startIndex / 2 + (dir == SkPathDirection::kCW ? 0 : 1);
SkPath_RectPointIterator rectIter(bounds, dir, rectStartIndex);
this->moveTo(rrectIter.current());
@@ -966,7 +966,7 @@
this->close();
SkPathRef::Editor ed(&fPathRef);
- ed.setIsRRect(isRRect, dir, startIndex % 8);
+ ed.setIsRRect(isRRect, dir == SkPathDirection::kCCW, startIndex % 8);
SkASSERT(this->countVerbs() == initialVerbCount + kVerbs);
}
@@ -1006,7 +1006,7 @@
}
SkPath& SkPath::addRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry,
- Direction dir) {
+ SkPathDirection dir) {
assert_known_direction(dir);
if (rx < 0 || ry < 0) {
@@ -1018,12 +1018,12 @@
return this->addRRect(rrect, dir);
}
-SkPath& SkPath::addOval(const SkRect& oval, Direction dir) {
+SkPath& SkPath::addOval(const SkRect& oval, SkPathDirection dir) {
// legacy start index: 1
return this->addOval(oval, dir, 1);
}
-SkPath& SkPath::addOval(const SkRect &oval, Direction dir, unsigned startPointIndex) {
+SkPath& SkPath::addOval(const SkRect &oval, SkPathDirection dir, unsigned startPointIndex) {
assert_known_direction(dir);
/* If addOval() is called after previous moveTo(),
@@ -1048,7 +1048,7 @@
SkPath_OvalPointIterator ovalIter(oval, dir, startPointIndex);
// The corner iterator pts are tracking "behind" the oval/radii pts.
- SkPath_RectPointIterator rectIter(oval, dir, startPointIndex + (dir == kCW_Direction ? 0 : 1));
+ SkPath_RectPointIterator rectIter(oval, dir, startPointIndex + (dir == SkPathDirection::kCW ? 0 : 1));
const SkScalar weight = SK_ScalarRoot2Over2;
this->moveTo(ovalIter.current());
@@ -1061,11 +1061,11 @@
SkPathRef::Editor ed(&fPathRef);
- ed.setIsOval(isOval, kCCW_Direction == dir, startPointIndex % 4);
+ ed.setIsOval(isOval, SkPathDirection::kCCW == dir, startPointIndex % 4);
return *this;
}
-SkPath& SkPath::addCircle(SkScalar x, SkScalar y, SkScalar r, Direction dir) {
+SkPath& SkPath::addCircle(SkScalar x, SkScalar y, SkScalar r, SkPathDirection dir) {
if (r > 0) {
this->addOval(SkRect::MakeLTRB(x - r, y - r, x + r, y + r), dir);
}
@@ -1145,7 +1145,7 @@
// http://www.w3.org/TR/SVG/implnote.html#ArcConversionEndpointToCenter
// Note that arcSweep bool value is flipped from the original implementation.
SkPath& SkPath::arcTo(SkScalar rx, SkScalar ry, SkScalar angle, SkPath::ArcSize arcLarge,
- SkPath::Direction arcSweep, SkScalar x, SkScalar y) {
+ SkPathDirection arcSweep, SkScalar x, SkScalar y) {
this->injectMoveToIfNeeded();
SkPoint srcPts[2];
this->getLastPt(&srcPts[0]);
@@ -1196,7 +1196,7 @@
SkScalar scaleFactorSquared = SkTMax(1 / d - 0.25f, 0.f);
SkScalar scaleFactor = SkScalarSqrt(scaleFactorSquared);
- if (SkToBool(arcSweep) != SkToBool(arcLarge)) { // flipped from the original implementation
+ if ((arcSweep == SkPathDirection::kCCW) != SkToBool(arcLarge)) { // flipped from the original implementation
scaleFactor = -scaleFactor;
}
delta.scale(scaleFactor);
@@ -1208,9 +1208,9 @@
SkScalar theta1 = SkScalarATan2(unitPts[0].fY, unitPts[0].fX);
SkScalar theta2 = SkScalarATan2(unitPts[1].fY, unitPts[1].fX);
SkScalar thetaArc = theta2 - theta1;
- if (thetaArc < 0 && !arcSweep) { // arcSweep flipped from the original implementation
+ if (thetaArc < 0 && (arcSweep == SkPathDirection::kCW)) { // arcSweep flipped from the original implementation
thetaArc += SK_ScalarPI * 2;
- } else if (thetaArc > 0 && arcSweep) { // arcSweep flipped from the original implementation
+ } else if (thetaArc > 0 && (arcSweep != SkPathDirection::kCW)) { // arcSweep flipped from the original implementation
thetaArc -= SK_ScalarPI * 2;
}
@@ -1270,7 +1270,7 @@
}
SkPath& SkPath::rArcTo(SkScalar rx, SkScalar ry, SkScalar xAxisRotate, SkPath::ArcSize largeArc,
- SkPath::Direction sweep, SkScalar dx, SkScalar dy) {
+ SkPathDirection sweep, SkScalar dx, SkScalar dy) {
SkPoint currentPoint;
this->getLastPt(¤tPoint);
return this->arcTo(rx, ry, xAxisRotate, largeArc, sweep,
@@ -1294,7 +1294,7 @@
// Index 1 is at startAngle == 0.
SkScalar startIndex = std::fmod(startOver90I + 1.f, 4.f);
startIndex = startIndex < 0 ? startIndex + 4.f : startIndex;
- return this->addOval(oval, sweepAngle > 0 ? kCW_Direction : kCCW_Direction,
+ return this->addOval(oval, sweepAngle > 0 ? SkPathDirection::kCW : SkPathDirection::kCCW,
(unsigned) startIndex);
}
}
@@ -1597,7 +1597,7 @@
matrix.mapPoints(ed.writablePoints(), ed.pathRef()->countPoints());
dst->setFirstDirection(SkPathPriv::kUnknown_FirstDirection);
} else {
- Convexity convexity = this->getConvexityOrUnknown();
+ SkPathConvexityType convexity = this->getConvexityTypeOrUnknown();
SkPathRef::CreateTransformedCopy(&dst->fPathRef, *fPathRef.get(), matrix);
@@ -1617,9 +1617,9 @@
// check, and keep convex paths marked as such after a general transform...
//
if (matrix.isScaleTranslate() && SkPathPriv::IsAxisAligned(*this)) {
- dst->setConvexity(convexity);
+ dst->setConvexityType(convexity);
} else {
- dst->setConvexity(kUnknown_Convexity);
+ dst->setConvexityType(SkPathConvexityType::kUnknown);
}
if (this->getFirstDirection() == SkPathPriv::kUnknown_FirstDirection) {
@@ -2012,7 +2012,7 @@
return true;
}
- static SkPath::Convexity BySign(const SkPoint points[], int count) {
+ static SkPathConvexityType BySign(const SkPoint points[], int count) {
const SkPoint* last = points + count;
SkPoint currPt = *points++;
SkPoint firstPt = currPt;
@@ -2026,14 +2026,14 @@
if (!vec.isZero()) {
// give up if vector construction failed
if (!vec.isFinite()) {
- return SkPath::kUnknown_Convexity;
+ return SkPathConvexityType::kUnknown;
}
int sx = sign(vec.fX);
int sy = sign(vec.fY);
dxes += (sx != lastSx);
dyes += (sy != lastSy);
if (dxes > 3 || dyes > 3) {
- return SkPath::kConcave_Convexity;
+ return SkPathConvexityType::kConcave;
}
lastSx = sx;
lastSy = sy;
@@ -2045,7 +2045,7 @@
}
points = &firstPt;
}
- return SkPath::kConvex_Convexity; // that is, it may be convex, don't know yet
+ return SkPathConvexityType::kConvex; // that is, it may be convex, don't know yet
}
bool close() {
@@ -2125,13 +2125,13 @@
bool fIsFinite { true };
};
-SkPath::Convexity SkPath::internalGetConvexity() const {
+SkPathConvexityType SkPath::internalGetConvexity() const {
SkPoint pts[4];
SkPath::Verb verb;
SkPath::Iter iter(*this, true);
- auto setComputedConvexity = [=](Convexity convexity){
- SkASSERT(kUnknown_Convexity != convexity);
- this->setConvexity(convexity);
+ auto setComputedConvexity = [=](SkPathConvexityType convexity){
+ SkASSERT(SkPathConvexityType::kUnknown != convexity);
+ this->setConvexityType(convexity);
return convexity;
};
@@ -2149,15 +2149,15 @@
++points;
}
--points;
- SkPath::Convexity convexity = Convexicator::BySign(points, (int) (last - points));
- if (SkPath::kConcave_Convexity == convexity) {
- return setComputedConvexity(SkPath::kConcave_Convexity);
- } else if (SkPath::kUnknown_Convexity == convexity) {
- return SkPath::kUnknown_Convexity;
+ SkPathConvexityType convexity = Convexicator::BySign(points, (int) (last - points));
+ if (SkPathConvexityType::kConcave == convexity) {
+ return setComputedConvexity(SkPathConvexityType::kConcave);
+ } else if (SkPathConvexityType::kUnknown == convexity) {
+ return SkPathConvexityType::kUnknown;
}
iter.setPath(*this, true);
} else if (!this->isFinite()) {
- return kUnknown_Convexity;
+ return SkPathConvexityType::kUnknown;
}
int contourCount = 0;
@@ -2165,16 +2165,16 @@
Convexicator state;
auto setFail = [=](){
if (!state.isFinite()) {
- return SkPath::kUnknown_Convexity;
+ return SkPathConvexityType::kUnknown;
}
- return setComputedConvexity(SkPath::kConcave_Convexity);
+ return setComputedConvexity(SkPathConvexityType::kConcave);
};
while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
switch (verb) {
case kMove_Verb:
if (++contourCount > 1) {
- return setComputedConvexity(kConcave_Convexity);
+ return setComputedConvexity(SkPathConvexityType::kConcave);
}
state.setMovePt(pts[0]);
count = 0;
@@ -2198,7 +2198,7 @@
break;
default:
SkDEBUGFAIL("bad verb");
- return setComputedConvexity(kConcave_Convexity);
+ return setComputedConvexity(SkPathConvexityType::kConcave);
}
for (int i = 1; i <= count; i++) {
if (!state.addPt(pts[i])) {
@@ -2211,16 +2211,16 @@
if (state.getFirstDirection() == SkPathPriv::kUnknown_FirstDirection
&& !this->getBounds().isEmpty()) {
return setComputedConvexity(state.reversals() < 3 ?
- kConvex_Convexity : kConcave_Convexity);
+ SkPathConvexityType::kConvex : SkPathConvexityType::kConcave);
}
this->setFirstDirection(state.getFirstDirection());
}
- return setComputedConvexity(kConvex_Convexity);
+ return setComputedConvexity(SkPathConvexityType::kConvex);
}
bool SkPathPriv::IsConvex(const SkPoint points[], int count) {
- SkPath::Convexity convexity = Convexicator::BySign(points, count);
- if (SkPath::kConvex_Convexity != convexity) {
+ SkPathConvexityType convexity = Convexicator::BySign(points, count);
+ if (SkPathConvexityType::kConvex != convexity) {
return false;
}
Convexicator state;
@@ -2417,7 +2417,7 @@
// We don't want to pay the cost for computing convexity if it is unknown,
// so we call getConvexityOrUnknown() instead of isConvex().
- if (path.getConvexityOrUnknown() == SkPath::kConvex_Convexity) {
+ if (path.getConvexityTypeOrUnknown() == SkPathConvexityType::kConvex) {
SkASSERT(path.getFirstDirection() == kUnknown_FirstDirection);
*dir = static_cast<FirstDirection>(path.getFirstDirection());
return false;
@@ -3010,7 +3010,7 @@
return conic.chopIntoQuadsPOW2(pts, pow2);
}
-bool SkPathPriv::IsSimpleClosedRect(const SkPath& path, SkRect* rect, SkPath::Direction* direction,
+bool SkPathPriv::IsSimpleClosedRect(const SkPath& path, SkRect* rect, SkPathDirection* direction,
unsigned* start) {
if (path.getSegmentMasks() != SkPath::kLine_SegmentMask) {
return false;
@@ -3080,22 +3080,22 @@
switch (sortFlags) {
case 0b00:
rect->setLTRB(rectPts[0].fX, rectPts[0].fY, rectPts[2].fX, rectPts[2].fY);
- *direction = vec03IsVertical ? SkPath::kCW_Direction : SkPath::kCCW_Direction;
+ *direction = vec03IsVertical ? SkPathDirection::kCW : SkPathDirection::kCCW;
*start = 0;
break;
case 0b01:
rect->setLTRB(rectPts[2].fX, rectPts[0].fY, rectPts[0].fX, rectPts[2].fY);
- *direction = vec03IsVertical ? SkPath::kCCW_Direction : SkPath::kCW_Direction;
+ *direction = vec03IsVertical ? SkPathDirection::kCCW : SkPathDirection::kCW;
*start = 1;
break;
case 0b10:
rect->setLTRB(rectPts[0].fX, rectPts[2].fY, rectPts[2].fX, rectPts[0].fY);
- *direction = vec03IsVertical ? SkPath::kCCW_Direction : SkPath::kCW_Direction;
+ *direction = vec03IsVertical ? SkPathDirection::kCCW : SkPathDirection::kCW;
*start = 3;
break;
case 0b11:
rect->setLTRB(rectPts[2].fX, rectPts[2].fY, rectPts[0].fX, rectPts[0].fY);
- *direction = vec03IsVertical ? SkPath::kCW_Direction : SkPath::kCCW_Direction;
+ *direction = vec03IsVertical ? SkPathDirection::kCW : SkPathDirection::kCCW;
*start = 2;
break;
}
@@ -3157,7 +3157,7 @@
if (useCenter) {
path->close();
}
- path->setConvexity(convex ? SkPath::kConvex_Convexity : SkPath::kConcave_Convexity);
+ path->setConvexityType(convex ? SkPathConvexityType::kConvex : SkPathConvexityType::kConcave);
path->setFirstDirection(firstDir);
}
@@ -3276,7 +3276,7 @@
//////////////////////////////////////////////////////////////////////////////////////////////////
bool SkPathPriv::IsRectContour(const SkPath& path, bool allowPartial, int* currVerb,
- const SkPoint** ptsPtr, bool* isClosed, SkPath::Direction* direction,
+ const SkPoint** ptsPtr, bool* isClosed, SkPathDirection* direction,
SkRect* rect) {
int corners = 0;
SkPoint closeXY; // used to determine if final line falls on a diagonal
@@ -3409,17 +3409,17 @@
}
if (direction) {
*direction = directions[0] == ((directions[1] + 1) & 3) ?
- SkPath::kCW_Direction : SkPath::kCCW_Direction;
+ SkPathDirection::kCW : SkPathDirection::kCCW;
}
return true;
}
-bool SkPathPriv::IsNestedFillRects(const SkPath& path, SkRect rects[2], SkPath::Direction dirs[2]) {
+bool SkPathPriv::IsNestedFillRects(const SkPath& path, SkRect rects[2], SkPathDirection dirs[2]) {
SkDEBUGCODE(path.validate();)
int currVerb = 0;
const SkPoint* pts = path.fPathRef->points();
- SkPath::Direction testDirs[2];
+ SkPathDirection testDirs[2];
SkRect testRects[2];
if (!IsRectContour(path, true, &currVerb, &pts, nullptr, &testDirs[0], &testRects[0])) {
return false;
diff --git a/src/core/SkPathMakers.h b/src/core/SkPathMakers.h
index a4ef7e1..8e668e5 100644
--- a/src/core/SkPathMakers.h
+++ b/src/core/SkPathMakers.h
@@ -8,15 +8,15 @@
#ifndef SkPathMakers_DEFINED
#define SkPathMakers_DEFINED
-#include "include/core/SkPath.h" // just for direction
+#include "include/core/SkPathTypes.h"
#include "include/core/SkPoint.h"
#include "include/core/SkRRect.h"
template <unsigned N> class SkPath_PointIterator {
public:
- SkPath_PointIterator(SkPath::Direction dir, unsigned startIndex)
+ SkPath_PointIterator(SkPathDirection dir, unsigned startIndex)
: fCurrent(startIndex % N)
- , fAdvance(dir == SkPath::kCW_Direction ? 1 : N - 1) { }
+ , fAdvance(dir == SkPathDirection::kCW ? 1 : N - 1) { }
const SkPoint& current() const {
SkASSERT(fCurrent < N);
@@ -38,7 +38,7 @@
class SkPath_RectPointIterator : public SkPath_PointIterator<4> {
public:
- SkPath_RectPointIterator(const SkRect& rect, SkPath::Direction dir, unsigned startIndex)
+ SkPath_RectPointIterator(const SkRect& rect, SkPathDirection dir, unsigned startIndex)
: SkPath_PointIterator(dir, startIndex) {
fPts[0] = SkPoint::Make(rect.fLeft, rect.fTop);
@@ -50,7 +50,7 @@
class SkPath_OvalPointIterator : public SkPath_PointIterator<4> {
public:
- SkPath_OvalPointIterator(const SkRect& oval, SkPath::Direction dir, unsigned startIndex)
+ SkPath_OvalPointIterator(const SkRect& oval, SkPathDirection dir, unsigned startIndex)
: SkPath_PointIterator(dir, startIndex) {
const SkScalar cx = oval.centerX();
@@ -65,7 +65,7 @@
class SkPath_RRectPointIterator : public SkPath_PointIterator<8> {
public:
- SkPath_RRectPointIterator(const SkRRect& rrect, SkPath::Direction dir, unsigned startIndex)
+ SkPath_RRectPointIterator(const SkRRect& rrect, SkPathDirection dir, unsigned startIndex)
: SkPath_PointIterator(dir, startIndex) {
const SkRect& bounds = rrect.getBounds();
diff --git a/src/core/SkPathPriv.h b/src/core/SkPathPriv.h
index a018be4..803d8f4 100644
--- a/src/core/SkPathPriv.h
+++ b/src/core/SkPathPriv.h
@@ -10,6 +10,11 @@
#include "include/core/SkPath.h"
+static_assert(0 == static_cast<int>(SkPathFillType::kWinding), "fill_type_mismatch");
+static_assert(1 == static_cast<int>(SkPathFillType::kEvenOdd), "fill_type_mismatch");
+static_assert(2 == static_cast<int>(SkPathFillType::kInverseWinding), "fill_type_mismatch");
+static_assert(3 == static_cast<int>(SkPathFillType::kInverseEvenOdd), "fill_type_mismatch");
+
class SkPathPriv {
public:
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
@@ -19,12 +24,12 @@
#endif
enum FirstDirection : int {
- kCW_FirstDirection, // == SkPath::kCW_Direction
- kCCW_FirstDirection, // == SkPath::kCCW_Direction
+ kCW_FirstDirection, // == SkPathDirection::kCW
+ kCCW_FirstDirection, // == SkPathDirection::kCCW
kUnknown_FirstDirection,
};
- static FirstDirection AsFirstDirection(SkPath::Direction dir) {
+ static FirstDirection AsFirstDirection(SkPathDirection dir) {
// since we agree numerically for the values in Direction, we can just cast.
return (FirstDirection)dir;
}
@@ -96,7 +101,7 @@
* followed by four lines or a move followed by 3 lines and a close. None of the parameters are
* optional. This does not permit degenerate line or point rectangles.
*/
- static bool IsSimpleClosedRect(const SkPath& path, SkRect* rect, SkPath::Direction* direction,
+ static bool IsSimpleClosedRect(const SkPath& path, SkRect* rect, SkPathDirection* direction,
unsigned* start);
/**
@@ -177,7 +182,7 @@
return true though SkPath draws oval.
rect receives bounds of oval.
- dir receives SkPath::Direction of oval: kCW_Direction if clockwise, kCCW_Direction if
+ dir receives SkPathDirection of oval: kCW_Direction if clockwise, kCCW_Direction if
counterclockwise.
start receives start of oval: 0 for top, 1 for right, 2 for bottom, 3 for left.
@@ -186,15 +191,15 @@
Triggers performance optimizations on some GPU surface implementations.
@param rect storage for bounding SkRect of oval; may be nullptr
- @param dir storage for SkPath::Direction; may be nullptr
+ @param dir storage for SkPathDirection; may be nullptr
@param start storage for start of oval; may be nullptr
@return true if SkPath was constructed by method that reduces to oval
*/
- static bool IsOval(const SkPath& path, SkRect* rect, SkPath::Direction* dir, unsigned* start) {
+ static bool IsOval(const SkPath& path, SkRect* rect, SkPathDirection* dir, unsigned* start) {
bool isCCW = false;
bool result = path.fPathRef->isOval(rect, &isCCW, start);
if (dir && result) {
- *dir = isCCW ? SkPath::kCCW_Direction : SkPath::kCW_Direction;
+ *dir = isCCW ? SkPathDirection::kCCW : SkPathDirection::kCW;
}
return result;
}
@@ -204,7 +209,7 @@
will not return true though SkPath draws SkRRect.
rrect receives bounds of SkRRect.
- dir receives SkPath::Direction of oval: kCW_Direction if clockwise, kCCW_Direction if
+ dir receives SkPathDirection of oval: kCW_Direction if clockwise, kCCW_Direction if
counterclockwise.
start receives start of SkRRect: 0 for top, 1 for right, 2 for bottom, 3 for left.
@@ -213,16 +218,16 @@
Triggers performance optimizations on some GPU surface implementations.
@param rrect storage for bounding SkRect of SkRRect; may be nullptr
- @param dir storage for SkPath::Direction; may be nullptr
+ @param dir storage for SkPathDirection; may be nullptr
@param start storage for start of SkRRect; may be nullptr
@return true if SkPath contains only SkRRect
*/
- static bool IsRRect(const SkPath& path, SkRRect* rrect, SkPath::Direction* dir,
+ static bool IsRRect(const SkPath& path, SkRRect* rrect, SkPathDirection* dir,
unsigned* start) {
bool isCCW = false;
bool result = path.fPathRef->isRRect(rrect, &isCCW, start);
if (dir && result) {
- *dir = isCCW ? SkPath::kCCW_Direction : SkPath::kCW_Direction;
+ *dir = isCCW ? SkPathDirection::kCCW : SkPathDirection::kCW;
}
return result;
}
@@ -280,22 +285,37 @@
}
static bool IsRectContour(const SkPath&, bool allowPartial, int* currVerb,
- const SkPoint** ptsPtr, bool* isClosed, SkPath::Direction* direction,
+ const SkPoint** ptsPtr, bool* isClosed, SkPathDirection* direction,
SkRect* rect);
/** Returns true if SkPath is equivalent to nested SkRect pair when filled.
If false, rect and dirs are unchanged.
If true, rect and dirs are written to if not nullptr:
setting rect[0] to outer SkRect, and rect[1] to inner SkRect;
- setting dirs[0] to SkPath::Direction of outer SkRect, and dirs[1] to SkPath::Direction of
+ setting dirs[0] to SkPathDirection of outer SkRect, and dirs[1] to SkPathDirection of
inner SkRect.
@param rect storage for SkRect pair; may be nullptr
- @param dirs storage for SkPath::Direction pair; may be nullptr
+ @param dirs storage for SkPathDirection pair; may be nullptr
@return true if SkPath contains nested SkRect pair
*/
static bool IsNestedFillRects(const SkPath&, SkRect rect[2],
- SkPath::Direction dirs[2] = nullptr);
+ SkPathDirection dirs[2] = nullptr);
+
+ static bool IsInverseFillType(SkPathFillType fill) {
+ return (static_cast<int>(fill) & 2) != 0;
+ }
+
+ /** Returns equivalent SkPath::FillType representing SkPath fill inside its bounds.
+ .
+
+ @param fill one of: kWinding_FillType, kEvenOdd_FillType,
+ kInverseWinding_FillType, kInverseEvenOdd_FillType
+ @return fill, or kWinding_FillType or kEvenOdd_FillType if fill is inverted
+ */
+ static SkPathFillType ConvertToNonInverseFillType(SkPathFillType fill) {
+ return (SkPathFillType)(static_cast<int>(fill) & 1);
+ }
};
// Lightweight variant of SkPath::Iter that only returns segments (e.g. lines/conics).
diff --git a/src/core/SkPath_serial.cpp b/src/core/SkPath_serial.cpp
index 44fd146..5c94c04 100644
--- a/src/core/SkPath_serial.cpp
+++ b/src/core/SkPath_serial.cpp
@@ -169,15 +169,15 @@
uint8_t dir = (packed >> kDirection_SerializationShift) & 0x3;
FillType fillType = extract_filltype(packed);
- Direction rrectDir;
+ SkPathDirection rrectDir;
SkRRect rrect;
int32_t start;
switch (dir) {
case SkPathPriv::kCW_FirstDirection:
- rrectDir = kCW_Direction;
+ rrectDir = SkPathDirection::kCW;
break;
case SkPathPriv::kCCW_FirstDirection:
- rrectDir = kCCW_Direction;
+ rrectDir = SkPathDirection::kCCW;
break;
default:
return 0;
diff --git a/src/core/SkStroke.cpp b/src/core/SkStroke.cpp
index a734efa..1c32900 100644
--- a/src/core/SkStroke.cpp
+++ b/src/core/SkStroke.cpp
@@ -1391,7 +1391,7 @@
{
SkRect rect;
bool isClosed = false;
- SkPath::Direction dir;
+ SkPathDirection dir;
if (src.isRect(&rect, &isClosed, &dir) && isClosed) {
this->strokeRect(rect, dst, dir);
// our answer should preserve the inverseness of the src
@@ -1498,15 +1498,15 @@
}
}
-static SkPath::Direction reverse_direction(SkPath::Direction dir) {
- static const SkPath::Direction gOpposite[] = { SkPath::kCCW_Direction, SkPath::kCW_Direction };
- return gOpposite[dir];
+static SkPathDirection reverse_direction(SkPathDirection dir) {
+ static const SkPathDirection gOpposite[] = { SkPathDirection::kCCW, SkPathDirection::kCW };
+ return gOpposite[(int)dir];
}
-static void addBevel(SkPath* path, const SkRect& r, const SkRect& outer, SkPath::Direction dir) {
+static void addBevel(SkPath* path, const SkRect& r, const SkRect& outer, SkPathDirection dir) {
SkPoint pts[8];
- if (SkPath::kCW_Direction == dir) {
+ if (SkPathDirection::kCW == dir) {
pts[0].set(r.fLeft, outer.fTop);
pts[1].set(r.fRight, outer.fTop);
pts[2].set(outer.fRight, r.fTop);
@@ -1529,7 +1529,7 @@
}
void SkStroke::strokeRect(const SkRect& origRect, SkPath* dst,
- SkPath::Direction dir) const {
+ SkPathDirection dir) const {
SkASSERT(dst != nullptr);
dst->reset();
diff --git a/src/core/SkStroke.h b/src/core/SkStroke.h
index 66edf3d..b0458d3 100644
--- a/src/core/SkStroke.h
+++ b/src/core/SkStroke.h
@@ -62,7 +62,7 @@
* Stroke the specified rect, winding it in the specified direction..
*/
void strokeRect(const SkRect& rect, SkPath* result,
- SkPath::Direction = SkPath::kCW_Direction) const;
+ SkPathDirection = SkPathDirection::kCW) const;
void strokePath(const SkPath& path, SkPath*) const;
////////////////////////////////////////////////////////////////
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index 0e1fc1a..bd8c894 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -1415,7 +1415,7 @@
assert_alive(paint);
this->drawShapeUsingPathRenderer(
clip, std::move(paint), aa, viewMatrix,
- GrShape(SkRRect::MakeOval(oval), SkPath::kCW_Direction, 2, false, style));
+ GrShape(SkRRect::MakeOval(oval), SkPathDirection::kCW, 2, false, style));
}
void GrRenderTargetContext::drawArc(const GrClip& clip,
diff --git a/src/gpu/GrTestUtils.cpp b/src/gpu/GrTestUtils.cpp
index 42aba5e..b348c78 100644
--- a/src/gpu/GrTestUtils.cpp
+++ b/src/gpu/GrTestUtils.cpp
@@ -232,7 +232,7 @@
gPath[2].lineTo(-50.0f, 31.0f);
for (size_t i = 0; i < SK_ARRAY_COUNT(gPath); i++) {
- SkASSERT(SkPath::kConvex_Convexity == gPath[i].getConvexity());
+ SkASSERT(SkPathConvexityType::kConvex == gPath[i].getConvexityType());
}
}
diff --git a/src/gpu/geometry/GrShape.cpp b/src/gpu/geometry/GrShape.cpp
index 4fc3472..bb4f92b 100644
--- a/src/gpu/geometry/GrShape.cpp
+++ b/src/gpu/geometry/GrShape.cpp
@@ -273,7 +273,7 @@
case Type::kRRect:
fRRectData.fRRect.writeToMemory(key);
key += SkRRect::kSizeInMemory / sizeof(uint32_t);
- *key = (fRRectData.fDir == SkPath::kCCW_Direction) ? (1 << 31) : 0;
+ *key = (fRRectData.fDir == SkPathDirection::kCCW) ? (1 << 31) : 0;
*key |= fRRectData.fInverted ? (1 << 30) : 0;
*key++ |= fRRectData.fStart;
SkASSERT(fRRectData.fStart < 8);
@@ -507,7 +507,7 @@
void GrShape::attemptToSimplifyPath() {
SkRect rect;
SkRRect rrect;
- SkPath::Direction rrectDir;
+ SkPathDirection rrectDir;
unsigned rrectStart;
bool inverted = this->path().isInverseFillType();
SkPoint pts[2];
diff --git a/src/gpu/geometry/GrShape.h b/src/gpu/geometry/GrShape.h
index 37f38f8..08146df 100644
--- a/src/gpu/geometry/GrShape.h
+++ b/src/gpu/geometry/GrShape.h
@@ -61,7 +61,7 @@
this->attemptToSimplifyRRect();
}
- GrShape(const SkRRect& rrect, SkPath::Direction dir, unsigned start, bool inverted,
+ GrShape(const SkRRect& rrect, SkPathDirection dir, unsigned start, bool inverted,
const GrStyle& style)
: fStyle(style) {
this->initType(Type::kRRect);
@@ -160,7 +160,7 @@
}
/** Returns the unstyled geometry as a rrect if possible. */
- bool asRRect(SkRRect* rrect, SkPath::Direction* dir, unsigned* start, bool* inverted) const {
+ bool asRRect(SkRRect* rrect, SkPathDirection* dir, unsigned* start, bool* inverted) const {
if (Type::kRRect != fType) {
return false;
}
@@ -255,7 +255,7 @@
return false;
}
- SkPath::Direction dirs[2];
+ SkPathDirection dirs[2];
if (!SkPathPriv::IsNestedFillRects(this->path(), rects, dirs)) {
return false;
}
@@ -554,11 +554,11 @@
static constexpr SkPath::FillType kDefaultPathInverseFillType =
SkPath::kInverseEvenOdd_FillType;
- static constexpr SkPath::Direction kDefaultRRectDir = SkPath::kCW_Direction;
+ static constexpr SkPathDirection kDefaultRRectDir = SkPathDirection::kCW;
static constexpr unsigned kDefaultRRectStart = 0;
static unsigned DefaultRectDirAndStartIndex(const SkRect& rect, bool hasPathEffect,
- SkPath::Direction* dir) {
+ SkPathDirection* dir) {
*dir = kDefaultRRectDir;
// This comes from SkPath's interface. The default for adding a SkRect is counter clockwise
// beginning at index 0 (which happens to correspond to rrect index 0 or 7).
@@ -575,11 +575,11 @@
// 0 becomes start index 2 and times 2 to convert from rect the rrect indices.
return 2 * 2;
} else if (swapX) {
- *dir = SkPath::kCCW_Direction;
+ *dir = SkPathDirection::kCCW;
// 0 becomes start index 1 and times 2 to convert from rect the rrect indices.
return 2 * 1;
} else if (swapY) {
- *dir = SkPath::kCCW_Direction;
+ *dir = SkPathDirection::kCCW;
// 0 becomes start index 3 and times 2 to convert from rect the rrect indices.
return 2 * 3;
}
@@ -587,7 +587,7 @@
}
static unsigned DefaultRRectDirAndStartIndex(const SkRRect& rrect, bool hasPathEffect,
- SkPath::Direction* dir) {
+ SkPathDirection* dir) {
// This comes from SkPath's interface. The default for adding a SkRRect to a path is
// clockwise beginning at starting index 6.
static constexpr unsigned kPathRRectStartIdx = 6;
@@ -602,7 +602,7 @@
union {
struct {
SkRRect fRRect;
- SkPath::Direction fDir;
+ SkPathDirection fDir;
unsigned fStart;
bool fInverted;
} fRRectData;
diff --git a/src/gpu/ops/GrAAConvexTessellator.cpp b/src/gpu/ops/GrAAConvexTessellator.cpp
index c345c33..86aa54c 100644
--- a/src/gpu/ops/GrAAConvexTessellator.cpp
+++ b/src/gpu/ops/GrAAConvexTessellator.cpp
@@ -377,7 +377,7 @@
}
bool GrAAConvexTessellator::extractFromPath(const SkMatrix& m, const SkPath& path) {
- SkASSERT(SkPath::kConvex_Convexity == path.getConvexity());
+ SkASSERT(SkPathConvexityType::kConvex == path.getConvexityType());
SkRect bounds = path.getBounds();
m.mapRect(&bounds);
diff --git a/src/pathops/SkPathOpsAsWinding.cpp b/src/pathops/SkPathOpsAsWinding.cpp
index 3dfae2f..b3d92a9 100644
--- a/src/pathops/SkPathOpsAsWinding.cpp
+++ b/src/pathops/SkPathOpsAsWinding.cpp
@@ -13,7 +13,7 @@
using std::vector;
struct Contour {
- enum class Direction { // SkPath::Direction doesn't have 'none' state
+ enum class Direction { // SkPathDirection doesn't have 'none' state
kCCW = -1,
kNone,
kCW,
diff --git a/src/pathops/SkPathOpsDebug.cpp b/src/pathops/SkPathOpsDebug.cpp
index 7ee44de..da4e76b 100644
--- a/src/pathops/SkPathOpsDebug.cpp
+++ b/src/pathops/SkPathOpsDebug.cpp
@@ -2914,15 +2914,15 @@
int rectCount = path.isRectContours() ? path.rectContours(nullptr, nullptr) : 0;
if (rectCount > 0) {
SkTDArray<SkRect> rects;
- SkTDArray<SkPath::Direction> directions;
+ SkTDArray<SkPathDirection> directions;
rects.setCount(rectCount);
directions.setCount(rectCount);
path.rectContours(rects.begin(), directions.begin());
for (int contour = 0; contour < rectCount; ++contour) {
const SkRect& rect = rects[contour];
SkDebugf("path.addRect(%1.9g, %1.9g, %1.9g, %1.9g, %s);\n", rect.fLeft, rect.fTop,
- rect.fRight, rect.fBottom, directions[contour] == SkPath::kCCW_Direction
- ? "SkPath::kCCW_Direction" : "SkPath::kCW_Direction");
+ rect.fRight, rect.fBottom, directions[contour] == SkPathDirection::kCCW
+ ? "SkPathDirection::kCCW" : "SkPathDirection::kCW");
}
return;
}
diff --git a/src/pdf/SkPDFUtils.cpp b/src/pdf/SkPDFUtils.cpp
index 9beedfb..0564b0f 100644
--- a/src/pdf/SkPDFUtils.cpp
+++ b/src/pdf/SkPDFUtils.cpp
@@ -128,10 +128,10 @@
SkRect rect;
bool isClosed; // Both closure and direction need to be checked.
- SkPath::Direction direction;
+ SkPathDirection direction;
if (path.isRect(&rect, &isClosed, &direction) &&
isClosed &&
- (SkPath::kCW_Direction == direction ||
+ (SkPathDirection::kCW == direction ||
SkPath::kEvenOdd_FillType == path.getFillType()))
{
SkPDFUtils::AppendRectangle(rect, content);
diff --git a/src/utils/SkDashPath.cpp b/src/utils/SkDashPath.cpp
index 92e4bdb..f94df30 100644
--- a/src/utils/SkDashPath.cpp
+++ b/src/utils/SkDashPath.cpp
@@ -425,7 +425,7 @@
} while (meas.nextContour());
if (segCount > 1) {
- dst->setConvexity(SkPath::kConcave_Convexity);
+ dst->setConvexityType(SkPathConvexityType::kConcave);
}
return true;
diff --git a/src/utils/SkLua.cpp b/src/utils/SkLua.cpp
index 03318bb..2f1482e 100644
--- a/src/utils/SkLua.cpp
+++ b/src/utils/SkLua.cpp
@@ -1310,7 +1310,7 @@
}
static int lpath_isConvex(lua_State* L) {
- bool isConvex = SkPath::kConvex_Convexity == get_obj<SkPath>(L, 1)->getConvexity();
+ bool isConvex = get_obj<SkPath>(L, 1)->isConvex();
SkLua(L).pushBool(isConvex);
return 1;
}
diff --git a/src/utils/SkParsePath.cpp b/src/utils/SkParsePath.cpp
index 8c9469b..688daae 100644
--- a/src/utils/SkParsePath.cpp
+++ b/src/utils/SkParsePath.cpp
@@ -175,7 +175,7 @@
&& (data = skip_sep(data))
&& (data = find_points(data, &points[0], 1, relative, &c))) {
path.arcTo(radii, angle, (SkPath::ArcSize) SkToBool(largeArc),
- (SkPath::Direction) !SkToBool(sweep), points[0]);
+ (SkPathDirection) !SkToBool(sweep), points[0]);
path.getLastPt(&c);
}
} break;