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
122
123
124
125
126
127
use *;
/// Describes a thrown [`JsValue`] without ever losing it.
///
/// # Arguments
///
/// - `&JsValue` - The thrown value.
///
/// # Returns
///
/// - `String` - The value rendered as a string, or a debug rendering
/// when the value is not convertible.
pub
/// Builds a [`JsValue`] error from a stable code and a detail string.
///
/// Every backend failure surfaces through this one constructor, so a
/// caller can branch on the code while a log keeps the driver's own
/// wording. A failure never degrades to `JsValue::UNDEFINED`, which
/// would make a dropped frame indistinguishable from a successful one.
///
/// # Arguments
///
/// - `&str` - The stable, machine-readable error code.
/// - `String` - The detail appended after the code.
///
/// # Returns
///
/// - `JsValue` - The error value.
pub
/// Validates a requested surface size and reports the RGBA bytes it
/// needs.
///
/// Two distinct budgets are checked, and neither is a substitute for
/// the other. The byte count is computed with checked arithmetic so a
/// request that overflows the address space is rejected instead of
/// wrapping into a short allocation; the optional limit is a
/// per-axis pixel ceiling the driver enforces on one texture or viewport
/// dimension, so it is compared against each dimension rather than
/// against the byte total. The byte budget of a storage binding is not
/// consulted here at all: a surface is not a packed buffer, and
/// rejecting a perfectly renderable size because it would exceed a
/// binding limit is the wrong failure.
///
/// The dimension is never silently clamped: a caller that asks for a
/// surface the hardware cannot address gets an error and keeps the
/// previous, still valid, size.
///
/// # Arguments
///
/// - `u32` - The requested width in pixels.
/// - `u32` - The requested height in pixels.
/// - `Option<u32>` - The largest pixel count allowed on one axis, when
/// the backend exposes one.
///
/// # Returns
///
/// - `Result<usize, JsValue>` - The RGBA byte length of the surface, or
/// the reason the size is not renderable.
pub
/// Resizes a reused output buffer to exactly one surface of RGBA bytes.
///
/// The buffer is only reallocated when it has to grow, so a repeated
/// render at a fixed size reuses the same allocation.
///
/// # Arguments
///
/// - `&mut Vec<u8>` - The reused buffer.
/// - `usize` - The RGBA byte length of one surface.
///
/// # Returns
///
/// - `()` - The resize itself.
pub