Go from a 1x2 to a 2x2 dither cell, and change/simplify the logic for how we
compute the "dithered" version of a color to just a graduated fixed-point-round.
Also, add this new dither to conical and sweep, which before had no dithering.
Disabled for now using SK_IGNORE_GRADIENT_DITHER_FIX. Will enable this and
and rebaseline skia.
http://code.google.com/p/skia/issues/detail?id=1098
Review URL: https://codereview.appspot.com/7248046
git-svn-id: http://skia.googlecode.com/svn/trunk@7549 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp
index db18521..458ddbc 100644
--- a/src/effects/gradients/SkSweepGradient.cpp
+++ b/src/effects/gradients/SkSweepGradient.cpp
@@ -298,6 +298,11 @@
SkMatrix::MapXYProc proc = fDstToIndexProc;
const SkMatrix& matrix = fDstToIndex;
const SkPMColor* SK_RESTRICT cache = this->getCache32();
+#ifndef SK_IGNORE_GRADIENT_DITHER_FIX
+ int toggle = init_dither_toggle(x, y);
+#else
+ int toggle = 0;
+#endif
SkPoint srcPt;
if (fDstToIndexClass != kPerspective_MatrixClass) {
@@ -319,15 +324,21 @@
}
for (; count > 0; --count) {
- *dstC++ = cache[SkATan2_255(fy, fx)];
+ *dstC++ = cache[toggle + SkATan2_255(fy, fx)];
fx += dx;
fy += dy;
+#ifndef SK_IGNORE_GRADIENT_DITHER_FIX
+ toggle = next_dither_toggle(toggle);
+#endif
}
} else { // perspective case
for (int stop = x + count; x < stop; x++) {
proc(matrix, SkIntToScalar(x) + SK_ScalarHalf,
SkIntToScalar(y) + SK_ScalarHalf, &srcPt);
- *dstC++ = cache[SkATan2_255(srcPt.fY, srcPt.fX)];
+ *dstC++ = cache[toggle + SkATan2_255(srcPt.fY, srcPt.fX)];
+#ifndef SK_IGNORE_GRADIENT_DITHER_FIX
+ toggle = next_dither_toggle(toggle);
+#endif
}
}
}