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

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: Set up impl-only timelines for ScrollOffset animations Created 5 years, 8 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/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/stl_util.h" 16 #include "base/stl_util.h"
17 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
18 #include "base/trace_event/trace_event.h" 18 #include "base/trace_event/trace_event.h"
19 #include "base/trace_event/trace_event_argument.h" 19 #include "base/trace_event/trace_event_argument.h"
20 #include "cc/animation/animation_host.h"
20 #include "cc/animation/animation_registrar.h" 21 #include "cc/animation/animation_registrar.h"
21 #include "cc/animation/layer_animation_controller.h" 22 #include "cc/animation/layer_animation_controller.h"
22 #include "cc/base/math_util.h" 23 #include "cc/base/math_util.h"
23 #include "cc/debug/devtools_instrumentation.h" 24 #include "cc/debug/devtools_instrumentation.h"
24 #include "cc/debug/frame_viewer_instrumentation.h" 25 #include "cc/debug/frame_viewer_instrumentation.h"
25 #include "cc/debug/rendering_stats_instrumentation.h" 26 #include "cc/debug/rendering_stats_instrumentation.h"
26 #include "cc/input/layer_selection_bound.h" 27 #include "cc/input/layer_selection_bound.h"
27 #include "cc/input/page_scale_animation.h" 28 #include "cc/input/page_scale_animation.h"
28 #include "cc/input/top_controls_manager.h" 29 #include "cc/input/top_controls_manager.h"
29 #include "cc/layers/heads_up_display_layer.h" 30 #include "cc/layers/heads_up_display_layer.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 next_commit_forces_redraw_(false), 127 next_commit_forces_redraw_(false),
127 shared_bitmap_manager_(shared_bitmap_manager), 128 shared_bitmap_manager_(shared_bitmap_manager),
128 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), 129 gpu_memory_buffer_manager_(gpu_memory_buffer_manager),
129 task_graph_runner_(task_graph_runner), 130 task_graph_runner_(task_graph_runner),
130 surface_id_namespace_(0u), 131 surface_id_namespace_(0u),
131 next_surface_sequence_(1u) { 132 next_surface_sequence_(1u) {
132 if (settings_.accelerated_animation_enabled) 133 if (settings_.accelerated_animation_enabled)
133 animation_registrar_ = AnimationRegistrar::Create(); 134 animation_registrar_ = AnimationRegistrar::Create();
134 rendering_stats_instrumentation_->set_record_rendering_stats( 135 rendering_stats_instrumentation_->set_record_rendering_stats(
135 debug_state_.RecordRenderingStats()); 136 debug_state_.RecordRenderingStats());
137
138 if (settings_.use_compositor_animation_timelines) {
139 animation_host_ = AnimationHost::Create(false);
140 animation_host_->SetLayerTreeMutatorsClient(this);
141 }
136 } 142 }
137 143
138 void LayerTreeHost::InitializeThreaded( 144 void LayerTreeHost::InitializeThreaded(
139 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 145 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
140 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, 146 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
141 scoped_ptr<BeginFrameSource> external_begin_frame_source) { 147 scoped_ptr<BeginFrameSource> external_begin_frame_source) {
142 InitializeProxy(ThreadProxy::Create(this, 148 InitializeProxy(ThreadProxy::Create(this,
143 main_task_runner, 149 main_task_runner,
144 impl_task_runner, 150 impl_task_runner,
145 external_begin_frame_source.Pass())); 151 external_begin_frame_source.Pass()));
(...skipping 21 matching lines...) Expand all
167 proxy_->Start(); 173 proxy_->Start();
168 if (settings_.accelerated_animation_enabled) { 174 if (settings_.accelerated_animation_enabled) {
169 animation_registrar_->set_supports_scroll_animations( 175 animation_registrar_->set_supports_scroll_animations(
170 proxy_->SupportsImplScrolling()); 176 proxy_->SupportsImplScrolling());
171 } 177 }
172 } 178 }
173 179
174 LayerTreeHost::~LayerTreeHost() { 180 LayerTreeHost::~LayerTreeHost() {
175 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); 181 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost");
176 182
183 if (animation_host_)
184 animation_host_->SetLayerTreeMutatorsClient(nullptr);
185
177 if (root_layer_.get()) 186 if (root_layer_.get())
178 root_layer_->SetLayerTreeHost(NULL); 187 root_layer_->SetLayerTreeHost(NULL);
179 188
180 DCHECK(swap_promise_monitor_.empty()); 189 DCHECK(swap_promise_monitor_.empty());
181 190
182 BreakSwapPromises(SwapPromise::COMMIT_FAILS); 191 BreakSwapPromises(SwapPromise::COMMIT_FAILS);
183 192
184 if (proxy_) { 193 if (proxy_) {
185 DCHECK(proxy_->IsMainThread()); 194 DCHECK(proxy_->IsMainThread());
186 proxy_->Stop(); 195 proxy_->Stop();
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 if (new_impl_tree_has_no_evicted_resources) { 369 if (new_impl_tree_has_no_evicted_resources) {
361 if (sync_tree->ContentsTexturesPurged()) 370 if (sync_tree->ContentsTexturesPurged())
362 sync_tree->ResetContentsTexturesPurged(); 371 sync_tree->ResetContentsTexturesPurged();
363 } 372 }
364 373
365 sync_tree->set_has_ever_been_drawn(false); 374 sync_tree->set_has_ever_been_drawn(false);
366 375
367 { 376 {
368 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties"); 377 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties");
369 TreeSynchronizer::PushProperties(root_layer(), sync_tree->root_layer()); 378 TreeSynchronizer::PushProperties(root_layer(), sync_tree->root_layer());
379
380 if (animation_host_) {
381 DCHECK(host_impl->animation_host());
382 animation_host_->PushPropertiesTo(host_impl->animation_host());
383 }
370 } 384 }
371 385
372 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); 386 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl);
373 } 387 }
374 388
375 void LayerTreeHost::WillCommit() { 389 void LayerTreeHost::WillCommit() {
376 client_->WillCommit(); 390 client_->WillCommit();
377 } 391 }
378 392
379 void LayerTreeHost::UpdateHudLayer() { 393 void LayerTreeHost::UpdateHudLayer() {
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 void LayerTreeHost::SendBeginFramesToChildren( 1285 void LayerTreeHost::SendBeginFramesToChildren(
1272 const BeginFrameArgs& args) const { 1286 const BeginFrameArgs& args) const {
1273 client_->SendBeginFramesToChildren(args); 1287 client_->SendBeginFramesToChildren(args);
1274 } 1288 }
1275 1289
1276 void LayerTreeHost::SetAuthoritativeVSyncInterval( 1290 void LayerTreeHost::SetAuthoritativeVSyncInterval(
1277 const base::TimeDelta& interval) { 1291 const base::TimeDelta& interval) {
1278 proxy_->SetAuthoritativeVSyncInterval(interval); 1292 proxy_->SetAuthoritativeVSyncInterval(interval);
1279 } 1293 }
1280 1294
1295 Layer* LayerTreeHost::LayerById(int id) const {
1296 LayerIdMap::const_iterator iter = layer_id_map_.find(id);
1297 return iter != layer_id_map_.end() ? iter->second : NULL;
1298 }
1299
1300 void LayerTreeHost::RegisterLayer(Layer* layer) {
1301 DCHECK(!LayerById(layer->id()));
1302 layer_id_map_[layer->id()] = layer;
1303 }
1304
1305 void LayerTreeHost::UnregisterLayer(Layer* layer) {
1306 DCHECK(LayerById(layer->id()));
1307 layer_id_map_.erase(layer->id());
1308 }
1309
1310 bool LayerTreeHost::IsLayerInActiveTree(int layer_id) const {
1311 return true;
1312 }
1313
1314 bool LayerTreeHost::IsLayerInPendingTree(int layer_id) const {
1315 return false;
1316 }
1317
1318 void LayerTreeHost::SetMutatorsNeedCommit() {
1319 SetNeedsCommit();
1320 }
1321
1322 void LayerTreeHost::SetLayerFilterMutated(int layer_id,
1323 bool active_tree,
1324 const FilterOperations& filters) {
1325 LayerAnimationValueObserver* layer = LayerById(layer_id);
1326 DCHECK(layer);
1327 layer->OnFilterAnimated(filters);
1328 }
1329
1330 void LayerTreeHost::SetLayerOpacityMutated(int layer_id,
1331 bool active_tree,
1332 float opacity) {
1333 LayerAnimationValueObserver* layer = LayerById(layer_id);
1334 DCHECK(layer);
1335 layer->OnOpacityAnimated(opacity);
1336 }
1337
1338 void LayerTreeHost::SetLayerTransformMutated(int layer_id,
1339 bool active_tree,
1340 const gfx::Transform& transform) {
1341 LayerAnimationValueObserver* layer = LayerById(layer_id);
1342 DCHECK(layer);
1343 layer->OnTransformAnimated(transform);
1344 }
1345
1346 void LayerTreeHost::SetLayerScrollOffsetMutated(
1347 int layer_id,
1348 bool active_tree,
1349 const gfx::ScrollOffset& scroll_offset) {
1350 LayerAnimationValueObserver* layer = LayerById(layer_id);
1351 DCHECK(layer);
1352 layer->OnScrollOffsetAnimated(scroll_offset);
1353 }
1354
1281 } // namespace cc 1355 } // 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