Flutter Engine
The Flutter Engine
SkBlendModeBlender.cpp
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
9
19
21#define RETURN_SINGLETON_BLENDER(m) \
22 case m: { \
23 static SkNoDestructor<SkBlendModeBlender> sBlender(m); \
24 return sk_ref_sp(sBlender.get()); \
25 }
26
27 switch (mode) {
57 }
58
59 SkDEBUGFAILF("invalid blend mode %d", (int)mode);
60 return nullptr;
61
62#undef RETURN_SINGLETON_BLENDER
63}
64
65sk_sp<SkFlattenable> SkBlendModeBlender::CreateProc(SkReadBuffer& buffer) {
67 return SkBlender::Mode(mode);
68}
69
70void SkBlendModeBlender::flatten(SkWriteBuffer& buffer) const {
71 buffer.writeInt((int)fMode);
72}
73
74bool SkBlendModeBlender::onAppendStages(const SkStageRec& rec) const {
76 return true;
77}
78
80 if (auto blendMode = this->asBlendMode()) {
82 if (SkBlendMode_AsCoeff(*blendMode, &src, &dst)) {
83 // If the source is (0,0,0,0), then dst is preserved as long as its coefficient
84 // evaluates to 1.0. This is true for kOne, kISA, and kISC. Anything else means the
85 // blend mode affects transparent black.
86 return dst != SkBlendModeCoeff::kOne &&
89 } else {
90 // An advanced blend mode, which do not affect transparent black
91 return false;
92 }
93 } else {
94 // Blenders that aren't blend modes are assumed to modify transparent black.
95 return true;
96 }
97}
#define SkDEBUGFAILF(fmt,...)
Definition: SkAssert.h:119
#define RETURN_SINGLETON_BLENDER(m)
void SkBlendMode_AppendStages(SkBlendMode mode, SkRasterPipeline *p)
Definition: SkBlendMode.cpp:97
SK_API bool SkBlendMode_AsCoeff(SkBlendMode mode, SkBlendModeCoeff *src, SkBlendModeCoeff *dst)
Definition: SkBlendMode.cpp:57
SkBlendMode
Definition: SkBlendMode.h:38
@ kSrcOut
r = s * (1-da)
@ kExclusion
rc = s + d - two(s*d), ra = kSrcOver
@ kSaturation
saturation of source with hue and luminosity of destination
@ kColorBurn
darken destination to reflect source
@ kPlus
r = min(s + d, 1)
@ kLighten
rc = s + d - min(s*da, d*sa), ra = kSrcOver
@ kHue
hue of source with saturation and luminosity of destination
@ kDstIn
r = d * sa
@ kModulate
r = s*d
@ kMultiply
r = s*(1-da) + d*(1-sa) + s*d
@ kColorDodge
brighten destination to reflect source
@ kScreen
r = s + d - s*d
@ kSrcOver
r = s + (1-sa)*d
@ kXor
r = s*(1-da) + d*(1-sa)
@ kLuminosity
luminosity of source with hue and saturation of destination
@ kSoftLight
lighten or darken, depending on source
@ kDifference
rc = s + d - 2*(min(s*da, d*sa)), ra = kSrcOver
@ kOverlay
multiply or screen, depending on destination
@ kSrcATop
r = s*da + d*(1-sa)
@ kDstATop
r = d*sa + s*(1-da)
@ kDstOver
r = d + (1-da)*s
@ kLastMode
last valid value
@ kColor
hue and saturation of source with luminosity of destination
@ kHardLight
multiply or screen, depending on source
@ kDstOut
r = d * (1-sa)
@ kDarken
rc = s + d - max(s*da, d*sa), ra = kSrcOver
@ kSrcIn
r = s * da
@ kClear
r = 0
SkBlendModeCoeff
Definition: SkBlendMode.h:84
SkBlendMode mode() const
bool affectsTransparentBlack() const
virtual std::optional< SkBlendMode > asBlendMode() const
Definition: SkBlenderBase.h:45
static sk_sp< SkBlender > Mode(SkBlendMode mode)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
Definition: switches.h:228
dst
Definition: cp.py:12
SkRasterPipeline * fPipeline
Definition: SkEffectPriv.h:21