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

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: Rebase. 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_common.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 <algorithm> 7 #include <algorithm>
8 #include <stack> 8 #include <stack>
9 #include <string> 9 #include <string>
10 10
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 did_complete_scale_animation_(false), 114 did_complete_scale_animation_(false),
115 in_paint_layer_contents_(false), 115 in_paint_layer_contents_(false),
116 id_(s_layer_tree_host_sequence_number.GetNext() + 1), 116 id_(s_layer_tree_host_sequence_number.GetNext() + 1),
117 next_commit_forces_redraw_(false), 117 next_commit_forces_redraw_(false),
118 shared_bitmap_manager_(params->shared_bitmap_manager), 118 shared_bitmap_manager_(params->shared_bitmap_manager),
119 gpu_memory_buffer_manager_(params->gpu_memory_buffer_manager), 119 gpu_memory_buffer_manager_(params->gpu_memory_buffer_manager),
120 task_graph_runner_(params->task_graph_runner), 120 task_graph_runner_(params->task_graph_runner),
121 surface_id_namespace_(0u), 121 surface_id_namespace_(0u),
122 next_surface_sequence_(1u) { 122 next_surface_sequence_(1u) {
123 DCHECK(task_graph_runner_); 123 DCHECK(task_graph_runner_);
124 if (settings_.accelerated_animation_enabled) 124
125 animation_registrar_ = AnimationRegistrar::Create(); 125 if (settings_.accelerated_animation_enabled) {
126 if (settings_.use_compositor_animation_timelines) {
127 animation_host_ = AnimationHost::Create(ThreadInstance::MAIN);
128 animation_host_->SetMutatorHostClient(this);
129 } else {
130 animation_registrar_ = AnimationRegistrar::Create();
131 }
132 }
133
126 rendering_stats_instrumentation_->set_record_rendering_stats( 134 rendering_stats_instrumentation_->set_record_rendering_stats(
127 debug_state_.RecordRenderingStats()); 135 debug_state_.RecordRenderingStats());
128
129 if (settings_.use_compositor_animation_timelines) {
130 animation_host_ = AnimationHost::Create(ThreadInstance::MAIN);
131 animation_host_->SetMutatorHostClient(this);
132 }
133 } 136 }
134 137
135 void LayerTreeHost::InitializeThreaded( 138 void LayerTreeHost::InitializeThreaded(
136 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 139 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
137 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, 140 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
138 scoped_ptr<BeginFrameSource> external_begin_frame_source) { 141 scoped_ptr<BeginFrameSource> external_begin_frame_source) {
139 InitializeProxy(ThreadProxy::Create(this, 142 InitializeProxy(ThreadProxy::Create(this,
140 main_task_runner, 143 main_task_runner,
141 impl_task_runner, 144 impl_task_runner,
142 external_begin_frame_source.Pass())); 145 external_begin_frame_source.Pass()));
(...skipping 13 matching lines...) Expand all
156 void LayerTreeHost::InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing) { 159 void LayerTreeHost::InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing) {
157 InitializeProxy(proxy_for_testing.Pass()); 160 InitializeProxy(proxy_for_testing.Pass());
158 } 161 }
159 162
160 void LayerTreeHost::InitializeProxy(scoped_ptr<Proxy> proxy) { 163 void LayerTreeHost::InitializeProxy(scoped_ptr<Proxy> proxy) {
161 TRACE_EVENT0("cc", "LayerTreeHost::InitializeForReal"); 164 TRACE_EVENT0("cc", "LayerTreeHost::InitializeForReal");
162 165
163 proxy_ = proxy.Pass(); 166 proxy_ = proxy.Pass();
164 proxy_->Start(); 167 proxy_->Start();
165 if (settings_.accelerated_animation_enabled) { 168 if (settings_.accelerated_animation_enabled) {
166 animation_registrar_->set_supports_scroll_animations( 169 if (animation_host_)
167 proxy_->SupportsImplScrolling()); 170 animation_host_->SetSupportsScrollAnimations(
171 proxy_->SupportsImplScrolling());
172 else
173 animation_registrar_->set_supports_scroll_animations(
174 proxy_->SupportsImplScrolling());
168 } 175 }
169 } 176 }
170 177
171 LayerTreeHost::~LayerTreeHost() { 178 LayerTreeHost::~LayerTreeHost() {
172 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); 179 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost");
173 180
174 if (animation_host_) 181 if (animation_host_)
175 animation_host_->SetMutatorHostClient(nullptr); 182 animation_host_->SetMutatorHostClient(nullptr);
176 183
177 if (root_layer_.get()) 184 if (root_layer_.get())
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 proxy_->SetNextCommitWaitsForActivation(); 513 proxy_->SetNextCommitWaitsForActivation();
507 } 514 }
508 515
509 void LayerTreeHost::SetNextCommitForcesRedraw() { 516 void LayerTreeHost::SetNextCommitForcesRedraw() {
510 next_commit_forces_redraw_ = true; 517 next_commit_forces_redraw_ = true;
511 } 518 }
512 519
513 void LayerTreeHost::SetAnimationEvents( 520 void LayerTreeHost::SetAnimationEvents(
514 scoped_ptr<AnimationEventsVector> events) { 521 scoped_ptr<AnimationEventsVector> events) {
515 DCHECK(proxy_->IsMainThread()); 522 DCHECK(proxy_->IsMainThread());
516 animation_registrar_->SetAnimationEvents(events.Pass()); 523 if (animation_host_)
524 animation_host_->SetAnimationEvents(events.Pass());
525 else
526 animation_registrar_->SetAnimationEvents(events.Pass());
517 } 527 }
518 528
519 void LayerTreeHost::SetRootLayer(scoped_refptr<Layer> root_layer) { 529 void LayerTreeHost::SetRootLayer(scoped_refptr<Layer> root_layer) {
520 if (root_layer_.get() == root_layer.get()) 530 if (root_layer_.get() == root_layer.get())
521 return; 531 return;
522 532
523 if (root_layer_.get()) 533 if (root_layer_.get())
524 root_layer_->SetLayerTreeHost(NULL); 534 root_layer_->SetLayerTreeHost(NULL);
525 root_layer_ = root_layer; 535 root_layer_ = root_layer;
526 if (root_layer_.get()) { 536 if (root_layer_.get()) {
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 constraints, 924 constraints,
915 current, 925 current,
916 animate)); 926 animate));
917 } 927 }
918 928
919 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) { 929 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) {
920 if (!settings_.accelerated_animation_enabled) 930 if (!settings_.accelerated_animation_enabled)
921 return; 931 return;
922 932
923 AnimationEventsVector events; 933 AnimationEventsVector events;
924 if (animation_registrar_->AnimateLayers(monotonic_time)) { 934 if (animation_host_) {
925 animation_registrar_->UpdateAnimationState(true, &events); 935 if (animation_host_->AnimateLayers(monotonic_time))
926 if (!events.empty()) 936 animation_host_->UpdateAnimationState(true, &events);
927 property_trees_.needs_rebuild = true; 937 } else {
938 if (animation_registrar_->AnimateLayers(monotonic_time))
939 animation_registrar_->UpdateAnimationState(true, &events);
928 } 940 }
941
942 if (!events.empty())
943 property_trees_.needs_rebuild = true;
929 } 944 }
930 945
931 UIResourceId LayerTreeHost::CreateUIResource(UIResourceClient* client) { 946 UIResourceId LayerTreeHost::CreateUIResource(UIResourceClient* client) {
932 DCHECK(client); 947 DCHECK(client);
933 948
934 UIResourceId next_id = next_ui_resource_id_++; 949 UIResourceId next_id = next_ui_resource_id_++;
935 DCHECK(ui_resource_client_map_.find(next_id) == 950 DCHECK(ui_resource_client_map_.find(next_id) ==
936 ui_resource_client_map_.end()); 951 ui_resource_client_map_.end());
937 952
938 bool resource_lost = false; 953 bool resource_lost = false;
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 1142
1128 void LayerTreeHost::SetLayerScrollOffsetMutated( 1143 void LayerTreeHost::SetLayerScrollOffsetMutated(
1129 int layer_id, 1144 int layer_id,
1130 LayerTreeType tree_type, 1145 LayerTreeType tree_type,
1131 const gfx::ScrollOffset& scroll_offset) { 1146 const gfx::ScrollOffset& scroll_offset) {
1132 LayerAnimationValueObserver* layer = LayerById(layer_id); 1147 LayerAnimationValueObserver* layer = LayerById(layer_id);
1133 DCHECK(layer); 1148 DCHECK(layer);
1134 layer->OnScrollOffsetAnimated(scroll_offset); 1149 layer->OnScrollOffsetAnimated(scroll_offset);
1135 } 1150 }
1136 1151
1152 bool LayerTreeHost::ScrollOffsetAnimationWasInterrupted(
1153 const Layer* layer) const {
1154 return animation_host_
1155 ? animation_host_->ScrollOffsetAnimationWasInterrupted(layer->id())
1156 : false;
1157 }
1158
1159 bool LayerTreeHost::IsAnimatingFilterProperty(const Layer* layer) const {
1160 return animation_host_
1161 ? animation_host_->IsAnimatingFilterProperty(layer->id())
1162 : false;
1163 }
1164
1165 bool LayerTreeHost::IsAnimatingOpacityProperty(const Layer* layer) const {
1166 return animation_host_
1167 ? animation_host_->IsAnimatingOpacityProperty(layer->id())
1168 : false;
1169 }
1170
1171 bool LayerTreeHost::IsAnimatingTransformProperty(const Layer* layer) const {
1172 return animation_host_
1173 ? animation_host_->IsAnimatingTransformProperty(layer->id())
1174 : false;
1175 }
1176
1177 bool LayerTreeHost::HasPotentiallyRunningOpacityAnimation(
1178 const Layer* layer) const {
1179 return animation_host_
1180 ? animation_host_->HasPotentiallyRunningOpacityAnimation(
1181 layer->id())
1182 : false;
1183 }
1184
1185 bool LayerTreeHost::HasPotentiallyRunningTransformAnimation(
1186 const Layer* layer) const {
1187 return animation_host_
1188 ? animation_host_->HasPotentiallyRunningTransformAnimation(
1189 layer->id())
1190 : false;
1191 }
1192
1193 bool LayerTreeHost::AnimationsPreserveAxisAlignment(const Layer* layer) const {
1194 return animation_host_
1195 ? animation_host_->AnimationsPreserveAxisAlignment(layer->id())
1196 : true;
1197 }
1198
1199 bool LayerTreeHost::HasAnyAnimation(const Layer* layer) const {
1200 return animation_host_ ? animation_host_->HasAnyAnimation(layer->id())
1201 : false;
1202 }
1203
1204 bool LayerTreeHost::HasActiveAnimation(const Layer* layer) const {
1205 return animation_host_ ? animation_host_->HasActiveAnimation(layer->id())
1206 : false;
1207 }
1208
1137 } // namespace cc 1209 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host.h ('k') | cc/trees/layer_tree_host_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698