aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Yuqian Li <liyuqian@google.com>2017-05-26 14:50:35 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-05-26 19:14:51 +0000
commit1c8408847cc626a34fc885b1c6313533d030e192 (patch)
treef10803c94307dae7835b008b59abe3fd19a9540a /src
parenta132c3869fcffb350d7a5ca7256496ab977bdd0c (diff)
Explicitly check edge count >= 2 in non-debug build
We also preserve the check in debug mode that the count should never be 1 when the path is convex. Bug: skia:6684 Change-Id: I4d4c9ad9f9d704e94bbe51f10a96f8b3066afaa1 Reviewed-on: https://skia-review.googlesource.com/17983 Commit-Queue: Yuqian Li <liyuqian@google.com> Reviewed-by: Mike Reed <reed@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/SkEdgeBuilder.cpp15
-rw-r--r--src/core/SkEdgeBuilder.h3
-rw-r--r--src/core/SkScan_AAAPath.cpp17
-rw-r--r--src/core/SkScan_Path.cpp17
4 files changed, 27 insertions, 25 deletions
diff --git a/src/core/SkEdgeBuilder.cpp b/src/core/SkEdgeBuilder.cpp
index f1aa105ec8..385193040b 100644
--- a/src/core/SkEdgeBuilder.cpp
+++ b/src/core/SkEdgeBuilder.cpp
@@ -441,3 +441,18 @@ int SkEdgeBuilder::build(const SkPath& path, const SkIRect* iclip, int shiftUp,
fEdgeList = fList.begin();
return fList.count();
}
+
+int SkEdgeBuilder::build_edges(const SkPath& path, const SkIRect* shiftedClip,
+ int shiftEdgesUp, bool pathContainedInClip, bool analyticAA) {
+ // If we're convex, then we need both edges, even the right edge is past the clip
+ const bool canCullToTheRight = !path.isConvex();
+
+ const SkIRect* builderClip = pathContainedInClip ? nullptr : shiftedClip;
+ int count = this->build(path, builderClip, shiftEdgesUp, canCullToTheRight, analyticAA);
+ SkASSERT(count >= 0);
+
+ // canCullToRight == false should imply count != 1
+ SkASSERT(canCullToTheRight || count != 1);
+
+ return count;
+}
diff --git a/src/core/SkEdgeBuilder.h b/src/core/SkEdgeBuilder.h
index 8d38f10466..2f2b35104f 100644
--- a/src/core/SkEdgeBuilder.h
+++ b/src/core/SkEdgeBuilder.h
@@ -25,6 +25,9 @@ public:
int build(const SkPath& path, const SkIRect* clip, int shiftUp, bool clipToTheRight,
bool analyticAA = false);
+ int build_edges(const SkPath& path, const SkIRect* shiftedClip,
+ int shiftEdgesUp, bool pathContainedInClip, bool analyticAA = false);
+
SkEdge** edgeList() { return (SkEdge**)fEdgeList; }
SkAnalyticEdge** analyticEdgeList() { return (SkAnalyticEdge**)fEdgeList; }
diff --git a/src/core/SkScan_AAAPath.cpp b/src/core/SkScan_AAAPath.cpp
index 3eca137642..cb38d6131a 100644
--- a/src/core/SkScan_AAAPath.cpp
+++ b/src/core/SkScan_AAAPath.cpp
@@ -1592,17 +1592,9 @@ static SK_ALWAYS_INLINE void aaa_fill_path(const SkPath& path, const SkIRect& cl
bool isUsingMask, bool forceRLE) { // forceRLE implies that SkAAClip is calling us
SkASSERT(blitter);
- SkEdgeBuilder builder;
-
- // If we're convex, then we need both edges, even the right edge is past the clip
- const bool canCullToTheRight = !path.isConvex();
-
- SkASSERT(gSkUseAnalyticAA.load());
- const SkIRect* builderClip = pathContainedInClip ? nullptr : &clipRect;
- int count = builder.build(path, builderClip, 0, canCullToTheRight, true);
- SkASSERT(count >= 0);
-
- SkAnalyticEdge** list = (SkAnalyticEdge**)builder.analyticEdgeList();
+ SkEdgeBuilder builder;
+ int count = builder.build_edges(path, &clipRect, 0, pathContainedInClip, true);
+ SkAnalyticEdge** list = builder.analyticEdgeList();
SkIRect rect = clipRect;
if (0 == count) {
@@ -1671,8 +1663,7 @@ static SK_ALWAYS_INLINE void aaa_fill_path(const SkPath& path, const SkIRect& cl
rightBound = SkTMin(rightBound, SkIntToFixed(ir.fRight));
}
- if (!path.isInverseFillType() && path.isConvex()) {
- SkASSERT(count >= 2); // convex walker does not handle missing right edges
+ if (!path.isInverseFillType() && path.isConvex() && count >= 2) {
aaa_walk_convex_edges(&headEdge, blitter, start_y, stop_y,
leftBound, rightBound, isUsingMask);
} else {
diff --git a/src/core/SkScan_Path.cpp b/src/core/SkScan_Path.cpp
index 0415b2f99a..0975af8ddc 100644
--- a/src/core/SkScan_Path.cpp
+++ b/src/core/SkScan_Path.cpp
@@ -396,16 +396,9 @@ void sk_fill_path(const SkPath& path, const SkIRect& clipRect, SkBlitter* blitte
shiftedClip.fTop <<= shiftEdgesUp;
shiftedClip.fBottom <<= shiftEdgesUp;
- SkEdgeBuilder builder;
-
- // If we're convex, then we need both edges, even the right edge is past the clip
- const bool canCullToTheRight = !path.isConvex();
-
- SkIRect* builderClip = pathContainedInClip ? nullptr : &shiftedClip;
- int count = builder.build(path, builderClip, shiftEdgesUp, canCullToTheRight);
- SkASSERT(count >= 0);
-
- SkEdge** list = builder.edgeList();
+ SkEdgeBuilder builder;
+ int count = builder.build_edges(path, &shiftedClip, shiftEdgesUp, pathContainedInClip);
+ SkEdge** list = builder.edgeList();
if (0 == count) {
if (path.isInverseFillType()) {
@@ -467,8 +460,8 @@ void sk_fill_path(const SkPath& path, const SkIRect& clipRect, SkBlitter* blitte
proc = PrePostInverseBlitterProc;
}
- if (path.isConvex() && (nullptr == proc)) {
- SkASSERT(count >= 2); // convex walker does not handle missing right edges
+ // count >= 2 is required as the convex walker does not handle missing right edges
+ if (path.isConvex() && (nullptr == proc) && count >= 2) {
walk_convex_edges(&headEdge, path.getFillType(), blitter, start_y, stop_y, nullptr);
} else {
walk_edges(&headEdge, path.getFillType(), blitter, start_y, stop_y, proc,