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

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

Issue 947033002: CC Animations: Establish AnimationHost, AnimationTimeline and AnimationPlayer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix MSVC warning. Created 5 years, 5 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/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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 shared_bitmap_manager_(params->shared_bitmap_manager), 118 shared_bitmap_manager_(params->shared_bitmap_manager),
118 gpu_memory_buffer_manager_(params->gpu_memory_buffer_manager), 119 gpu_memory_buffer_manager_(params->gpu_memory_buffer_manager),
119 task_graph_runner_(params->task_graph_runner), 120 task_graph_runner_(params->task_graph_runner),
120 surface_id_namespace_(0u), 121 surface_id_namespace_(0u),
121 next_surface_sequence_(1u) { 122 next_surface_sequence_(1u) {
122 DCHECK(task_graph_runner_); 123 DCHECK(task_graph_runner_);
123 if (settings_.accelerated_animation_enabled) 124 if (settings_.accelerated_animation_enabled)
124 animation_registrar_ = AnimationRegistrar::Create(); 125 animation_registrar_ = AnimationRegistrar::Create();
125 rendering_stats_instrumentation_->set_record_rendering_stats( 126 rendering_stats_instrumentation_->set_record_rendering_stats(
126 debug_state_.RecordRenderingStats()); 127 debug_state_.RecordRenderingStats());
128
129 if (settings_.use_compositor_animation_timelines) {
130 animation_host_ = AnimationHost::Create(ThreadInstance::MAIN);
131 animation_host_->SetMutatorHostClient(this);
132 }
127 } 133 }
128 134
129 void LayerTreeHost::InitializeThreaded( 135 void LayerTreeHost::InitializeThreaded(
130 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 136 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
131 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, 137 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
132 scoped_ptr<BeginFrameSource> external_begin_frame_source) { 138 scoped_ptr<BeginFrameSource> external_begin_frame_source) {
133 InitializeProxy(ThreadProxy::Create(this, 139 InitializeProxy(ThreadProxy::Create(this,
134 main_task_runner, 140 main_task_runner,
135 impl_task_runner, 141 impl_task_runner,
136 external_begin_frame_source.Pass())); 142 external_begin_frame_source.Pass()));
(...skipping 21 matching lines...) Expand all
158 proxy_->Start(); 164 proxy_->Start();
159 if (settings_.accelerated_animation_enabled) { 165 if (settings_.accelerated_animation_enabled) {
160 animation_registrar_->set_supports_scroll_animations( 166 animation_registrar_->set_supports_scroll_animations(
161 proxy_->SupportsImplScrolling()); 167 proxy_->SupportsImplScrolling());
162 } 168 }
163 } 169 }
164 170
165 LayerTreeHost::~LayerTreeHost() { 171 LayerTreeHost::~LayerTreeHost() {
166 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); 172 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost");
167 173
174 if (animation_host_)
175 animation_host_->SetMutatorHostClient(nullptr);
176
168 if (root_layer_.get()) 177 if (root_layer_.get())
169 root_layer_->SetLayerTreeHost(NULL); 178 root_layer_->SetLayerTreeHost(NULL);
170 179
171 DCHECK(swap_promise_monitor_.empty()); 180 DCHECK(swap_promise_monitor_.empty());
172 181
173 BreakSwapPromises(SwapPromise::COMMIT_FAILS); 182 BreakSwapPromises(SwapPromise::COMMIT_FAILS);
174 183
175 if (proxy_) { 184 if (proxy_) {
176 DCHECK(proxy_->IsMainThread()); 185 DCHECK(proxy_->IsMainThread());
177 proxy_->Stop(); 186 proxy_->Stop();
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 ui_resource_request_queue_.clear(); 325 ui_resource_request_queue_.clear();
317 } 326 }
318 327
319 DCHECK(!sync_tree->ViewportSizeInvalid()); 328 DCHECK(!sync_tree->ViewportSizeInvalid());
320 329
321 sync_tree->set_has_ever_been_drawn(false); 330 sync_tree->set_has_ever_been_drawn(false);
322 331
323 { 332 {
324 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties"); 333 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties");
325 TreeSynchronizer::PushProperties(root_layer(), sync_tree->root_layer()); 334 TreeSynchronizer::PushProperties(root_layer(), sync_tree->root_layer());
335
336 if (animation_host_) {
337 DCHECK(host_impl->animation_host());
338 animation_host_->PushPropertiesTo(host_impl->animation_host());
339 }
326 } 340 }
327 341
328 // This must happen after synchronizing property trees and after push 342 // This must happen after synchronizing property trees and after push
329 // properties, which updates property tree indices. 343 // properties, which updates property tree indices.
330 sync_tree->UpdatePropertyTreeScrollingAndAnimationFromMainThread(); 344 sync_tree->UpdatePropertyTreeScrollingAndAnimationFromMainThread();
331 345
332 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); 346 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl);
333 } 347 }
334 348
335 void LayerTreeHost::WillCommit() { 349 void LayerTreeHost::WillCommit() {
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 proxy_->SetAuthoritativeVSyncInterval(interval); 1067 proxy_->SetAuthoritativeVSyncInterval(interval);
1054 } 1068 }
1055 1069
1056 void LayerTreeHost::RecordFrameTimingEvents( 1070 void LayerTreeHost::RecordFrameTimingEvents(
1057 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, 1071 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
1058 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { 1072 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) {
1059 client_->RecordFrameTimingEvents(composite_events.Pass(), 1073 client_->RecordFrameTimingEvents(composite_events.Pass(),
1060 main_frame_events.Pass()); 1074 main_frame_events.Pass());
1061 } 1075 }
1062 1076
1077 Layer* LayerTreeHost::LayerById(int id) const {
1078 LayerIdMap::const_iterator iter = layer_id_map_.find(id);
1079 return iter != layer_id_map_.end() ? iter->second : NULL;
1080 }
1081
1082 void LayerTreeHost::RegisterLayer(Layer* layer) {
1083 DCHECK(!LayerById(layer->id()));
1084 layer_id_map_[layer->id()] = layer;
1085 if (animation_host_)
1086 animation_host_->RegisterLayer(layer->id(), LayerTreeType::ACTIVE);
1087 }
1088
1089 void LayerTreeHost::UnregisterLayer(Layer* layer) {
1090 DCHECK(LayerById(layer->id()));
1091 if (animation_host_)
1092 animation_host_->UnregisterLayer(layer->id(), LayerTreeType::ACTIVE);
1093 layer_id_map_.erase(layer->id());
1094 }
1095
1096 bool LayerTreeHost::IsLayerInTree(int layer_id, LayerTreeType tree_type) const {
1097 return tree_type == LayerTreeType::ACTIVE;
1098 }
1099
1100 void LayerTreeHost::SetMutatorsNeedCommit() {
1101 SetNeedsCommit();
1102 }
1103
1104 void LayerTreeHost::SetLayerFilterMutated(int layer_id,
1105 LayerTreeType tree_type,
1106 const FilterOperations& filters) {
1107 LayerAnimationValueObserver* layer = LayerById(layer_id);
1108 DCHECK(layer);
1109 layer->OnFilterAnimated(filters);
1110 }
1111
1112 void LayerTreeHost::SetLayerOpacityMutated(int layer_id,
1113 LayerTreeType tree_type,
1114 float opacity) {
1115 LayerAnimationValueObserver* layer = LayerById(layer_id);
1116 DCHECK(layer);
1117 layer->OnOpacityAnimated(opacity);
1118 }
1119
1120 void LayerTreeHost::SetLayerTransformMutated(int layer_id,
1121 LayerTreeType tree_type,
1122 const gfx::Transform& transform) {
1123 LayerAnimationValueObserver* layer = LayerById(layer_id);
1124 DCHECK(layer);
1125 layer->OnTransformAnimated(transform);
1126 }
1127
1128 void LayerTreeHost::SetLayerScrollOffsetMutated(
1129 int layer_id,
1130 LayerTreeType tree_type,
1131 const gfx::ScrollOffset& scroll_offset) {
1132 LayerAnimationValueObserver* layer = LayerById(layer_id);
1133 DCHECK(layer);
1134 layer->OnScrollOffsetAnimated(scroll_offset);
1135 }
1136
1063 } // namespace cc 1137 } // 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