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

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

Issue 2582823002: WIP: Surface Synchronization System
Patch Set: Only create ClientSurfaceEmbedder if window is visible. Trash it otherwise. Created 3 years, 11 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::SetLockManager(
84 std::unique_ptr<DisplayCompositorLockManager> lock_manager) {
85 lock_manager_ = std::move(lock_manager);
86 }
87
88 void SurfaceManager::RequestSurfaceResolution(Surface* pending_surface) {
89 if (lock_manager_)
90 lock_manager_->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 == child_id) { 153 if (parent_id == child_id) {
144 DLOG(ERROR) << "Cannot add self reference for " << parent_id.ToString(); 154 DLOG(ERROR) << "Cannot add self reference for " << parent_id.ToString();
145 return; 155 return;
146 } 156 }
147 if (parent_id != root_surface_id_ && surface_map_.count(parent_id) == 0) { 157 if (parent_id != root_surface_id_ && surface_map_.count(parent_id) == 0) {
148 DLOG(ERROR) << "No surface in map for " << parent_id.ToString(); 158 DLOG(ERROR) << "No surface in map for " << parent_id.ToString();
149 return; 159 return;
150 } 160 }
151 if (surface_map_.count(child_id) == 0) { 161 // if (surface_map_.count(child_id) == 0) {
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 // LocalFrameIds, and then search for the LocalFrameId of |child_id| in the 170 // LocalFrameIds, and then search for the LocalFrameId of |child_id| in the
161 // said vector. If there is no temporary reference, we can immediately add the 171 // said vector. If there is no temporary reference, we can immediately add the
162 // reference from |parent_id| and return. 172 // reference from |parent_id| and return.
163 auto refs_iter = temp_references_.find(child_id.frame_sink_id()); 173 auto refs_iter = temp_references_.find(child_id.frame_sink_id());
164 if (refs_iter == temp_references_.end()) { 174 if (refs_iter == temp_references_.end()) {
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 std::vector<SurfaceId> children(iter->second.begin(), iter->second.end()); 636 std::vector<SurfaceId> children(iter->second.begin(), iter->second.end());
627 std::sort(children.begin(), children.end()); 637 std::sort(children.begin(), children.end());
628 638
629 for (const SurfaceId& child_id : children) 639 for (const SurfaceId& child_id : children)
630 SurfaceReferencesToStringImpl(child_id, indent + " ", str); 640 SurfaceReferencesToStringImpl(child_id, indent + " ", str);
631 } 641 }
632 } 642 }
633 #endif // DCHECK_IS_ON() 643 #endif // DCHECK_IS_ON()
634 644
635 } // namespace cc 645 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698