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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
//! The [`Presenter`] trait: what a renderer crate implements to rasterize a
//! grid and present it to a window surface.
//!
//! `Presenter` is the output half of [`Backend`](retroglyph_core::Backend)
//! plus window-surface operations, with no input methods: the event loop
//! owns input, and [`WindowBackend`](crate::WindowBackend) forwards
//! translated events into its own queue instead.
//!
//! | Presenter | `present()` | `init_surface()` |
//! |---|---|---|
//! | `SoftwareRenderer` (retroglyph-software) | Copies pixel buffer to softbuffer surface | Creates `softbuffer::Context` + `Surface` |
//! | `WgpuRenderer` (future) | Submits render pass + presents swap chain | Creates `wgpu::Surface` + `Device` |
//! | `GlRenderer` (future) | Draws full-screen quad + swaps buffers | Creates GL context from the window |
//!
//! See the crate-level docs (`crate` root, "DPI, scale, and the resize contract" and
//! "Threading model" sections) for the physical-pixel/no-auto-scaling contract on
//! [`cell_size`](Presenter::cell_size), the sub-cell-remainder behavior on
//! [`resize_surface`](Presenter::resize_surface), and the single-threaded execution model
//! every `Presenter` implementation runs under.
use ;
use BackendError;
use ;
use Tile;
use Arc;
/// A window/display handle pair, as one trait.
///
/// Presenters receive [`raw-window-handle`](raw_window_handle) types, not a
/// concrete `winit::window::Window`: softbuffer, wgpu, and glutin all accept
/// these handles directly, so any windowing library that produces them can
/// drive the same presenter, and only this crate depends on winit itself.
///
/// `raw-window-handle` has no combined trait, and surface libraries need to
/// *own* the handle (softbuffer stores it for the surface's lifetime), so
/// presenters receive `Arc<dyn WindowHandle>` -- rwh implements the handle
/// traits for `Arc<H: ?Sized>`, so the trait object passes straight into
/// `softbuffer::Surface::new` / `wgpu::Instance::create_surface`.
/// A renderer that rasterizes grid content and presents it to a window
/// surface.
///
/// Mirrors the output half of [`Backend`](retroglyph_core::Backend) (`draw`,
/// `draw_layers`, `flush`, `size`, `clear`, `resize`) so
/// [`WindowBackend`](crate::WindowBackend) can delegate those methods
/// wholesale, and adds the surface lifecycle (`init_surface`,
/// `resize_surface`, `present`, `cell_size`) that the event loop drives.
///
/// The `needs_full_frame` and `composites_layers` defaults are `true`: every
/// windowed presenter is a pixel-family backend that composites layers
/// itself, receiving the raw per-layer stream instead of a pre-flattened
/// single layer. Only character-cell terminal backends return `false`, and
/// those implement [`Backend`](retroglyph_core::Backend) directly instead of
/// this trait.