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
//! `RenderSurfaceFactory` — bridge from window handle to backend render state.
//!
//! Each window provider crate (`uzor-window-desktop`, `uzor-window-web`,
//! `uzor-window-mobile`) supplies a factory implementation that knows how to
//! convert its raw handle type into a backend-appropriate [`WindowRenderState`].
//!
//! The runtime (`uzor-framework`) holds a `Box<dyn RenderSurfaceFactory>` and
//! calls [`RenderSurfaceFactory::create_render_state`] once per window. The
//! factory chooses the right surface initialization path based on the
//! [`RenderBackend`] variant.
use RawHandle;
use crate::;
// ── SurfaceError ──────────────────────────────────────────────────────────────
/// Errors a [`RenderSurfaceFactory`] may produce while creating a render state.
// ── SurfaceSize ───────────────────────────────────────────────────────────────
/// Initial size of the render surface in physical pixels.
// ── RenderSurfaceFactory ──────────────────────────────────────────────────────
/// Converts a [`RawHandle`] + [`RenderBackend`] into a ready-to-render
/// [`WindowRenderState`].
///
/// Implementations live in window-provider crates:
/// - `uzor-window-desktop` — winit `Window` → vello-gpu factory
/// - `uzor-window-web` — `<canvas>` → canvas2d factory
/// - `uzor-window-mobile` — `CALayer` → Metal-backed factory
///
/// The factory is free to support one or many backends; unsupported
/// `(handle, backend)` pairs should return [`SurfaceError::UnsupportedBackend`]
/// or [`SurfaceError::HandleMismatch`] as appropriate.
///
/// # Thread safety
///
/// `Send + Sync` is required so the factory can be stored in a
/// `Box<dyn RenderSurfaceFactory>` across the async framework runtime.