add guard to switch to SkPathTypes
Change-Id: I44d8b5ae8a5172d11a6d4cd9d994373dd3816d6f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/241278
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
diff --git a/src/gpu/GrDistanceFieldGenFromVector.cpp b/src/gpu/GrDistanceFieldGenFromVector.cpp
index 29aa16d..fc505e5 100644
--- a/src/gpu/GrDistanceFieldGenFromVector.cpp
+++ b/src/gpu/GrDistanceFieldGenFromVector.cpp
@@ -763,7 +763,7 @@
workingPath = path;
}
- if (!IsDistanceFieldSupportedFillType(workingPath.getFillType())) {
+ if (!IsDistanceFieldSupportedFillType((SkPathFillType)workingPath.getFillType())) {
return false;
}
@@ -829,15 +829,19 @@
kOutside = 1
} dfSign;
- if (workingPath.getFillType() == SkPath::kWinding_FillType) {
- dfSign = windingNumber ? kInside : kOutside;
- } else if (workingPath.getFillType() == SkPath::kInverseWinding_FillType) {
- dfSign = windingNumber ? kOutside : kInside;
- } else if (workingPath.getFillType() == SkPath::kEvenOdd_FillType) {
- dfSign = (windingNumber % 2) ? kInside : kOutside;
- } else {
- SkASSERT(workingPath.getFillType() == SkPath::kInverseEvenOdd_FillType);
- dfSign = (windingNumber % 2) ? kOutside : kInside;
+ switch ((SkPathFillType)workingPath.getFillType()) {
+ case SkPathFillType::kWinding:
+ dfSign = windingNumber ? kInside : kOutside;
+ break;
+ case SkPathFillType::kInverseWinding:
+ dfSign = windingNumber ? kOutside : kInside;
+ break;
+ case SkPathFillType::kEvenOdd:
+ dfSign = (windingNumber % 2) ? kInside : kOutside;
+ break;
+ case SkPathFillType::kInverseEvenOdd:
+ dfSign = (windingNumber % 2) ? kOutside : kInside;
+ break;
}
// The winding number at the end of a scanline should be zero.
diff --git a/src/gpu/GrDistanceFieldGenFromVector.h b/src/gpu/GrDistanceFieldGenFromVector.h
index 8e8d1b3..0362166 100644
--- a/src/gpu/GrDistanceFieldGenFromVector.h
+++ b/src/gpu/GrDistanceFieldGenFromVector.h
@@ -30,10 +30,10 @@
const SkPath& path, const SkMatrix& viewMatrix,
int width, int height, size_t rowBytes);
-inline bool IsDistanceFieldSupportedFillType(SkPath::FillType fFillType)
+inline bool IsDistanceFieldSupportedFillType(SkPathFillType fFillType)
{
- return (SkPath::kEvenOdd_FillType == fFillType ||
- SkPath::kInverseEvenOdd_FillType == fFillType);
+ return (SkPathFillType::kEvenOdd == fFillType ||
+ SkPathFillType::kInverseEvenOdd == fFillType);
}
#endif
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index dd3472c..edb7611 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -1493,7 +1493,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 c6e95a3..cabac43 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 == (SkPathConvexityType)gPath[i].getConvexity());
}
}
diff --git a/src/gpu/ccpr/GrCCFiller.cpp b/src/gpu/ccpr/GrCCFiller.cpp
index 9c09b4a..9a6c9dd 100644
--- a/src/gpu/ccpr/GrCCFiller.cpp
+++ b/src/gpu/ccpr/GrCCFiller.cpp
@@ -135,7 +135,7 @@
// We use "winding" fill type right now because we are producing a coverage count, and must
// fill in every region that has non-zero wind. The path processor will convert coverage
// count to the appropriate fill type later.
- fan.setFillType(SkPath::kWinding_FillType);
+ fan.setFillType(SkPathFillType::kWinding);
} else {
// When counting winding numbers in the stencil buffer, it works to just tessellate the
// Redbook fan with the same fill type as the path.
diff --git a/src/gpu/geometry/GrShape.cpp b/src/gpu/geometry/GrShape.cpp
index 4fc3472..a510a19 100644
--- a/src/gpu/geometry/GrShape.cpp
+++ b/src/gpu/geometry/GrShape.cpp
@@ -201,7 +201,7 @@
const int conicWeightCnt = SkPathPriv::ConicWeightCnt(path);
SkASSERT(verbCnt <= GrShape::kMaxKeyFromDataVerbCnt);
SkASSERT(pointCnt && verbCnt);
- *key++ = path.getFillType();
+ *key++ = (uint32_t)path.getFillType();
*key++ = verbCnt;
memcpy(key, SkPathPriv::VerbData(path), verbCnt * sizeof(uint8_t));
int verbKeySize = SkAlign4(verbCnt);
@@ -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);
@@ -297,7 +297,7 @@
*key++ = fPathData.fGenID;
// We could canonicalize the fill rule for paths that don't differentiate between
// even/odd or winding fill (e.g. convex).
- *key++ = this->path().getFillType();
+ *key++ = (uint32_t)this->path().getFillType();
break;
}
}
@@ -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..8771c94 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,12 +255,12 @@
return false;
}
- SkPath::Direction dirs[2];
+ SkPathDirection dirs[2];
if (!SkPathPriv::IsNestedFillRects(this->path(), rects, dirs)) {
return false;
}
- if (SkPath::kWinding_FillType == this->path().getFillType() && dirs[0] == dirs[1]) {
+ if (SkPathFillType::kWinding == (SkPathFillType)this->path().getFillType() && dirs[0] == dirs[1]) {
// The two rects need to be wound opposite to each other
return false;
}
@@ -550,15 +550,15 @@
const SkPath* originalPathForListeners() const;
// Defaults to use when there is no distinction between even/odd and winding fills.
- static constexpr SkPath::FillType kDefaultPathFillType = SkPath::kEvenOdd_FillType;
- static constexpr SkPath::FillType kDefaultPathInverseFillType =
- SkPath::kInverseEvenOdd_FillType;
+ static constexpr SkPathFillType kDefaultPathFillType = SkPathFillType::kEvenOdd;
+ static constexpr SkPathFillType kDefaultPathInverseFillType =
+ SkPathFillType::kInverseEvenOdd;
- 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 9952491..9468692 100644
--- a/src/gpu/ops/GrAAConvexTessellator.cpp
+++ b/src/gpu/ops/GrAAConvexTessellator.cpp
@@ -369,7 +369,7 @@
}
bool GrAAConvexTessellator::extractFromPath(const SkMatrix& m, const SkPath& path) {
- SkASSERT(SkPath::kConvex_Convexity == path.getConvexity());
+ SkASSERT(SkPathConvexityType::kConvex == (SkPathConvexityType)path.getConvexity());
SkRect bounds = path.getBounds();
m.mapRect(&bounds);