Reuse gfx::ColorTransform filters

This CL modifies gfx::ColorTransform to generate SkSL shaders (

The main differences between GLSL and SkSL that manifest in this CL are:

+ SkSL has no precision modifiers: There is no low precision floating
  point. half is medium precision floating point.

+ You cannot define functions in an SkSL fragment processor. I have
  manually inlined repeated code. I use temporary variable "half v" as
  input and output and trust that the compiler will eliminate it.

+ SkSL vector types are named <base type><columns>. SkSL matrix types
  are named <base type><columns>x<rows>

+ GLSL uses 3 component color. SkSL uses "inout half4 color", which
  includes alpha. I have modified the code to preserve the alpha

I have added a simple SimpleColorSpace.CanParseSkShaderSource that
checks that the autogenerated SkSL fragment processor compiles.

This CL makes many media/ webkit layout tests pass with SkiaRenderer due
to more accurate YUVA->RGBA color conversion
(e.g. media/controls/paint-controls-webkit-appearance-none-custom-bg.html)

Bug: 908957
Change-Id: I711ff18c441291d150e01604d1fdb2ee4ebee10b
Commit-Queue: Jonathan Backer <>
Reviewed-by: ccameron <>
Reviewed-by: Peng Huang <>
Cr-Commit-Position: refs/heads/master@{#642725}
13 files changed