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/auto_reset.h" | 12 #include "base/auto_reset.h" |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/location.h" | 15 #include "base/location.h" |
16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
17 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
18 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
19 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
20 #include "base/thread_task_runner_handle.h" | 20 #include "base/thread_task_runner_handle.h" |
21 #include "base/trace_event/trace_event.h" | 21 #include "base/trace_event/trace_event.h" |
22 #include "base/trace_event/trace_event_argument.h" | 22 #include "base/trace_event/trace_event_argument.h" |
| 23 #include "cc/animation/animation_host.h" |
23 #include "cc/animation/animation_registrar.h" | 24 #include "cc/animation/animation_registrar.h" |
24 #include "cc/animation/layer_animation_controller.h" | 25 #include "cc/animation/layer_animation_controller.h" |
25 #include "cc/base/math_util.h" | 26 #include "cc/base/math_util.h" |
26 #include "cc/debug/devtools_instrumentation.h" | 27 #include "cc/debug/devtools_instrumentation.h" |
27 #include "cc/debug/frame_viewer_instrumentation.h" | 28 #include "cc/debug/frame_viewer_instrumentation.h" |
28 #include "cc/debug/rendering_stats_instrumentation.h" | 29 #include "cc/debug/rendering_stats_instrumentation.h" |
29 #include "cc/input/layer_selection_bound.h" | 30 #include "cc/input/layer_selection_bound.h" |
30 #include "cc/input/page_scale_animation.h" | 31 #include "cc/input/page_scale_animation.h" |
31 #include "cc/input/top_controls_manager.h" | 32 #include "cc/input/top_controls_manager.h" |
32 #include "cc/layers/heads_up_display_layer.h" | 33 #include "cc/layers/heads_up_display_layer.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 next_commit_forces_redraw_(false), | 119 next_commit_forces_redraw_(false), |
119 shared_bitmap_manager_(params->shared_bitmap_manager), | 120 shared_bitmap_manager_(params->shared_bitmap_manager), |
120 gpu_memory_buffer_manager_(params->gpu_memory_buffer_manager), | 121 gpu_memory_buffer_manager_(params->gpu_memory_buffer_manager), |
121 task_graph_runner_(params->task_graph_runner), | 122 task_graph_runner_(params->task_graph_runner), |
122 surface_id_namespace_(0u), | 123 surface_id_namespace_(0u), |
123 next_surface_sequence_(1u) { | 124 next_surface_sequence_(1u) { |
124 if (settings_.accelerated_animation_enabled) | 125 if (settings_.accelerated_animation_enabled) |
125 animation_registrar_ = AnimationRegistrar::Create(); | 126 animation_registrar_ = AnimationRegistrar::Create(); |
126 rendering_stats_instrumentation_->set_record_rendering_stats( | 127 rendering_stats_instrumentation_->set_record_rendering_stats( |
127 debug_state_.RecordRenderingStats()); | 128 debug_state_.RecordRenderingStats()); |
| 129 |
| 130 if (settings_.use_compositor_animation_timelines) { |
| 131 animation_host_ = AnimationHost::Create(ThreadInstance::MAIN); |
| 132 animation_host_->SetMutatorHostClient(this); |
| 133 } |
128 } | 134 } |
129 | 135 |
130 void LayerTreeHost::InitializeThreaded( | 136 void LayerTreeHost::InitializeThreaded( |
131 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 137 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
132 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 138 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
133 scoped_ptr<BeginFrameSource> external_begin_frame_source) { | 139 scoped_ptr<BeginFrameSource> external_begin_frame_source) { |
134 InitializeProxy(ThreadProxy::Create(this, | 140 InitializeProxy(ThreadProxy::Create(this, |
135 main_task_runner, | 141 main_task_runner, |
136 impl_task_runner, | 142 impl_task_runner, |
137 external_begin_frame_source.Pass())); | 143 external_begin_frame_source.Pass())); |
(...skipping 21 matching lines...) Expand all Loading... |
159 proxy_->Start(); | 165 proxy_->Start(); |
160 if (settings_.accelerated_animation_enabled) { | 166 if (settings_.accelerated_animation_enabled) { |
161 animation_registrar_->set_supports_scroll_animations( | 167 animation_registrar_->set_supports_scroll_animations( |
162 proxy_->SupportsImplScrolling()); | 168 proxy_->SupportsImplScrolling()); |
163 } | 169 } |
164 } | 170 } |
165 | 171 |
166 LayerTreeHost::~LayerTreeHost() { | 172 LayerTreeHost::~LayerTreeHost() { |
167 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); | 173 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); |
168 | 174 |
| 175 if (animation_host_) |
| 176 animation_host_->SetMutatorHostClient(nullptr); |
| 177 |
169 if (root_layer_.get()) | 178 if (root_layer_.get()) |
170 root_layer_->SetLayerTreeHost(NULL); | 179 root_layer_->SetLayerTreeHost(NULL); |
171 | 180 |
172 DCHECK(swap_promise_monitor_.empty()); | 181 DCHECK(swap_promise_monitor_.empty()); |
173 | 182 |
174 BreakSwapPromises(SwapPromise::COMMIT_FAILS); | 183 BreakSwapPromises(SwapPromise::COMMIT_FAILS); |
175 | 184 |
176 if (proxy_) { | 185 if (proxy_) { |
177 DCHECK(proxy_->IsMainThread()); | 186 DCHECK(proxy_->IsMainThread()); |
178 proxy_->Stop(); | 187 proxy_->Stop(); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 if (sync_tree->ContentsTexturesPurged()) | 363 if (sync_tree->ContentsTexturesPurged()) |
355 sync_tree->ResetContentsTexturesPurged(); | 364 sync_tree->ResetContentsTexturesPurged(); |
356 } | 365 } |
357 | 366 |
358 sync_tree->set_has_ever_been_drawn(false); | 367 sync_tree->set_has_ever_been_drawn(false); |
359 sync_tree->SetPropertyTrees(property_trees_); | 368 sync_tree->SetPropertyTrees(property_trees_); |
360 | 369 |
361 { | 370 { |
362 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties"); | 371 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties"); |
363 TreeSynchronizer::PushProperties(root_layer(), sync_tree->root_layer()); | 372 TreeSynchronizer::PushProperties(root_layer(), sync_tree->root_layer()); |
| 373 |
| 374 if (animation_host_) { |
| 375 DCHECK(host_impl->animation_host()); |
| 376 animation_host_->PushPropertiesTo(host_impl->animation_host()); |
| 377 } |
364 } | 378 } |
365 | 379 |
366 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); | 380 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); |
367 } | 381 } |
368 | 382 |
369 void LayerTreeHost::WillCommit() { | 383 void LayerTreeHost::WillCommit() { |
370 client_->WillCommit(); | 384 client_->WillCommit(); |
371 } | 385 } |
372 | 386 |
373 void LayerTreeHost::UpdateHudLayer() { | 387 void LayerTreeHost::UpdateHudLayer() { |
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1293 proxy_->SetAuthoritativeVSyncInterval(interval); | 1307 proxy_->SetAuthoritativeVSyncInterval(interval); |
1294 } | 1308 } |
1295 | 1309 |
1296 void LayerTreeHost::RecordFrameTimingEvents( | 1310 void LayerTreeHost::RecordFrameTimingEvents( |
1297 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | 1311 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
1298 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { | 1312 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { |
1299 client_->RecordFrameTimingEvents(composite_events.Pass(), | 1313 client_->RecordFrameTimingEvents(composite_events.Pass(), |
1300 main_frame_events.Pass()); | 1314 main_frame_events.Pass()); |
1301 } | 1315 } |
1302 | 1316 |
| 1317 Layer* LayerTreeHost::LayerById(int id) const { |
| 1318 LayerIdMap::const_iterator iter = layer_id_map_.find(id); |
| 1319 return iter != layer_id_map_.end() ? iter->second : NULL; |
| 1320 } |
| 1321 |
| 1322 void LayerTreeHost::RegisterLayer(Layer* layer) { |
| 1323 DCHECK(!LayerById(layer->id())); |
| 1324 layer_id_map_[layer->id()] = layer; |
| 1325 if (animation_host_) |
| 1326 animation_host_->RegisterLayer(layer->id(), LayerTreeType::ACTIVE); |
| 1327 } |
| 1328 |
| 1329 void LayerTreeHost::UnregisterLayer(Layer* layer) { |
| 1330 DCHECK(LayerById(layer->id())); |
| 1331 if (animation_host_) |
| 1332 animation_host_->UnregisterLayer(layer->id(), LayerTreeType::ACTIVE); |
| 1333 layer_id_map_.erase(layer->id()); |
| 1334 } |
| 1335 |
| 1336 bool LayerTreeHost::IsLayerInTree(int layer_id, LayerTreeType tree_type) const { |
| 1337 return tree_type == LayerTreeType::ACTIVE; |
| 1338 } |
| 1339 |
| 1340 void LayerTreeHost::SetMutatorsNeedCommit() { |
| 1341 SetNeedsCommit(); |
| 1342 } |
| 1343 |
| 1344 void LayerTreeHost::SetLayerFilterMutated(int layer_id, |
| 1345 LayerTreeType tree_type, |
| 1346 const FilterOperations& filters) { |
| 1347 LayerAnimationValueObserver* layer = LayerById(layer_id); |
| 1348 DCHECK(layer); |
| 1349 layer->OnFilterAnimated(filters); |
| 1350 } |
| 1351 |
| 1352 void LayerTreeHost::SetLayerOpacityMutated(int layer_id, |
| 1353 LayerTreeType tree_type, |
| 1354 float opacity) { |
| 1355 LayerAnimationValueObserver* layer = LayerById(layer_id); |
| 1356 DCHECK(layer); |
| 1357 layer->OnOpacityAnimated(opacity); |
| 1358 } |
| 1359 |
| 1360 void LayerTreeHost::SetLayerTransformMutated(int layer_id, |
| 1361 LayerTreeType tree_type, |
| 1362 const gfx::Transform& transform) { |
| 1363 LayerAnimationValueObserver* layer = LayerById(layer_id); |
| 1364 DCHECK(layer); |
| 1365 layer->OnTransformAnimated(transform); |
| 1366 } |
| 1367 |
| 1368 void LayerTreeHost::SetLayerScrollOffsetMutated( |
| 1369 int layer_id, |
| 1370 LayerTreeType tree_type, |
| 1371 const gfx::ScrollOffset& scroll_offset) { |
| 1372 LayerAnimationValueObserver* layer = LayerById(layer_id); |
| 1373 DCHECK(layer); |
| 1374 layer->OnScrollOffsetAnimated(scroll_offset); |
| 1375 } |
| 1376 |
1303 } // namespace cc | 1377 } // namespace cc |
OLD | NEW |