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

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

Issue 2802023002: Remove SurfaceFactory And SurfaceFactoryClient (Closed)
Patch Set: Use range in for loop Created 3 years, 7 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/framesink_manager.h" 5 #include "cc/surfaces/framesink_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "cc/surfaces/framesink_manager_client.h" 11 #include "cc/surfaces/framesink_manager_client.h"
12 #include "cc/surfaces/surface_factory_client.h"
13 12
14 #if DCHECK_IS_ON() 13 #if DCHECK_IS_ON()
15 #include <sstream> 14 #include <sstream>
16 #endif 15 #endif
17 16
18 namespace cc { 17 namespace cc {
19 18
20 FrameSinkManager::FrameSinkSourceMapping::FrameSinkSourceMapping() 19 FrameSinkManager::FrameSinkSourceMapping::FrameSinkSourceMapping()
21 : source(nullptr) {} 20 : source(nullptr) {}
22 21
23 FrameSinkManager::FrameSinkSourceMapping::FrameSinkSourceMapping( 22 FrameSinkManager::FrameSinkSourceMapping::FrameSinkSourceMapping(
24 const FrameSinkSourceMapping& other) = default; 23 const FrameSinkSourceMapping& other) = default;
25 24
26 FrameSinkManager::FrameSinkSourceMapping::~FrameSinkSourceMapping() { 25 FrameSinkManager::FrameSinkSourceMapping::~FrameSinkSourceMapping() {
27 } 26 }
28 27
29 FrameSinkManager::FrameSinkManager() {} 28 FrameSinkManager::FrameSinkManager() {}
30 29
31 FrameSinkManager::~FrameSinkManager() { 30 FrameSinkManager::~FrameSinkManager() {
32 // All surface factory clients should be unregistered prior to SurfaceManager 31 // All CompositorFrameSinks should be unregistered prior to
33 // destruction. 32 // SurfaceManager destruction.
34 DCHECK_EQ(clients_.size(), 0u); 33 DCHECK_EQ(clients_.size(), 0u);
35 DCHECK_EQ(registered_sources_.size(), 0u); 34 DCHECK_EQ(registered_sources_.size(), 0u);
36 } 35 }
37 36
38 void FrameSinkManager::RegisterFrameSinkId(const FrameSinkId& frame_sink_id) { 37 void FrameSinkManager::RegisterFrameSinkId(const FrameSinkId& frame_sink_id) {
39 bool inserted = valid_frame_sink_ids_.insert(frame_sink_id).second; 38 bool inserted = valid_frame_sink_ids_.insert(frame_sink_id).second;
40 DCHECK(inserted); 39 DCHECK(inserted);
41 } 40 }
42 41
43 void FrameSinkManager::InvalidateFrameSinkId(const FrameSinkId& frame_sink_id) { 42 void FrameSinkManager::InvalidateFrameSinkId(const FrameSinkId& frame_sink_id) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 120
122 void FrameSinkManager::RecursivelyDetachBeginFrameSource( 121 void FrameSinkManager::RecursivelyDetachBeginFrameSource(
123 const FrameSinkId& frame_sink_id, 122 const FrameSinkId& frame_sink_id,
124 BeginFrameSource* source) { 123 BeginFrameSource* source) {
125 auto iter = frame_sink_source_map_.find(frame_sink_id); 124 auto iter = frame_sink_source_map_.find(frame_sink_id);
126 if (iter == frame_sink_source_map_.end()) 125 if (iter == frame_sink_source_map_.end())
127 return; 126 return;
128 if (iter->second.source == source) { 127 if (iter->second.source == source) {
129 iter->second.source = nullptr; 128 iter->second.source = nullptr;
130 auto client_iter = clients_.find(frame_sink_id); 129 auto client_iter = clients_.find(frame_sink_id);
131 if (client_iter != clients_.end()) 130 if (client_iter != clients_.end()) {
132 client_iter->second->SetBeginFrameSource(nullptr); 131 client_iter->second->SetBeginFrameSource(nullptr);
132 }
133 } 133 }
134 134
135 if (!iter->second.has_children() && !clients_.count(frame_sink_id)) { 135 if (!iter->second.has_children() && !clients_.count(frame_sink_id)) {
136 frame_sink_source_map_.erase(iter); 136 frame_sink_source_map_.erase(iter);
137 return; 137 return;
138 } 138 }
139 139
140 std::vector<FrameSinkId>& children = iter->second.children; 140 std::vector<FrameSinkId>& children = iter->second.children;
141 for (size_t i = 0; i < children.size(); ++i) { 141 for (size_t i = 0; i < children.size(); ++i) {
142 RecursivelyDetachBeginFrameSource(children[i], source); 142 RecursivelyDetachBeginFrameSource(children[i], source);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 for (size_t i = 0; i < children.size(); ++i) { 201 for (size_t i = 0; i < children.size(); ++i) {
202 if (children[i] == child_frame_sink_id) { 202 if (children[i] == child_frame_sink_id) {
203 found_child = true; 203 found_child = true;
204 children[i] = children.back(); 204 children[i] = children.back();
205 children.resize(children.size() - 1); 205 children.resize(children.size() - 1);
206 break; 206 break;
207 } 207 }
208 } 208 }
209 DCHECK(found_child); 209 DCHECK(found_child);
210 210
211 // The SurfaceFactoryClient and hierarchy can be registered/unregistered 211 // The CompositorFrameSinkSupport and hierarchy can be registered/unregistered
212 // in either order, so empty frame_sink_source_map entries need to be 212 // in either order, so empty frame_sink_source_map entries need to be
213 // checked when removing either clients or relationships. 213 // checked when removing either clients or relationships.
214 if (!iter->second.has_children() && !clients_.count(parent_frame_sink_id) && 214 if (!iter->second.has_children() && !clients_.count(parent_frame_sink_id) &&
215 !iter->second.source) { 215 !iter->second.source) {
216 frame_sink_source_map_.erase(iter); 216 frame_sink_source_map_.erase(iter);
217 return; 217 return;
218 } 218 }
219 219
220 // If the parent does not have a begin frame source, then disconnecting it 220 // If the parent does not have a begin frame source, then disconnecting it
221 // will not change any of its children. 221 // will not change any of its children.
222 BeginFrameSource* parent_source = iter->second.source; 222 BeginFrameSource* parent_source = iter->second.source;
223 if (!parent_source) 223 if (!parent_source)
224 return; 224 return;
225 225
226 // TODO(enne): these walks could be done in one step. 226 // TODO(enne): these walks could be done in one step.
227 RecursivelyDetachBeginFrameSource(child_frame_sink_id, parent_source); 227 RecursivelyDetachBeginFrameSource(child_frame_sink_id, parent_source);
228 for (auto source_iter : registered_sources_) 228 for (auto source_iter : registered_sources_)
229 RecursivelyAttachBeginFrameSource(source_iter.second, source_iter.first); 229 RecursivelyAttachBeginFrameSource(source_iter.second, source_iter.first);
230 } 230 }
231 231
232 } // namespace cc 232 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698