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

Unified Diff: cc/surfaces/surface_manager.cc

Issue 2144733005: [WIP] cc: Plumb SurfaceId from clients Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ensure only SurfaceFactoy and tests can update hierarchy Created 4 years, 5 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_manager.h ('k') | cc/surfaces/surface_manager_unittest.cc » ('j') | 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 e34bb63a40970e6632440d6c40eede3b1f5e61b1..85c33f3c65885c8d4f8c3a4c10aca118d0c3dd5e 100644
--- a/cc/surfaces/surface_manager.cc
+++ b/cc/surfaces/surface_manager.cc
@@ -47,14 +47,16 @@ SurfaceManager::~SurfaceManager() {
void SurfaceManager::RegisterSurface(Surface* surface) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(surface);
- DCHECK(!surface_map_.count(surface->surface_id()));
+ // We may submit a new CompositorFrame with the same surface ID
+ // before the previous one has been garbage collected.
surface_map_[surface->surface_id()] = surface;
}
void SurfaceManager::DeregisterSurface(const SurfaceId& surface_id) {
DCHECK(thread_checker_.CalledOnValidThread());
SurfaceMap::iterator it = surface_map_.find(surface_id);
- DCHECK(it != surface_map_.end());
+ if (it == surface_map_.end())
+ return;
surface_map_.erase(it);
}
@@ -77,16 +79,6 @@ void SurfaceManager::DidSatisfySequences(uint32_t client_id,
GarbageCollectSurfaces();
}
-void SurfaceManager::RegisterSurfaceClientId(uint32_t client_id) {
- bool inserted = valid_surface_client_ids_.insert(client_id).second;
- DCHECK(inserted);
-}
-
-void SurfaceManager::InvalidateSurfaceClientId(uint32_t client_id) {
- valid_surface_client_ids_.erase(client_id);
- GarbageCollectSurfaces();
-}
-
void SurfaceManager::GarbageCollectSurfaces() {
// Simple mark and sweep GC.
// TODO(jbauman): Reduce the amount of work when nothing needs to be
@@ -142,12 +134,12 @@ void SurfaceManager::GarbageCollectSurfaces() {
to_destroy.clear();
}
-void SurfaceManager::RegisterSurfaceFactoryClient(
- uint32_t client_id,
- SurfaceFactoryClient* client) {
+void SurfaceManager::RegisterClient(uint32_t client_id,
+ SurfaceFactoryClient* client) {
DCHECK(client);
+ bool inserted = valid_surface_client_ids_.insert(client_id).second;
+ DCHECK(inserted);
DCHECK(!namespace_client_map_[client_id].client);
- DCHECK_EQ(valid_surface_client_ids_.count(client_id), 1u);
auto iter = namespace_client_map_.find(client_id);
if (iter == namespace_client_map_.end()) {
@@ -163,7 +155,7 @@ void SurfaceManager::RegisterSurfaceFactoryClient(
client->SetBeginFrameSource(iter->second.source);
}
-void SurfaceManager::UnregisterSurfaceFactoryClient(uint32_t client_id) {
+void SurfaceManager::UnregisterClient(uint32_t client_id) {
DCHECK_EQ(valid_surface_client_ids_.count(client_id), 1u);
DCHECK_EQ(namespace_client_map_.count(client_id), 1u);
@@ -177,6 +169,9 @@ void SurfaceManager::UnregisterSurfaceFactoryClient(uint32_t client_id) {
// checked when removing either clients or relationships.
if (iter->second.is_empty())
namespace_client_map_.erase(iter);
+
+ valid_surface_client_ids_.erase(client_id);
+ GarbageCollectSurfaces();
}
void SurfaceManager::RegisterBeginFrameSource(BeginFrameSource* source,
« no previous file with comments | « cc/surfaces/surface_manager.h ('k') | cc/surfaces/surface_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698