Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | List of all members
skgpu::graphite::PrecompileBlendShader Class Reference
Inheritance diagram for skgpu::graphite::PrecompileBlendShader:
skgpu::graphite::PrecompileShader skgpu::graphite::PrecompileBase SkRefCnt SkRefCntBase

Public Member Functions

 PrecompileBlendShader (SkSpan< const sk_sp< PrecompileBlender > > runtimeBlendEffects, SkSpan< const sk_sp< PrecompileShader > > dsts, SkSpan< const sk_sp< PrecompileShader > > srcs, bool needsPorterDuffBased, bool needsSeparableMode)
 
- Public Member Functions inherited from skgpu::graphite::PrecompileShader
 PrecompileShader ()
 
virtual bool isConstant (int desiredCombination) const
 
sk_sp< PrecompileShadermakeWithLocalMatrix ()
 
sk_sp< PrecompileShadermakeWithColorFilter (sk_sp< PrecompileColorFilter >)
 
sk_sp< PrecompileShadermakeWithWorkingColorSpace (sk_sp< SkColorSpace >)
 
sk_sp< PrecompileShadermakeWithCTM ()
 
- Public Member Functions inherited from skgpu::graphite::PrecompileBase
 PrecompileBase (Type type)
 
Type type () const
 
virtual int numIntrinsicCombinations () const
 
int numCombinations () const
 
PrecompileBasePriv priv ()
 
const PrecompileBasePriv priv () const
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Private Member Functions

int numChildCombinations () const override
 
void addToKey (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, int desiredCombination) const override
 

Additional Inherited Members

- Public Types inherited from skgpu::graphite::PrecompileBase
enum class  Type {
  kBlender , kColorFilter , kImageFilter , kMaskFilter ,
  kShader
}
 
- Static Protected Member Functions inherited from skgpu::graphite::PrecompileBase
template<typename T >
static std::pair< sk_sp< T >, intSelectOption (SkSpan< const sk_sp< T > > options, int desiredOption)
 
template<typename T >
static void AddToKey (const KeyContext &, PaintParamsKeyBuilder *, PipelineDataGatherer *, SkSpan< const sk_sp< T > > options, int desiredOption)
 

Detailed Description

Definition at line 182 of file FactoryFunctions.cpp.

Constructor & Destructor Documentation

◆ PrecompileBlendShader()

skgpu::graphite::PrecompileBlendShader::PrecompileBlendShader ( SkSpan< const sk_sp< PrecompileBlender > >  runtimeBlendEffects,
SkSpan< const sk_sp< PrecompileShader > >  dsts,
SkSpan< const sk_sp< PrecompileShader > >  srcs,
bool  needsPorterDuffBased,
bool  needsSeparableMode 
)
inline

Definition at line 184 of file FactoryFunctions.cpp.

189 : fRuntimeBlendEffects(runtimeBlendEffects.begin(), runtimeBlendEffects.end())
190 , fDstOptions(dsts.begin(), dsts.end())
191 , fSrcOptions(srcs.begin(), srcs.end()) {
192
193 fNumBlenderCombos = 0;
194 for (const auto& rt : fRuntimeBlendEffects) {
195 fNumBlenderCombos += rt->numCombinations();
196 }
197 if (needsPorterDuffBased) {
198 ++fNumBlenderCombos;
199 }
200 if (needsSeparableMode) {
201 ++fNumBlenderCombos;
202 }
203
204 SkASSERT(fNumBlenderCombos >= 1);
205
206 fNumDstCombos = 0;
207 for (const auto& d : fDstOptions) {
208 fNumDstCombos += d->numCombinations();
209 }
210
211 fNumSrcCombos = 0;
212 for (const auto& s : fSrcOptions) {
213 fNumSrcCombos += s->numCombinations();
214 }
215
216 if (needsPorterDuffBased) {
217 fPorterDuffIndex = 0;
218 if (needsSeparableMode) {
219 fSeparableModeIndex = 1;
220 if (!fRuntimeBlendEffects.empty()) {
221 fBlenderIndex = 2;
222 }
223 } else if (!fRuntimeBlendEffects.empty()) {
224 fBlenderIndex = 1;
225 }
226 } else if (needsSeparableMode) {
227 fSeparableModeIndex = 0;
228 if (!fRuntimeBlendEffects.empty()) {
229 fBlenderIndex = 1;
230 }
231 } else {
232 SkASSERT(!fRuntimeBlendEffects.empty());
233 fBlenderIndex = 0;
234 }
235 }
static const char * srcs[2]
#define SkASSERT(cond)
Definition SkAssert.h:116
constexpr T * begin() const
Definition SkSpan_impl.h:90
constexpr T * end() const
Definition SkSpan_impl.h:91
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition main.cc:19
struct MyStruct s

Member Function Documentation

◆ addToKey()

void skgpu::graphite::PrecompileBlendShader::addToKey ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
int  desiredCombination 
) const
inlineoverrideprivatevirtual

Implements skgpu::graphite::PrecompileBase.

Definition at line 242 of file FactoryFunctions.cpp.

245 {
246 SkASSERT(desiredCombination < this->numCombinations());
247
248 const int desiredDstCombination = desiredCombination % fNumDstCombos;
249 int remainingCombinations = desiredCombination / fNumDstCombos;
250
251 const int desiredSrcCombination = remainingCombinations % fNumSrcCombos;
252 remainingCombinations /= fNumSrcCombos;
253
254 int desiredBlendCombination = remainingCombinations;
255 SkASSERT(desiredBlendCombination < fNumBlenderCombos);
256
257 if (desiredBlendCombination == fPorterDuffIndex ||
258 desiredBlendCombination == fSeparableModeIndex) {
259 BlendShaderBlock::BeginBlock(keyContext, builder, gatherer);
260
261 } else {
262 const SkRuntimeEffect* blendEffect =
263 GetKnownRuntimeEffect(SkKnownRuntimeEffects::StableKey::kBlend);
264
265 RuntimeEffectBlock::BeginBlock(keyContext, builder, gatherer,
266 { sk_ref_sp(blendEffect) });
267 SkASSERT(desiredBlendCombination >= fBlenderIndex);
268 desiredBlendCombination -= fBlenderIndex;
269 }
270
271 AddToKey<PrecompileShader>(keyContext, builder, gatherer, fSrcOptions,
272 desiredSrcCombination);
273 AddToKey<PrecompileShader>(keyContext, builder, gatherer, fDstOptions,
274 desiredDstCombination);
275
276 if (desiredBlendCombination == fPorterDuffIndex) {
277 CoeffBlenderBlock::AddBlock(keyContext, builder, gatherer,
278 { 0.0f, 0.0f, 0.0f, 0.0f }); // coeffs aren't used
279 } else if (desiredBlendCombination == fSeparableModeIndex) {
280 BlendModeBlenderBlock::AddBlock(keyContext, builder, gatherer,
281 SkBlendMode::kOverlay); // the blendmode is unused
282 } else {
283 AddToKey<PrecompileBlender>(keyContext, builder, gatherer, fRuntimeBlendEffects,
284 desiredBlendCombination);
285 }
286
287 builder->endBlock(); // BlendShaderBlock or RuntimeEffectBlock
288 }
@ kOverlay
multiply or screen, depending on destination
sk_sp< T > sk_ref_sp(T *obj)
Definition SkRefCnt.h:381
const SkRuntimeEffect * GetKnownRuntimeEffect(StableKey stableKey)
static void AddBlock(const KeyContext &, PaintParamsKeyBuilder *, PipelineDataGatherer *, SkBlendMode)
static void BeginBlock(const KeyContext &, PaintParamsKeyBuilder *, PipelineDataGatherer *)
static void AddBlock(const KeyContext &, PaintParamsKeyBuilder *, PipelineDataGatherer *, SkSpan< const float > coeffs)
static void BeginBlock(const KeyContext &, PaintParamsKeyBuilder *, PipelineDataGatherer *, const ShaderData &)

◆ numChildCombinations()

int skgpu::graphite::PrecompileBlendShader::numChildCombinations ( ) const
inlineoverrideprivatevirtual

Reimplemented from skgpu::graphite::PrecompileBase.

Definition at line 238 of file FactoryFunctions.cpp.

238 {
239 return fNumBlenderCombos * fNumDstCombos * fNumSrcCombos;
240 }

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