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

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: Remove vtbl in LayerAnimationController. Fix formatting. 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
« no previous file with comments | « cc/trees/layer_tree_host.h ('k') | cc/trees/layer_tree_host_common_unittest.cc » ('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 <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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 // Top controls are only used in threaded or remote mode. 1049 // Top controls are only used in threaded or remote mode.
1063 DCHECK(IsThreaded() || IsRemoteServer()); 1050 DCHECK(IsThreaded() || IsRemoteServer());
1064 proxy_->UpdateTopControlsState(constraints, current, animate); 1051 proxy_->UpdateTopControlsState(constraints, current, animate);
1065 } 1052 }
1066 1053
1067 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) { 1054 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) {
1068 if (!settings_.accelerated_animation_enabled) 1055 if (!settings_.accelerated_animation_enabled)
1069 return; 1056 return;
1070 1057
1071 scoped_ptr<AnimationEvents> events; 1058 scoped_ptr<AnimationEvents> events;
1072 if (animation_host_) { 1059 events = animation_host_->CreateEvents();
1073 events = animation_host_->CreateEvents(); 1060 if (animation_host_->AnimateLayers(monotonic_time))
1074 if (animation_host_->AnimateLayers(monotonic_time)) 1061 animation_host_->UpdateAnimationState(true, events.get());
1075 animation_host_->UpdateAnimationState(true, events.get());
1076 } else {
1077 events = animation_registrar_->CreateEvents();
1078 if (animation_registrar_->AnimateLayers(monotonic_time))
1079 animation_registrar_->UpdateAnimationState(true, events.get());
1080 }
1081 1062
1082 if (!events->events_.empty()) 1063 if (!events->events_.empty())
1083 property_trees_.needs_rebuild = true; 1064 property_trees_.needs_rebuild = true;
1084 } 1065 }
1085 1066
1086 UIResourceId LayerTreeHost::CreateUIResource(UIResourceClient* client) { 1067 UIResourceId LayerTreeHost::CreateUIResource(UIResourceClient* client) {
1087 DCHECK(client); 1068 DCHECK(client);
1088 1069
1089 UIResourceId next_id = next_ui_resource_id_++; 1070 UIResourceId next_id = next_ui_resource_id_++;
1090 DCHECK(ui_resource_client_map_.find(next_id) == 1071 DCHECK(ui_resource_client_map_.find(next_id) ==
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 SetNeedsCommit(); 1260 SetNeedsCommit();
1280 } 1261 }
1281 1262
1282 void LayerTreeHost::SetMutatorsNeedRebuildPropertyTrees() { 1263 void LayerTreeHost::SetMutatorsNeedRebuildPropertyTrees() {
1283 property_trees_.needs_rebuild = true; 1264 property_trees_.needs_rebuild = true;
1284 } 1265 }
1285 1266
1286 void LayerTreeHost::SetLayerFilterMutated(int layer_id, 1267 void LayerTreeHost::SetLayerFilterMutated(int layer_id,
1287 LayerTreeType tree_type, 1268 LayerTreeType tree_type,
1288 const FilterOperations& filters) { 1269 const FilterOperations& filters) {
1289 LayerAnimationValueObserver* layer = LayerById(layer_id); 1270 Layer* layer = LayerById(layer_id);
1290 DCHECK(layer); 1271 DCHECK(layer);
1291 layer->OnFilterAnimated(filters); 1272 layer->OnFilterAnimated(filters);
1292 } 1273 }
1293 1274
1294 void LayerTreeHost::SetLayerOpacityMutated(int layer_id, 1275 void LayerTreeHost::SetLayerOpacityMutated(int layer_id,
1295 LayerTreeType tree_type, 1276 LayerTreeType tree_type,
1296 float opacity) { 1277 float opacity) {
1297 LayerAnimationValueObserver* layer = LayerById(layer_id); 1278 Layer* layer = LayerById(layer_id);
1298 DCHECK(layer); 1279 DCHECK(layer);
1299 layer->OnOpacityAnimated(opacity); 1280 layer->OnOpacityAnimated(opacity);
1300 } 1281 }
1301 1282
1302 void LayerTreeHost::SetLayerTransformMutated(int layer_id, 1283 void LayerTreeHost::SetLayerTransformMutated(int layer_id,
1303 LayerTreeType tree_type, 1284 LayerTreeType tree_type,
1304 const gfx::Transform& transform) { 1285 const gfx::Transform& transform) {
1305 LayerAnimationValueObserver* layer = LayerById(layer_id); 1286 Layer* layer = LayerById(layer_id);
1306 DCHECK(layer); 1287 DCHECK(layer);
1307 layer->OnTransformAnimated(transform); 1288 layer->OnTransformAnimated(transform);
1308 } 1289 }
1309 1290
1310 void LayerTreeHost::SetLayerScrollOffsetMutated( 1291 void LayerTreeHost::SetLayerScrollOffsetMutated(
1311 int layer_id, 1292 int layer_id,
1312 LayerTreeType tree_type, 1293 LayerTreeType tree_type,
1313 const gfx::ScrollOffset& scroll_offset) { 1294 const gfx::ScrollOffset& scroll_offset) {
1314 LayerAnimationValueObserver* layer = LayerById(layer_id); 1295 Layer* layer = LayerById(layer_id);
1315 DCHECK(layer); 1296 DCHECK(layer);
1316 layer->OnScrollOffsetAnimated(scroll_offset); 1297 layer->OnScrollOffsetAnimated(scroll_offset);
1317 } 1298 }
1318 1299
1319 void LayerTreeHost::LayerTransformIsPotentiallyAnimatingChanged( 1300 void LayerTreeHost::LayerTransformIsPotentiallyAnimatingChanged(
1320 int layer_id, 1301 int layer_id,
1321 LayerTreeType tree_type, 1302 LayerTreeType tree_type,
1322 bool is_animating) { 1303 bool is_animating) {
1323 LayerAnimationValueObserver* layer = LayerById(layer_id); 1304 Layer* layer = LayerById(layer_id);
1324 DCHECK(layer); 1305 DCHECK(layer);
1325 layer->OnTransformIsPotentiallyAnimatingChanged(is_animating); 1306 layer->OnTransformIsPotentiallyAnimatingChanged(is_animating);
1326 } 1307 }
1327 1308
1328 gfx::ScrollOffset LayerTreeHost::GetScrollOffsetForAnimation( 1309 gfx::ScrollOffset LayerTreeHost::GetScrollOffsetForAnimation(
1329 int layer_id) const { 1310 int layer_id) const {
1330 LayerAnimationValueProvider* layer = LayerById(layer_id); 1311 Layer* layer = LayerById(layer_id);
1331 DCHECK(layer); 1312 DCHECK(layer);
1332 return layer->ScrollOffsetForAnimation(); 1313 return layer->ScrollOffsetForAnimation();
1333 } 1314 }
1334 1315
1335 bool LayerTreeHost::ScrollOffsetAnimationWasInterrupted( 1316 bool LayerTreeHost::ScrollOffsetAnimationWasInterrupted(
1336 const Layer* layer) const { 1317 const Layer* layer) const {
1337 return animation_host_ 1318 return animation_host_
1338 ? animation_host_->ScrollOffsetAnimationWasInterrupted(layer->id()) 1319 ? animation_host_->ScrollOffsetAnimationWasInterrupted(layer->id())
1339 : false; 1320 : false;
1340 } 1321 }
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1613 LayerTreeHostCommon::CallFunctionForSubtree( 1594 LayerTreeHostCommon::CallFunctionForSubtree(
1614 root_layer(), [seq_num](Layer* layer) { 1595 root_layer(), [seq_num](Layer* layer) {
1615 layer->set_property_tree_sequence_number(seq_num); 1596 layer->set_property_tree_sequence_number(seq_num);
1616 }); 1597 });
1617 1598
1618 surface_id_namespace_ = proto.surface_id_namespace(); 1599 surface_id_namespace_ = proto.surface_id_namespace();
1619 next_surface_sequence_ = proto.next_surface_sequence(); 1600 next_surface_sequence_ = proto.next_surface_sequence();
1620 } 1601 }
1621 1602
1622 } // namespace cc 1603 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host.h ('k') | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698