Fix disappearing images or panics when hiding and showing a window with wayland

Properly release GL resource when unmapping a window and detect stale
cache indices using a generation count. This fixes the disappearing
images (GL textures would be invalid and need to be re-created) as well
as the panics when an item's cache index ended up being re-used because
some other item was drawn first and allocated that indices. The latter
is fixed by using a generational counter on the cache that's bumped when
clearing, instead of a single "cache_ok" bool.
This commit is contained in:
Simon Hausmann 2021-05-28 09:11:03 +02:00
parent 9503ba69b3
commit d4385280eb
4 changed files with 64 additions and 10 deletions

View file

@ -209,6 +209,8 @@ impl GraphicsWindow {
/// Removes the window from the screen. The window is not destroyed though, it can be show (mapped) again later
/// by calling [`PlatformWindow::map_window`].
fn unmap_window(self: Rc<Self>) {
// Release GL textures and other GPU bound resources.
self.graphics_cache.borrow_mut().clear();
self.map_state.replace(GraphicsWindowBackendState::Unmapped);
/* FIXME:
if let Some(existing_blinker) = self.cursor_blinker.borrow().upgrade() {