Reland "Use a table for dither effect rather than math."

This is a reland of 0de475e29ec84f9ec892997565fc4f6348e4610e

Old code restored behind a build flag pending web_test rebaseline.

Original change's description:
> Use a table for dither effect rather than math.
>
> We used to use integer math on sk_FragCoord, when supported, and a
> fallback using floating point (on a 4x4 rather than 8x8 grid). Now we
> precompute a 8x8 table in a texture because it was shown to be
> significantly faster on several devices. Test was done with the following
> running in viewer with the stats layer enabled and looking at total
> frame time:
>  SkRandom r;
>  for (int i = 0; i < N; ++i) {
>      SkColor c[2] = {r.nextU(), c[1] = r.nextU()};
>      SkPoint pts[2] = {{r.nextRangeScalar(0, 500), r.nextRangeScalar(0, 500)},
>                        {r.nextRangeScalar(0, 500), r.nextRangeScalar(0, 500)}};
>      SkPaint p;
>      p.setDither(true);
>      p.setShader(SkGradientShader::MakeLinear(pts, c, nullptr, 2, SkTileMode::kRepeat));
>      canvas->drawPaint(p);
>  }
>
> Device            GPU             N      no dither    int math dither   table dither
> Linux desktop     QuadroP1000     5000   304ms        400ms (1.31x)     383ms (1.26x)
> TecnoSpark3Pro    PowerVRGE8320   200    299ms        820ms (2.74x)     592ms (1.98x)
> Pixel 4           Adreno640       500    110ms        221ms (2.01x)     214ms (1.95x)
> Galaxy S20 FE     Mali-G77 MP11   600    165ms        360ms (2.18x)     260ms (1.58x)
>
>
> Bug: b/195281495
> Change-Id: I200a2be8e450ab66f7c8ae340a5c83ec6780db09
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437239
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>

Bug: b/195281495
Change-Id: Ia52d24aa731281b161865b08954f9eeaca0033eb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437677
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
1 file changed