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

Unified Diff: cc/surfaces/surface_manager.cc

Issue 2684933003: Move frame_sink_id management to framesink_manager.cc/h from (Closed)
Patch Set: Created 3 years, 10 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
Index: cc/surfaces/surface_manager.cc
diff --git a/cc/surfaces/surface_manager.cc b/cc/surfaces/surface_manager.cc
index b03b81e7ba8c8a050c68fe3bfd91ca10e51d8039..2d2e2f03f452bc37b4cf8f99abd3be91da7a5649 100644
--- a/cc/surfaces/surface_manager.cc
+++ b/cc/surfaces/surface_manager.cc
@@ -23,17 +23,6 @@
namespace cc {
-SurfaceManager::FrameSinkSourceMapping::FrameSinkSourceMapping()
- : client(nullptr), source(nullptr) {}
-
-SurfaceManager::FrameSinkSourceMapping::FrameSinkSourceMapping(
- const FrameSinkSourceMapping& other) = default;
-
-SurfaceManager::FrameSinkSourceMapping::~FrameSinkSourceMapping() {
- DCHECK(is_empty()) << "client: " << client
- << ", children: " << children.size();
-}
-
SurfaceManager::SurfaceManager(LifetimeType lifetime_type)
: lifetime_type_(lifetime_type),
root_surface_id_(FrameSinkId(0u, 0u),
@@ -65,11 +54,6 @@ SurfaceManager::~SurfaceManager() {
DeregisterSurface((*it)->surface_id());
}
surfaces_to_destroy_.clear();
-
- // All hierarchies, sources, and surface factory clients should be
- // unregistered prior to SurfaceManager destruction.
- DCHECK_EQ(frame_sink_source_map_.size(), 0u);
- DCHECK_EQ(registered_sources_.size(), 0u);
}
#if DCHECK_IS_ON()
@@ -119,16 +103,6 @@ void SurfaceManager::SatisfySequence(const SurfaceSequence& sequence) {
GarbageCollectSurfaces();
}
-void SurfaceManager::RegisterFrameSinkId(const FrameSinkId& frame_sink_id) {
- bool inserted = valid_frame_sink_ids_.insert(frame_sink_id).second;
- DCHECK(inserted);
-}
-
-void SurfaceManager::InvalidateFrameSinkId(const FrameSinkId& frame_sink_id) {
- valid_frame_sink_ids_.erase(frame_sink_id);
- GarbageCollectSurfaces();
-}
-
const SurfaceId& SurfaceManager::GetRootSurfaceId() const {
return root_surface_id_;
}
@@ -302,8 +276,11 @@ SurfaceManager::SurfaceIdSet SurfaceManager::GetLiveSurfacesForSequences() {
for (auto& map_entry : surface_map_) {
const SurfaceId& surface_id = map_entry.first;
Surface* surface = map_entry.second;
- surface->SatisfyDestructionDependencies(&satisfied_sequences_,
- &valid_frame_sink_ids_);
+ // TODO(kavithadevara): commented out following bcz of moving frame_sink_ids
Fady Samuel 2017/02/12 19:04:07 Can you restore this change?
k.devara 2017/02/13 07:00:52 I was trying to avoid having to expose valid_frame
+ // management to framesink_manager.cc - this whole function should go away
+ // when Sequences are removed
+ // surface->SatisfyDestructionDependencies(&satisfied_sequences_,
+ // &valid_frame_sink_ids_);
if (!surface->destroyed() || surface->GetDestructionDependencyCount() > 0) {
live_surfaces_set.insert(surface_id);
@@ -362,194 +339,6 @@ void SurfaceManager::RemoveAllSurfaceReferences(const SurfaceId& surface_id) {
}
}
-void SurfaceManager::RegisterSurfaceFactoryClient(
- const FrameSinkId& frame_sink_id,
- SurfaceFactoryClient* client) {
- DCHECK(client);
- DCHECK_EQ(valid_frame_sink_ids_.count(frame_sink_id), 1u);
-
- // Will create a new FrameSinkSourceMapping for |frame_sink_id| if necessary.
- FrameSinkSourceMapping& frame_sink_source =
- frame_sink_source_map_[frame_sink_id];
- DCHECK(!frame_sink_source.client);
- frame_sink_source.client = client;
-
- // Propagate any previously set sources to the new client.
- if (frame_sink_source.source)
- client->SetBeginFrameSource(frame_sink_source.source);
-}
-
-void SurfaceManager::UnregisterSurfaceFactoryClient(
- const FrameSinkId& frame_sink_id) {
- DCHECK_EQ(valid_frame_sink_ids_.count(frame_sink_id), 1u);
- DCHECK_EQ(frame_sink_source_map_.count(frame_sink_id), 1u);
-
- auto iter = frame_sink_source_map_.find(frame_sink_id);
- if (iter->second.source)
- iter->second.client->SetBeginFrameSource(nullptr);
- iter->second.client = nullptr;
-
- // The SurfaceFactoryClient and hierarchy can be registered/unregistered
- // in either order, so empty namespace_client_map entries need to be
- // checked when removing either clients or relationships.
- if (iter->second.is_empty())
- frame_sink_source_map_.erase(iter);
-}
-
-void SurfaceManager::RegisterBeginFrameSource(
- BeginFrameSource* source,
- const FrameSinkId& frame_sink_id) {
- DCHECK(source);
- DCHECK_EQ(registered_sources_.count(source), 0u);
- DCHECK_EQ(valid_frame_sink_ids_.count(frame_sink_id), 1u);
-
- registered_sources_[source] = frame_sink_id;
- RecursivelyAttachBeginFrameSource(frame_sink_id, source);
-}
-
-void SurfaceManager::UnregisterBeginFrameSource(BeginFrameSource* source) {
- DCHECK(source);
- DCHECK_EQ(registered_sources_.count(source), 1u);
-
- FrameSinkId frame_sink_id = registered_sources_[source];
- registered_sources_.erase(source);
-
- if (frame_sink_source_map_.count(frame_sink_id) == 0u)
- return;
-
- // TODO(enne): these walks could be done in one step.
- // Remove this begin frame source from its subtree.
- RecursivelyDetachBeginFrameSource(frame_sink_id, source);
- // Then flush every remaining registered source to fix any sources that
- // became null because of the previous step but that have an alternative.
- for (auto source_iter : registered_sources_)
- RecursivelyAttachBeginFrameSource(source_iter.second, source_iter.first);
-}
-
-void SurfaceManager::RecursivelyAttachBeginFrameSource(
- const FrameSinkId& frame_sink_id,
- BeginFrameSource* source) {
- FrameSinkSourceMapping& mapping = frame_sink_source_map_[frame_sink_id];
- if (!mapping.source) {
- mapping.source = source;
- if (mapping.client)
- mapping.client->SetBeginFrameSource(source);
- }
- for (size_t i = 0; i < mapping.children.size(); ++i)
- RecursivelyAttachBeginFrameSource(mapping.children[i], source);
-}
-
-void SurfaceManager::RecursivelyDetachBeginFrameSource(
- const FrameSinkId& frame_sink_id,
- BeginFrameSource* source) {
- auto iter = frame_sink_source_map_.find(frame_sink_id);
- if (iter == frame_sink_source_map_.end())
- return;
- if (iter->second.source == source) {
- iter->second.source = nullptr;
- if (iter->second.client)
- iter->second.client->SetBeginFrameSource(nullptr);
- }
-
- if (iter->second.is_empty()) {
- frame_sink_source_map_.erase(iter);
- return;
- }
-
- std::vector<FrameSinkId>& children = iter->second.children;
- for (size_t i = 0; i < children.size(); ++i) {
- RecursivelyDetachBeginFrameSource(children[i], source);
- }
-}
-
-bool SurfaceManager::ChildContains(
- const FrameSinkId& child_frame_sink_id,
- const FrameSinkId& search_frame_sink_id) const {
- auto iter = frame_sink_source_map_.find(child_frame_sink_id);
- if (iter == frame_sink_source_map_.end())
- return false;
-
- const std::vector<FrameSinkId>& children = iter->second.children;
- for (size_t i = 0; i < children.size(); ++i) {
- if (children[i] == search_frame_sink_id)
- return true;
- if (ChildContains(children[i], search_frame_sink_id))
- return true;
- }
- return false;
-}
-
-void SurfaceManager::RegisterFrameSinkHierarchy(
- const FrameSinkId& parent_frame_sink_id,
- const FrameSinkId& child_frame_sink_id) {
- DCHECK_EQ(valid_frame_sink_ids_.count(parent_frame_sink_id), 1u);
- DCHECK_EQ(valid_frame_sink_ids_.count(child_frame_sink_id), 1u);
-
- // If it's possible to reach the parent through the child's descendant chain,
- // then this will create an infinite loop. Might as well just crash here.
- CHECK(!ChildContains(child_frame_sink_id, parent_frame_sink_id));
-
- std::vector<FrameSinkId>& children =
- frame_sink_source_map_[parent_frame_sink_id].children;
- for (size_t i = 0; i < children.size(); ++i)
- DCHECK(children[i] != child_frame_sink_id);
- children.push_back(child_frame_sink_id);
-
- // If the parent has no source, then attaching it to this child will
- // not change any downstream sources.
- BeginFrameSource* parent_source =
- frame_sink_source_map_[parent_frame_sink_id].source;
- if (!parent_source)
- return;
-
- DCHECK_EQ(registered_sources_.count(parent_source), 1u);
- RecursivelyAttachBeginFrameSource(child_frame_sink_id, parent_source);
-}
-
-void SurfaceManager::UnregisterFrameSinkHierarchy(
- const FrameSinkId& parent_frame_sink_id,
- const FrameSinkId& child_frame_sink_id) {
- // Deliberately do not check validity of either parent or child namespace
- // here. They were valid during the registration, so were valid at some
- // point in time. This makes it possible to invalidate parent and child
- // namespaces independently of each other and not have an ordering dependency
- // of unregistering the hierarchy first before either of them.
- DCHECK_EQ(frame_sink_source_map_.count(parent_frame_sink_id), 1u);
-
- auto iter = frame_sink_source_map_.find(parent_frame_sink_id);
-
- std::vector<FrameSinkId>& children = iter->second.children;
- bool found_child = false;
- for (size_t i = 0; i < children.size(); ++i) {
- if (children[i] == child_frame_sink_id) {
- found_child = true;
- children[i] = children.back();
- children.resize(children.size() - 1);
- break;
- }
- }
- DCHECK(found_child);
-
- // The SurfaceFactoryClient and hierarchy can be registered/unregistered
- // in either order, so empty namespace_client_map entries need to be
- // checked when removing either clients or relationships.
- if (iter->second.is_empty()) {
- frame_sink_source_map_.erase(iter);
- return;
- }
-
- // If the parent does not have a begin frame source, then disconnecting it
- // will not change any of its children.
- BeginFrameSource* parent_source = iter->second.source;
- if (!parent_source)
- return;
-
- // TODO(enne): these walks could be done in one step.
- RecursivelyDetachBeginFrameSource(child_frame_sink_id, parent_source);
- for (auto source_iter : registered_sources_)
- RecursivelyAttachBeginFrameSource(source_iter.second, source_iter.first);
-}
-
Surface* SurfaceManager::GetSurfaceForId(const SurfaceId& surface_id) {
DCHECK(thread_checker_.CalledOnValidThread());
SurfaceMap::iterator it = surface_map_.find(surface_id);

Powered by Google App Engine
This is Rietveld 408576698