Flutter Engine
The Flutter Engine
PrecompileBlender.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2024 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
9
13
14namespace skgpu::graphite {
15
17
18//--------------------------------------------------------------------------------------------------
20public:
21 PrecompileBlendModeBlender(SkBlendMode blendMode) : fBlendMode(blendMode) {}
22
23protected:
24 std::optional<SkBlendMode> asBlendMode() const final { return fBlendMode; }
25
26 void addToKey(const KeyContext& keyContext,
28 PipelineDataGatherer* gatherer,
29 int desiredCombination) const final {
30 SkASSERT(desiredCombination == 0); // The blend mode blender only ever has one combination
31
32 AddModeBlend(keyContext, builder, gatherer, fBlendMode);
33 }
34
35private:
36 SkBlendMode fBlendMode;
37};
38
40 return sk_make_sp<PrecompileBlendModeBlender>(blendMode);
41}
42
43//--------------------------------------------------------------------------------------------------
45 const SkRuntimeEffect* arithmeticEffect =
46 GetKnownRuntimeEffect(SkKnownRuntimeEffects::StableKey::kArithmetic);
47
48 return MakePrecompileBlender(sk_ref_sp(arithmeticEffect));
49}
50
51} // namespace skgpu::graphite
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkBlendMode
Definition: SkBlendMode.h:38
sk_sp< T > sk_ref_sp(T *obj)
Definition: SkRefCnt.h:381
std::optional< SkBlendMode > asBlendMode() const final
void addToKey(const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, int desiredCombination) const final
const SkRuntimeEffect * GetKnownRuntimeEffect(StableKey stableKey)
SK_API sk_sp< PrecompileBlender > Arithmetic()
SK_API sk_sp< PrecompileBlender > Mode(SkBlendMode)
sk_sp< PrecompileBlender > MakePrecompileBlender(sk_sp< SkRuntimeEffect > effect, SkSpan< const PrecompileChildOptions > childOptions)
void AddModeBlend(const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, SkBlendMode bm)