Improve subpixel coverage calculation for thin quads

In the linked bug, the 1px stroked rectangles would either be treated as
a regular AA rectangle with full coverage interior, or as a subpixel
rectangle that would have to calculate reduced coverage for the interior.
The translations of the coordinates meant that floating point precision
caused the <1px test to go one way or the other since these rectangles
were exactly on the boundary.

However, the subpixel coverage calculator, as-originally-implemented,
suffered from being discontinuous right at 1px if the rectangle was
rotated, so there'd be a noticeable pop in intensity of the shape when
animating across the 1px boundary.

This CL changes the subpixel coverage calculation to no longer be
dependent on the orientation of the quadrilateral w/ respect to the pixel
grid, and still be accurate when the shape is a rectangle. When it is
an arbitrary quad, the approximation isn't geometrically correct but
exhibits qualitatively good behavior. It also has the benefit of being
much simpler code.

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