| OLD | NEW |
| 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/frame_sink_manager.h" | 5 #include "cc/surfaces/frame_sink_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/frame_sink_manager_client.h" | 11 #include "cc/surfaces/frame_sink_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 FrameSinkManager::FrameSinkManager() {} | 27 FrameSinkManager::FrameSinkManager() {} |
| 29 | 28 |
| 30 FrameSinkManager::~FrameSinkManager() { | 29 FrameSinkManager::~FrameSinkManager() { |
| 31 // All surface factory clients should be unregistered prior to SurfaceManager | 30 // All CompositorFrameSinks should be unregistered prior to |
| 32 // destruction. | 31 // SurfaceManager destruction. |
| 33 DCHECK_EQ(clients_.size(), 0u); | 32 DCHECK_EQ(clients_.size(), 0u); |
| 34 DCHECK_EQ(registered_sources_.size(), 0u); | 33 DCHECK_EQ(registered_sources_.size(), 0u); |
| 35 } | 34 } |
| 36 | 35 |
| 37 void FrameSinkManager::RegisterFrameSinkId(const FrameSinkId& frame_sink_id) { | 36 void FrameSinkManager::RegisterFrameSinkId(const FrameSinkId& frame_sink_id) { |
| 38 bool inserted = valid_frame_sink_ids_.insert(frame_sink_id).second; | 37 bool inserted = valid_frame_sink_ids_.insert(frame_sink_id).second; |
| 39 DCHECK(inserted); | 38 DCHECK(inserted); |
| 40 } | 39 } |
| 41 | 40 |
| 42 void FrameSinkManager::InvalidateFrameSinkId(const FrameSinkId& frame_sink_id) { | 41 void FrameSinkManager::InvalidateFrameSinkId(const FrameSinkId& frame_sink_id) { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 for (size_t i = 0; i < children.size(); ++i) { | 199 for (size_t i = 0; i < children.size(); ++i) { |
| 201 if (children[i] == child_frame_sink_id) { | 200 if (children[i] == child_frame_sink_id) { |
| 202 found_child = true; | 201 found_child = true; |
| 203 children[i] = children.back(); | 202 children[i] = children.back(); |
| 204 children.resize(children.size() - 1); | 203 children.resize(children.size() - 1); |
| 205 break; | 204 break; |
| 206 } | 205 } |
| 207 } | 206 } |
| 208 DCHECK(found_child); | 207 DCHECK(found_child); |
| 209 | 208 |
| 210 // The SurfaceFactoryClient and hierarchy can be registered/unregistered | 209 // The CompositorFrameSinkSupport and hierarchy can be registered/unregistered |
| 211 // in either order, so empty frame_sink_source_map entries need to be | 210 // in either order, so empty frame_sink_source_map entries need to be |
| 212 // checked when removing either clients or relationships. | 211 // checked when removing either clients or relationships. |
| 213 if (!iter->second.has_children() && !clients_.count(parent_frame_sink_id) && | 212 if (!iter->second.has_children() && !clients_.count(parent_frame_sink_id) && |
| 214 !iter->second.source) { | 213 !iter->second.source) { |
| 215 frame_sink_source_map_.erase(iter); | 214 frame_sink_source_map_.erase(iter); |
| 216 return; | 215 return; |
| 217 } | 216 } |
| 218 | 217 |
| 219 // If the parent does not have a begin frame source, then disconnecting it | 218 // If the parent does not have a begin frame source, then disconnecting it |
| 220 // will not change any of its children. | 219 // will not change any of its children. |
| 221 BeginFrameSource* parent_source = iter->second.source; | 220 BeginFrameSource* parent_source = iter->second.source; |
| 222 if (!parent_source) | 221 if (!parent_source) |
| 223 return; | 222 return; |
| 224 | 223 |
| 225 // TODO(enne): these walks could be done in one step. | 224 // TODO(enne): these walks could be done in one step. |
| 226 RecursivelyDetachBeginFrameSource(child_frame_sink_id, parent_source); | 225 RecursivelyDetachBeginFrameSource(child_frame_sink_id, parent_source); |
| 227 for (auto source_iter : registered_sources_) | 226 for (auto source_iter : registered_sources_) |
| 228 RecursivelyAttachBeginFrameSource(source_iter.second, source_iter.first); | 227 RecursivelyAttachBeginFrameSource(source_iter.second, source_iter.first); |
| 229 } | 228 } |
| 230 | 229 |
| 231 } // namespace cc | 230 } // namespace cc |
| OLD | NEW |