fix major perf regression from modal menus getting sections. need to

call draw_queued for text once per frame, otherwise cache gets ruined
This commit is contained in:
Dustin Carlino 2019-07-26 15:52:10 +02:00
parent 3c2d794c62
commit 84ac102d05
4 changed files with 28 additions and 4 deletions

View File

@ -707,3 +707,20 @@ transitions... pop current state, push some new state, replace current state
I don't want to wind up with the mess of plugins again. Why am I sure it's not that?
- these are complete, mutex states
## Text
What's slow right now?
- drawing the rectangles?
- forming the Text?
- doing the draw_queued flush?
Simpler ideas for speedup:
= only one draw_queued flush, to preserve caching behavior!
- batch fork/unfork and all the rectangles? maybe not needed for modal menu
- detect state changes in ModalMenu, recreate Drawable thing only when needed
Current stack:
- https://docs.rs/glium-glyph/0.3.0/glium_glyph/
- https://docs.rs/glyph_brush/0.4.0/glyph_brush/
- https://docs.rs/rusttype/0.7.7/rusttype/

View File

@ -220,6 +220,10 @@ impl<'a> LoadingScreen<'a> {
&txt,
(HorizontalAlignment::Center, VerticalAlignment::Center),
);
self.canvas
.glyphs
.borrow_mut()
.draw_queued(self.prerender.display, &mut target);
target.finish().unwrap();
}
}

View File

@ -122,6 +122,13 @@ impl<G: GUI> State<G> {
menu.draw(&mut g);
}
// Flush text just once, so that GlyphBrush's internal caching works. We have to assume
// nothing will ever cover up text.
self.canvas
.glyphs
.borrow_mut()
.draw_queued(display, &mut target);
target.finish().unwrap();
naming_hint
}

View File

@ -239,10 +239,6 @@ pub fn draw_text_bubble(
y += height;
g.canvas.glyphs.borrow_mut().queue(section);
}
g.canvas
.glyphs
.borrow_mut()
.draw_queued(g.display, g.target);
g.unfork();