Skip to content

Commit

Permalink
remove dead code around old SkPath enums
Browse files Browse the repository at this point in the history
Change-Id: I8dc06da48e881d3a9c40b47c799afe27bdcce819
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/257689
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
  • Loading branch information
reed-at-google authored and Skia Commit-Bot committed Dec 14, 2019
1 parent cd9ad40 commit cf0e3c6
Show file tree
Hide file tree
Showing 30 changed files with 54 additions and 217 deletions.
6 changes: 3 additions & 3 deletions docs/examples/Path_getFillType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ REG_FIDDLE(Path_getFillType, 256, 256, true, 0) {
void draw(SkCanvas* canvas) {
SkPath path;
SkDebugf("default path fill type is %s\n",
path.getNewFillType() == SkPathFillType::kWinding ? "kWinding" :
path.getNewFillType() == SkPathFillType::kEvenOdd ? "kEvenOdd" :
path.getNewFillType() == SkPathFillType::kInverseWinding ? "kInverseWinding" :
path.getFillType() == SkPathFillType::kWinding ? "kWinding" :
path.getFillType() == SkPathFillType::kEvenOdd ? "kEvenOdd" :
path.getFillType() == SkPathFillType::kInverseWinding ? "kInverseWinding" :
"kInverseEvenOdd");
}
} // END FIDDLE
169 changes: 3 additions & 166 deletions include/core/SkPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,6 @@ class SkWStream;
class SK_API SkPath {
public:

#ifdef SK_SUPPORT_LEGACY_PATH_DIRECTION_ENUM
/** \enum SkPath::Direction
Direction describes whether contour is clockwise or counterclockwise.
When SkPath contains multiple overlapping contours, Direction together with
FillType determines whether overlaps are filled or form holes.
Direction also determines how contour is measured. For instance, dashing
measures along SkPath to determine where to start and stop stroke; Direction
will change dashed results as it steps clockwise or counterclockwise.
Closed contours like SkRect, SkRRect, circle, and oval added with
kCW_Direction travel clockwise; the same added with kCCW_Direction
travel counterclockwise.
*/
enum Direction : int {
kCW_Direction = static_cast<int>(SkPathDirection::kCW),
kCCW_Direction = static_cast<int>(SkPathDirection::kCCW)
};
#endif

/** Constructs an empty SkPath. By default, SkPath has no verbs, no SkPoint, and no weights.
SkPath::FillType is set to kWinding_FillType.
Expand Down Expand Up @@ -165,81 +145,16 @@ class SK_API SkPath {
*/
bool interpolate(const SkPath& ending, SkScalar weight, SkPath* out) const;

#ifdef SK_SUPPORT_LEGACY_PATH_FILLTYPE_ENUM
/** \enum SkPath::FillType
FillType selects the rule used to fill SkPath. SkPath set to kWinding_FillType
fills if the sum of contour edges is not zero, where clockwise edges add one, and
counterclockwise edges subtract one. SkPath set to kEvenOdd_FillType fills if the
number of contour edges is odd. Each FillType has an inverse variant that
reverses the rule:
kInverseWinding_FillType fills where the sum of contour edges is zero;
kInverseEvenOdd_FillType fills where the number of contour edges is even.
*/
enum FillType {
kWinding_FillType = static_cast<int>(SkPathFillType::kWinding),
kEvenOdd_FillType = static_cast<int>(SkPathFillType::kEvenOdd),
kInverseWinding_FillType = static_cast<int>(SkPathFillType::kInverseWinding),
kInverseEvenOdd_FillType = static_cast<int>(SkPathFillType::kInverseEvenOdd)
};

/** Returns FillType, the rule used to fill SkPath. FillType of a new SkPath is
kWinding_FillType.
@return one of: kWinding_FillType, kEvenOdd_FillType, kInverseWinding_FillType,
kInverseEvenOdd_FillType
*/
FillType getFillType() const { return (FillType)fFillType; }

/** Sets FillType, the rule used to fill SkPath. While there is no check
that ft is legal, values outside of FillType are not supported.
@param ft one of: kWinding_FillType, kEvenOdd_FillType, kInverseWinding_FillType,
kInverseEvenOdd_FillType
*/
void setFillType(FillType ft) {
fFillType = SkToU8(ft);
}

/** Returns true if fill is inverted and SkPath with fill represents area outside
of its geometric bounds.
@param fill one of: kWinding_FillType, kEvenOdd_FillType,
kInverseWinding_FillType, kInverseEvenOdd_FillType
@return true if SkPath fills outside its bounds
*/
static bool IsInverseFillType(FillType fill) {
static_assert(0 == kWinding_FillType, "fill_type_mismatch");
static_assert(1 == kEvenOdd_FillType, "fill_type_mismatch");
static_assert(2 == kInverseWinding_FillType, "fill_type_mismatch");
static_assert(3 == kInverseEvenOdd_FillType, "fill_type_mismatch");
return (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 FillType ConvertToNonInverseFillType(FillType fill) {
static_assert(0 == kWinding_FillType, "fill_type_mismatch");
static_assert(1 == kEvenOdd_FillType, "fill_type_mismatch");
static_assert(2 == kInverseWinding_FillType, "fill_type_mismatch");
static_assert(3 == kInverseEvenOdd_FillType, "fill_type_mismatch");
return (FillType)(fill & 1);
}
#else
/** Returns FillType, the rule used to fill SkPath. FillType of a new SkPath is
kWinding_FillType.
@return one of: kWinding_FillType, kEvenOdd_FillType, kInverseWinding_FillType,
kInverseEvenOdd_FillType
*/
SkPathFillType getFillType() const { return (SkPathFillType)fFillType; }
#endif

// Temporary method -- remove when we've switched to the new enum
SkPathFillType getNewFillType() const { return (SkPathFillType)this->getFillType(); }
// SkPathFillType getNewFillType() const { return (SkPathFillType)this->getFillType(); }

/** Sets FillType, the rule used to fill SkPath. While there is no check
that ft is legal, values outside of FillType are not supported.
Expand All @@ -255,7 +170,7 @@ class SK_API SkPath {
@return true if FillType is kInverseWinding_FillType or kInverseEvenOdd_FillType
*/
bool isInverseFillType() const { return SkPathFillType_IsInverse(this->getNewFillType()); }
bool isInverseFillType() const { return SkPathFillType_IsInverse(this->getFillType()); }

/** Replaces FillType with its inverse. The inverse of FillType describes the area
unmodified by the original FillType.
Expand Down Expand Up @@ -301,32 +216,6 @@ class SK_API SkPath {
return SkPathConvexityType::kConvex == this->getConvexityType();
}

#ifdef SK_SUPPORT_LEGACY_PATH_DIRECTION_ENUM
/** \enum SkPath::Convexity
SkPath is convex if it contains one contour and contour loops no more than
360 degrees, and contour angles all have same Direction. Convex SkPath
may have better performance and require fewer resources on GPU surface.
SkPath is concave when either at least one Direction change is clockwise and
another is counterclockwise, or the sum of the changes in Direction is not 360
degrees.
Initially SkPath Convexity is kUnknown_Convexity. SkPath Convexity is computed
if needed by destination SkSurface.
*/
enum Convexity : uint8_t {
kUnknown_Convexity = static_cast<int>(SkPathConvexityType::kUnknown),
kConvex_Convexity = static_cast<int>(SkPathConvexityType::kConvex),
kConcave_Convexity = static_cast<int>(SkPathConvexityType::kConcave),
};

Convexity getConvexity() const { return (Convexity)this->getConvexityType(); }
Convexity getConvexityOrUnknown() const { return (Convexity)this->getConvexityTypeOrUnknown(); }
void setConvexity(Convexity convexity) {
this->setConvexityType((SkPathConvexityType)convexity);
}
#endif

/** Returns true if this path is recognized as an oval or circle.
bounds receives bounds of oval.
Expand Down Expand Up @@ -1795,58 +1684,6 @@ class SK_API SkPath {
*/
bool isValid() const { return this->isValidImpl() && fPathRef->isValid(); }

#ifdef SK_SUPPORT_LEGACY_PATH_DIRECTION_ENUM
SkPath& arcTo(SkScalar rx, SkScalar ry, SkScalar xAxisRotate, ArcSize largeArc,
Direction sweep, SkScalar x, SkScalar y) {
return this->arcTo(rx, ry, xAxisRotate, largeArc, (SkPathDirection)sweep, x, y);
}
SkPath& arcTo(const SkPoint r, SkScalar xAxisRotate, ArcSize largeArc, Direction sweep,
const SkPoint xy) {
return this->arcTo(r.fX, r.fY, xAxisRotate, largeArc, (SkPathDirection)sweep, xy.fX, xy.fY);
}
SkPath& rArcTo(SkScalar rx, SkScalar ry, SkScalar xAxisRotate, ArcSize largeArc,
Direction sweep, SkScalar dx, SkScalar dy) {
return this->rArcTo(rx, ry, xAxisRotate, largeArc, (SkPathDirection)sweep, dx, dy);
}
bool isRect(SkRect* rect, bool* isClosed, Direction* direction) const {
return this->isRect(rect, isClosed, (SkPathDirection*)direction);
}
bool isRect(SkRect* rect, bool* isClosed, nullptr_t) const {
return this->isRect(rect, isClosed);
}
SkPath& addRect(const SkRect& rect, Direction dir) {
return this->addRect(rect, (SkPathDirection)dir);
}
SkPath& addRect(const SkRect& rect, Direction dir, unsigned start) {
return this->addRect(rect, (SkPathDirection)dir, start);
}
SkPath& addRect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom,
Direction dir) {
return this->addRect(left, top, right, bottom, (SkPathDirection)dir);
}
SkPath& addOval(const SkRect& oval, Direction dir) {
return addOval(oval, (SkPathDirection)dir);
}
SkPath& addOval(const SkRect& oval, Direction dir, unsigned start) {
return this->addOval(oval, (SkPathDirection)dir, start);
}
SkPath& addCircle(SkScalar x, SkScalar y, SkScalar radius, Direction dir) {
return this->addCircle(x, y, radius, (SkPathDirection)dir);
}
SkPath& addRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry, Direction dir) {
return this->addRoundRect(rect, rx, ry, (SkPathDirection)dir);
}
SkPath& addRoundRect(const SkRect& rect, const SkScalar radii[], Direction dir) {
return this->addRoundRect(rect, radii, (SkPathDirection)dir);
}
SkPath& addRRect(const SkRRect& rrect, Direction dir) {
return this->addRRect(rrect, (SkPathDirection)dir);
}
SkPath& addRRect(const SkRRect& rrect, Direction dir, unsigned start) {
return this->addRRect(rrect, (SkPathDirection)dir, start);
}
#endif

private:
sk_sp<SkPathRef> fPathRef;
int fLastMoveToIndex;
Expand Down
2 changes: 1 addition & 1 deletion include/private/GrTypesPriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ enum class GrFillRule : bool {
};

inline GrFillRule GrFillRuleForSkPath(const SkPath& path) {
switch (path.getNewFillType()) {
switch (path.getFillType()) {
case SkPathFillType::kWinding:
case SkPathFillType::kInverseWinding:
return GrFillRule::kNonzero;
Expand Down
4 changes: 2 additions & 2 deletions modules/pathkit/pathkit_wasm_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,9 @@ void ApplyAddPath(SkPath& orig, const SkPath& newPath,
}

JSString GetFillTypeString(const SkPath& path) {
if (path.getNewFillType() == SkPathFillType::kWinding) {
if (path.getFillType() == SkPathFillType::kWinding) {
return emscripten::val("nonzero");
} else if (path.getNewFillType() == SkPathFillType::kEvenOdd) {
} else if (path.getFillType() == SkPathFillType::kEvenOdd) {
return emscripten::val("evenodd");
} else {
SkDebugf("warning: can't translate inverted filltype to HTML Canvas\n");
Expand Down
4 changes: 2 additions & 2 deletions modules/sksg/include/SkSGPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ class Path : public GeometryNode {
// SG_MAPPED_ATTRIBUTE(FillType, SkPathFillType, fPath)

SkPathFillType getFillType() const {
return fPath.getNewFillType();
return fPath.getFillType();
}

void setFillType(SkPathFillType fillType) {
if (fillType != fPath.getNewFillType()) {
if (fillType != fPath.getFillType()) {
fPath.setFillType(fillType);
this->invalidate();
}
Expand Down
2 changes: 1 addition & 1 deletion modules/sksg/src/SkSGPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ bool Path::onContains(const SkPoint& p) const {
SkRect Path::onRevalidate(InvalidationController*, const SkMatrix&) {
SkASSERT(this->hasInval());

const auto ft = fPath.getNewFillType();
const auto ft = fPath.getFillType();
return (ft == SkPathFillType::kWinding || ft == SkPathFillType::kEvenOdd)
// "Containing" fills have finite bounds.
? fPath.computeTightBounds()
Expand Down
4 changes: 2 additions & 2 deletions src/core/SkPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2948,8 +2948,8 @@ bool SkPath::contains(SkScalar x, SkScalar y) const {
break;
}
} while (!done);
bool evenOddFill = SkPathFillType::kEvenOdd == this->getNewFillType()
|| SkPathFillType::kInverseEvenOdd == this->getNewFillType();
bool evenOddFill = SkPathFillType::kEvenOdd == this->getFillType()
|| SkPathFillType::kInverseEvenOdd == this->getFillType();
if (evenOddFill) {
w &= 1;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/SkScan_AAAPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1934,7 +1934,7 @@ static SK_ALWAYS_INLINE void aaa_fill_path(

aaa_walk_edges(&headEdge,
&tailEdge,
path.getNewFillType(),
path.getFillType(),
blitter,
start_y,
stop_y,
Expand Down
2 changes: 1 addition & 1 deletion src/core/SkScan_Path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ void sk_fill_path(const SkPath& path, const SkIRect& clipRect, SkBlitter* blitte
if (path.isConvex() && (nullptr == proc) && count >= 2) {
walk_simple_edges(&headEdge, blitter, start_y, stop_y);
} else {
walk_edges(&headEdge, path.getNewFillType(), blitter, start_y, stop_y, proc,
walk_edges(&headEdge, path.getFillType(), blitter, start_y, stop_y, proc,
shiftedClip.right());
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/gpu/GrDistanceFieldGenFromVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ bool GrGenerateDistanceFieldFromPath(unsigned char* distanceField,
workingPath = path;
}

if (!IsDistanceFieldSupportedFillType(workingPath.getNewFillType())) {
if (!IsDistanceFieldSupportedFillType(workingPath.getFillType())) {
return false;
}

Expand Down Expand Up @@ -829,7 +829,7 @@ bool GrGenerateDistanceFieldFromPath(unsigned char* distanceField,
kOutside = 1
} dfSign;

switch (workingPath.getNewFillType()) {
switch (workingPath.getFillType()) {
case SkPathFillType::kWinding:
dfSign = windingNumber ? kInside : kOutside;
break;
Expand Down
8 changes: 4 additions & 4 deletions src/gpu/GrTessellator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2272,14 +2272,14 @@ void* polys_to_triangles(Poly* polys, SkPathFillType fillType, bool emitCoverage
Poly* path_to_polys(const SkPath& path, SkScalar tolerance, const SkRect& clipBounds,
int contourCnt, SkArenaAlloc& alloc, bool antialias, bool* isLinear,
VertexList* outerMesh) {
SkPathFillType fillType = path.getNewFillType();
SkPathFillType fillType = path.getFillType();
if (SkPathFillType_IsInverse(fillType)) {
contourCnt++;
}
std::unique_ptr<VertexList[]> contours(new VertexList[contourCnt]);

path_to_contours(path, tolerance, clipBounds, contours.get(), alloc, isLinear);
return contours_to_polys(contours.get(), contourCnt, path.getNewFillType(), path.getBounds(),
return contours_to_polys(contours.get(), contourCnt, path.getFillType(), path.getBounds(),
antialias, outerMesh, alloc);
}

Expand Down Expand Up @@ -2343,7 +2343,7 @@ int PathToTriangles(const SkPath& path, SkScalar tolerance, const SkRect& clipBo
VertexList outerMesh;
Poly* polys = path_to_polys(path, tolerance, clipBounds, contourCnt, alloc, antialias,
isLinear, &outerMesh);
SkPathFillType fillType = antialias ? SkPathFillType::kWinding : path.getNewFillType();
SkPathFillType fillType = antialias ? SkPathFillType::kWinding : path.getFillType();
int64_t count64 = count_points(polys, fillType);
if (antialias) {
count64 += count_outer_mesh_points(outerMesh);
Expand Down Expand Up @@ -2381,7 +2381,7 @@ int PathToVertices(const SkPath& path, SkScalar tolerance, const SkRect& clipBou
bool isLinear;
Poly* polys = path_to_polys(path, tolerance, clipBounds, contourCnt, alloc, false, &isLinear,
nullptr);
SkPathFillType fillType = path.getNewFillType();
SkPathFillType fillType = path.getFillType();
int64_t count64 = count_points(polys, fillType);
if (0 == count64 || count64 > SK_MaxS32) {
*verts = nullptr;
Expand Down
4 changes: 2 additions & 2 deletions src/gpu/ccpr/GrCCFiller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void GrCCFiller::PathInfo::tessellateFan(
// When counting winding numbers in the stencil buffer, it works to use even/odd for the fan
// tessellation (where applicable). But we need to strip out inverse fill info because
// inverse-ness gets accounted for later on.
fan.setFillType(SkPathFillType_ConvertToNonInverse(originalPath.getNewFillType()));
fan.setFillType(SkPathFillType_ConvertToNonInverse(originalPath.getFillType()));
}
SkASSERT(Verb::kBeginPath == verbs[verbsIdx]);
for (int i = verbsIdx + 1; i < verbs.count(); ++i) {
Expand Down Expand Up @@ -204,7 +204,7 @@ void GrCCFiller::PathInfo::tessellateFan(
}

int weight = abs(tessWinding);
if (SkPathFillType::kEvenOdd == fan.getNewFillType()) {
if (SkPathFillType::kEvenOdd == fan.getFillType()) {
SkASSERT(Algorithm::kCoverageCount != algorithm); // Covg. count always uses winding.
if (weight != 1) {
// The tessellator doesn't wrap weights modulo 2 when we request even/odd fill type.
Expand Down
2 changes: 1 addition & 1 deletion src/gpu/geometry/GrShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ class GrShape {
return false;
}

if (SkPathFillType::kWinding == this->path().getNewFillType() && dirs[0] == dirs[1]) {
if (SkPathFillType::kWinding == this->path().getFillType() && dirs[0] == dirs[1]) {
// The two rects need to be wound opposite to each other
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/gpu/gl/GrGLPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ GrGLPath::GrGLPath(GrGLGpu* gpu, const SkPath& origSkPath, const GrStyle& style)
fShouldFill = stroke.isFillStyle() ||
stroke.getStyle() == SkStrokeRec::kStrokeAndFill_Style;

fFillType = convert_skpath_filltype(skPath->getNewFillType());
fFillType = convert_skpath_filltype(skPath->getFillType());
fBounds = skPath->getBounds();
SkScalar radius = stroke.getInflationRadius();
fBounds.outset(radius, radius);
Expand Down
2 changes: 1 addition & 1 deletion src/gpu/ops/GrDefaultPathRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ bool GrDefaultPathRenderer::internalDrawPath(GrRenderTargetContext* renderTarget
}
lastPassIsBounds = false;
} else {
switch (path.getNewFillType()) {
switch (path.getFillType()) {
case SkPathFillType::kInverseEvenOdd:
reverse = true;
// fallthrough
Expand Down
Loading

0 comments on commit cf0e3c6

Please sign in to comment.