Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkBlenderBase.h
Go to the documentation of this file.
1/*
2 * Copyright 2021 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
8#ifndef SkBlenderBase_DEFINED
9#define SkBlenderBase_DEFINED
10
13
14#include <memory>
15#include <optional>
16
17struct GrFPArgs;
19class SkColorInfo;
20class SkRuntimeEffect;
21struct SkStageRec;
22
23namespace skgpu::graphite {
24enum class DstColorType;
25class KeyContext;
26class PaintParamsKeyBuilder;
27class PipelineDataGatherer;
28}
29
30#define SK_ALL_BLENDERS(M) \
31 M(BlendMode) \
32 M(Runtime)
33
34/**
35 * Encapsulates a blend function, including non-public APIs.
36 * Blends combine a source color (the result of our paint) and destination color (from the canvas)
37 * into a final color.
38 */
39class SkBlenderBase : public SkBlender {
40public:
41 /**
42 * Returns true if this SkBlender represents any SkBlendMode, and returns the blender's
43 * SkBlendMode in `mode`. Returns false for other types of blends.
44 */
45 virtual std::optional<SkBlendMode> asBlendMode() const { return {}; }
46
47 bool affectsTransparentBlack() const;
48
49 [[nodiscard]] bool appendStages(const SkStageRec& rec) const {
50 return this->onAppendStages(rec);
51 }
52
53 [[nodiscard]] virtual bool onAppendStages(const SkStageRec& rec) const = 0;
54
55 virtual SkRuntimeEffect* asRuntimeEffect() const { return nullptr; }
56
59
60 enum class BlenderType {
61 #define M(type) k ## type,
63 #undef M
64 };
65
66 virtual BlenderType type() const = 0;
67};
68
70 return static_cast<SkBlenderBase*>(blend);
71}
72
73inline const SkBlenderBase* as_BB(const SkBlender* blend) {
74 return static_cast<const SkBlenderBase*>(blend);
75}
76
78 return static_cast<SkBlenderBase*>(blend.get());
79}
80
81#endif // SkBlenderBase_DEFINED
#define SK_ALL_BLENDERS(M)
SkBlenderBase * as_BB(SkBlender *blend)
virtual SkRuntimeEffect * asRuntimeEffect() const
SkFlattenable::Type getFlattenableType() const override
virtual BlenderType type() const =0
virtual bool onAppendStages(const SkStageRec &rec) const =0
static SkFlattenable::Type GetFlattenableType()
bool appendStages(const SkStageRec &rec) const
bool affectsTransparentBlack() const
virtual std::optional< SkBlendMode > asBlendMode() const
static SkColor blend(SkColor dst, SkColor src, void(*mode)(float, float, float, float *, float *, float *))
Definition hsl.cpp:142