aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar liyuqian <liyuqian@google.com>2016-11-07 08:10:44 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-11-07 08:10:44 -0800
commit451ceba3544fa1ff810378f1e9a47c7d20f48a9f (patch)
treeec172b9ffd6a31e2d89512dd88714136f7557436 /src/core
parenta225e9be53001a8397344ce1e272a7df2fced499 (diff)
Combine analytic edges with tolerance
If not, we sometimes would end up with only one edge for a convex path. That either triggers SkASSERT(count >= 2) failure in debug build or SIGSEGV in release build. After the change, we should return 0 edges for such a path because everything is totally combined. Note that this change also makes the SkAnalyticEdge's CombineVertical function behave more similarly to SkEdge's CombineVertical function: SkEdge only compares fFirstY and fLastY which are integer values, which is equivalent to setting our tolerance to SK_Fixed1 (our current tolerance is 0x100, 1/256 of SK_Fixed1). And this is intentional. BUG=chrome:662914 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2477373002 Review-Url: https://codereview.chromium.org/2477373002
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkEdgeBuilder.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/core/SkEdgeBuilder.cpp b/src/core/SkEdgeBuilder.cpp
index 1a160882d4..22ee9ed346 100644
--- a/src/core/SkEdgeBuilder.cpp
+++ b/src/core/SkEdgeBuilder.cpp
@@ -63,6 +63,10 @@ SkEdgeBuilder::Combine SkEdgeBuilder::CombineVertical(const SkEdge* edge, SkEdge
return kNo_Combine;
}
+static inline bool approximatelyEqual(SkFixed a, SkFixed b) {
+ return SkAbs32(a - b) < 0x100;
+}
+
SkEdgeBuilder::Combine SkEdgeBuilder::CombineVertical(
const SkAnalyticEdge* edge, SkAnalyticEdge* last) {
SkASSERT(fAnalyticAA);
@@ -75,14 +79,14 @@ SkEdgeBuilder::Combine SkEdgeBuilder::CombineVertical(
last->fY = last->fUpperY;
return kPartial_Combine;
}
- if (edge->fUpperY == last->fLowerY) {
+ if (approximatelyEqual(edge->fUpperY, last->fLowerY)) {
last->fLowerY = edge->fLowerY;
return kPartial_Combine;
}
return kNo_Combine;
}
- if (edge->fUpperY == last->fUpperY) {
- if (edge->fLowerY == last->fLowerY) {
+ if (approximatelyEqual(edge->fUpperY, last->fUpperY)) {
+ if (approximatelyEqual(edge->fLowerY, last->fLowerY)) {
return kTotal_Combine;
}
if (edge->fLowerY < last->fLowerY) {
@@ -96,7 +100,7 @@ SkEdgeBuilder::Combine SkEdgeBuilder::CombineVertical(
last->fWinding = edge->fWinding;
return kPartial_Combine;
}
- if (edge->fLowerY == last->fLowerY) {
+ if (approximatelyEqual(edge->fLowerY, last->fLowerY)) {
if (edge->fUpperY > last->fUpperY) {
last->fLowerY = edge->fUpperY;
return kPartial_Combine;