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/primary_begin_frame_source.h" |
12 | 13 |
13 #if DCHECK_IS_ON() | 14 #if DCHECK_IS_ON() |
14 #include <sstream> | 15 #include <sstream> |
15 #endif | 16 #endif |
16 | 17 |
17 namespace cc { | 18 namespace cc { |
18 | 19 |
19 FrameSinkManager::FrameSinkSourceMapping::FrameSinkSourceMapping() | 20 FrameSinkManager::FrameSinkSourceMapping::FrameSinkSourceMapping() = default; |
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() = default; |
26 | 26 |
27 FrameSinkManager::FrameSinkManager() {} | 27 FrameSinkManager::FrameSinkManager() = default; |
28 | 28 |
29 FrameSinkManager::~FrameSinkManager() { | 29 FrameSinkManager::~FrameSinkManager() { |
30 // All CompositorFrameSinks should be unregistered prior to | 30 // All CompositorFrameSinks should be unregistered prior to |
31 // SurfaceManager destruction. | 31 // SurfaceManager destruction. |
32 DCHECK_EQ(clients_.size(), 0u); | 32 DCHECK_EQ(clients_.size(), 0u); |
33 DCHECK_EQ(registered_sources_.size(), 0u); | 33 DCHECK_EQ(registered_sources_.size(), 0u); |
34 } | 34 } |
35 | 35 |
36 void FrameSinkManager::RegisterFrameSinkId(const FrameSinkId& frame_sink_id) { | 36 void FrameSinkManager::RegisterFrameSinkId(const FrameSinkId& frame_sink_id) { |
37 bool inserted = valid_frame_sink_ids_.insert(frame_sink_id).second; | 37 bool inserted = valid_frame_sink_ids_.insert(frame_sink_id).second; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 void FrameSinkManager::RegisterBeginFrameSource( | 76 void FrameSinkManager::RegisterBeginFrameSource( |
77 BeginFrameSource* source, | 77 BeginFrameSource* source, |
78 const FrameSinkId& frame_sink_id) { | 78 const FrameSinkId& frame_sink_id) { |
79 DCHECK(source); | 79 DCHECK(source); |
80 DCHECK_EQ(registered_sources_.count(source), 0u); | 80 DCHECK_EQ(registered_sources_.count(source), 0u); |
81 DCHECK_EQ(valid_frame_sink_ids_.count(frame_sink_id), 1u); | 81 DCHECK_EQ(valid_frame_sink_ids_.count(frame_sink_id), 1u); |
82 | 82 |
83 registered_sources_[source] = frame_sink_id; | 83 registered_sources_[source] = frame_sink_id; |
84 RecursivelyAttachBeginFrameSource(frame_sink_id, source); | 84 RecursivelyAttachBeginFrameSource(frame_sink_id, source); |
| 85 |
| 86 primary_source_.OnBeginFrameSourceAdded(source); |
85 } | 87 } |
86 | 88 |
87 void FrameSinkManager::UnregisterBeginFrameSource(BeginFrameSource* source) { | 89 void FrameSinkManager::UnregisterBeginFrameSource(BeginFrameSource* source) { |
88 DCHECK(source); | 90 DCHECK(source); |
89 DCHECK_EQ(registered_sources_.count(source), 1u); | 91 DCHECK_EQ(registered_sources_.count(source), 1u); |
90 | 92 |
91 FrameSinkId frame_sink_id = registered_sources_[source]; | 93 FrameSinkId frame_sink_id = registered_sources_[source]; |
92 registered_sources_.erase(source); | 94 registered_sources_.erase(source); |
93 | 95 |
| 96 primary_source_.OnBeginFrameSourceRemoved(source); |
| 97 |
94 if (frame_sink_source_map_.count(frame_sink_id) == 0u) | 98 if (frame_sink_source_map_.count(frame_sink_id) == 0u) |
95 return; | 99 return; |
96 | 100 |
97 // TODO(enne): these walks could be done in one step. | 101 // TODO(enne): these walks could be done in one step. |
98 // Remove this begin frame source from its subtree. | 102 // Remove this begin frame source from its subtree. |
99 RecursivelyDetachBeginFrameSource(frame_sink_id, source); | 103 RecursivelyDetachBeginFrameSource(frame_sink_id, source); |
100 // Then flush every remaining registered source to fix any sources that | 104 // Then flush every remaining registered source to fix any sources that |
101 // became null because of the previous step but that have an alternative. | 105 // became null because of the previous step but that have an alternative. |
102 for (auto source_iter : registered_sources_) | 106 for (auto source_iter : registered_sources_) |
103 RecursivelyAttachBeginFrameSource(source_iter.second, source_iter.first); | 107 RecursivelyAttachBeginFrameSource(source_iter.second, source_iter.first); |
104 } | 108 } |
105 | 109 |
| 110 BeginFrameSource* FrameSinkManager::GetPrimaryBeginFrameSource() { |
| 111 return &primary_source_; |
| 112 } |
| 113 |
106 void FrameSinkManager::RecursivelyAttachBeginFrameSource( | 114 void FrameSinkManager::RecursivelyAttachBeginFrameSource( |
107 const FrameSinkId& frame_sink_id, | 115 const FrameSinkId& frame_sink_id, |
108 BeginFrameSource* source) { | 116 BeginFrameSource* source) { |
109 FrameSinkSourceMapping& mapping = frame_sink_source_map_[frame_sink_id]; | 117 FrameSinkSourceMapping& mapping = frame_sink_source_map_[frame_sink_id]; |
110 if (!mapping.source) { | 118 if (!mapping.source) { |
111 mapping.source = source; | 119 mapping.source = source; |
112 auto client_iter = clients_.find(frame_sink_id); | 120 auto client_iter = clients_.find(frame_sink_id); |
113 if (client_iter != clients_.end()) | 121 if (client_iter != clients_.end()) |
114 client_iter->second->SetBeginFrameSource(source); | 122 client_iter->second->SetBeginFrameSource(source); |
115 } | 123 } |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 if (!parent_source) | 229 if (!parent_source) |
222 return; | 230 return; |
223 | 231 |
224 // TODO(enne): these walks could be done in one step. | 232 // TODO(enne): these walks could be done in one step. |
225 RecursivelyDetachBeginFrameSource(child_frame_sink_id, parent_source); | 233 RecursivelyDetachBeginFrameSource(child_frame_sink_id, parent_source); |
226 for (auto source_iter : registered_sources_) | 234 for (auto source_iter : registered_sources_) |
227 RecursivelyAttachBeginFrameSource(source_iter.second, source_iter.first); | 235 RecursivelyAttachBeginFrameSource(source_iter.second, source_iter.first); |
228 } | 236 } |
229 | 237 |
230 } // namespace cc | 238 } // namespace cc |
OLD | NEW |