Flutter Engine
The Flutter Engine
|
#include <GrFragmentProcessor.h>
Classes | |
class | ProgramImpl |
Public Member Functions | |
virtual std::unique_ptr< GrFragmentProcessor > | clone () const =0 |
const GrFragmentProcessor * | parent () const |
std::unique_ptr< ProgramImpl > | makeProgramImpl () const |
void | addToKey (const GrShaderCaps &caps, skgpu::KeyBuilder *b) const |
int | numChildProcessors () const |
int | numNonNullChildProcessors () const |
GrFragmentProcessor * | childProcessor (int index) |
const GrFragmentProcessor * | childProcessor (int index) const |
SkDEBUGCODE (bool isInstantiated() const ;) bool willReadDstColor() const | |
bool | isBlendFunction () const |
bool | usesSampleCoordsDirectly () const |
bool | usesSampleCoords () const |
const SkSL::SampleUsage & | sampleUsage () const |
bool | compatibleWithCoverageAsAlpha () const |
bool | preservesOpaqueInput () const |
bool | hasConstantOutputForConstantInput (SkPMColor4f inputColor, SkPMColor4f *outputColor) const |
bool | hasConstantOutputForConstantInput () const |
void | clearConstantOutputForConstantInputFlag () |
bool | isEqual (const GrFragmentProcessor &that) const |
void | visitProxies (const GrVisitProxyFunc &) const |
void | visitTextureEffects (const std::function< void(const GrTextureEffect &)> &) const |
void | visitWithImpls (const std::function< void(const GrFragmentProcessor &, ProgramImpl &)> &, ProgramImpl &) const |
GrTextureEffect * | asTextureEffect () |
const GrTextureEffect * | asTextureEffect () const |
Public Member Functions inherited from GrProcessor | |
virtual | ~GrProcessor ()=default |
virtual const char * | name () const =0 |
void * | operator new (size_t size) |
void * | operator new (size_t object_size, size_t footer_size) |
void | operator delete (void *target) |
void * | operator new (size_t size, void *placement) |
void | operator delete (void *target, void *placement) |
template<typename T > | |
const T & | cast () const |
ClassID | classID () const |
Static Public Member Functions | |
static std::unique_ptr< GrFragmentProcessor > | MakeColor (SkPMColor4f color) |
static std::unique_ptr< GrFragmentProcessor > | MulInputByChildAlpha (std::unique_ptr< GrFragmentProcessor > child) |
static std::unique_ptr< GrFragmentProcessor > | ApplyPaintAlpha (std::unique_ptr< GrFragmentProcessor > child) |
static std::unique_ptr< GrFragmentProcessor > | ModulateRGBA (std::unique_ptr< GrFragmentProcessor > child, const SkPMColor4f &color) |
static std::unique_ptr< GrFragmentProcessor > | OverrideInput (std::unique_ptr< GrFragmentProcessor >, const SkPMColor4f &) |
static std::unique_ptr< GrFragmentProcessor > | DisableCoverageAsAlpha (std::unique_ptr< GrFragmentProcessor >) |
static std::unique_ptr< GrFragmentProcessor > | DestColor () |
static std::unique_ptr< GrFragmentProcessor > | SwizzleOutput (std::unique_ptr< GrFragmentProcessor >, const skgpu::Swizzle &) |
static std::unique_ptr< GrFragmentProcessor > | ClampOutput (std::unique_ptr< GrFragmentProcessor >) |
static std::unique_ptr< GrFragmentProcessor > | Compose (std::unique_ptr< GrFragmentProcessor > f, std::unique_ptr< GrFragmentProcessor > g) |
static std::unique_ptr< GrFragmentProcessor > | ColorMatrix (std::unique_ptr< GrFragmentProcessor > child, const float matrix[20], bool unpremulInput, bool clampRGBOutput, bool premulOutput) |
static std::unique_ptr< GrFragmentProcessor > | SurfaceColor () |
static std::unique_ptr< GrFragmentProcessor > | DeviceSpace (std::unique_ptr< GrFragmentProcessor >) |
static std::unique_ptr< GrFragmentProcessor > | Rect (std::unique_ptr< GrFragmentProcessor >, GrClipEdgeType, SkRect) |
static GrFPResult | Circle (std::unique_ptr< GrFragmentProcessor >, GrClipEdgeType, SkPoint center, float radius) |
static GrFPResult | Ellipse (std::unique_ptr< GrFragmentProcessor >, GrClipEdgeType, SkPoint center, SkPoint radii, const GrShaderCaps &) |
static std::unique_ptr< GrFragmentProcessor > | HighPrecision (std::unique_ptr< GrFragmentProcessor >) |
Protected Types | |
enum | OptimizationFlags : uint32_t { kNone_OptimizationFlags , kCompatibleWithCoverageAsAlpha_OptimizationFlag = 0x1 , kPreservesOpaqueInput_OptimizationFlag = 0x2 , kConstantOutputForConstantInput_OptimizationFlag = 0x4 , kAll_OptimizationFlags } |
Protected Member Functions | |
GrFragmentProcessor (ClassID classID, OptimizationFlags optimizationFlags) | |
GrFragmentProcessor (const GrFragmentProcessor &src) | |
OptimizationFlags | optimizationFlags () const |
void | registerChild (std::unique_ptr< GrFragmentProcessor > child, SkSL::SampleUsage sampleUsage=SkSL::SampleUsage::PassThrough()) |
void | cloneAndRegisterAllChildProcessors (const GrFragmentProcessor &src) |
void | setUsesSampleCoordsDirectly () |
void | setWillReadDstColor () |
void | setIsBlendFunction () |
void | mergeOptimizationFlags (OptimizationFlags flags) |
Protected Member Functions inherited from GrProcessor | |
GrProcessor (ClassID classID) | |
GrProcessor (const GrProcessor &)=delete | |
GrProcessor & | operator= (const GrProcessor &)=delete |
Static Protected Member Functions | |
static OptimizationFlags | ModulateForSamplerOptFlags (SkAlphaType alphaType, bool samplingDecal) |
static OptimizationFlags | ModulateForClampedSamplerOptFlags (SkAlphaType alphaType) |
static OptimizationFlags | ProcessorOptimizationFlags (const GrFragmentProcessor *fp) |
static SkPMColor4f | ConstantOutputForConstantInput (const GrFragmentProcessor *fp, const SkPMColor4f &input) |
Private Member Functions | |
virtual SkPMColor4f | constantOutputForConstantInput (const SkPMColor4f &) const |
virtual std::unique_ptr< ProgramImpl > | onMakeProgramImpl () const =0 |
virtual void | onAddToKey (const GrShaderCaps &, skgpu::KeyBuilder *) const =0 |
virtual bool | onIsEqual (const GrFragmentProcessor &) const =0 |
Provides custom fragment shader code. Fragment processors receive an input position and produce an output color. They may contain uniforms and may have children fragment processors that are sampled.
Definition at line 45 of file GrFragmentProcessor.h.
|
protected |
Enumerator | |
---|---|
kNone_OptimizationFlags | |
kCompatibleWithCoverageAsAlpha_OptimizationFlag | |
kPreservesOpaqueInput_OptimizationFlag | |
kConstantOutputForConstantInput_OptimizationFlag | |
kAll_OptimizationFlags |
Definition at line 307 of file GrFragmentProcessor.h.
|
inlineprotected |
Definition at line 346 of file GrFragmentProcessor.h.
|
inlineexplicitprotected |
Definition at line 351 of file GrFragmentProcessor.h.
|
inline |
Definition at line 184 of file GrFragmentProcessor.h.
|
static |
Invokes child with an opaque version of the input color, then applies the input alpha to the result. Used to incorporate paint alpha to the evaluation of an SkShader tree FP.
Definition at line 214 of file GrFragmentProcessor.cpp.
GrTextureEffect * GrFragmentProcessor::asTextureEffect | ( | ) |
Definition at line 81 of file GrFragmentProcessor.cpp.
const GrTextureEffect * GrFragmentProcessor::asTextureEffect | ( | ) | const |
Definition at line 88 of file GrFragmentProcessor.cpp.
|
inline |
Definition at line 196 of file GrFragmentProcessor.h.
|
inline |
Definition at line 197 of file GrFragmentProcessor.h.
|
static |
Definition at line 647 of file GrFragmentProcessor.cpp.
|
static |
Returns a fragment processor that calls the passed in fragment processor, and then clamps the output to [0, 1].
Definition at line 236 of file GrFragmentProcessor.cpp.
|
inline |
Definition at line 277 of file GrFragmentProcessor.h.
|
pure virtual |
Makes a copy of this fragment processor that draws equivalently to the original. If the processor has child processors they are cloned as well.
Implemented in SampleCoordEffect, GrBicubicEffect, BlendFragmentProcessor, ColorTableEffect, GrConvexPolyEffect, GrMatrixEffect, GrModulateAtlasCoverageEffect, GrPerlinNoise2Effect, GrSkSLFP, GrTextureEffect, GrYUVtoRGBEffect, GrColorSpaceXformEffect, and BlockInputFragmentProcessor.
|
protected |
This method takes an existing fragment processor, clones all of its children, and registers the clones as children of this fragment processor.
Definition at line 183 of file GrFragmentProcessor.cpp.
|
static |
Definition at line 456 of file GrFragmentProcessor.cpp.
|
inline |
A GrDrawOp may premultiply its antialiasing coverage into its GrGeometryProcessor's color output under the following scenario:
Definition at line 250 of file GrFragmentProcessor.h.
|
static |
Returns a fragment processor that composes two fragment processors f
and g
into f(g(x)). This is equivalent to running them in series (g
, then f
). This is not the same as transfer-mode composition; there is no blending step.
Definition at line 366 of file GrFragmentProcessor.cpp.
|
inlinestaticprotected |
This allows one subclass to access another subclass's implementation of constantOutputForConstantInput. It must only be called when hasConstantOutputForConstantInput() is known to be true.
Definition at line 370 of file GrFragmentProcessor.h.
|
inlineprivatevirtual |
Definition at line 424 of file GrFragmentProcessor.h.
|
static |
Returns a fragment processor which returns args.fDestColor
. This is only meaningful in contexts like blenders, which use a source and dest color.)
Definition at line 355 of file GrFragmentProcessor.cpp.
|
static |
Returns a fragment processor that calls the passed in fragment processor, but evaluates it in device-space (rather than local space).
Definition at line 541 of file GrFragmentProcessor.cpp.
|
static |
Returns a parent fragment processor that adopts the passed fragment processor as a child. The parent will simply return the child's color, but disable the coverage-as-alpha optimization.
Definition at line 340 of file GrFragmentProcessor.cpp.
|
static |
Definition at line 698 of file GrFragmentProcessor.cpp.
|
inline |
Definition at line 273 of file GrFragmentProcessor.h.
|
inline |
Tests whether given a constant input color the processor produces a constant output color (for all fragments). If true outputColor will contain the constant color produces for inputColor.
Definition at line 266 of file GrFragmentProcessor.h.
|
static |
Returns a fragment processor that calls the passed in fragment processor, but ensures the entire program is compiled with high-precision types.
Definition at line 799 of file GrFragmentProcessor.cpp.
|
inline |
Does the SkSL for this FP take two colors as its input arguments?
Definition at line 209 of file GrFragmentProcessor.h.
bool GrFragmentProcessor::isEqual | ( | const GrFragmentProcessor & | that | ) | const |
Returns true if this and other processor conservatively draw identically. It can only return true when the two processor are of the same subclass (i.e. they return the same object from from getFactory()).
A return value of true from isEqual() should not be used to test whether the processor would generate the same shader code. To test for identical code generation use addToKey.
Definition at line 25 of file GrFragmentProcessor.cpp.
|
static |
Always returns 'color'.
Definition at line 193 of file GrFragmentProcessor.cpp.
std::unique_ptr< GrFragmentProcessor::ProgramImpl > GrFragmentProcessor::makeProgramImpl | ( | ) | const |
Definition at line 119 of file GrFragmentProcessor.cpp.
|
inlineprotected |
Definition at line 418 of file GrFragmentProcessor.h.
|
inlinestaticprotected |
Definition at line 337 of file GrFragmentProcessor.h.
|
inlinestaticprotected |
Can be used as a helper to decide which fragment processor OptimizationFlags should be set. This assumes that the subclass output color will be a modulation of the input color with a value read from a texture of the passed color type and that the texture contains premultiplied color or alpha values that are in range.
Since there are multiple ways in which a sampler may have its coordinates clamped or wrapped, callers must determine on their own if the sampling uses a decal strategy in any way, in which case the texture may become transparent regardless of the color type.
Definition at line 328 of file GrFragmentProcessor.h.
|
static |
Returns a fragment processor that generates the passed-in color, modulated by the child's RGBA color. The child's input color will be the parent's fInputColor. (Pass a null FP to use the color from fInputColor instead of a child FP.)
Definition at line 229 of file GrFragmentProcessor.cpp.
|
static |
Returns the input color, modulated by the child's alpha.
output = input * child.a
Definition at line 206 of file GrFragmentProcessor.cpp.
|
inline |
Definition at line 193 of file GrFragmentProcessor.h.
int GrFragmentProcessor::numNonNullChildProcessors | ( | ) | const |
Definition at line 129 of file GrFragmentProcessor.cpp.
|
privatepure virtual |
Implemented in SampleCoordEffect.
|
privatepure virtual |
Subclass implements this to support isEqual(). It will only be called if it is known that the two processors are of the same subclass (i.e. have the same ClassID).
Implemented in SampleCoordEffect.
|
privatepure virtual |
Returns a new instance of the appropriate ProgramImpl subclass for the given GrFragmentProcessor. It will emit the appropriate code and live with the cached program to setup uniform data for each draw that uses the program.
Implemented in BlockInputFragmentProcessor.
|
inlineprotected |
Definition at line 356 of file GrFragmentProcessor.h.
|
static |
Returns a parent fragment processor that adopts the passed fragment processor as a child. The parent will ignore its input color and instead feed the passed in color as input to the child.
Definition at line 319 of file GrFragmentProcessor.cpp.
|
inline |
Definition at line 180 of file GrFragmentProcessor.h.
|
inline |
If this is true then all opaque input colors to the processor produce opaque output colors.
Definition at line 257 of file GrFragmentProcessor.h.
|
inlinestaticprotected |
Useful when you can't call fp->optimizationFlags() on a base class object from a subclass.
Definition at line 361 of file GrFragmentProcessor.h.
|
static |
"Shape" FPs, often used for clipping. Each one evaluates a particular kind of shape (rect, circle, ellipse), and modulates the coverage of that shape against the results of the input FP. GrClipEdgeType is used to select inverse/normal fill, and AA or non-AA edges.
Definition at line 604 of file GrFragmentProcessor.cpp.
|
protected |
FragmentProcessor subclasses call this from their constructor to register any child FragmentProcessors they have. This must be called AFTER all texture accesses and coord transforms have been added. This is for processors whose shader code will be composed of nested processors whose output colors will be combined somehow to produce its output color. Registering these child processors will allow the ProgramBuilder to automatically handle their transformed coords and texture accesses and mangle their uniform and output color names.
The SampleUsage parameter describes all of the ways that the child is sampled by the parent.
Definition at line 146 of file GrFragmentProcessor.cpp.
|
inline |
Definition at line 234 of file GrFragmentProcessor.h.
|
inlineprotected |
Definition at line 414 of file GrFragmentProcessor.h.
|
inlineprotected |
Definition at line 402 of file GrFragmentProcessor.h.
|
inlineprotected |
Definition at line 408 of file GrFragmentProcessor.h.
|
inline |
Do any of the FPs in this tree read back the color from the destination surface?
Definition at line 201 of file GrFragmentProcessor.h.
|
static |
Returns a fragment processor that reads back the color on the surface being painted; that is, sampling this will return the color of the pixel that is currently being painted over.
Definition at line 501 of file GrFragmentProcessor.cpp.
|
static |
Returns a fragment processor that calls the passed in fragment processor, and then swizzles the output.
Definition at line 249 of file GrFragmentProcessor.cpp.
|
inline |
True if this FP uses its input coordinates or if any descendant FP uses them through a chain of non-explicit sample usages. (e.g. uses EmitArgs::fSampleCoord in emitCode()). This is decided at FP-tree construction time and is not affected by lifting coords to varyings.
Definition at line 227 of file GrFragmentProcessor.h.
|
inline |
True if this FP refers directly to the sample coordinate parameter of its function (e.g. uses EmitArgs::fSampleCoord in emitCode()). This is decided at FP-tree construction time and is not affected by lifting coords to varyings.
Definition at line 218 of file GrFragmentProcessor.h.
void GrFragmentProcessor::visitProxies | ( | const GrVisitProxyFunc & | func | ) | const |
Definition at line 51 of file GrFragmentProcessor.cpp.
void GrFragmentProcessor::visitTextureEffects | ( | const std::function< void(const GrTextureEffect &)> & | func | ) | const |
Definition at line 57 of file GrFragmentProcessor.cpp.
void GrFragmentProcessor::visitWithImpls | ( | const std::function< void(const GrFragmentProcessor &, ProgramImpl &)> & | f, |
ProgramImpl & | impl | ||
) | const |
Definition at line 69 of file GrFragmentProcessor.cpp.