Chromium Code Reviews| 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/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/surface_factory_client.h" | 11 #include "cc/surfaces/compositor_frame_sink_support.h" |
| 12 | 12 |
| 13 #if DCHECK_IS_ON() | 13 #if DCHECK_IS_ON() |
| 14 #include <sstream> | 14 #include <sstream> |
| 15 #endif | 15 #endif |
| 16 | 16 |
| 17 namespace cc { | 17 namespace cc { |
| 18 | 18 |
| 19 FrameSinkManager::FrameSinkSourceMapping::FrameSinkSourceMapping() | 19 FrameSinkManager::FrameSinkSourceMapping::FrameSinkSourceMapping() |
| 20 : source(nullptr) {} | 20 : source(nullptr) {} |
| 21 | 21 |
| 22 FrameSinkManager::FrameSinkSourceMapping::FrameSinkSourceMapping( | 22 FrameSinkManager::FrameSinkSourceMapping::FrameSinkSourceMapping( |
| 23 const FrameSinkSourceMapping& other) = default; | 23 const FrameSinkSourceMapping& other) = default; |
| 24 | 24 |
| 25 FrameSinkManager::FrameSinkSourceMapping::~FrameSinkSourceMapping() { | 25 FrameSinkManager::FrameSinkSourceMapping::~FrameSinkSourceMapping() { |
| 26 } | 26 } |
| 27 | 27 |
| 28 FrameSinkManager::FrameSinkManager() {} | 28 FrameSinkManager::FrameSinkManager() {} |
| 29 | 29 |
| 30 FrameSinkManager::~FrameSinkManager() { | 30 FrameSinkManager::~FrameSinkManager() { |
| 31 // All surface factory clients should be unregistered prior to SurfaceManager | 31 // All compositor frame supports should be unregistered prior to |
|
Fady Samuel
2017/04/06 21:53:23
All CompositorFrameSinks should be unregistered...
Alex Z.
2017/04/13 17:15:30
Done.
| |
| 32 // destruction. | 32 // SurfaceManager destruction. |
| 33 DCHECK_EQ(clients_.size(), 0u); | 33 DCHECK_EQ(clients_.size(), 0u); |
| 34 DCHECK_EQ(registered_sources_.size(), 0u); | 34 DCHECK_EQ(registered_sources_.size(), 0u); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void FrameSinkManager::RegisterFrameSinkId(const FrameSinkId& frame_sink_id) { | 37 void FrameSinkManager::RegisterFrameSinkId(const FrameSinkId& frame_sink_id) { |
| 38 bool inserted = valid_frame_sink_ids_.insert(frame_sink_id).second; | 38 bool inserted = valid_frame_sink_ids_.insert(frame_sink_id).second; |
| 39 DCHECK(inserted); | 39 DCHECK(inserted); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void FrameSinkManager::InvalidateFrameSinkId(const FrameSinkId& frame_sink_id) { | 42 void FrameSinkManager::InvalidateFrameSinkId(const FrameSinkId& frame_sink_id) { |
| 43 valid_frame_sink_ids_.erase(frame_sink_id); | 43 valid_frame_sink_ids_.erase(frame_sink_id); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void FrameSinkManager::RegisterSurfaceFactoryClient( | 46 void FrameSinkManager::RegisterCompositorFrameSinkSupport( |
|
Fady Samuel
2017/04/06 21:53:23
How about just RegisterCompositorFrameSink?
Alex Z.
2017/04/13 17:15:30
Done.
| |
| 47 const FrameSinkId& frame_sink_id, | 47 const FrameSinkId& frame_sink_id, |
| 48 SurfaceFactoryClient* client) { | 48 CompositorFrameSinkSupport* support) { |
| 49 DCHECK(client); | 49 DCHECK(support); |
| 50 DCHECK_EQ(valid_frame_sink_ids_.count(frame_sink_id), 1u); | 50 DCHECK_EQ(valid_frame_sink_ids_.count(frame_sink_id), 1u); |
| 51 | 51 |
| 52 clients_[frame_sink_id] = client; | 52 clients_[frame_sink_id] = support; |
| 53 | 53 |
| 54 auto it = frame_sink_source_map_.find(frame_sink_id); | 54 auto it = frame_sink_source_map_.find(frame_sink_id); |
| 55 if (it != frame_sink_source_map_.end()) { | 55 if (it != frame_sink_source_map_.end()) { |
| 56 if (it->second.source) | 56 if (it->second.source) |
| 57 client->SetBeginFrameSource(it->second.source); | 57 support->SetBeginFrameSource(it->second.source); |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 | 60 |
| 61 void FrameSinkManager::UnregisterSurfaceFactoryClient( | 61 void FrameSinkManager::UnregisterCompositorFrameSinkSupport( |
|
Fady Samuel
2017/04/06 21:53:23
How about just UnregisterCompositorFrameSink?
Alex Z.
2017/04/13 17:15:30
Done.
| |
| 62 const FrameSinkId& frame_sink_id) { | 62 const FrameSinkId& frame_sink_id) { |
| 63 DCHECK_EQ(valid_frame_sink_ids_.count(frame_sink_id), 1u); | 63 DCHECK_EQ(valid_frame_sink_ids_.count(frame_sink_id), 1u); |
| 64 auto client_iter = clients_.find(frame_sink_id); | 64 auto client_iter = clients_.find(frame_sink_id); |
| 65 DCHECK(client_iter != clients_.end()); | 65 DCHECK(client_iter != clients_.end()); |
| 66 | 66 |
| 67 auto source_iter = frame_sink_source_map_.find(frame_sink_id); | 67 auto source_iter = frame_sink_source_map_.find(frame_sink_id); |
| 68 if (source_iter != frame_sink_source_map_.end()) { | 68 if (source_iter != frame_sink_source_map_.end()) { |
| 69 if (source_iter->second.source) | 69 if (source_iter->second.source) |
| 70 client_iter->second->SetBeginFrameSource(nullptr); | 70 client_iter->second->SetBeginFrameSource(nullptr); |
| 71 if (!source_iter->second.has_children()) | 71 if (!source_iter->second.has_children()) |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 for (size_t i = 0; i < children.size(); ++i) { | 200 for (size_t i = 0; i < children.size(); ++i) { |
| 201 if (children[i] == child_frame_sink_id) { | 201 if (children[i] == child_frame_sink_id) { |
| 202 found_child = true; | 202 found_child = true; |
| 203 children[i] = children.back(); | 203 children[i] = children.back(); |
| 204 children.resize(children.size() - 1); | 204 children.resize(children.size() - 1); |
| 205 break; | 205 break; |
| 206 } | 206 } |
| 207 } | 207 } |
| 208 DCHECK(found_child); | 208 DCHECK(found_child); |
| 209 | 209 |
| 210 // The SurfaceFactoryClient and hierarchy can be registered/unregistered | 210 // The CompositorFrameSinkSupport and hierarchy can be registered/unregistered |
| 211 // in either order, so empty frame_sink_source_map entries need to be | 211 // in either order, so empty frame_sink_source_map entries need to be |
| 212 // checked when removing either clients or relationships. | 212 // checked when removing either clients or relationships. |
| 213 if (!iter->second.has_children() && !clients_.count(parent_frame_sink_id) && | 213 if (!iter->second.has_children() && !clients_.count(parent_frame_sink_id) && |
| 214 !iter->second.source) { | 214 !iter->second.source) { |
| 215 frame_sink_source_map_.erase(iter); | 215 frame_sink_source_map_.erase(iter); |
| 216 return; | 216 return; |
| 217 } | 217 } |
| 218 | 218 |
| 219 // If the parent does not have a begin frame source, then disconnecting it | 219 // If the parent does not have a begin frame source, then disconnecting it |
| 220 // will not change any of its children. | 220 // will not change any of its children. |
| 221 BeginFrameSource* parent_source = iter->second.source; | 221 BeginFrameSource* parent_source = iter->second.source; |
| 222 if (!parent_source) | 222 if (!parent_source) |
| 223 return; | 223 return; |
| 224 | 224 |
| 225 // TODO(enne): these walks could be done in one step. | 225 // TODO(enne): these walks could be done in one step. |
| 226 RecursivelyDetachBeginFrameSource(child_frame_sink_id, parent_source); | 226 RecursivelyDetachBeginFrameSource(child_frame_sink_id, parent_source); |
| 227 for (auto source_iter : registered_sources_) | 227 for (auto source_iter : registered_sources_) |
| 228 RecursivelyAttachBeginFrameSource(source_iter.second, source_iter.first); | 228 RecursivelyAttachBeginFrameSource(source_iter.second, source_iter.first); |
| 229 } | 229 } |
| 230 | 230 |
| 231 } // namespace cc | 231 } // namespace cc |
| OLD | NEW |