Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
dl_blend_mode.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_DISPLAY_LIST_DL_BLEND_MODE_H_
6#define FLUTTER_DISPLAY_LIST_DL_BLEND_MODE_H_
7
8namespace flutter {
9
10/// A enum define the blend mode.
11/// Blends are operators that take in two colors (source, destination) and
12/// return a new color. Many of these operate the same on all 4
13/// components: red, green, blue, alpha. For these, we just document what
14/// happens to one component, rather than naming each one separately. Different
15/// color types might have different representations for color components:
16/// 8-bit: 0..255
17/// 6-bit: 0..63
18/// 5-bit: 0..31
19/// 4-bit: 0..15
20/// floats: 0...1
21/// The comments are expressed as if the component values are always 0..1
22/// (floats). For brevity, the documentation uses the following abbreviations s
23/// : source d : destination sa : source alpha da : destination alpha Results
24/// are abbreviated r : if all 4 components are computed in the same manner ra
25/// : result alpha component rc : result "color": red, green, blue components
26enum class DlBlendMode {
27 kClear, //!< r = 0
28 kSrc, //!< r = s
29 kDst, //!< r = d
30 kSrcOver, //!< r = s + (1-sa)*d
31 kDstOver, //!< r = d + (1-da)*s
32 kSrcIn, //!< r = s * da
33 kDstIn, //!< r = d * sa
34 kSrcOut, //!< r = s * (1-da)
35 kDstOut, //!< r = d * (1-sa)
36 kSrcATop, //!< r = s*da + d*(1-sa)
37 kDstATop, //!< r = d*sa + s*(1-da)
38 kXor, //!< r = s*(1-da) + d*(1-sa)
39 kPlus, //!< r = min(s + d, 1)
40 kModulate, //!< r = s*d
41 kScreen, //!< r = s + d - s*d
42
43 kOverlay, //!< multiply or screen, depending on destination
44 kDarken, //!< rc = s + d - max(s*da, d*sa), ra = kSrcOver
45 kLighten, //!< rc = s + d - min(s*da, d*sa), ra = kSrcOver
46 kColorDodge, //!< brighten destination to reflect source
47 kColorBurn, //!< darken destination to reflect source
48 kHardLight, //!< multiply or screen, depending on source
49 kSoftLight, //!< lighten or darken, depending on source
50 kDifference, //!< rc = s + d - 2*(min(s*da, d*sa)), ra = kSrcOver
51 kExclusion, //!< rc = s + d - two(s*d), ra = kSrcOver
52 kMultiply, //!< r = s*(1-da) + d*(1-sa) + s*d
53
54 kHue, //!< hue of source with saturation and luminosity of destination
55 kSaturation, //!< saturation of source with hue and luminosity of destination
56 kColor, //!< hue and saturation of source with luminosity of destination
57 kLuminosity, //!< luminosity of source with hue and saturation of destination
58
59 kLastCoeffMode = kScreen, //!< last porter duff blend mode
61 kMultiply, //!< last blend mode operating separately on components
62 kLastMode = kLuminosity, //!< last valid value
64};
65
66} // namespace flutter
67
68#endif // FLUTTER_DISPLAY_LIST_DL_BLEND_MODE_H_
@ 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
@ kMultiply
r = s*(1-da) + d*(1-sa) + s*d
@ kLastCoeffMode
last porter duff blend mode
@ 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)
@ kLastSeparableMode
last blend mode operating separately on components
@ 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