Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Unified Diff: src/core/SkEdgeBuilder.cpp

Issue 2477373002: Combine analytic edges with tolerance (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/aaa.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkEdgeBuilder.cpp
diff --git a/src/core/SkEdgeBuilder.cpp b/src/core/SkEdgeBuilder.cpp
index 1a160882d466d3b3d71355ec560da7aa96f4a632..22ee9ed3467c11e8e9ba4ecdaabd6bb594a9622a 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;
« no previous file with comments | « gm/aaa.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698