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

Unified Diff: cc/surfaces/surface_manager.cc

Issue 2685393003: Surfaces: Allow parent to refer to child surfaces that don't exist yet. (Closed)
Patch Set: Added unit test 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 f7e3119eb375b978ff7be255e5a77231f57dc509..d0c8afaf43156b482d95fa78711acad90011f066 100644
--- a/cc/surfaces/surface_manager.cc
+++ b/cc/surfaces/surface_manager.cc
@@ -156,21 +156,13 @@ void SurfaceManager::AddSurfaceReference(const SurfaceId& parent_id,
return;
}
- // We trust that |parent_id| either exists or is about to exist, since is not
- // sent over IPC. We don't trust |child_id|, since it is sent over IPC.
- if (surface_map_.count(child_id) == 0) {
- DLOG(ERROR) << "No surface in map for " << child_id.ToString();
- return;
- }
-
// There could be a temporary reference to |child_id| which we should now
// remove because a real reference is being added to it. To find out whether
// or not a temporary reference exists, we need to first look up the
// FrameSinkId of |child_id| in |temp_references_|, which returns a vector of
// LocalSurfaceIds, and then search for the LocalSurfaceId of |child_id| in
- // the
- // said vector. If there is no temporary reference, we can immediately add the
- // reference from |parent_id| and return.
+ // the said vector. If there is no temporary reference, we can immediately add
+ // the reference from |parent_id| and return.
auto refs_iter = temp_references_.find(child_id.frame_sink_id());
if (refs_iter == temp_references_.end()) {
AddSurfaceReferenceImpl(parent_id, child_id);
@@ -582,15 +574,19 @@ void SurfaceManager::SurfaceCreated(const SurfaceInfo& surface_info) {
CHECK(thread_checker_.CalledOnValidThread());
if (lifetime_type_ == LifetimeType::REFERENCES) {
- // We can get into a situation where multiple CompositorFrames arrive for a
- // CompositorFrameSink before the client can add any references for the
+ // We can get into a situation where multiple CompositorFrames arrive for
+ // a CompositorFrameSink before the client can add any references for the
// frame. When the second frame with a new size arrives, the first will be
// destroyed in SurfaceFactory and then if there are no references it will
- // be deleted during surface GC. A temporary reference, removed when a real
- // reference is received, is added to prevent this from happening.
- AddSurfaceReferenceImpl(GetRootSurfaceId(), surface_info.id());
- temp_references_[surface_info.id().frame_sink_id()].push_back(
- surface_info.id().local_surface_id());
+ // be deleted during surface GC. A temporary reference, removed when a
+ // real reference is received, is added to prevent this from happening.
+ bool has_real_reference = child_to_parent_refs_.find(surface_info.id()) !=
kylechar 2017/02/10 19:51:27 It's a map from SurfaceId -> unordered_set<Surface
Fady Samuel 2017/02/10 20:39:10 Done.
+ child_to_parent_refs_.end();
+ if (!has_real_reference) {
+ AddSurfaceReferenceImpl(GetRootSurfaceId(), surface_info.id());
+ temp_references_[surface_info.id().frame_sink_id()].push_back(
+ surface_info.id().local_surface_id());
+ }
}
for (auto& observer : observer_list_)
« cc/surfaces/compositor_frame_sink_support_unittest.cc ('K') | « cc/surfaces/surface_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698