Implement gradient fixup for powerless hue

When an achromatic color is converted to a polar color space, the hue is
meaningless (called "powerless" in the CSS spec). Setting it to the
(arbitrary) zero introduces undesirable hue interpolation. Instead, we
copy the hue of the adjacent color to minimize that artifact.

For powerless hues in the middle of a multi-stop gradient, we actually
need to inject new hard-stops, because the hue on either side might be
different.

The logic here is based on:
    https://drafts.csswg.org/css-color-4/#interpolation-missing

Bug: chromium:1462612
Change-Id: I6c88b7f679a0005651455ae6ef5abd85bf96c71a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/771698
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2 files changed