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

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

Issue 1782433002: CC Animation: Erase old animation system. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@erasetests
Patch Set: Format. Created 4 years, 9 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
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 #include <stack> 11 #include <stack>
12 #include <string> 12 #include <string>
13 #include <unordered_map> 13 #include <unordered_map>
14 14
15 #include "base/atomic_sequence_num.h" 15 #include "base/atomic_sequence_num.h"
16 #include "base/auto_reset.h" 16 #include "base/auto_reset.h"
17 #include "base/bind.h" 17 #include "base/bind.h"
18 #include "base/command_line.h" 18 #include "base/command_line.h"
19 #include "base/location.h" 19 #include "base/location.h"
20 #include "base/metrics/histogram.h" 20 #include "base/metrics/histogram.h"
21 #include "base/single_thread_task_runner.h" 21 #include "base/single_thread_task_runner.h"
22 #include "base/stl_util.h" 22 #include "base/stl_util.h"
23 #include "base/strings/string_number_conversions.h" 23 #include "base/strings/string_number_conversions.h"
24 #include "base/thread_task_runner_handle.h" 24 #include "base/thread_task_runner_handle.h"
25 #include "base/trace_event/trace_event.h" 25 #include "base/trace_event/trace_event.h"
26 #include "base/trace_event/trace_event_argument.h" 26 #include "base/trace_event/trace_event_argument.h"
27 #include "cc/animation/animation_events.h" 27 #include "cc/animation/animation_events.h"
28 #include "cc/animation/animation_host.h" 28 #include "cc/animation/animation_host.h"
29 #include "cc/animation/animation_registrar.h"
30 #include "cc/animation/layer_animation_controller.h"
31 #include "cc/base/math_util.h" 29 #include "cc/base/math_util.h"
32 #include "cc/debug/devtools_instrumentation.h" 30 #include "cc/debug/devtools_instrumentation.h"
33 #include "cc/debug/frame_viewer_instrumentation.h" 31 #include "cc/debug/frame_viewer_instrumentation.h"
34 #include "cc/debug/rendering_stats_instrumentation.h" 32 #include "cc/debug/rendering_stats_instrumentation.h"
35 #include "cc/input/layer_selection_bound.h" 33 #include "cc/input/layer_selection_bound.h"
36 #include "cc/input/page_scale_animation.h" 34 #include "cc/input/page_scale_animation.h"
37 #include "cc/layers/heads_up_display_layer.h" 35 #include "cc/layers/heads_up_display_layer.h"
38 #include "cc/layers/heads_up_display_layer_impl.h" 36 #include "cc/layers/heads_up_display_layer_impl.h"
39 #include "cc/layers/layer.h" 37 #include "cc/layers/layer.h"
40 #include "cc/layers/layer_iterator.h" 38 #include "cc/layers/layer_iterator.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 next_commit_forces_redraw_(false), 192 next_commit_forces_redraw_(false),
195 shared_bitmap_manager_(params->shared_bitmap_manager), 193 shared_bitmap_manager_(params->shared_bitmap_manager),
196 gpu_memory_buffer_manager_(params->gpu_memory_buffer_manager), 194 gpu_memory_buffer_manager_(params->gpu_memory_buffer_manager),
197 task_graph_runner_(params->task_graph_runner), 195 task_graph_runner_(params->task_graph_runner),
198 image_serialization_processor_(params->image_serialization_processor), 196 image_serialization_processor_(params->image_serialization_processor),
199 surface_id_namespace_(0u), 197 surface_id_namespace_(0u),
200 next_surface_sequence_(1u) { 198 next_surface_sequence_(1u) {
201 DCHECK(task_graph_runner_); 199 DCHECK(task_graph_runner_);
202 200
203 if (settings_.accelerated_animation_enabled) { 201 if (settings_.accelerated_animation_enabled) {
204 if (settings_.use_compositor_animation_timelines) { 202 animation_host_ = AnimationHost::Create(ThreadInstance::MAIN);
205 animation_host_ = AnimationHost::Create(ThreadInstance::MAIN); 203 animation_host_->SetMutatorHostClient(this);
206 animation_host_->SetMutatorHostClient(this);
207 } else {
208 animation_registrar_ = AnimationRegistrar::Create();
209 }
210 } 204 }
211 205
212 rendering_stats_instrumentation_->set_record_rendering_stats( 206 rendering_stats_instrumentation_->set_record_rendering_stats(
213 debug_state_.RecordRenderingStats()); 207 debug_state_.RecordRenderingStats());
214 } 208 }
215 209
216 void LayerTreeHost::InitializeThreaded( 210 void LayerTreeHost::InitializeThreaded(
217 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 211 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
218 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, 212 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
219 scoped_ptr<BeginFrameSource> external_begin_frame_source) { 213 scoped_ptr<BeginFrameSource> external_begin_frame_source) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 280
287 void LayerTreeHost::InitializeProxy( 281 void LayerTreeHost::InitializeProxy(
288 scoped_ptr<Proxy> proxy, 282 scoped_ptr<Proxy> proxy,
289 scoped_ptr<BeginFrameSource> external_begin_frame_source) { 283 scoped_ptr<BeginFrameSource> external_begin_frame_source) {
290 TRACE_EVENT0("cc", "LayerTreeHost::InitializeForReal"); 284 TRACE_EVENT0("cc", "LayerTreeHost::InitializeForReal");
291 DCHECK(task_runner_provider_); 285 DCHECK(task_runner_provider_);
292 286
293 proxy_ = std::move(proxy); 287 proxy_ = std::move(proxy);
294 proxy_->Start(std::move(external_begin_frame_source)); 288 proxy_->Start(std::move(external_begin_frame_source));
295 if (settings_.accelerated_animation_enabled) { 289 if (settings_.accelerated_animation_enabled) {
296 if (animation_host_) 290 animation_host_->SetSupportsScrollAnimations(
297 animation_host_->SetSupportsScrollAnimations( 291 proxy_->SupportsImplScrolling());
298 proxy_->SupportsImplScrolling());
299 else
300 animation_registrar_->set_supports_scroll_animations(
301 proxy_->SupportsImplScrolling());
302 } 292 }
303 } 293 }
304 294
305 LayerTreeHost::~LayerTreeHost() { 295 LayerTreeHost::~LayerTreeHost() {
306 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); 296 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost");
307 297
308 if (animation_host_) 298 if (animation_host_)
309 animation_host_->SetMutatorHostClient(nullptr); 299 animation_host_->SetMutatorHostClient(nullptr);
310 300
311 if (root_layer_.get()) 301 if (root_layer_.get())
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 proxy_->SetNextCommitWaitsForActivation(); 681 proxy_->SetNextCommitWaitsForActivation();
692 } 682 }
693 683
694 void LayerTreeHost::SetNextCommitForcesRedraw() { 684 void LayerTreeHost::SetNextCommitForcesRedraw() {
695 next_commit_forces_redraw_ = true; 685 next_commit_forces_redraw_ = true;
696 proxy_->SetNeedsUpdateLayers(); 686 proxy_->SetNeedsUpdateLayers();
697 } 687 }
698 688
699 void LayerTreeHost::SetAnimationEvents(scoped_ptr<AnimationEvents> events) { 689 void LayerTreeHost::SetAnimationEvents(scoped_ptr<AnimationEvents> events) {
700 DCHECK(task_runner_provider_->IsMainThread()); 690 DCHECK(task_runner_provider_->IsMainThread());
701 if (animation_host_) 691 animation_host_->SetAnimationEvents(std::move(events));
702 animation_host_->SetAnimationEvents(std::move(events));
703 else
704 animation_registrar_->SetAnimationEvents(std::move(events));
705 } 692 }
706 693
707 void LayerTreeHost::SetRootLayer(scoped_refptr<Layer> root_layer) { 694 void LayerTreeHost::SetRootLayer(scoped_refptr<Layer> root_layer) {
708 if (root_layer_.get() == root_layer.get()) 695 if (root_layer_.get() == root_layer.get())
709 return; 696 return;
710 697
711 if (root_layer_.get()) 698 if (root_layer_.get())
712 root_layer_->SetLayerTreeHost(NULL); 699 root_layer_->SetLayerTreeHost(NULL);
713 root_layer_ = root_layer; 700 root_layer_ = root_layer;
714 if (root_layer_.get()) { 701 if (root_layer_.get()) {
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 // Top controls are only used in threaded or remote mode. 1053 // Top controls are only used in threaded or remote mode.
1067 DCHECK(IsThreaded() || IsRemoteServer()); 1054 DCHECK(IsThreaded() || IsRemoteServer());
1068 proxy_->UpdateTopControlsState(constraints, current, animate); 1055 proxy_->UpdateTopControlsState(constraints, current, animate);
1069 } 1056 }
1070 1057
1071 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) { 1058 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) {
1072 if (!settings_.accelerated_animation_enabled) 1059 if (!settings_.accelerated_animation_enabled)
1073 return; 1060 return;
1074 1061
1075 scoped_ptr<AnimationEvents> events; 1062 scoped_ptr<AnimationEvents> events;
1076 if (animation_host_) { 1063 events = animation_host_->CreateEvents();
1077 events = animation_host_->CreateEvents(); 1064 if (animation_host_->AnimateLayers(monotonic_time))
1078 if (animation_host_->AnimateLayers(monotonic_time)) 1065 animation_host_->UpdateAnimationState(true, events.get());
1079 animation_host_->UpdateAnimationState(true, events.get());
1080 } else {
1081 events = animation_registrar_->CreateEvents();
1082 if (animation_registrar_->AnimateLayers(monotonic_time))
1083 animation_registrar_->UpdateAnimationState(true, events.get());
1084 }
1085 1066
1086 if (!events->events_.empty()) 1067 if (!events->events_.empty())
1087 property_trees_.needs_rebuild = true; 1068 property_trees_.needs_rebuild = true;
1088 } 1069 }
1089 1070
1090 UIResourceId LayerTreeHost::CreateUIResource(UIResourceClient* client) { 1071 UIResourceId LayerTreeHost::CreateUIResource(UIResourceClient* client) {
1091 DCHECK(client); 1072 DCHECK(client);
1092 1073
1093 UIResourceId next_id = next_ui_resource_id_++; 1074 UIResourceId next_id = next_ui_resource_id_++;
1094 DCHECK(ui_resource_client_map_.find(next_id) == 1075 DCHECK(ui_resource_client_map_.find(next_id) ==
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 SetNeedsCommit(); 1264 SetNeedsCommit();
1284 } 1265 }
1285 1266
1286 void LayerTreeHost::SetMutatorsNeedRebuildPropertyTrees() { 1267 void LayerTreeHost::SetMutatorsNeedRebuildPropertyTrees() {
1287 property_trees_.needs_rebuild = true; 1268 property_trees_.needs_rebuild = true;
1288 } 1269 }
1289 1270
1290 void LayerTreeHost::SetLayerFilterMutated(int layer_id, 1271 void LayerTreeHost::SetLayerFilterMutated(int layer_id,
1291 LayerTreeType tree_type, 1272 LayerTreeType tree_type,
1292 const FilterOperations& filters) { 1273 const FilterOperations& filters) {
1293 LayerAnimationValueObserver* layer = LayerById(layer_id); 1274 Layer* layer = LayerById(layer_id);
1294 DCHECK(layer); 1275 DCHECK(layer);
1295 layer->OnFilterAnimated(filters); 1276 layer->OnFilterAnimated(filters);
1296 } 1277 }
1297 1278
1298 void LayerTreeHost::SetLayerOpacityMutated(int layer_id, 1279 void LayerTreeHost::SetLayerOpacityMutated(int layer_id,
1299 LayerTreeType tree_type, 1280 LayerTreeType tree_type,
1300 float opacity) { 1281 float opacity) {
1301 LayerAnimationValueObserver* layer = LayerById(layer_id); 1282 Layer* layer = LayerById(layer_id);
1302 DCHECK(layer); 1283 DCHECK(layer);
1303 layer->OnOpacityAnimated(opacity); 1284 layer->OnOpacityAnimated(opacity);
1304 } 1285 }
1305 1286
1306 void LayerTreeHost::SetLayerTransformMutated(int layer_id, 1287 void LayerTreeHost::SetLayerTransformMutated(int layer_id,
1307 LayerTreeType tree_type, 1288 LayerTreeType tree_type,
1308 const gfx::Transform& transform) { 1289 const gfx::Transform& transform) {
1309 LayerAnimationValueObserver* layer = LayerById(layer_id); 1290 Layer* layer = LayerById(layer_id);
1310 DCHECK(layer); 1291 DCHECK(layer);
1311 layer->OnTransformAnimated(transform); 1292 layer->OnTransformAnimated(transform);
1312 } 1293 }
1313 1294
1314 void LayerTreeHost::SetLayerScrollOffsetMutated( 1295 void LayerTreeHost::SetLayerScrollOffsetMutated(
1315 int layer_id, 1296 int layer_id,
1316 LayerTreeType tree_type, 1297 LayerTreeType tree_type,
1317 const gfx::ScrollOffset& scroll_offset) { 1298 const gfx::ScrollOffset& scroll_offset) {
1318 LayerAnimationValueObserver* layer = LayerById(layer_id); 1299 Layer* layer = LayerById(layer_id);
1319 DCHECK(layer); 1300 DCHECK(layer);
1320 layer->OnScrollOffsetAnimated(scroll_offset); 1301 layer->OnScrollOffsetAnimated(scroll_offset);
1321 } 1302 }
1322 1303
1323 void LayerTreeHost::LayerTransformIsPotentiallyAnimatingChanged( 1304 void LayerTreeHost::LayerTransformIsPotentiallyAnimatingChanged(
1324 int layer_id, 1305 int layer_id,
1325 LayerTreeType tree_type, 1306 LayerTreeType tree_type,
1326 bool is_animating) { 1307 bool is_animating) {
1327 LayerAnimationValueObserver* layer = LayerById(layer_id); 1308 Layer* layer = LayerById(layer_id);
1328 DCHECK(layer); 1309 DCHECK(layer);
1329 layer->OnTransformIsPotentiallyAnimatingChanged(is_animating); 1310 layer->OnTransformIsPotentiallyAnimatingChanged(is_animating);
1330 } 1311 }
1331 1312
1332 gfx::ScrollOffset LayerTreeHost::GetScrollOffsetForAnimation( 1313 gfx::ScrollOffset LayerTreeHost::GetScrollOffsetForAnimation(
1333 int layer_id) const { 1314 int layer_id) const {
1334 LayerAnimationValueProvider* layer = LayerById(layer_id); 1315 Layer* layer = LayerById(layer_id);
1335 DCHECK(layer); 1316 DCHECK(layer);
1336 return layer->ScrollOffsetForAnimation(); 1317 return layer->ScrollOffsetForAnimation();
1337 } 1318 }
1338 1319
1339 bool LayerTreeHost::ScrollOffsetAnimationWasInterrupted( 1320 bool LayerTreeHost::ScrollOffsetAnimationWasInterrupted(
1340 const Layer* layer) const { 1321 const Layer* layer) const {
1341 return animation_host_ 1322 return animation_host_
1342 ? animation_host_->ScrollOffsetAnimationWasInterrupted(layer->id()) 1323 ? animation_host_->ScrollOffsetAnimationWasInterrupted(layer->id())
1343 : false; 1324 : false;
1344 } 1325 }
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 LayerTreeHostCommon::CallFunctionForSubtree( 1598 LayerTreeHostCommon::CallFunctionForSubtree(
1618 root_layer(), [seq_num](Layer* layer) { 1599 root_layer(), [seq_num](Layer* layer) {
1619 layer->set_property_tree_sequence_number(seq_num); 1600 layer->set_property_tree_sequence_number(seq_num);
1620 }); 1601 });
1621 1602
1622 surface_id_namespace_ = proto.surface_id_namespace(); 1603 surface_id_namespace_ = proto.surface_id_namespace();
1623 next_surface_sequence_ = proto.next_surface_sequence(); 1604 next_surface_sequence_ = proto.next_surface_sequence();
1624 } 1605 }
1625 1606
1626 } // namespace cc 1607 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698