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

Side by Side Diff: cc/surfaces/surface_manager.cc

Issue 2676373004: Implement service-side surface synchronization (Closed)
Patch Set: DisplayCompositorLockManager => SurfaceDependencyTracker. Added More Comments 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/surfaces/surface_manager.h" 5 #include "cc/surfaces/surface_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <queue> 10 #include <queue>
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 73 }
74 74
75 #if DCHECK_IS_ON() 75 #if DCHECK_IS_ON()
76 std::string SurfaceManager::SurfaceReferencesToString() { 76 std::string SurfaceManager::SurfaceReferencesToString() {
77 std::stringstream str; 77 std::stringstream str;
78 SurfaceReferencesToStringImpl(root_surface_id_, "", &str); 78 SurfaceReferencesToStringImpl(root_surface_id_, "", &str);
79 return str.str(); 79 return str.str();
80 } 80 }
81 #endif 81 #endif
82 82
83 void SurfaceManager::SetDependencyTracker(
84 std::unique_ptr<SurfaceDependencyTracker> dependency_tracker) {
85 dependency_tracker_ = std::move(dependency_tracker);
86 }
87
88 void SurfaceManager::RequestSurfaceResolution(Surface* pending_surface) {
89 if (dependency_tracker_)
90 dependency_tracker_->RequestSurfaceResolution(pending_surface);
91 }
92
83 void SurfaceManager::RegisterSurface(Surface* surface) { 93 void SurfaceManager::RegisterSurface(Surface* surface) {
84 DCHECK(thread_checker_.CalledOnValidThread()); 94 DCHECK(thread_checker_.CalledOnValidThread());
85 DCHECK(surface); 95 DCHECK(surface);
86 DCHECK(!surface_map_.count(surface->surface_id())); 96 DCHECK(!surface_map_.count(surface->surface_id()));
87 surface_map_[surface->surface_id()] = surface; 97 surface_map_[surface->surface_id()] = surface;
88 } 98 }
89 99
90 void SurfaceManager::DeregisterSurface(const SurfaceId& surface_id) { 100 void SurfaceManager::DeregisterSurface(const SurfaceId& surface_id) {
91 DCHECK(thread_checker_.CalledOnValidThread()); 101 DCHECK(thread_checker_.CalledOnValidThread());
92 SurfaceMap::iterator it = surface_map_.find(surface_id); 102 SurfaceMap::iterator it = surface_map_.find(surface_id);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // Check some conditions that should never happen. We don't want to crash on 151 // Check some conditions that should never happen. We don't want to crash on
142 // bad input from a compromised client so just return early. 152 // bad input from a compromised client so just return early.
143 if (parent_id.frame_sink_id() == child_id.frame_sink_id()) { 153 if (parent_id.frame_sink_id() == child_id.frame_sink_id()) {
144 DLOG(ERROR) << "Cannot add self reference from " << parent_id << " to " 154 DLOG(ERROR) << "Cannot add self reference from " << parent_id << " to "
145 << child_id; 155 << child_id;
146 return; 156 return;
147 } 157 }
148 158
149 // We trust that |parent_id| either exists or is about to exist, since is not 159 // We trust that |parent_id| either exists or is about to exist, since is not
150 // sent over IPC. We don't trust |child_id|, since it is sent over IPC. 160 // sent over IPC. We don't trust |child_id|, since it is sent over IPC.
151 if (surface_map_.count(child_id) == 0) { 161 // if (surface_map_.count(child_id) == 0) {
vmpstr 2017/02/07 22:46:20 <_<
Fady Samuel 2017/02/08 00:52:50 Heh fixed in a later patchset. Sorry about that.
152 DLOG(ERROR) << "No surface in map for " << child_id.ToString(); 162 // DLOG(ERROR) << "No surface in map for " << child_id.ToString();
153 return; 163 // return;
154 } 164 //}
155 165
156 // There could be a temporary reference to |child_id| which we should now 166 // There could be a temporary reference to |child_id| which we should now
157 // remove because a real reference is being added to it. To find out whether 167 // remove because a real reference is being added to it. To find out whether
158 // or not a temporary reference exists, we need to first look up the 168 // or not a temporary reference exists, we need to first look up the
159 // FrameSinkId of |child_id| in |temp_references_|, which returns a vector of 169 // FrameSinkId of |child_id| in |temp_references_|, which returns a vector of
160 // LocalSurfaceIds, and then search for the LocalSurfaceId of |child_id| in 170 // LocalSurfaceIds, and then search for the LocalSurfaceId of |child_id| in
161 // the 171 // the
162 // said vector. If there is no temporary reference, we can immediately add the 172 // said vector. If there is no temporary reference, we can immediately add the
163 // reference from |parent_id| and return. 173 // reference from |parent_id| and return.
164 auto refs_iter = temp_references_.find(child_id.frame_sink_id()); 174 auto refs_iter = temp_references_.find(child_id.frame_sink_id());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 // Check if we have the reference that is requested to be removed. We don't 220 // Check if we have the reference that is requested to be removed. We don't
211 // want to crash on bad input from a compromised client so just return early. 221 // want to crash on bad input from a compromised client so just return early.
212 if (parent_to_child_refs_.count(parent_id) == 0 || 222 if (parent_to_child_refs_.count(parent_id) == 0 ||
213 parent_to_child_refs_[parent_id].count(child_id) == 0) { 223 parent_to_child_refs_[parent_id].count(child_id) == 0) {
214 DLOG(ERROR) << "No reference from " << parent_id.ToString() << " to " 224 DLOG(ERROR) << "No reference from " << parent_id.ToString() << " to "
215 << child_id.ToString(); 225 << child_id.ToString();
216 return; 226 return;
217 } 227 }
218 228
219 RemoveSurfaceReferenceImpl(parent_id, child_id); 229 RemoveSurfaceReferenceImpl(parent_id, child_id);
230 GarbageCollectSurfaces();
220 } 231 }
221 232
222 void SurfaceManager::AddSurfaceReferences( 233 void SurfaceManager::AddSurfaceReferences(
223 const std::vector<SurfaceReference>& references) { 234 const std::vector<SurfaceReference>& references) {
224 DCHECK(thread_checker_.CalledOnValidThread()); 235 DCHECK(thread_checker_.CalledOnValidThread());
225 236
226 for (const auto& reference : references) 237 for (const auto& reference : references)
227 AddSurfaceReference(reference.parent_id(), reference.child_id()); 238 AddSurfaceReference(reference.parent_id(), reference.child_id());
228 } 239 }
229 240
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 std::string indent, 601 std::string indent,
591 std::stringstream* str) { 602 std::stringstream* str) {
592 *str << indent; 603 *str << indent;
593 604
594 // Print the current line for |surface_id|. 605 // Print the current line for |surface_id|.
595 Surface* surface = GetSurfaceForId(surface_id); 606 Surface* surface = GetSurfaceForId(surface_id);
596 if (surface) { 607 if (surface) {
597 *str << surface->surface_id().ToString(); 608 *str << surface->surface_id().ToString();
598 *str << (surface->destroyed() ? " destroyed " : " live "); 609 *str << (surface->destroyed() ? " destroyed " : " live ");
599 610
611 if (surface->GetPendingFrame().has_value()) {
612 // This provides the surface size from the root render pass.
613 const CompositorFrame& frame = surface->GetPendingFrame().value();
614 *str << "pending "
615 << frame.render_pass_list.back()->output_rect.size().ToString()
616 << " ";
617 }
618
600 if (surface->HasFrame()) { 619 if (surface->HasFrame()) {
601 // This provides the surface size from the root render pass. 620 // This provides the surface size from the root render pass.
602 const CompositorFrame& frame = surface->GetEligibleFrame(); 621 const CompositorFrame& frame = surface->GetEligibleFrame();
603 *str << frame.render_pass_list.back()->output_rect.size().ToString(); 622 *str << "active "
623 << frame.render_pass_list.back()->output_rect.size().ToString();
604 } 624 }
605 } else { 625 } else {
606 *str << surface_id; 626 *str << surface_id;
607 } 627 }
608 *str << "\n"; 628 *str << "\n";
609 629
610 // If the current surface has references to children, sort children and print 630 // If the current surface has references to children, sort children and print
611 // references for each child. 631 // references for each child.
612 auto iter = parent_to_child_refs_.find(surface_id); 632 auto iter = parent_to_child_refs_.find(surface_id);
613 if (iter != parent_to_child_refs_.end()) { 633 if (iter != parent_to_child_refs_.end()) {
614 std::vector<SurfaceId> children(iter->second.begin(), iter->second.end()); 634 std::vector<SurfaceId> children(iter->second.begin(), iter->second.end());
615 std::sort(children.begin(), children.end()); 635 std::sort(children.begin(), children.end());
616 636
617 for (const SurfaceId& child_id : children) 637 for (const SurfaceId& child_id : children)
618 SurfaceReferencesToStringImpl(child_id, indent + " ", str); 638 SurfaceReferencesToStringImpl(child_id, indent + " ", str);
619 } 639 }
620 } 640 }
621 #endif // DCHECK_IS_ON() 641 #endif // DCHECK_IS_ON()
622 642
623 } // namespace cc 643 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698