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 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 partial_texture_update_requests_(0), | 125 partial_texture_update_requests_(0), |
126 did_complete_scale_animation_(false), | 126 did_complete_scale_animation_(false), |
127 in_paint_layer_contents_(false), | 127 in_paint_layer_contents_(false), |
128 id_(s_layer_tree_host_sequence_number.GetNext() + 1), | 128 id_(s_layer_tree_host_sequence_number.GetNext() + 1), |
129 next_commit_forces_redraw_(false), | 129 next_commit_forces_redraw_(false), |
130 shared_bitmap_manager_(shared_bitmap_manager), | 130 shared_bitmap_manager_(shared_bitmap_manager), |
131 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 131 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
132 task_graph_runner_(task_graph_runner), | 132 task_graph_runner_(task_graph_runner), |
133 surface_id_namespace_(0u), | 133 surface_id_namespace_(0u), |
134 next_surface_sequence_(1u) { | 134 next_surface_sequence_(1u) { |
135 if (settings_.accelerated_animation_enabled) | 135 if (settings_.accelerated_animation_enabled && |
| 136 !settings.use_compositor_animation_timelines) |
136 animation_registrar_ = AnimationRegistrar::Create(); | 137 animation_registrar_ = AnimationRegistrar::Create(); |
137 rendering_stats_instrumentation_->set_record_rendering_stats( | 138 rendering_stats_instrumentation_->set_record_rendering_stats( |
138 debug_state_.RecordRenderingStats()); | 139 debug_state_.RecordRenderingStats()); |
139 | 140 |
140 if (settings_.use_compositor_animation_timelines) { | 141 if (settings_.use_compositor_animation_timelines) { |
141 animation_host_ = AnimationHost::Create(false); | 142 animation_host_ = AnimationHost::Create(false); |
142 animation_host_->SetLayerTreeMutatorsClient(this); | 143 animation_host_->SetLayerTreeMutatorsClient(this); |
143 } | 144 } |
144 } | 145 } |
145 | 146 |
(...skipping 21 matching lines...) Expand all Loading... |
167 void LayerTreeHost::InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing) { | 168 void LayerTreeHost::InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing) { |
168 InitializeProxy(proxy_for_testing.Pass()); | 169 InitializeProxy(proxy_for_testing.Pass()); |
169 } | 170 } |
170 | 171 |
171 void LayerTreeHost::InitializeProxy(scoped_ptr<Proxy> proxy) { | 172 void LayerTreeHost::InitializeProxy(scoped_ptr<Proxy> proxy) { |
172 TRACE_EVENT0("cc", "LayerTreeHost::InitializeForReal"); | 173 TRACE_EVENT0("cc", "LayerTreeHost::InitializeForReal"); |
173 | 174 |
174 proxy_ = proxy.Pass(); | 175 proxy_ = proxy.Pass(); |
175 proxy_->Start(); | 176 proxy_->Start(); |
176 if (settings_.accelerated_animation_enabled) { | 177 if (settings_.accelerated_animation_enabled) { |
177 animation_registrar_->set_supports_scroll_animations( | 178 if (animation_registrar_) |
178 proxy_->SupportsImplScrolling()); | 179 animation_registrar_->set_supports_scroll_animations( |
| 180 proxy_->SupportsImplScrolling()); |
| 181 |
| 182 if (animation_host_) |
| 183 animation_host_->SetSupportsScrollAnimations( |
| 184 proxy_->SupportsImplScrolling()); |
179 } | 185 } |
180 } | 186 } |
181 | 187 |
182 LayerTreeHost::~LayerTreeHost() { | 188 LayerTreeHost::~LayerTreeHost() { |
183 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); | 189 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); |
184 | 190 |
185 if (animation_host_) | 191 if (animation_host_) |
186 animation_host_->SetLayerTreeMutatorsClient(nullptr); | 192 animation_host_->SetLayerTreeMutatorsClient(nullptr); |
187 | 193 |
188 if (root_layer_.get()) | 194 if (root_layer_.get()) |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 proxy_->SetNextCommitWaitsForActivation(); | 558 proxy_->SetNextCommitWaitsForActivation(); |
553 } | 559 } |
554 | 560 |
555 void LayerTreeHost::SetNextCommitForcesRedraw() { | 561 void LayerTreeHost::SetNextCommitForcesRedraw() { |
556 next_commit_forces_redraw_ = true; | 562 next_commit_forces_redraw_ = true; |
557 } | 563 } |
558 | 564 |
559 void LayerTreeHost::SetAnimationEvents( | 565 void LayerTreeHost::SetAnimationEvents( |
560 scoped_ptr<AnimationEventsVector> events) { | 566 scoped_ptr<AnimationEventsVector> events) { |
561 DCHECK(proxy_->IsMainThread()); | 567 DCHECK(proxy_->IsMainThread()); |
562 animation_registrar_->SetAnimationEvents(events.Pass()); | 568 if (animation_host_) |
| 569 animation_host_->SetAnimationEvents(events.Pass()); |
| 570 else |
| 571 animation_registrar_->SetAnimationEvents(events.Pass()); |
563 } | 572 } |
564 | 573 |
565 void LayerTreeHost::SetRootLayer(scoped_refptr<Layer> root_layer) { | 574 void LayerTreeHost::SetRootLayer(scoped_refptr<Layer> root_layer) { |
566 if (root_layer_.get() == root_layer.get()) | 575 if (root_layer_.get() == root_layer.get()) |
567 return; | 576 return; |
568 | 577 |
569 if (root_layer_.get()) | 578 if (root_layer_.get()) |
570 root_layer_->SetLayerTreeHost(NULL); | 579 root_layer_->SetLayerTreeHost(NULL); |
571 root_layer_ = root_layer; | 580 root_layer_ = root_layer; |
572 if (root_layer_.get()) { | 581 if (root_layer_.get()) { |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 constraints, | 1166 constraints, |
1158 current, | 1167 current, |
1159 animate)); | 1168 animate)); |
1160 } | 1169 } |
1161 | 1170 |
1162 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) { | 1171 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) { |
1163 if (!settings_.accelerated_animation_enabled) | 1172 if (!settings_.accelerated_animation_enabled) |
1164 return; | 1173 return; |
1165 | 1174 |
1166 AnimationEventsVector events; | 1175 AnimationEventsVector events; |
1167 if (animation_registrar_->AnimateLayers(monotonic_time)) { | 1176 if (animation_host_) { |
1168 animation_registrar_->UpdateAnimationState(true, &events); | 1177 if (animation_host_->AnimateLayers(monotonic_time)) |
1169 if (!events.empty()) | 1178 animation_host_->UpdateAnimationState(true, &events); |
1170 property_trees_.needs_rebuild = true; | 1179 } else if (animation_registrar_) { |
| 1180 if (animation_registrar_->AnimateLayers(monotonic_time)) |
| 1181 animation_registrar_->UpdateAnimationState(true, &events); |
1171 } | 1182 } |
| 1183 |
| 1184 if (!events.empty()) |
| 1185 property_trees_.needs_rebuild = true; |
1172 } | 1186 } |
1173 | 1187 |
1174 UIResourceId LayerTreeHost::CreateUIResource(UIResourceClient* client) { | 1188 UIResourceId LayerTreeHost::CreateUIResource(UIResourceClient* client) { |
1175 DCHECK(client); | 1189 DCHECK(client); |
1176 | 1190 |
1177 UIResourceId next_id = next_ui_resource_id_++; | 1191 UIResourceId next_id = next_ui_resource_id_++; |
1178 DCHECK(ui_resource_client_map_.find(next_id) == | 1192 DCHECK(ui_resource_client_map_.find(next_id) == |
1179 ui_resource_client_map_.end()); | 1193 ui_resource_client_map_.end()); |
1180 | 1194 |
1181 bool resource_lost = false; | 1195 bool resource_lost = false; |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1362 | 1376 |
1363 void LayerTreeHost::SetLayerScrollOffsetMutated( | 1377 void LayerTreeHost::SetLayerScrollOffsetMutated( |
1364 int layer_id, | 1378 int layer_id, |
1365 bool active_tree, | 1379 bool active_tree, |
1366 const gfx::ScrollOffset& scroll_offset) { | 1380 const gfx::ScrollOffset& scroll_offset) { |
1367 LayerAnimationValueObserver* layer = LayerById(layer_id); | 1381 LayerAnimationValueObserver* layer = LayerById(layer_id); |
1368 DCHECK(layer); | 1382 DCHECK(layer); |
1369 layer->OnScrollOffsetAnimated(scroll_offset); | 1383 layer->OnScrollOffsetAnimated(scroll_offset); |
1370 } | 1384 } |
1371 | 1385 |
| 1386 bool LayerTreeHost::ScrollOffsetAnimationWasInterrupted( |
| 1387 const Layer* layer) const { |
| 1388 return animation_host_ |
| 1389 ? animation_host_->ScrollOffsetAnimationWasInterrupted(layer->id()) |
| 1390 : false; |
| 1391 } |
| 1392 |
| 1393 bool LayerTreeHost::IsAnimatingFilterProperty(const Layer* layer) const { |
| 1394 return animation_host_ |
| 1395 ? animation_host_->IsAnimatingFilterProperty(layer->id()) |
| 1396 : false; |
| 1397 } |
| 1398 |
| 1399 bool LayerTreeHost::IsAnimatingOpacityProperty(const Layer* layer) const { |
| 1400 return animation_host_ |
| 1401 ? animation_host_->IsAnimatingOpacityProperty(layer->id()) |
| 1402 : false; |
| 1403 } |
| 1404 |
| 1405 bool LayerTreeHost::IsAnimatingTransformProperty(const Layer* layer) const { |
| 1406 return animation_host_ |
| 1407 ? animation_host_->IsAnimatingTransformProperty(layer->id()) |
| 1408 : false; |
| 1409 } |
| 1410 |
| 1411 bool LayerTreeHost::HasPotentiallyRunningOpacityAnimation( |
| 1412 const Layer* layer) const { |
| 1413 return animation_host_ |
| 1414 ? animation_host_->HasPotentiallyRunningOpacityAnimation( |
| 1415 layer->id()) |
| 1416 : false; |
| 1417 } |
| 1418 |
| 1419 bool LayerTreeHost::HasPotentiallyRunningTransformAnimation( |
| 1420 const Layer* layer) const { |
| 1421 return animation_host_ |
| 1422 ? animation_host_->HasPotentiallyRunningTransformAnimation( |
| 1423 layer->id()) |
| 1424 : false; |
| 1425 } |
| 1426 |
| 1427 bool LayerTreeHost::AnimationsPreserveAxisAlignment(const Layer* layer) const { |
| 1428 return animation_host_ |
| 1429 ? animation_host_->AnimationsPreserveAxisAlignment(layer->id()) |
| 1430 : true; |
| 1431 } |
| 1432 |
| 1433 bool LayerTreeHost::HasAnyAnimation(const Layer* layer) const { |
| 1434 return animation_host_ ? animation_host_->HasAnyAnimation(layer->id()) |
| 1435 : false; |
| 1436 } |
| 1437 |
| 1438 bool LayerTreeHost::HasActiveAnimation(const Layer* layer) const { |
| 1439 return animation_host_ ? animation_host_->HasActiveAnimation(layer->id()) |
| 1440 : false; |
| 1441 } |
| 1442 |
1372 } // namespace cc | 1443 } // namespace cc |
OLD | NEW |