1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
use bitflags::bitflags;
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
#[repr(i32)]
pub enum CompositionBlendMode {
/// No regions are enabled.
#[default]
Clear,
/// Only the source will be present.
Src,
/// Only the destination will be present.
Dst,
/// Source is placed over the destination.
SrcOver,
/// Destination is placed over the source.
DstOver,
/// The source that overlaps the destination, replaces the destination.
SrcIn,
/// Destination which overlaps the source, replaces the source.
DstIn,
/// Source is placed, where it falls outside of the destination.
SrcOut,
/// Destination is placed, where it falls outside of the source.
DstOut,
/// Source which overlaps the destination, replaces the destination.
SrcATop,
/// Destination which overlaps the source replaces the source.
DstATop,
/// The non-overlapping regions of source and destination are combined.
Xor,
/// Display the sum of the source image and destination image.
Plus,
/// Multiplies all components (= alpha and color).
Modulate,
/// Multiplies the complements of the backdrop and source color values,
/// then complements the result.
Screen,
/// Multiplies or screens the colors, depending on the backdrop color
/// value.
Overlay,
/// Selects the darker of the backdrop and source colors.
Darken,
/// Selects the lighter of the backdrop and source colors.
Lighten,
/// Brightens the backdrop color to reflect the source color.
ColorDodge,
/// Darkens the backdrop color to reflect the source color.
ColorBurn,
/// Multiplies or screens the colors, depending on the source color
/// value.
HardLight,
/// Darkens or lightens the colors, depending on the source color value.
SoftLight,
/// Subtracts the darker of the two constituent colors from the lighter
/// color.
Difference,
/// Produces an effect similar to that of the Difference mode but lower
/// in contrast.
Exclusion,
/// The source color is multiplied by the destination color and replaces
/// the destination.
Multiply,
/// Creates a color with the hue of the source color and the saturation
/// and luminosity of the backdrop color.
Hue,
/// Creates a color with the saturation of the source color and the hue
/// and luminosity of the backdrop color.
Saturation,
/// Creates a color with the hue and saturation of the source color and
/// the luminosity of the backdrop color.
Color,
/// Creates a color with the luminosity of the source color and the hue
/// and saturation of the backdrop color.
Luminosity,
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
#[repr(i32)]
pub enum CompositionGradientExtendMode {
#[default]
Clamp,
Wrap,
Mirror,
}
bitflags! {
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct CompositionTileMode: i32 {
const NONE = 0;
const TILE_X = 1;
const TILE_Y = 2;
const FLIP_X = 4;
const FLIP_Y = 8;
const TILE = Self::TILE_X.bits() | Self::TILE_Y.bits();
const FLIP = Self::FLIP_X.bits() | Self::FLIP_Y.bits();
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
#[repr(i32)]
pub enum CompositionStretch {
#[default]
None = 0,
Fill = 1,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn values_match_the_reference() {
assert_eq!(CompositionBlendMode::Clear as i32, 0);
assert_eq!(CompositionBlendMode::SrcOver as i32, 3);
assert_eq!(CompositionBlendMode::Luminosity as i32, 28);
assert_eq!(CompositionGradientExtendMode::Mirror as i32, 2);
assert_eq!(CompositionTileMode::TILE.bits(), 3);
assert_eq!(CompositionTileMode::FLIP.bits(), 12);
assert_eq!(CompositionStretch::Fill as i32, 1);
}
}