euv_core/render/command/enum.rs
1use super::*;
2
3/// Backend-agnostic vector/UI drawing primitive emitted by `PaintPass` and consumed by all renderers.
4#[derive(Clone, Debug, PartialEq)]
5pub enum DrawCommand {
6 /// Clears the target surface to `Color`.
7 Clear(Color),
8 /// Draws a rounded or sharp filled rectangle with optional border stroke.
9 FillRoundedRect {
10 /// Bounds in logical pixels.
11 rect: Rect,
12 /// Fill color.
13 color: Color,
14 /// Corner radii.
15 radius: CornerRadius,
16 /// Optional border stroke.
17 border: Border,
18 },
19 /// Draws a two-stop linear gradient inside a rounded rectangle.
20 LinearGradientRect {
21 /// Bounds in logical pixels.
22 rect: Rect,
23 /// Gradient specification.
24 gradient: LinearGradient,
25 /// Corner radii.
26 radius: CornerRadius,
27 },
28 /// Draws a soft drop shadow under a rounded rectangle.
29 BoxShadow {
30 /// Casting box bounds.
31 rect: Rect,
32 /// Corner radii.
33 radius: CornerRadius,
34 /// Shadow parameters.
35 shadow: Shadow,
36 },
37 /// Applies a backdrop blur sampling the previously rendered pixels beneath `rect`.
38 BackdropBlur {
39 /// Output bounds in logical pixels.
40 rect: Rect,
41 /// Corner radii mask in logical pixels.
42 radius: CornerRadius,
43 /// Gaussian blur radius in logical pixels.
44 blur_radius: f32,
45 },
46 /// Draws a laid-out text run using the shared deterministic glyph atlas.
47 TextRun {
48 /// Bounding rectangle in logical pixels.
49 rect: Rect,
50 /// UTF-8 text string.
51 text: String,
52 /// Typography style.
53 style: TextStyle,
54 },
55 /// Draws a blinking text-input caret aligned to exact rasterized glyph advances.
56 TextCaret {
57 /// Text layout bounding rectangle in logical pixels.
58 text_rect: Rect,
59 /// Input inner content clip rectangle in logical pixels.
60 content_rect: Rect,
61 /// Active input text preceding the caret.
62 text: String,
63 /// Typography style matching the input's `TextRun`.
64 style: TextStyle,
65 /// Caret height in logical pixels.
66 caret_height: f32,
67 /// Caret fill color.
68 color: Color,
69 /// Whether the input wraps across multiple lines.
70 multiline: bool,
71 },
72 /// Blits a decoded RGBA8 image buffer into `rect`.
73 Image {
74 /// Destination bounds.
75 rect: Rect,
76 /// Image pixel buffer.
77 buffer: ImageBuffer,
78 /// Corner radii mask.
79 radius: CornerRadius,
80 },
81 /// Blits a reference-counted pooled RGBA8 pixel buffer into `rect` with zero per-frame copy.
82 SharedImage {
83 /// Destination bounds.
84 rect: Rect,
85 /// Image width in pixels.
86 width: u32,
87 /// Image height in pixels.
88 height: u32,
89 /// Shared RGBA8 pixel bytes (`width * height * 4`).
90 pixels: Arc<Vec<u8>>,
91 /// Corner radii mask.
92 radius: CornerRadius,
93 },
94 /// Draws a straight anti-aliased line segment (used by custom canvases and dividers).
95 Line {
96 /// Start point.
97 from: Point,
98 /// End point.
99 to: Point,
100 /// Line color.
101 color: Color,
102 /// Stroke width.
103 width: f32,
104 },
105 /// Draws a filled anti-aliased circle (used by badges, avatars, spinners, and custom canvases).
106 Circle {
107 /// Center point.
108 center: Point,
109 /// Circle radius.
110 radius: f32,
111 /// Fill color.
112 color: Color,
113 },
114 /// Draws a filled triangle primitive (used by 2D game meshes, spaceships, lasers, and polygons).
115 Triangle {
116 /// First vertex in logical pixels.
117 p0: Point,
118 /// Second vertex in logical pixels.
119 p1: Point,
120 /// Third vertex in logical pixels.
121 p2: Point,
122 /// Fill color.
123 color: Color,
124 },
125 /// Blits a cropped sub-region of an `ImageBuffer` sprite sheet with optional tint color.
126 SpriteRegion {
127 /// Destination bounds in logical pixels.
128 rect: Rect,
129 /// Source sprite-sheet RGBA8 buffer.
130 buffer: ImageBuffer,
131 /// Source pixel sub-rectangle `(x, y, w, h)`.
132 src_rect: Rect,
133 /// Multiplicative tint color (`COLOR_WHITE` for untinted).
134 tint: Color,
135 },
136 /// Composites the hardware GPU offscreen scene render target (`external_tex`) directly into `rect`.
137 ExternalSurface {
138 /// Destination bounds in logical pixels.
139 rect: Rect,
140 /// Corner radii mask in logical pixels.
141 radius: CornerRadius,
142 },
143 /// Pushes an axis-aligned clip rectangle onto the clip stack.
144 PushClip(Rect),
145 /// Pushes a rounded-rectangle clip mask onto the clip stack, balanced by `PopClip`.
146 PushRoundedClip {
147 /// Clip rectangle bounds in logical pixels.
148 rect: Rect,
149 /// Corner radii in logical pixels.
150 radius: CornerRadius,
151 },
152 /// Pops the top clip rectangle from the clip stack.
153 PopClip,
154}
155
156/// Slab-backed zero-String-allocation representation of `DrawCommand` stored inside `PaintFragmentCache`.
157#[derive(Clone, Debug)]
158pub(crate) enum CachedDrawCommand {
159 /// Clears the target surface to `Color`.
160 Clear(Color),
161 /// Draws a rounded or sharp filled rectangle with optional border stroke.
162 FillRoundedRect {
163 /// Bounds in logical pixels.
164 rect: Rect,
165 /// Fill color.
166 color: Color,
167 /// Corner radii.
168 radius: CornerRadius,
169 /// Optional border stroke.
170 border: Border,
171 },
172 /// Draws a two-stop linear gradient inside a rounded rectangle.
173 LinearGradientRect {
174 /// Bounds in logical pixels.
175 rect: Rect,
176 /// Gradient specification.
177 gradient: LinearGradient,
178 /// Corner radii.
179 radius: CornerRadius,
180 },
181 /// Draws a soft drop shadow under a rounded rectangle.
182 BoxShadow {
183 /// Casting box bounds.
184 rect: Rect,
185 /// Corner radii.
186 radius: CornerRadius,
187 /// Shadow parameters.
188 shadow: Shadow,
189 },
190 /// Applies a backdrop blur sampling the previously rendered pixels beneath `rect`.
191 BackdropBlur {
192 /// Output bounds in logical pixels.
193 rect: Rect,
194 /// Corner radii mask in logical pixels.
195 radius: CornerRadius,
196 /// Gaussian blur radius in logical pixels.
197 blur_radius: f32,
198 },
199 /// Draws a laid-out text run backed by byte slice `[text_start..text_start + text_len]` in `PaintFragmentCache::text_slab`.
200 TextRun {
201 /// Bounding rectangle in logical pixels.
202 rect: Rect,
203 /// Start UTF-8 byte offset inside `text_slab`.
204 text_start: u32,
205 /// UTF-8 byte length inside `text_slab`.
206 text_len: u32,
207 /// Typography style.
208 style: TextStyle,
209 },
210 /// Draws a blinking text-input caret backed by byte slice `[text_start..text_start + text_len]` in `PaintFragmentCache::text_slab`.
211 TextCaret {
212 /// Text layout bounding rectangle in logical pixels.
213 text_rect: Rect,
214 /// Input inner content clip rectangle in logical pixels.
215 content_rect: Rect,
216 /// Start UTF-8 byte offset inside `text_slab`.
217 text_start: u32,
218 /// UTF-8 byte length inside `text_slab`.
219 text_len: u32,
220 /// Typography style matching the input's `TextRun`.
221 style: TextStyle,
222 /// Caret height in logical pixels.
223 caret_height: f32,
224 /// Caret fill color.
225 color: Color,
226 /// Whether the input wraps across multiple lines.
227 multiline: bool,
228 },
229 /// Blits a decoded RGBA8 image buffer into `rect`.
230 Image {
231 /// Destination bounds.
232 rect: Rect,
233 /// Image pixel buffer.
234 buffer: ImageBuffer,
235 /// Corner radii mask.
236 radius: CornerRadius,
237 },
238 /// Blits a reference-counted pooled RGBA8 pixel buffer into `rect` with zero per-frame copy.
239 SharedImage {
240 /// Destination bounds.
241 rect: Rect,
242 /// Image width in pixels.
243 width: u32,
244 /// Image height in pixels.
245 height: u32,
246 /// Shared RGBA8 pixel bytes (`width * height * 4`).
247 pixels: Arc<Vec<u8>>,
248 /// Corner radii mask.
249 radius: CornerRadius,
250 },
251 /// Draws a straight anti-aliased line segment.
252 Line {
253 /// Start point.
254 from: Point,
255 /// End point.
256 to: Point,
257 /// Line color.
258 color: Color,
259 /// Stroke width.
260 width: f32,
261 },
262 /// Draws a filled anti-aliased circle.
263 Circle {
264 /// Center point.
265 center: Point,
266 /// Circle radius.
267 radius: f32,
268 /// Fill color.
269 color: Color,
270 },
271 /// Draws a filled triangle primitive.
272 Triangle {
273 /// First vertex in logical pixels.
274 p0: Point,
275 /// Second vertex in logical pixels.
276 p1: Point,
277 /// Third vertex in logical pixels.
278 p2: Point,
279 /// Fill color.
280 color: Color,
281 },
282 /// Blits a cropped sub-region of an `ImageBuffer` sprite sheet with optional tint color.
283 SpriteRegion {
284 /// Destination bounds in logical pixels.
285 rect: Rect,
286 /// Source sprite-sheet RGBA8 buffer.
287 buffer: ImageBuffer,
288 /// Source pixel sub-rectangle `(x, y, w, h)`.
289 src_rect: Rect,
290 /// Multiplicative tint color.
291 tint: Color,
292 },
293 /// Composites the hardware GPU offscreen scene render target (`external_tex`) directly into `rect`.
294 ExternalSurface {
295 /// Destination bounds in logical pixels.
296 rect: Rect,
297 /// Corner radii mask in logical pixels.
298 radius: CornerRadius,
299 },
300 /// Pushes an axis-aligned clip rectangle onto the clip stack.
301 PushClip(Rect),
302 /// Pushes a rounded-rectangle clip mask onto the clip stack, balanced by `PopClip`.
303 PushRoundedClip {
304 /// Clip rectangle bounds in logical pixels.
305 rect: Rect,
306 /// Corner radii in logical pixels.
307 radius: CornerRadius,
308 },
309 /// Pops the top clip rectangle from the clip stack.
310 PopClip,
311}