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

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

Issue 1010663002: CC Animations: Redirect all compositor animation requests to AnimationHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@introduce
Patch Set: Add ported unittests. 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
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
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 partial_texture_update_requests_(0), 125 partial_texture_update_requests_(0),
126 did_complete_scale_animation_(false), 126 did_complete_scale_animation_(false),
127 in_paint_layer_contents_(false), 127 in_paint_layer_contents_(false),
128 id_(s_layer_tree_host_sequence_number.GetNext() + 1), 128 id_(s_layer_tree_host_sequence_number.GetNext() + 1),
129 next_commit_forces_redraw_(false), 129 next_commit_forces_redraw_(false),
130 shared_bitmap_manager_(shared_bitmap_manager), 130 shared_bitmap_manager_(shared_bitmap_manager),
131 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), 131 gpu_memory_buffer_manager_(gpu_memory_buffer_manager),
132 task_graph_runner_(task_graph_runner), 132 task_graph_runner_(task_graph_runner),
133 surface_id_namespace_(0u), 133 surface_id_namespace_(0u),
134 next_surface_sequence_(1u) { 134 next_surface_sequence_(1u) {
135 if (settings_.accelerated_animation_enabled) 135 if (settings_.accelerated_animation_enabled &&
136 !settings.use_compositor_animation_timelines)
136 animation_registrar_ = AnimationRegistrar::Create(); 137 animation_registrar_ = AnimationRegistrar::Create();
137 rendering_stats_instrumentation_->set_record_rendering_stats( 138 rendering_stats_instrumentation_->set_record_rendering_stats(
138 debug_state_.RecordRenderingStats()); 139 debug_state_.RecordRenderingStats());
139 140
140 if (settings_.use_compositor_animation_timelines) { 141 if (settings_.use_compositor_animation_timelines) {
141 animation_host_ = AnimationHost::Create(false); 142 animation_host_ = AnimationHost::Create(false);
142 animation_host_->SetLayerTreeMutatorsClient(this); 143 animation_host_->SetLayerTreeMutatorsClient(this);
143 } 144 }
144 } 145 }
145 146
(...skipping 21 matching lines...) Expand all
167 void LayerTreeHost::InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing) { 168 void LayerTreeHost::InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing) {
168 InitializeProxy(proxy_for_testing.Pass()); 169 InitializeProxy(proxy_for_testing.Pass());
169 } 170 }
170 171
171 void LayerTreeHost::InitializeProxy(scoped_ptr<Proxy> proxy) { 172 void LayerTreeHost::InitializeProxy(scoped_ptr<Proxy> proxy) {
172 TRACE_EVENT0("cc", "LayerTreeHost::InitializeForReal"); 173 TRACE_EVENT0("cc", "LayerTreeHost::InitializeForReal");
173 174
174 proxy_ = proxy.Pass(); 175 proxy_ = proxy.Pass();
175 proxy_->Start(); 176 proxy_->Start();
176 if (settings_.accelerated_animation_enabled) { 177 if (settings_.accelerated_animation_enabled) {
177 animation_registrar_->set_supports_scroll_animations( 178 if (animation_registrar_)
178 proxy_->SupportsImplScrolling()); 179 animation_registrar_->set_supports_scroll_animations(
180 proxy_->SupportsImplScrolling());
181
182 if (animation_host_)
183 animation_host_->SetSupportsScrollAnimations(
184 proxy_->SupportsImplScrolling());
179 } 185 }
180 } 186 }
181 187
182 LayerTreeHost::~LayerTreeHost() { 188 LayerTreeHost::~LayerTreeHost() {
183 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); 189 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost");
184 190
185 if (animation_host_) 191 if (animation_host_)
186 animation_host_->SetLayerTreeMutatorsClient(nullptr); 192 animation_host_->SetLayerTreeMutatorsClient(nullptr);
187 193
188 if (root_layer_.get()) 194 if (root_layer_.get())
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 proxy_->SetNextCommitWaitsForActivation(); 555 proxy_->SetNextCommitWaitsForActivation();
550 } 556 }
551 557
552 void LayerTreeHost::SetNextCommitForcesRedraw() { 558 void LayerTreeHost::SetNextCommitForcesRedraw() {
553 next_commit_forces_redraw_ = true; 559 next_commit_forces_redraw_ = true;
554 } 560 }
555 561
556 void LayerTreeHost::SetAnimationEvents( 562 void LayerTreeHost::SetAnimationEvents(
557 scoped_ptr<AnimationEventsVector> events) { 563 scoped_ptr<AnimationEventsVector> events) {
558 DCHECK(proxy_->IsMainThread()); 564 DCHECK(proxy_->IsMainThread());
559 animation_registrar_->SetAnimationEvents(events.Pass()); 565 if (animation_host_)
566 animation_host_->SetAnimationEvents(events.Pass());
567 else
568 animation_registrar_->SetAnimationEvents(events.Pass());
560 } 569 }
561 570
562 void LayerTreeHost::SetRootLayer(scoped_refptr<Layer> root_layer) { 571 void LayerTreeHost::SetRootLayer(scoped_refptr<Layer> root_layer) {
563 if (root_layer_.get() == root_layer.get()) 572 if (root_layer_.get() == root_layer.get())
564 return; 573 return;
565 574
566 if (root_layer_.get()) 575 if (root_layer_.get())
567 root_layer_->SetLayerTreeHost(NULL); 576 root_layer_->SetLayerTreeHost(NULL);
568 root_layer_ = root_layer; 577 root_layer_ = root_layer;
569 if (root_layer_.get()) { 578 if (root_layer_.get()) {
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 top_controls_manager_weak_ptr_, 1157 top_controls_manager_weak_ptr_,
1149 constraints, 1158 constraints,
1150 current, 1159 current,
1151 animate)); 1160 animate));
1152 } 1161 }
1153 1162
1154 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) { 1163 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) {
1155 if (!settings_.accelerated_animation_enabled) 1164 if (!settings_.accelerated_animation_enabled)
1156 return; 1165 return;
1157 1166
1158 if (animation_registrar_->AnimateLayers(monotonic_time)) 1167 if (animation_host_) {
1159 animation_registrar_->UpdateAnimationState(true, NULL); 1168 if (animation_host_->AnimateLayers(monotonic_time))
1169 animation_host_->UpdateAnimationState(true, NULL);
1170 } else if (animation_registrar_) {
1171 if (animation_registrar_->AnimateLayers(monotonic_time))
1172 animation_registrar_->UpdateAnimationState(true, NULL);
1173 }
1160 } 1174 }
1161 1175
1162 UIResourceId LayerTreeHost::CreateUIResource(UIResourceClient* client) { 1176 UIResourceId LayerTreeHost::CreateUIResource(UIResourceClient* client) {
1163 DCHECK(client); 1177 DCHECK(client);
1164 1178
1165 UIResourceId next_id = next_ui_resource_id_++; 1179 UIResourceId next_id = next_ui_resource_id_++;
1166 DCHECK(ui_resource_client_map_.find(next_id) == 1180 DCHECK(ui_resource_client_map_.find(next_id) ==
1167 ui_resource_client_map_.end()); 1181 ui_resource_client_map_.end());
1168 1182
1169 bool resource_lost = false; 1183 bool resource_lost = false;
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1352 1366
1353 void LayerTreeHost::SetLayerScrollOffsetMutated( 1367 void LayerTreeHost::SetLayerScrollOffsetMutated(
1354 int layer_id, 1368 int layer_id,
1355 bool active_tree, 1369 bool active_tree,
1356 const gfx::ScrollOffset& scroll_offset) { 1370 const gfx::ScrollOffset& scroll_offset) {
1357 LayerAnimationValueObserver* layer = LayerById(layer_id); 1371 LayerAnimationValueObserver* layer = LayerById(layer_id);
1358 DCHECK(layer); 1372 DCHECK(layer);
1359 layer->OnScrollOffsetAnimated(scroll_offset); 1373 layer->OnScrollOffsetAnimated(scroll_offset);
1360 } 1374 }
1361 1375
1376 bool LayerTreeHost::IsAnimatingFilterProperty(const Layer* layer) const {
1377 return animation_host_
1378 ? animation_host_->IsAnimatingFilterProperty(layer->id())
1379 : false;
1380 }
1381
1382 bool LayerTreeHost::IsAnimatingOpacityProperty(const Layer* layer) const {
1383 return animation_host_
1384 ? animation_host_->IsAnimatingOpacityProperty(layer->id())
1385 : false;
1386 }
1387
1388 bool LayerTreeHost::IsAnimatingTransformProperty(const Layer* layer) const {
1389 return animation_host_
1390 ? animation_host_->IsAnimatingTransformProperty(layer->id())
1391 : false;
1392 }
1393
1394 bool LayerTreeHost::AnimationsPreserveAxisAlignment(const Layer* layer) const {
1395 return animation_host_
1396 ? animation_host_->AnimationsPreserveAxisAlignment(layer->id())
1397 : true;
1398 }
1399
1400 bool LayerTreeHost::HasAnyAnimation(const Layer* layer) const {
1401 return animation_host_ ? animation_host_->HasAnyAnimation(layer->id())
1402 : false;
1403 }
1404
1405 bool LayerTreeHost::HasActiveAnimation(const Layer* layer) const {
1406 return animation_host_ ? animation_host_->HasActiveAnimation(layer->id())
1407 : false;
1408 }
1409
1362 } // namespace cc 1410 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698