1
0
Fork 0

gl_rasterizer_cache: unlink watchers if surface is moved to remove_surfaces but is not immediately removed

This commit is contained in:
wwylele 2018-07-24 23:18:36 +03:00 committed by Weiyi Wang
parent 777af04f4a
commit ebdef4fd69
2 changed files with 11 additions and 0 deletions

View File

@ -1300,6 +1300,7 @@ SurfaceRect_Tuple RasterizerCacheOpenGL::GetSurfaceSubRect(const SurfaceParams&
// Delete the expanded surface, this can't be done safely yet // Delete the expanded surface, this can't be done safely yet
// because it may still be in use // because it may still be in use
surface->UnlinkAllWatcher(); // unlink watchers as if this surface is already deleted
remove_surfaces.emplace(surface); remove_surfaces.emplace(surface);
surface = new_surface; surface = new_surface;

View File

@ -397,6 +397,16 @@ struct CachedSurface : SurfaceParams, std::enable_shared_from_this<CachedSurface
} }
} }
void UnlinkAllWatcher() {
for (const auto& watcher : watchers) {
if (auto locked = watcher.lock()) {
locked->valid = false;
locked->surface.reset();
}
}
watchers.clear();
}
private: private:
std::list<std::weak_ptr<SurfaceWatcher>> watchers; std::list<std::weak_ptr<SurfaceWatcher>> watchers;
}; };