OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <stack> | 8 #include <stack> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/atomic_sequence_num.h" | 11 #include "base/atomic_sequence_num.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/location.h" | 14 #include "base/location.h" |
15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
16 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
17 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
19 #include "base/thread_task_runner_handle.h" | 19 #include "base/thread_task_runner_handle.h" |
20 #include "base/trace_event/trace_event.h" | 20 #include "base/trace_event/trace_event.h" |
21 #include "base/trace_event/trace_event_argument.h" | 21 #include "base/trace_event/trace_event_argument.h" |
| 22 #include "cc/animation/animation_host.h" |
22 #include "cc/animation/animation_registrar.h" | 23 #include "cc/animation/animation_registrar.h" |
23 #include "cc/animation/layer_animation_controller.h" | 24 #include "cc/animation/layer_animation_controller.h" |
24 #include "cc/base/math_util.h" | 25 #include "cc/base/math_util.h" |
25 #include "cc/debug/devtools_instrumentation.h" | 26 #include "cc/debug/devtools_instrumentation.h" |
26 #include "cc/debug/frame_viewer_instrumentation.h" | 27 #include "cc/debug/frame_viewer_instrumentation.h" |
27 #include "cc/debug/rendering_stats_instrumentation.h" | 28 #include "cc/debug/rendering_stats_instrumentation.h" |
28 #include "cc/input/layer_selection_bound.h" | 29 #include "cc/input/layer_selection_bound.h" |
29 #include "cc/input/page_scale_animation.h" | 30 #include "cc/input/page_scale_animation.h" |
30 #include "cc/input/top_controls_manager.h" | 31 #include "cc/input/top_controls_manager.h" |
31 #include "cc/layers/heads_up_display_layer.h" | 32 #include "cc/layers/heads_up_display_layer.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 next_commit_forces_redraw_(false), | 129 next_commit_forces_redraw_(false), |
129 shared_bitmap_manager_(shared_bitmap_manager), | 130 shared_bitmap_manager_(shared_bitmap_manager), |
130 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 131 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
131 task_graph_runner_(task_graph_runner), | 132 task_graph_runner_(task_graph_runner), |
132 surface_id_namespace_(0u), | 133 surface_id_namespace_(0u), |
133 next_surface_sequence_(1u) { | 134 next_surface_sequence_(1u) { |
134 if (settings_.accelerated_animation_enabled) | 135 if (settings_.accelerated_animation_enabled) |
135 animation_registrar_ = AnimationRegistrar::Create(); | 136 animation_registrar_ = AnimationRegistrar::Create(); |
136 rendering_stats_instrumentation_->set_record_rendering_stats( | 137 rendering_stats_instrumentation_->set_record_rendering_stats( |
137 debug_state_.RecordRenderingStats()); | 138 debug_state_.RecordRenderingStats()); |
| 139 |
| 140 if (settings_.use_compositor_animation_timelines) { |
| 141 animation_host_ = AnimationHost::Create(false); |
| 142 animation_host_->SetLayerTreeMutatorsClient(this); |
| 143 } |
138 } | 144 } |
139 | 145 |
140 void LayerTreeHost::InitializeThreaded( | 146 void LayerTreeHost::InitializeThreaded( |
141 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 147 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
142 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 148 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
143 scoped_ptr<BeginFrameSource> external_begin_frame_source) { | 149 scoped_ptr<BeginFrameSource> external_begin_frame_source) { |
144 InitializeProxy(ThreadProxy::Create(this, | 150 InitializeProxy(ThreadProxy::Create(this, |
145 main_task_runner, | 151 main_task_runner, |
146 impl_task_runner, | 152 impl_task_runner, |
147 external_begin_frame_source.Pass())); | 153 external_begin_frame_source.Pass())); |
(...skipping 21 matching lines...) Expand all Loading... |
169 proxy_->Start(); | 175 proxy_->Start(); |
170 if (settings_.accelerated_animation_enabled) { | 176 if (settings_.accelerated_animation_enabled) { |
171 animation_registrar_->set_supports_scroll_animations( | 177 animation_registrar_->set_supports_scroll_animations( |
172 proxy_->SupportsImplScrolling()); | 178 proxy_->SupportsImplScrolling()); |
173 } | 179 } |
174 } | 180 } |
175 | 181 |
176 LayerTreeHost::~LayerTreeHost() { | 182 LayerTreeHost::~LayerTreeHost() { |
177 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); | 183 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); |
178 | 184 |
| 185 if (animation_host_) |
| 186 animation_host_->SetLayerTreeMutatorsClient(nullptr); |
| 187 |
179 if (root_layer_.get()) | 188 if (root_layer_.get()) |
180 root_layer_->SetLayerTreeHost(NULL); | 189 root_layer_->SetLayerTreeHost(NULL); |
181 | 190 |
182 DCHECK(swap_promise_monitor_.empty()); | 191 DCHECK(swap_promise_monitor_.empty()); |
183 | 192 |
184 BreakSwapPromises(SwapPromise::COMMIT_FAILS); | 193 BreakSwapPromises(SwapPromise::COMMIT_FAILS); |
185 | 194 |
186 if (proxy_) { | 195 if (proxy_) { |
187 DCHECK(proxy_->IsMainThread()); | 196 DCHECK(proxy_->IsMainThread()); |
188 proxy_->Stop(); | 197 proxy_->Stop(); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 if (new_impl_tree_has_no_evicted_resources) { | 371 if (new_impl_tree_has_no_evicted_resources) { |
363 if (sync_tree->ContentsTexturesPurged()) | 372 if (sync_tree->ContentsTexturesPurged()) |
364 sync_tree->ResetContentsTexturesPurged(); | 373 sync_tree->ResetContentsTexturesPurged(); |
365 } | 374 } |
366 | 375 |
367 sync_tree->set_has_ever_been_drawn(false); | 376 sync_tree->set_has_ever_been_drawn(false); |
368 | 377 |
369 { | 378 { |
370 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties"); | 379 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties"); |
371 TreeSynchronizer::PushProperties(root_layer(), sync_tree->root_layer()); | 380 TreeSynchronizer::PushProperties(root_layer(), sync_tree->root_layer()); |
| 381 |
| 382 if (animation_host_) { |
| 383 DCHECK(host_impl->animation_host()); |
| 384 animation_host_->PushPropertiesTo(host_impl->animation_host()); |
| 385 } |
372 } | 386 } |
373 | 387 |
374 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); | 388 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); |
375 } | 389 } |
376 | 390 |
377 void LayerTreeHost::WillCommit() { | 391 void LayerTreeHost::WillCommit() { |
378 client_->WillCommit(); | 392 client_->WillCommit(); |
379 } | 393 } |
380 | 394 |
381 void LayerTreeHost::UpdateHudLayer() { | 395 void LayerTreeHost::UpdateHudLayer() { |
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1274 void LayerTreeHost::SendBeginFramesToChildren( | 1288 void LayerTreeHost::SendBeginFramesToChildren( |
1275 const BeginFrameArgs& args) const { | 1289 const BeginFrameArgs& args) const { |
1276 client_->SendBeginFramesToChildren(args); | 1290 client_->SendBeginFramesToChildren(args); |
1277 } | 1291 } |
1278 | 1292 |
1279 void LayerTreeHost::SetAuthoritativeVSyncInterval( | 1293 void LayerTreeHost::SetAuthoritativeVSyncInterval( |
1280 const base::TimeDelta& interval) { | 1294 const base::TimeDelta& interval) { |
1281 proxy_->SetAuthoritativeVSyncInterval(interval); | 1295 proxy_->SetAuthoritativeVSyncInterval(interval); |
1282 } | 1296 } |
1283 | 1297 |
| 1298 Layer* LayerTreeHost::LayerById(int id) const { |
| 1299 LayerIdMap::const_iterator iter = layer_id_map_.find(id); |
| 1300 return iter != layer_id_map_.end() ? iter->second : NULL; |
| 1301 } |
| 1302 |
| 1303 void LayerTreeHost::RegisterLayer(Layer* layer) { |
| 1304 DCHECK(!LayerById(layer->id())); |
| 1305 layer_id_map_[layer->id()] = layer; |
| 1306 if (animation_host_) |
| 1307 animation_host_->RegisterLayer(layer->id(), true); |
| 1308 } |
| 1309 |
| 1310 void LayerTreeHost::UnregisterLayer(Layer* layer) { |
| 1311 DCHECK(LayerById(layer->id())); |
| 1312 if (animation_host_) |
| 1313 animation_host_->UnregisterLayer(layer->id(), true); |
| 1314 layer_id_map_.erase(layer->id()); |
| 1315 } |
| 1316 |
| 1317 bool LayerTreeHost::IsLayerInActiveTree(int layer_id) const { |
| 1318 return true; |
| 1319 } |
| 1320 |
| 1321 bool LayerTreeHost::IsLayerInPendingTree(int layer_id) const { |
| 1322 return false; |
| 1323 } |
| 1324 |
| 1325 void LayerTreeHost::SetMutatorsNeedCommit() { |
| 1326 SetNeedsCommit(); |
| 1327 } |
| 1328 |
| 1329 void LayerTreeHost::SetLayerFilterMutated(int layer_id, |
| 1330 bool active_tree, |
| 1331 const FilterOperations& filters) { |
| 1332 LayerAnimationValueObserver* layer = LayerById(layer_id); |
| 1333 DCHECK(layer); |
| 1334 layer->OnFilterAnimated(filters); |
| 1335 } |
| 1336 |
| 1337 void LayerTreeHost::SetLayerOpacityMutated(int layer_id, |
| 1338 bool active_tree, |
| 1339 float opacity) { |
| 1340 LayerAnimationValueObserver* layer = LayerById(layer_id); |
| 1341 DCHECK(layer); |
| 1342 layer->OnOpacityAnimated(opacity); |
| 1343 } |
| 1344 |
| 1345 void LayerTreeHost::SetLayerTransformMutated(int layer_id, |
| 1346 bool active_tree, |
| 1347 const gfx::Transform& transform) { |
| 1348 LayerAnimationValueObserver* layer = LayerById(layer_id); |
| 1349 DCHECK(layer); |
| 1350 layer->OnTransformAnimated(transform); |
| 1351 } |
| 1352 |
| 1353 void LayerTreeHost::SetLayerScrollOffsetMutated( |
| 1354 int layer_id, |
| 1355 bool active_tree, |
| 1356 const gfx::ScrollOffset& scroll_offset) { |
| 1357 LayerAnimationValueObserver* layer = LayerById(layer_id); |
| 1358 DCHECK(layer); |
| 1359 layer->OnScrollOffsetAnimated(scroll_offset); |
| 1360 } |
| 1361 |
1284 } // namespace cc | 1362 } // namespace cc |
OLD | NEW |