Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(833)

Side by Side Diff: cc/trees/layer_tree_host.cc

Issue 1130043003: [Sketch] CC Animations: Torpedo the old intrusive animation system. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@implscroll
Patch Set: Delete more (headers and animation_registrar_ leftover) Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host.h ('k') | cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_host.h"
23 #include "cc/animation/animation_registrar.h"
24 #include "cc/animation/layer_animation_controller.h"
25 #include "cc/base/math_util.h" 23 #include "cc/base/math_util.h"
26 #include "cc/debug/devtools_instrumentation.h" 24 #include "cc/debug/devtools_instrumentation.h"
27 #include "cc/debug/frame_viewer_instrumentation.h" 25 #include "cc/debug/frame_viewer_instrumentation.h"
28 #include "cc/debug/rendering_stats_instrumentation.h" 26 #include "cc/debug/rendering_stats_instrumentation.h"
29 #include "cc/input/layer_selection_bound.h" 27 #include "cc/input/layer_selection_bound.h"
30 #include "cc/input/page_scale_animation.h" 28 #include "cc/input/page_scale_animation.h"
31 #include "cc/input/top_controls_manager.h" 29 #include "cc/input/top_controls_manager.h"
32 #include "cc/layers/heads_up_display_layer.h" 30 #include "cc/layers/heads_up_display_layer.h"
33 #include "cc/layers/heads_up_display_layer_impl.h" 31 #include "cc/layers/heads_up_display_layer_impl.h"
34 #include "cc/layers/layer.h" 32 #include "cc/layers/layer.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 partial_texture_update_requests_(0), 123 partial_texture_update_requests_(0),
126 did_complete_scale_animation_(false), 124 did_complete_scale_animation_(false),
127 in_paint_layer_contents_(false), 125 in_paint_layer_contents_(false),
128 id_(s_layer_tree_host_sequence_number.GetNext() + 1), 126 id_(s_layer_tree_host_sequence_number.GetNext() + 1),
129 next_commit_forces_redraw_(false), 127 next_commit_forces_redraw_(false),
130 shared_bitmap_manager_(shared_bitmap_manager), 128 shared_bitmap_manager_(shared_bitmap_manager),
131 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), 129 gpu_memory_buffer_manager_(gpu_memory_buffer_manager),
132 task_graph_runner_(task_graph_runner), 130 task_graph_runner_(task_graph_runner),
133 surface_id_namespace_(0u), 131 surface_id_namespace_(0u),
134 next_surface_sequence_(1u) { 132 next_surface_sequence_(1u) {
135 if (settings_.accelerated_animation_enabled &&
136 !settings.use_compositor_animation_timelines)
137 animation_registrar_ = AnimationRegistrar::Create();
138 rendering_stats_instrumentation_->set_record_rendering_stats( 133 rendering_stats_instrumentation_->set_record_rendering_stats(
139 debug_state_.RecordRenderingStats()); 134 debug_state_.RecordRenderingStats());
140 135
141 if (settings_.use_compositor_animation_timelines) { 136 animation_host_ = AnimationHost::Create(false);
142 animation_host_ = AnimationHost::Create(false); 137 animation_host_->SetLayerTreeMutatorsClient(this);
143 animation_host_->SetLayerTreeMutatorsClient(this);
144 }
145 } 138 }
146 139
147 void LayerTreeHost::InitializeThreaded( 140 void LayerTreeHost::InitializeThreaded(
148 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 141 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
149 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, 142 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
150 scoped_ptr<BeginFrameSource> external_begin_frame_source) { 143 scoped_ptr<BeginFrameSource> external_begin_frame_source) {
151 InitializeProxy(ThreadProxy::Create(this, 144 InitializeProxy(ThreadProxy::Create(this,
152 main_task_runner, 145 main_task_runner,
153 impl_task_runner, 146 impl_task_runner,
154 external_begin_frame_source.Pass())); 147 external_begin_frame_source.Pass()));
(...skipping 13 matching lines...) Expand all
168 void LayerTreeHost::InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing) { 161 void LayerTreeHost::InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing) {
169 InitializeProxy(proxy_for_testing.Pass()); 162 InitializeProxy(proxy_for_testing.Pass());
170 } 163 }
171 164
172 void LayerTreeHost::InitializeProxy(scoped_ptr<Proxy> proxy) { 165 void LayerTreeHost::InitializeProxy(scoped_ptr<Proxy> proxy) {
173 TRACE_EVENT0("cc", "LayerTreeHost::InitializeForReal"); 166 TRACE_EVENT0("cc", "LayerTreeHost::InitializeForReal");
174 167
175 proxy_ = proxy.Pass(); 168 proxy_ = proxy.Pass();
176 proxy_->Start(); 169 proxy_->Start();
177 if (settings_.accelerated_animation_enabled) { 170 if (settings_.accelerated_animation_enabled) {
178 if (animation_registrar_) 171 animation_host_->SetSupportsScrollAnimations(
179 animation_registrar_->set_supports_scroll_animations( 172 proxy_->SupportsImplScrolling());
180 proxy_->SupportsImplScrolling());
181
182 if (animation_host_)
183 animation_host_->SetSupportsScrollAnimations(
184 proxy_->SupportsImplScrolling());
185 } 173 }
186 } 174 }
187 175
188 LayerTreeHost::~LayerTreeHost() { 176 LayerTreeHost::~LayerTreeHost() {
189 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); 177 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost");
190 178
191 if (animation_host_) 179 if (animation_host_)
192 animation_host_->SetLayerTreeMutatorsClient(nullptr); 180 animation_host_->SetLayerTreeMutatorsClient(nullptr);
193 181
194 if (root_layer_.get()) 182 if (root_layer_.get())
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 proxy_->SetNextCommitWaitsForActivation(); 546 proxy_->SetNextCommitWaitsForActivation();
559 } 547 }
560 548
561 void LayerTreeHost::SetNextCommitForcesRedraw() { 549 void LayerTreeHost::SetNextCommitForcesRedraw() {
562 next_commit_forces_redraw_ = true; 550 next_commit_forces_redraw_ = true;
563 } 551 }
564 552
565 void LayerTreeHost::SetAnimationEvents( 553 void LayerTreeHost::SetAnimationEvents(
566 scoped_ptr<AnimationEventsVector> events) { 554 scoped_ptr<AnimationEventsVector> events) {
567 DCHECK(proxy_->IsMainThread()); 555 DCHECK(proxy_->IsMainThread());
568 if (animation_host_) 556 animation_host_->SetAnimationEvents(events.Pass());
569 animation_host_->SetAnimationEvents(events.Pass());
570 else
571 animation_registrar_->SetAnimationEvents(events.Pass());
572 } 557 }
573 558
574 void LayerTreeHost::SetRootLayer(scoped_refptr<Layer> root_layer) { 559 void LayerTreeHost::SetRootLayer(scoped_refptr<Layer> root_layer) {
575 if (root_layer_.get() == root_layer.get()) 560 if (root_layer_.get() == root_layer.get())
576 return; 561 return;
577 562
578 if (root_layer_.get()) 563 if (root_layer_.get())
579 root_layer_->SetLayerTreeHost(NULL); 564 root_layer_->SetLayerTreeHost(NULL);
580 root_layer_ = root_layer; 565 root_layer_ = root_layer;
581 if (root_layer_.get()) { 566 if (root_layer_.get()) {
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 constraints, 1151 constraints,
1167 current, 1152 current,
1168 animate)); 1153 animate));
1169 } 1154 }
1170 1155
1171 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) { 1156 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) {
1172 if (!settings_.accelerated_animation_enabled) 1157 if (!settings_.accelerated_animation_enabled)
1173 return; 1158 return;
1174 1159
1175 AnimationEventsVector events; 1160 AnimationEventsVector events;
1176 if (animation_host_) { 1161 if (animation_host_->AnimateLayers(monotonic_time))
1177 if (animation_host_->AnimateLayers(monotonic_time)) 1162 animation_host_->UpdateAnimationState(true, &events);
1178 animation_host_->UpdateAnimationState(true, &events);
1179 } else if (animation_registrar_) {
1180 if (animation_registrar_->AnimateLayers(monotonic_time))
1181 animation_registrar_->UpdateAnimationState(true, &events);
1182 }
1183 1163
1184 if (!events.empty()) 1164 if (!events.empty())
1185 property_trees_.needs_rebuild = true; 1165 property_trees_.needs_rebuild = true;
1186 } 1166 }
1187 1167
1188 UIResourceId LayerTreeHost::CreateUIResource(UIResourceClient* client) { 1168 UIResourceId LayerTreeHost::CreateUIResource(UIResourceClient* client) {
1189 DCHECK(client); 1169 DCHECK(client);
1190 1170
1191 UIResourceId next_id = next_ui_resource_id_++; 1171 UIResourceId next_id = next_ui_resource_id_++;
1192 DCHECK(ui_resource_client_map_.find(next_id) == 1172 DCHECK(ui_resource_client_map_.find(next_id) ==
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 return false; 1326 return false;
1347 } 1327 }
1348 1328
1349 void LayerTreeHost::SetMutatorsNeedCommit() { 1329 void LayerTreeHost::SetMutatorsNeedCommit() {
1350 SetNeedsCommit(); 1330 SetNeedsCommit();
1351 } 1331 }
1352 1332
1353 void LayerTreeHost::SetLayerFilterMutated(int layer_id, 1333 void LayerTreeHost::SetLayerFilterMutated(int layer_id,
1354 bool active_tree, 1334 bool active_tree,
1355 const FilterOperations& filters) { 1335 const FilterOperations& filters) {
1356 LayerAnimationValueObserver* layer = LayerById(layer_id); 1336 Layer* layer = LayerById(layer_id);
1357 DCHECK(layer); 1337 DCHECK(layer);
1358 layer->OnFilterAnimated(filters); 1338 layer->OnFilterAnimated(filters);
1359 } 1339 }
1360 1340
1361 void LayerTreeHost::SetLayerOpacityMutated(int layer_id, 1341 void LayerTreeHost::SetLayerOpacityMutated(int layer_id,
1362 bool active_tree, 1342 bool active_tree,
1363 float opacity) { 1343 float opacity) {
1364 LayerAnimationValueObserver* layer = LayerById(layer_id); 1344 Layer* layer = LayerById(layer_id);
1365 DCHECK(layer); 1345 DCHECK(layer);
1366 layer->OnOpacityAnimated(opacity); 1346 layer->OnOpacityAnimated(opacity);
1367 } 1347 }
1368 1348
1369 void LayerTreeHost::SetLayerTransformMutated(int layer_id, 1349 void LayerTreeHost::SetLayerTransformMutated(int layer_id,
1370 bool active_tree, 1350 bool active_tree,
1371 const gfx::Transform& transform) { 1351 const gfx::Transform& transform) {
1372 LayerAnimationValueObserver* layer = LayerById(layer_id); 1352 Layer* layer = LayerById(layer_id);
1373 DCHECK(layer); 1353 DCHECK(layer);
1374 layer->OnTransformAnimated(transform); 1354 layer->OnTransformAnimated(transform);
1375 } 1355 }
1376 1356
1377 void LayerTreeHost::SetLayerScrollOffsetMutated( 1357 void LayerTreeHost::SetLayerScrollOffsetMutated(
1378 int layer_id, 1358 int layer_id,
1379 bool active_tree, 1359 bool active_tree,
1380 const gfx::ScrollOffset& scroll_offset) { 1360 const gfx::ScrollOffset& scroll_offset) {
1381 LayerAnimationValueObserver* layer = LayerById(layer_id); 1361 // Do nothing. Scroll deltas will be sent from the compositor thread back
1382 DCHECK(layer); 1362 // to the main thread in the same manner as during non-animated
1383 layer->OnScrollOffsetAnimated(scroll_offset); 1363 // compositor-driven scrolling.
1384 } 1364 }
1385 1365
1386 gfx::ScrollOffset LayerTreeHost::GetScrollOffsetForAnimation( 1366 gfx::ScrollOffset LayerTreeHost::GetScrollOffsetForAnimation(
1387 int layer_id) const { 1367 int layer_id) const {
1388 LayerAnimationValueProvider* layer = LayerById(layer_id); 1368 Layer* layer = LayerById(layer_id);
1389 DCHECK(layer); 1369 DCHECK(layer);
1390 return layer->ScrollOffsetForAnimation(); 1370 return layer->ScrollOffsetForAnimation();
1391 } 1371 }
1392 1372
1393 bool LayerTreeHost::ScrollOffsetAnimationWasInterrupted( 1373 bool LayerTreeHost::ScrollOffsetAnimationWasInterrupted(
1394 const Layer* layer) const { 1374 const Layer* layer) const {
1395 return animation_host_ 1375 return animation_host_->ScrollOffsetAnimationWasInterrupted(layer->id());
1396 ? animation_host_->ScrollOffsetAnimationWasInterrupted(layer->id())
1397 : false;
1398 } 1376 }
1399 1377
1400 bool LayerTreeHost::IsAnimatingFilterProperty(const Layer* layer) const { 1378 bool LayerTreeHost::IsAnimatingFilterProperty(const Layer* layer) const {
1401 return animation_host_ 1379 return animation_host_->IsAnimatingFilterProperty(layer->id());
1402 ? animation_host_->IsAnimatingFilterProperty(layer->id())
1403 : false;
1404 } 1380 }
1405 1381
1406 bool LayerTreeHost::IsAnimatingOpacityProperty(const Layer* layer) const { 1382 bool LayerTreeHost::IsAnimatingOpacityProperty(const Layer* layer) const {
1407 return animation_host_ 1383 return animation_host_->IsAnimatingOpacityProperty(layer->id());
1408 ? animation_host_->IsAnimatingOpacityProperty(layer->id())
1409 : false;
1410 } 1384 }
1411 1385
1412 bool LayerTreeHost::IsAnimatingTransformProperty(const Layer* layer) const { 1386 bool LayerTreeHost::IsAnimatingTransformProperty(const Layer* layer) const {
1413 return animation_host_ 1387 return animation_host_->IsAnimatingTransformProperty(layer->id());
1414 ? animation_host_->IsAnimatingTransformProperty(layer->id())
1415 : false;
1416 } 1388 }
1417 1389
1418 bool LayerTreeHost::HasPotentiallyRunningOpacityAnimation( 1390 bool LayerTreeHost::HasPotentiallyRunningOpacityAnimation(
1419 const Layer* layer) const { 1391 const Layer* layer) const {
1420 return animation_host_ 1392 return animation_host_->HasPotentiallyRunningOpacityAnimation(layer->id());
1421 ? animation_host_->HasPotentiallyRunningOpacityAnimation(
1422 layer->id())
1423 : false;
1424 } 1393 }
1425 1394
1426 bool LayerTreeHost::HasPotentiallyRunningTransformAnimation( 1395 bool LayerTreeHost::HasPotentiallyRunningTransformAnimation(
1427 const Layer* layer) const { 1396 const Layer* layer) const {
1428 return animation_host_ 1397 return animation_host_->HasPotentiallyRunningTransformAnimation(layer->id());
1429 ? animation_host_->HasPotentiallyRunningTransformAnimation(
1430 layer->id())
1431 : false;
1432 } 1398 }
1433 1399
1434 bool LayerTreeHost::AnimationsPreserveAxisAlignment(const Layer* layer) const { 1400 bool LayerTreeHost::AnimationsPreserveAxisAlignment(const Layer* layer) const {
1435 return animation_host_ 1401 return animation_host_->AnimationsPreserveAxisAlignment(layer->id());
1436 ? animation_host_->AnimationsPreserveAxisAlignment(layer->id())
1437 : true;
1438 } 1402 }
1439 1403
1440 bool LayerTreeHost::HasAnyAnimation(const Layer* layer) const { 1404 bool LayerTreeHost::HasAnyAnimation(const Layer* layer) const {
1441 return animation_host_ ? animation_host_->HasAnyAnimation(layer->id()) 1405 return animation_host_->HasAnyAnimation(layer->id());
1442 : false;
1443 } 1406 }
1444 1407
1445 bool LayerTreeHost::HasActiveAnimation(const Layer* layer) const { 1408 bool LayerTreeHost::HasActiveAnimation(const Layer* layer) const {
1446 return animation_host_ ? animation_host_->HasActiveAnimation(layer->id()) 1409 return animation_host_->HasActiveAnimation(layer->id());
1447 : false;
1448 } 1410 }
1449 1411
1450 } // namespace cc 1412 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host.h ('k') | cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698