Increase precision in barycentric_coord calculations

For quads with very large coordinates, the barycentric coordinate
calculations could be very inaccurate in 32 bit. This lead to
erroneously thinking the render target was contained within the
quad's triangles, instead of just intersecting it.

By scaling the coordinates to a more reasonable magnitude before
multiplying and subtracting the coordinate values, reasonable
accuracy is preserved w/o needing to do everything in 64 bit.

Because it produces coordinates relative to the triangle vertices,
the computed values remain the same as if the unscaled coordinates
were used with higher precision math.

This seems to prevent GM_crbug_10141204 from being misclassified as
a fullscreen clear when its large rect geometry just intersects
the device.

Bug: skia:9779, chromium:10141204
Change-Id: Ia97c2c4e288907ddbb7058d3e7ed97112143b7dc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/265977
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
1 file changed