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
/// Internal namespace.
mod private
{
use crate::*;
/// A builder for creating a `web_sys::GpuMultisampleState`.
#[ derive( Default, Clone ) ]
pub struct MultiSampleState
{
/// A flag to enable or disable alpha-to-coverage.
///
/// When `true`, the alpha value of the fragment shader output is used to
/// mask the multisample coverage, which is useful for rendering transparent
/// textures.
///
/// Defaults to `false`.
alpha_to_coverage_enabled : Option< bool >,
/// The number of samples per pixel for multisample anti-aliasing.
///
/// Common values are 1, 4, or 8. A value of 1 means no multisampling.
///
/// Defaults to `1`.
count : Option< u32 >,
/// A bitmask that is ANDed with the sample coverage mask.
///
/// This can be used to explicitly disable certain samples from being written to.
///
/// Defaults to `0xFFFFFFFF` (all bits set).
mask : Option< u32 >,
}
impl MultiSampleState
{
/// Creates a new `MultiSampleState` with default values.
pub fn new() -> Self
{
Self::default()
}
/// Sets the sample mask.
pub fn mask( mut self, mask : u32 ) -> Self
{
self.mask = Some( mask );
self
}
/// Sets the number of samples per pixel.
pub fn count( mut self, count : u32 ) -> Self
{
self.count = Some( count );
self
}
/// Enables alpha-to-coverage.
pub fn enable_alpha_to_coverage( mut self ) -> Self
{
self.alpha_to_coverage_enabled = Some( true );
self
}
}
impl From< MultiSampleState > for web_sys::GpuMultisampleState
{
fn from ( value: MultiSampleState ) -> Self
{
let state = web_sys::GpuMultisampleState::new();
if let Some( v ) = value.alpha_to_coverage_enabled { state.set_alpha_to_coverage_enabled( v ); }
if let Some( v ) = value.count { state.set_count( v ); }
if let Some( v ) = value.mask { state.set_mask( v ); }
state
}
}
}
crate::mod_interface!
{
exposed use
{
MultiSampleState
};
}