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>
This commit is contained in:
parent
19c8726a08
commit
07c07e2dc0
@ -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
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user