Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1364)

Unified Diff: cc/surfaces/surface_manager.cc

Issue 2760433002: SurfaceManager::CreateSurface must set the surface's factory (Closed)
Patch Set: Reset Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/surfaces/surface.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/surfaces/surface_manager.cc
diff --git a/cc/surfaces/surface_manager.cc b/cc/surfaces/surface_manager.cc
index 753191d7460be547e751b117afe584ad3734c89b..dbeb15279d5822e4122c669ac279c627b2ad4228 100644
--- a/cc/surfaces/surface_manager.cc
+++ b/cc/surfaces/surface_manager.cc
@@ -122,12 +122,24 @@ std::unique_ptr<Surface> SurfaceManager::CreateSurface(
std::unique_ptr<Surface> surface = std::move(*it);
surfaces_to_destroy_.erase(it);
surface->set_destroyed(false);
+ // If the surface was used by another factory, we should update its factory.
+ // The old frames must be evicted because the new factory is not capable of
+ // returning their resources.
+ // TODO(samans): This should not be necessary once crbug.com/701988 is fixed.
+ if (surface->factory() == nullptr) {
+ DLOG(ERROR) << "Surface is being reused by another factory. "
+ "Resources can potentially leak. id="
+ << surface_id;
+ surface->Reset();
+ surface->set_factory(surface_factory);
+ }
DCHECK_EQ(surface_factory.get(), surface->factory().get());
return surface;
}
void SurfaceManager::DestroySurface(std::unique_ptr<Surface> surface) {
DCHECK(thread_checker_.CalledOnValidThread());
+
surface->set_destroyed(true);
surfaces_to_destroy_.push_back(std::move(surface));
GarbageCollectSurfaces();
« no previous file with comments | « cc/surfaces/surface.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698