blob: 9f3aea8cb4ffc0f0a375477c035cdebb3babbebd [file] [log] [blame]
Cary Clark61313f32018-10-08 14:57:48 -04001#Topic Blend_Mode_Overview
2
3Describes how destination pixel is replaced with a combination of itself and
4source pixel. Blend_Mode may use source, destination, or both. Blend_Mode may
5operate on each Color component independently, or may allow all source pixel
6components to contribute to one destination pixel component.
7
8Blend_Mode does not use adjacent pixels to determine the outcome.
9
10Blend_Mode uses source and read destination Alpha to determine written
11destination Alpha; both source and destination Alpha may also affect written
12destination Color components.
13
14Regardless of how Alpha is encoded in source and destination pixel, nearly all
15Color_Types treat it as ranging from zero to one. And, nearly all Blend_Mode
16algorithms limit the output so that all results are also zero to one.
17
18Two exceptions are SkBlendMode::kPlus and kRGBA_F16_SkColorType.
19
20SkBlendMode::kPlus permits computing Alpha and Color component values larger
21than one. For Color_Types other than kRGBA_F16_SkColorType, resulting Alpha
22and component values are clamped to one.
23
24kRGBA_F16_SkColorType permits values outside the zero to one range. It is up
25to the client to ensure that the result is within the range of zero to one,
26and therefore well-defined.
27
28#Subtopic Porter_Duff
29#Alias Porter_Duff ##
30#Line # classic color blend algorithms ##
31
32#A Compositing Digital Images # https://graphics.pixar.com/library/Compositing/paper.pdf ##
33describes Porter_Duff modes SkBlendMode::kClear through SkBlendMode::kXor.
34
35Drawing a bitmap with transparency using Porter_Duff compositing is free to clear
36the destination.
37
38#Illustration 1
39
40Draw geometry with transparency using Porter_Duff compositing does not combine
41transparent source pixels, leaving the destination outside the geometry untouched.
42
43#Illustration 2
44
45##
46
47#Subtopic Lighten_Darken
48#Line # color blends to lighten or darken result ##
49
50Modes SkBlendMode::kPlus and SkBlendMode::kScreen use
51simple arithmetic to lighten or darken the destination. Modes
52SkBlendMode::kOverlay through SkBlendMode::kMultiply use more complicated
53algorithms to lighten or darken; sometimes one mode does both, as described by
54#A Blend Modes # https://en.wikipedia.org/wiki/Blend_modes ##
55.
56
57#Illustration
58
59##
60
61#Subtopic Modulate_Blend
62#Line # multiply color components ##
63
64SkBlendMode::kModulate is a mashup of SkBlendMode::kSrcATop and SkBlendMode::kMultiply.
65It multiplies all components, including Alpha; unlike SkBlendMode::kMultiply, if either
66source or destination is transparent, result is transparent. SkBlendMode::kModulate
67uses Premultiplied values to compute the product; SkBlendMode::kMultiply uses Unpremultiplied
68values to compute the product.
69
70#Illustration
71
72##
73
74#Subtopic Color_Blends
75#Line # non-separable blend modes ##
76
77Modes SkBlendMode::kHue, SkBlendMode::kSaturation, SkBlendMode::kColor, and
78SkBlendMode::kLuminosity convert source and destination pixels using all
79components color information, using
80###$
81$A non-separable blend modes $ https://www.w3.org/TR/compositing-1/#blendingnonseparable $$
82$$$#
83.
84
85#Illustration
86
87##
88
89#Topic Blend_Mode_Overview ##