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/SkAnalyticEdge.h

Issue 2430343003: Use Analytic AA in SkAAClip (Closed)
Patch Set: Nit fixes Created 4 years, 2 months 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 | « src/core/SkAAClip.cpp ('k') | src/core/SkBitmapDevice.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkAnalyticEdge.h
diff --git a/src/core/SkAnalyticEdge.h b/src/core/SkAnalyticEdge.h
index f4b23ba2b6bd6ab77c5e0b2d0bc5aaeb1d291d96..00812866d5063cc848e42239dea2ba57a4dcd84d 100644
--- a/src/core/SkAnalyticEdge.h
+++ b/src/core/SkAnalyticEdge.h
@@ -43,7 +43,8 @@ struct SkAnalyticEdge {
static const int kDefaultAccuracy = 2; // default accuracy for snapping
static inline SkFixed snapY(SkFixed y, int accuracy = kDefaultAccuracy) {
- return SkFixedRoundToFixed(y << accuracy) >> accuracy;
+ // This approach is safer than left shift, round, then right shift
+ return (y + (SK_Fixed1 >> (accuracy + 1))) >> (16 - accuracy) << (16 - accuracy);
}
// Update fX, fY of this edge so fY = y
« no previous file with comments | « src/core/SkAAClip.cpp ('k') | src/core/SkBitmapDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698