diff options
author | Lee Salzman <lsalzman@mozilla.com> | 2017-09-05 13:28:38 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-09-05 18:00:45 +0000 |
commit | 07c07e2dc0e36081c0f9b776d8d902d6ab602bd0 (patch) | |
tree | b4343a2cf30a7d349d04f1af02876356b62da873 /src/core | |
parent | 19c8726a0829e506c5c42d22d67b3fe7505ed24e (diff) |
fix analytic AA to work with even rounding
Bug: skia:
Change-Id: I92b19baa06429ef2c0e9cf6928d63528f29943fe
Reviewed-on: https://skia-review.googlesource.com/42520
Reviewed-by: Yuqian Li <liyuqian@google.com>
Commit-Queue: Yuqian Li <liyuqian@google.com>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkAnalyticEdge.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/core/SkAnalyticEdge.h b/src/core/SkAnalyticEdge.h index 13f62571a9..5e8403f5ec 100644 --- a/src/core/SkAnalyticEdge.h +++ b/src/core/SkAnalyticEdge.h @@ -139,11 +139,18 @@ bool SkAnalyticEdge::setLine(const SkPoint& p0, const SkPoint& p1) { // We must set X/Y using the same way (e.g., times 4, to FDot6, then to Fixed) as Quads/Cubics. // Otherwise the order of the edge might be wrong due to precision limit. const int accuracy = kDefaultAccuracy; +#ifdef SK_RASTERIZE_EVEN_ROUNDING + SkFixed x0 = SkFDot6ToFixed(SkScalarRoundToFDot6(p0.fX, accuracy)) >> accuracy; + SkFixed y0 = SnapY(SkFDot6ToFixed(SkScalarRoundToFDot6(p0.fY, accuracy)) >> accuracy); + SkFixed x1 = SkFDot6ToFixed(SkScalarRoundToFDot6(p1.fX, accuracy)) >> accuracy; + SkFixed y1 = SnapY(SkFDot6ToFixed(SkScalarRoundToFDot6(p1.fY, accuracy)) >> accuracy); +#else const int multiplier = (1 << kDefaultAccuracy); SkFixed x0 = SkFDot6ToFixed(SkScalarToFDot6(p0.fX * multiplier)) >> accuracy; SkFixed y0 = SnapY(SkFDot6ToFixed(SkScalarToFDot6(p0.fY * multiplier)) >> accuracy); SkFixed x1 = SkFDot6ToFixed(SkScalarToFDot6(p1.fX * multiplier)) >> accuracy; SkFixed y1 = SnapY(SkFDot6ToFixed(SkScalarToFDot6(p1.fY * multiplier)) >> accuracy); +#endif int winding = 1; @@ -186,8 +193,12 @@ struct SkBezier { // See if left shift, covert to SkFDot6, and round has the same top and bottom y. // If so, the edge will be empty. static inline bool IsEmpty(SkScalar y0, SkScalar y1, int shift = 2) { +#ifdef SK_RASTERIZE_EVEN_ROUNDING + return SkScalarRoundToFDot6(y0, shift) == SkScalarRoundToFDot6(y1, shift); +#else SkScalar scale = (1 << (shift + 6)); return SkFDot6Round(int(y0 * scale)) == SkFDot6Round(int(y1 * scale)); +#endif } }; |