SkPMColor* dstC, const SkPMColor* cache,
int toggle, int count);
-// lerp is unnecessary if there are no sharp discontinuities in the
-// gradient - which must be true if there are only 2 colors - but for
-// vertical gradients it's so cheap we do it anyway.
+// This function is deprecated, and will be replaced by
+// shadeSpan_linear_vertical_lerp() once Chrome has been weaned off of it.
+void shadeSpan_linear_vertical(TileProc proc, SkFixed dx, SkFixed fx,
+ SkPMColor* SK_RESTRICT dstC,
+ const SkPMColor* SK_RESTRICT cache,
+ int toggle, int count) {
+ // We're a vertical gradient, so no change in a span.
+ // If colors change sharply across the gradient, dithering is
+ // insufficient (it subsamples the color space) and we need to lerp.
+ unsigned fullIndex = proc(fx);
+ unsigned fi = fullIndex >> (16 - Gradient_Shader::kCache32Bits);
+ sk_memset32_dither(dstC,
+ cache[toggle + fi],
+ cache[(toggle ^ Gradient_Shader::kDitherStride32) + fi],
+ count);
+}
+
+// Linear interpolation (lerp) is unnecessary if there are no sharp
+// discontinuities in the gradient - which must be true if there are
+// only 2 colors - but it's cheap.
void shadeSpan_linear_vertical_lerp(TileProc proc, SkFixed dx, SkFixed fx,
SkPMColor* SK_RESTRICT dstC,
const SkPMColor* SK_RESTRICT cache,
LinearShadeProc shadeProc = shadeSpan_linear_repeat;
if (SkFixedNearlyZero(dx)) {
+#ifdef SK_SIMPLE_TWOCOLOR_VERTICAL_GRADIENTS
+ if (fColorCount > 2) {
+ shadeProc = shadeSpan_linear_vertical_lerp;
+ } else {
+ shadeProc = shadeSpan_linear_vertical;
+ }
+#else
shadeProc = shadeSpan_linear_vertical_lerp;
+#endif
} else if (proc == clamp_tileproc) {
shadeProc = shadeSpan_linear_clamp;
} else if (proc == mirror_tileproc) {