MCPcopy Create free account
hub / github.com/PerroEngine/Perro / submit

Method submit

perro_source/render_stack/perro_graphics/src/ui/renderer.rs:148–428  ·  view source on GitHub ↗
(&mut self, command: UiCommand)

Source from the content-addressed store, hash-verified

146 NineSlice(UiNineSliceDraw),
147 Label(UiLabelDraw),
148 TextEdit(UiTextEditDraw),
149}
150
151pub struct UiRenderer {
152 nodes: AHashMap<NodeID, UiDraw>,
153 revision: u64,
154 painter: EpaintUiPainter,
155 static_font_lookup: Option<crate::StaticFontLookup>,
156 default_font: perro_ui::UiFont,
157 // Path hashes already handed to the painter; labels re-submit every
158 // change, so gate here keeps registration off the per-frame path.
159 registered_resource_fonts: ahash::AHashSet<u64>,
160}
161
162impl Default for UiRenderer {
163 fn default() -> Self {
164 Self::new()
165 }
166}
167
168impl UiRenderer {
169 pub fn new() -> Self {
170 Self {
171 nodes: AHashMap::new(),
172 revision: 0,
173 painter: EpaintUiPainter::new(),
174 static_font_lookup: None,
175 default_font: perro_ui::UiFont::Default,
176 registered_resource_fonts: ahash::AHashSet::new(),
177 }
178 }
179
180 pub fn submit(&mut self, mut command: UiCommand) {
181 match &mut command {
182 UiCommand::UpsertLabel { font, .. } | UiCommand::UpsertTextEdit { font, .. }
183 if matches!(font, perro_ui::UiFont::Default) =>
184 {
185 *font = self.default_font.clone();
186 }
187 _ => {}
188 }
189 match &command {
190 UiCommand::UpsertLabel {
191 font: perro_ui::UiFont::Resource(path),
192 ..
193 }
194 | UiCommand::UpsertTextEdit {
195 font: perro_ui::UiFont::Resource(path),
196 ..
197 } => {
198 let hash = perro_ids::string_to_u64(path);
199 if self.registered_resource_fonts.insert(hash) {
200 self.painter
201 .register_resource_font(path, self.static_font_lookup);
202 }
203 }
204 _ => {}
205 }

Callers 15

create_textureFunction · 0.45
force_2d_redrawFunction · 0.45
force_3d_redrawFunction · 0.45
bench_postprocess_framesFunction · 0.45
bench_light_framesFunction · 0.45
bench_sky_framesFunction · 0.45
setup_stream_2dFunction · 0.45
setup_stream_3dFunction · 0.45
redraw_2dFunction · 0.45
redraw_3dFunction · 0.45
create_textureFunction · 0.45
create_textureFunction · 0.45

Calls 5

upsertMethod · 0.80
bump_revisionMethod · 0.80
removeMethod · 0.45
is_emptyMethod · 0.45
clearMethod · 0.45