Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
GrSkSLFP Class Reference

#include <GrSkSLFP.h>

Inheritance diagram for GrSkSLFP:
GrFragmentProcessor GrProcessor

Classes

struct  GrIgnoreOptFlags
 
struct  GrOptionalUniform
 
struct  GrSpecializedUniform
 
class  Impl
 

Public Types

enum class  OptFlags : uint32_t { kNone = kNone_OptimizationFlags , kCompatibleWithCoverageAsAlpha = kCompatibleWithCoverageAsAlpha_OptimizationFlag , kPreservesOpaqueInput = kPreservesOpaqueInput_OptimizationFlag , kAll = kCompatibleWithCoverageAsAlpha | kPreservesOpaqueInput }
 
- Public Types inherited from GrProcessor
enum  ClassID {
  kNull_ClassID , kAttributeTestProcessor_ClassID , kBigKeyProcessor_ClassID , kBlendFragmentProcessor_ClassID ,
  kBlockInputFragmentProcessor_ClassID , kButtCapStrokedCircleGeometryProcessor_ClassID , kCircleGeometryProcessor_ClassID , kCircularRRectEffect_ClassID ,
  kClockwiseTestProcessor_ClassID , kColorTableEffect_ClassID , kCoverageSetOpXP_ClassID , kCustomXP_ClassID ,
  kDashingCircleEffect_ClassID , kDashingLineEffect_ClassID , kDefaultGeoProc_ClassID , kDeviceSpace_ClassID ,
  kDIEllipseGeometryProcessor_ClassID , kDisableColorXP_ClassID , kDrawAtlasPathShader_ClassID , kEllipseGeometryProcessor_ClassID ,
  kEllipticalRRectEffect_ClassID , kFwidthSquircleTestProcessor_ClassID , kGP_ClassID , kGrBicubicEffect_ClassID ,
  kGrBitmapTextGeoProc_ClassID , kGrColorSpaceXformEffect_ClassID , kGrConicEffect_ClassID , kGrConvexPolyEffect_ClassID ,
  kGrDiffuseLightingEffect_ClassID , kGrDisplacementMapEffect_ClassID , kGrDistanceFieldA8TextGeoProc_ClassID , kGrDistanceFieldLCDTextGeoProc_ClassID ,
  kGrDistanceFieldPathGeoProc_ClassID , kGrFillRRectOp_Processor_ClassID , kGrGaussianConvolutionFragmentProcessor_ClassID , kGrMatrixConvolutionEffect_ClassID ,
  kGrMatrixEffect_ClassID , kGrMeshTestProcessor_ClassID , kGrMorphologyEffect_ClassID , kGrPerlinNoise2Effect_ClassID ,
  kGrPipelineDynamicStateTestProcessor_ClassID , kGrQuadEffect_ClassID , kGrRRectShadowGeoProc_ClassID , kGrSkSLFP_ClassID ,
  kGrSpecularLightingEffect_ClassID , kGrTextureEffect_ClassID , kGrUnrolledBinaryGradientColorizer_ClassID , kGrYUVtoRGBEffect_ClassID ,
  kHighPrecisionFragmentProcessor_ClassID , kLatticeGP_ClassID , kPDLCDXferProcessor_ClassID , kPorterDuffXferProcessor_ClassID ,
  kPremulFragmentProcessor_ClassID , kQuadEdgeEffect_ClassID , kQuadPerEdgeAAGeometryProcessor_ClassID , kSeriesFragmentProcessor_ClassID ,
  kShaderPDXferProcessor_ClassID , kSurfaceColorProcessor_ClassID , kSwizzleFragmentProcessor_ClassID , kTessellate_BoundingBoxShader_ClassID ,
  kTessellate_GrModulateAtlasCoverageEffect_ClassID , kTessellate_GrStrokeTessellationShader_ClassID , kTessellate_HullShader_ClassID , kTessellate_MiddleOutShader_ClassID ,
  kTessellate_SimpleTriangleShader_ClassID , kTessellationTestTriShader_ClassID , kTestFP_ClassID , kTestRectOp_ClassID ,
  kVertexColorSpaceBenchGP_ClassID , kVerticesGP_ClassID
}
 

Public Member Functions

const char * name () const override
 
std::unique_ptr< GrFragmentProcessorclone () const override
 
- Public Member Functions inherited from GrFragmentProcessor
virtual std::unique_ptr< GrFragmentProcessorclone () const =0
 
const GrFragmentProcessorparent () const
 
std::unique_ptr< ProgramImplmakeProgramImpl () const
 
void addToKey (const GrShaderCaps &caps, skgpu::KeyBuilder *b) const
 
int numChildProcessors () const
 
int numNonNullChildProcessors () const
 
GrFragmentProcessorchildProcessor (int index)
 
const GrFragmentProcessorchildProcessor (int index) const
 
 SkDEBUGCODE (bool isInstantiated() const ;) bool willReadDstColor() const
 
bool isBlendFunction () const
 
bool usesSampleCoordsDirectly () const
 
bool usesSampleCoords () const
 
const SkSL::SampleUsagesampleUsage () 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
 
GrTextureEffectasTextureEffect ()
 
const GrTextureEffectasTextureEffect () 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 Tcast () const
 
ClassID classID () const
 

Static Public Member Functions

template<typename T >
static GrSpecializedUniform< TSpecialize (const T &value)
 
template<typename T >
static GrSpecializedUniform< TSpecializeIf (bool condition, const T &value)
 
template<typename T >
static GrOptionalUniform< TWhen (bool condition, const T &value)
 
static GrIgnoreOptFlags IgnoreOptFlags (std::unique_ptr< GrFragmentProcessor > child)
 
static std::unique_ptr< GrSkSLFPMakeWithData (sk_sp< SkRuntimeEffect > effect, const char *name, sk_sp< SkColorSpace > dstColorSpace, std::unique_ptr< GrFragmentProcessor > inputFP, std::unique_ptr< GrFragmentProcessor > destColorFP, const sk_sp< const SkData > &uniforms, SkSpan< std::unique_ptr< GrFragmentProcessor > > childFPs)
 
template<typename... Args>
static std::unique_ptr< GrSkSLFPMake (const SkRuntimeEffect *effect, const char *name, std::unique_ptr< GrFragmentProcessor > inputFP, OptFlags optFlags, Args &&... args)
 
- Static Public Member Functions inherited from GrFragmentProcessor
static std::unique_ptr< GrFragmentProcessorMakeColor (SkPMColor4f color)
 
static std::unique_ptr< GrFragmentProcessorMulInputByChildAlpha (std::unique_ptr< GrFragmentProcessor > child)
 
static std::unique_ptr< GrFragmentProcessorApplyPaintAlpha (std::unique_ptr< GrFragmentProcessor > child)
 
static std::unique_ptr< GrFragmentProcessorModulateRGBA (std::unique_ptr< GrFragmentProcessor > child, const SkPMColor4f &color)
 
static std::unique_ptr< GrFragmentProcessorOverrideInput (std::unique_ptr< GrFragmentProcessor >, const SkPMColor4f &)
 
static std::unique_ptr< GrFragmentProcessorDisableCoverageAsAlpha (std::unique_ptr< GrFragmentProcessor >)
 
static std::unique_ptr< GrFragmentProcessorDestColor ()
 
static std::unique_ptr< GrFragmentProcessorSwizzleOutput (std::unique_ptr< GrFragmentProcessor >, const skgpu::Swizzle &)
 
static std::unique_ptr< GrFragmentProcessorClampOutput (std::unique_ptr< GrFragmentProcessor >)
 
static std::unique_ptr< GrFragmentProcessorCompose (std::unique_ptr< GrFragmentProcessor > f, std::unique_ptr< GrFragmentProcessor > g)
 
static std::unique_ptr< GrFragmentProcessorColorMatrix (std::unique_ptr< GrFragmentProcessor > child, const float matrix[20], bool unpremulInput, bool clampRGBOutput, bool premulOutput)
 
static std::unique_ptr< GrFragmentProcessorSurfaceColor ()
 
static std::unique_ptr< GrFragmentProcessorDeviceSpace (std::unique_ptr< GrFragmentProcessor >)
 
static std::unique_ptr< GrFragmentProcessorRect (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< GrFragmentProcessorHighPrecision (std::unique_ptr< GrFragmentProcessor >)
 

Friends

class GrSkSLFPFactory
 

Additional Inherited Members

- Protected Types inherited from GrFragmentProcessor
enum  OptimizationFlags : uint32_t {
  kNone_OptimizationFlags , kCompatibleWithCoverageAsAlpha_OptimizationFlag = 0x1 , kPreservesOpaqueInput_OptimizationFlag = 0x2 , kConstantOutputForConstantInput_OptimizationFlag = 0x4 ,
  kAll_OptimizationFlags
}
 
- Protected Member Functions inherited from GrFragmentProcessor
 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
 
GrProcessoroperator= (const GrProcessor &)=delete
 
- Static Protected Member Functions inherited from GrFragmentProcessor
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)
 
- Protected Attributes inherited from GrProcessor
const ClassID fClassID
 

Detailed Description

Definition at line 70 of file GrSkSLFP.h.

Member Enumeration Documentation

◆ OptFlags

enum class GrSkSLFP::OptFlags : uint32_t
strong
Enumerator
kNone 
kCompatibleWithCoverageAsAlpha 
kPreservesOpaqueInput 
kAll 

Definition at line 101 of file GrSkSLFP.h.

101 : uint32_t {
103 kCompatibleWithCoverageAsAlpha = kCompatibleWithCoverageAsAlpha_OptimizationFlag,
104 kPreservesOpaqueInput = kPreservesOpaqueInput_OptimizationFlag,
105 kAll = kCompatibleWithCoverageAsAlpha | kPreservesOpaqueInput,
106 };
@ kNone
Definition: layer.h:53

Member Function Documentation

◆ clone()

std::unique_ptr< GrFragmentProcessor > GrSkSLFP::clone ( ) const
overridevirtual

Makes a copy of this fragment processor that draws equivalently to the original. If the processor has child processors they are cloned as well.

Implements GrFragmentProcessor.

Definition at line 448 of file GrSkSLFP.cpp.

448 {
449 return std::unique_ptr<GrFragmentProcessor>(new (UniformPayloadSize(fEffect.get()))
450 GrSkSLFP(*this));
451}
T * get() const
Definition: SkRefCnt.h:303

◆ IgnoreOptFlags()

static GrIgnoreOptFlags GrSkSLFP::IgnoreOptFlags ( std::unique_ptr< GrFragmentProcessor child)
inlinestatic

Definition at line 97 of file GrSkSLFP.h.

97 {
98 return {std::move(child)};
99 }

◆ Make()

template<typename... Args>
static std::unique_ptr< GrSkSLFP > GrSkSLFP::Make ( const SkRuntimeEffect effect,
const char *  name,
std::unique_ptr< GrFragmentProcessor inputFP,
OptFlags  optFlags,
Args &&...  args 
)
inlinestatic

Definition at line 159 of file GrSkSLFP.h.

163 {
164#ifdef SK_DEBUG
165 checkArgs(effect->fUniforms.begin(),
166 effect->fUniforms.end(),
167 effect->fChildren.begin(),
168 effect->fChildren.end(),
169 std::forward<Args>(args)...);
170#endif
171 // This factory is used internally (for "runtime FPs"). We don't pass/know the destination
172 // color space, so these effects can't use the color transform intrinsics. Callers of this
173 // factory should instead construct an GrColorSpaceXformEffect as part of the FP tree.
174 SkASSERT(!effect->usesColorTransform());
175
176 size_t uniformPayloadSize = UniformPayloadSize(effect);
177 std::unique_ptr<GrSkSLFP> fp(new (uniformPayloadSize) GrSkSLFP(sk_ref_sp(effect),
178 name, optFlags));
179 fp->appendArgs(fp->uniformData(), fp->specialized(), std::forward<Args>(args)...);
180 if (inputFP) {
181 fp->setInput(std::move(inputFP));
182 }
183 return fp;
184 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
sk_sp< T > sk_ref_sp(T *obj)
Definition: SkRefCnt.h:381
const char * name() const override
Definition: GrSkSLFP.h:186
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
const uint32_t fp

◆ MakeWithData()

std::unique_ptr< GrSkSLFP > GrSkSLFP::MakeWithData ( sk_sp< SkRuntimeEffect effect,
const char *  name,
sk_sp< SkColorSpace dstColorSpace,
std::unique_ptr< GrFragmentProcessor inputFP,
std::unique_ptr< GrFragmentProcessor destColorFP,
const sk_sp< const SkData > &  uniforms,
SkSpan< std::unique_ptr< GrFragmentProcessor > >  childFPs 
)
static

Both factories support a single 'input' FP, as well as a collection of other 'child' FPs. The 'child' FPs correspond to the children declared in the effect's SkSL. The inputFP is optional, and intended for instances that have color filter semantics. This is an implicit child - if present, it's evaluated to produce the input color fed to the SkSL. Otherwise, the SkSL receives this FP's input color directly. Creates a new fragment processor from an SkRuntimeEffect and a data blob containing values for all of the 'uniform' variables in the SkSL source. The layout of the uniforms blob is dictated by the SkRuntimeEffect.

Definition at line 289 of file GrSkSLFP.cpp.

296 {
297 if (uniforms->size() != effect->uniformSize()) {
298 return nullptr;
299 }
300 size_t uniformSize = uniforms->size();
301 size_t specializedSize = effect->uniforms().size() * sizeof(Specialized);
302 std::unique_ptr<GrSkSLFP> fp(new (uniformSize + specializedSize)
303 GrSkSLFP(std::move(effect), name, OptFlags::kNone));
304 sk_careful_memcpy(fp->uniformData(), uniforms->data(), uniformSize);
305 for (auto& childFP : childFPs) {
306 fp->addChild(std::move(childFP), /*mergeOptFlags=*/true);
307 }
308 if (inputFP) {
309 fp->setInput(std::move(inputFP));
310 }
311 if (destColorFP) {
312 fp->setDestColorFP(std::move(destColorFP));
313 }
314 if (fp->fEffect->usesColorTransform() && dstColorSpace) {
315 fp->addColorTransformChildren(dstColorSpace.get());
316 }
317 return fp;
318}
static void * sk_careful_memcpy(void *dst, const void *src, size_t len)
Definition: SkMalloc.h:125
const void * data() const
Definition: SkData.h:37
size_t size() const
Definition: SkData.h:30
size_t uniformSize() const
SkSpan< const Uniform > uniforms() const

◆ name()

const char * GrSkSLFP::name ( ) const
inlineoverridevirtual

Human-meaningful string to identify this processor; may be embedded in generated shader code and must be a legal SkSL identifier prefix.

Implements GrProcessor.

Definition at line 186 of file GrSkSLFP.h.

186{ return fName; }

◆ Specialize()

template<typename T >
static GrSpecializedUniform< T > GrSkSLFP::Specialize ( const T value)
inlinestatic

Definition at line 77 of file GrSkSLFP.h.

77 {
78 return {true, value};
79 }
uint8_t value

◆ SpecializeIf()

template<typename T >
static GrSpecializedUniform< T > GrSkSLFP::SpecializeIf ( bool  condition,
const T value 
)
inlinestatic

Definition at line 81 of file GrSkSLFP.h.

81 {
82 return {condition, value};
83 }

◆ When()

template<typename T >
static GrOptionalUniform< T > GrSkSLFP::When ( bool  condition,
const T value 
)
inlinestatic

Definition at line 90 of file GrSkSLFP.h.

90 {
91 return {condition, value};
92 }

Friends And Related Function Documentation

◆ GrSkSLFPFactory

friend class GrSkSLFPFactory
friend

Definition at line 445 of file GrSkSLFP.h.


The documentation for this class was generated from the following files: