Harden LinearGradient4fContext

Three distinct issues exposed by Fuzzer:

1) truncating the flags to 8 bits may trip the assert in SkToU8

Since clients can pass in any garbage, we cannot assume it fits in 8
bits.  Just static_cast<> instead.

2) vertical gradients with dx == -0.0 don't trigger interval inversion.

For dx < 0 we want reversed intervals.  But, alas, -0.0 < 0 == false
(thanks, Ob^WIEEE 754!).  Use signbit() instead.

3) half closed range checking needs to be inverted for reversed
intervals.

Normally we check for [p0, p1), but for reversed intervals (p1 < p0) we
want to check for [p1, p0), and not (p1, p0].  Adjust the logic
accordingly.

BUG=skia:5647
R=reed@google.com,kjlubick@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2349153004

Review-Url: https://codereview.chromium.org/2349153004
2 files changed