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

Unified Diff: cc/surfaces/surface_manager.cc

Issue 2541683004: Add/remove surface references via MojoCompositorFrameSink. (Closed)
Patch Set: WIP Created 4 years 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 b95954aab2659af9264ca1d6977304f64427dfd8..0be1c33f12d26c8eb76a6bd62bb909fbb79bba60 100644
--- a/cc/surfaces/surface_manager.cc
+++ b/cc/surfaces/surface_manager.cc
@@ -28,8 +28,8 @@ SurfaceManager::FrameSinkSourceMapping::~FrameSinkSourceMapping() {
}
SurfaceManager::SurfaceManager()
- : kRootSurfaceId(FrameSinkId(0u, 0u),
- LocalFrameId(0u, base::UnguessableToken::Create())) {
+ : root_surface_id_(FrameSinkId(0u, 0u),
+ LocalFrameId(1u, base::UnguessableToken::Create())) {
thread_checker_.DetachFromThread();
}
@@ -91,7 +91,7 @@ void SurfaceManager::InvalidateFrameSinkId(const FrameSinkId& frame_sink_id) {
}
const SurfaceId& SurfaceManager::GetRootSurfaceId() const {
- return kRootSurfaceId;
+ return root_surface_id_;
}
void SurfaceManager::AddSurfaceReference(const SurfaceId& parent_id,
@@ -102,15 +102,15 @@ void SurfaceManager::AddSurfaceReference(const SurfaceId& parent_id,
// bad input from a compromised client so just return early.
if (parent_id == child_id) {
LOG(ERROR) << "Cannot add self reference for " << parent_id.ToString();
- return;
+ NOTREACHED();
}
- if (parent_id != kRootSurfaceId && surface_map_.count(parent_id) == 0) {
+ if (parent_id != root_surface_id_ && surface_map_.count(parent_id) == 0) {
LOG(ERROR) << "No surface in map for " << parent_id.ToString();
- return;
+ NOTREACHED();
}
if (surface_map_.count(child_id) == 0) {
LOG(ERROR) << "No surface in map for " << child_id.ToString();
- return;
+ NOTREACHED();
}
parent_to_child_refs_[parent_id].insert(child_id);
@@ -127,13 +127,19 @@ void SurfaceManager::RemoveSurfaceReference(const SurfaceId& parent_id,
parent_to_child_refs_[parent_id].count(child_id) == 0) {
LOG(ERROR) << "No reference from " << parent_id.ToString() << " to "
<< child_id.ToString();
- return;
+ NOTREACHED();
}
RemoveSurfaceReferenceImpl(parent_id, child_id);
GarbageCollectSurfaces();
}
+void SurfaceManager::PrintReferenceTree(const std::string& name) {
+ std::string str = "PrintReferenceTree[" + name + "]\n";
+ PrintReferenceTreeImpl(root_surface_id_, " ", &str);
+ LOG(ERROR) << str;
+}
+
size_t SurfaceManager::GetSurfaceReferenceCount(
const SurfaceId& surface_id) const {
auto iter = child_to_parent_refs_.find(surface_id);
@@ -150,6 +156,37 @@ size_t SurfaceManager::GetReferencedSurfaceCount(
return iter->second.size();
}
+void SurfaceManager::PrintReferenceTreeImpl(const SurfaceId& surface_id,
+ std::string indent,
+ std::string* str) {
+ Surface* surface = GetSurfaceForId(surface_id);
+ std::string description;
+ if (surface) {
+ if (surface->destroyed())
+ description = " destroyed ";
+ else
+ description = " live ";
+
+ if (surface->HasFrame()) {
+ description += surface->GetEligibleFrame()
+ .render_pass_list[0]
+ ->output_rect.size()
+ .ToString();
+ }
+ }
+
+ *str += indent + surface_id.ToString() + description + "\n";
+ auto iter = parent_to_child_refs_.find(surface_id);
+ if (iter != parent_to_child_refs_.end()) {
+ const SurfaceIdSet& children = iter->second;
+ std::vector<SurfaceId> list(children.begin(), children.end());
+ std::sort(list.begin(), list.end());
+ for (const SurfaceId& child_id : list) {
+ PrintReferenceTreeImpl(child_id, indent + " ", str);
+ }
+ }
+}
+
void SurfaceManager::GarbageCollectSurfaces() {
// Simple mark and sweep GC.
// TODO(jbauman): Reduce the amount of work when nothing needs to be

Powered by Google App Engine
This is Rietveld 408576698