skia /
skia /
8fdbbca7d35db149148019993fe12df850b9970c 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
GrFragmentProcessors.cpp.
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 https://crrev.com/c/4591270) 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
SK_DISABLE_LEGACY_SHADERCONTEXT
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
removed.
Suggested Review Order:
- SkShaderBase.h/.cpp, noting that much of the .cpp came from
SkShader.cpp
- 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
src/shaders/gradients
- All other files in any order.
Change-Id: Icf3db955d0653f97d7c793b167463162fb70d9f2
Bug: skia:14317
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/706216
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
113 files changed