Decouple SkShaders from Ganesh backend

This moves all asFragmentProcessor methods from the src/shaders
and src/shaders/gradients into GrFragmentProcessors. As a requirement
to do so, all shaders have had a public header made with the class
declaration. Many classes required new getters to expose some
fields for the construction of the GrFragmentProcessor. I briefly
toyed with the idea of using friend functions, but decided against
it for 2 reasons: 1) the syntax was verbose and gnarly; 2) the
syntax would make the functions of GrFragmentProcessors callable
from other places and not be static / contained to just

Other notable changes:
 - SkShaderBase::GradientType::kColor removed, as it has been
   superseded by SkShaderBase::ShaderType::kColor for detecting
   "is this a color shader?" Callsites that needed the color
   now cast it to SkColorShader
 - SkPerlinNoiseShader class removed from public API
   (Chromium migrated in and
   used internally instead of SkPerlinNoiseShaderImpl for closer
   alignment with the ShaderType enum.
 - SkPerlinNoiseShader::PaintingData no longer uses #ifdefs
   to make the bitmaps for the GPU backends, but this is now
   explicitly done in a function generateBitmaps().
 - SkShaderBase::MatrixRec has been moved to the SkShaders
   namespace and had the Ganesh-specific apply() changed to
   applyForFragmentProcessor(). The Ganesh-parts (e.g. the creation
   of the GrMatrixEffect) were made the responsibility of
   the caller (e.g. in GrFragmentProcessors.cpp).
 - I thought it was strange that SkBitmapProcShader.h (but not
   the .cpp) was in public.bzl. I made that not necessary by
   #ifdef'ing the one include that was necessary removing
   other unnecessary ones. This is because G3 sets

The following shader subclasses did not appear to have Ganesh
implementations and that is still the case:
 - SkEmptyShader
 - SpriteShader (appears SkVM only)
 - DitherShader (appears SkVM only)
 - SkTransformShader
 - SkTriColorShader
 - SkUpdatableColorShader

I enforced IWYU on src/shaders and all other new files I created
in this CL. This had some impact in wider files, but I do not
expect it to impact clients as no public #includes had #includes

Suggested Review Order:
 - SkShaderBase.h/.cpp, noting that much of the .cpp came from
 - GrFragmentProcessors.cpp, glancing at the relevant subclass
   .h and .cpp changes as necessary
 - SkPerlinNoise* and GrPerlinNoise* to make sure I didn't overlook
   something in the refactor/extraction
 - Another pass through other changes in src/shaders and
 - All other files in any order.

Change-Id: Icf3db955d0653f97d7c793b167463162fb70d9f2
Bug: skia:14317
Reviewed-by: Brian Osman <>
Commit-Queue: Kevin Lubick <>
113 files changed