OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/animation/animation_host.h" | 5 #include "cc/animation/animation_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
| 9 #include "base/metrics/histogram.h" |
9 #include "cc/animation/animation_delegate.h" | 10 #include "cc/animation/animation_delegate.h" |
10 #include "cc/animation/animation_id_provider.h" | 11 #include "cc/animation/animation_id_provider.h" |
11 #include "cc/animation/animation_player.h" | 12 #include "cc/animation/animation_player.h" |
12 #include "cc/animation/animation_registrar.h" | 13 #include "cc/animation/animation_registrar.h" |
13 #include "cc/animation/animation_timeline.h" | 14 #include "cc/animation/animation_timeline.h" |
14 #include "cc/animation/scroll_offset_animation_curve.h" | 15 #include "cc/animation/scroll_offset_animation_curve.h" |
15 #include "cc/animation/timing_function.h" | 16 #include "cc/animation/timing_function.h" |
16 #include "cc/trees/layer_tree_mutators_client.h" | 17 #include "cc/trees/layer_tree_mutators_client.h" |
17 #include "ui/gfx/geometry/box_f.h" | 18 #include "ui/gfx/geometry/box_f.h" |
18 #include "ui/gfx/geometry/scroll_offset.h" | 19 #include "ui/gfx/geometry/scroll_offset.h" |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 return; | 211 return; |
211 | 212 |
212 layer_tree_mutators_client_ = client; | 213 layer_tree_mutators_client_ = client; |
213 } | 214 } |
214 | 215 |
215 void AnimationHost::SetNeedsCommit() { | 216 void AnimationHost::SetNeedsCommit() { |
216 DCHECK(layer_tree_mutators_client_); | 217 DCHECK(layer_tree_mutators_client_); |
217 layer_tree_mutators_client_->SetMutatorsNeedCommit(); | 218 layer_tree_mutators_client_->SetMutatorsNeedCommit(); |
218 } | 219 } |
219 | 220 |
| 221 void AnimationHost::ReportAndClearStatsOnFrameEnd() { |
| 222 if (is_impl_instance_) |
| 223 LOCAL_HISTOGRAM_CUSTOM_COUNTS( |
| 224 "Mutators.FindPlayerForLayerImplId", |
| 225 find_player_for_layer_id_stats_.InMicroseconds(), 1, 1000, 10); |
| 226 else |
| 227 LOCAL_HISTOGRAM_CUSTOM_COUNTS( |
| 228 "Mutators.FindPlayerForLayerId", |
| 229 find_player_for_layer_id_stats_.InMicroseconds(), 1, 1000, 10); |
| 230 find_player_for_layer_id_stats_ = base::TimeDelta(); |
| 231 } |
| 232 |
220 void AnimationHost::PushPropertiesTo(AnimationHost* host_impl) { | 233 void AnimationHost::PushPropertiesTo(AnimationHost* host_impl) { |
221 PushTimelinesToImplThread(host_impl); | 234 PushTimelinesToImplThread(host_impl); |
222 RemoveTimelinesFromImplThread(host_impl); | 235 RemoveTimelinesFromImplThread(host_impl); |
223 PushPropertiesToImplThread(host_impl); | 236 PushPropertiesToImplThread(host_impl); |
224 } | 237 } |
225 | 238 |
226 void AnimationHost::PushTimelinesToImplThread(AnimationHost* host_impl) const { | 239 void AnimationHost::PushTimelinesToImplThread(AnimationHost* host_impl) const { |
227 for (auto& timeline : timelines_) { | 240 for (auto& timeline : timelines_) { |
228 AnimationTimeline* timeline_impl = | 241 AnimationTimeline* timeline_impl = |
229 host_impl->GetTimelineById(timeline->id()); | 242 host_impl->GetTimelineById(timeline->id()); |
(...skipping 23 matching lines...) Expand all Loading... |
253 for (auto& timeline : timelines_) { | 266 for (auto& timeline : timelines_) { |
254 AnimationTimeline* timeline_impl = | 267 AnimationTimeline* timeline_impl = |
255 host_impl->GetTimelineById(timeline->id()); | 268 host_impl->GetTimelineById(timeline->id()); |
256 if (timeline_impl) | 269 if (timeline_impl) |
257 timeline->PushPropertiesTo(timeline_impl); | 270 timeline->PushPropertiesTo(timeline_impl); |
258 } | 271 } |
259 } | 272 } |
260 | 273 |
261 AnimationPlayer* AnimationHost::GetPlayerForLayerId(int layer_id) const { | 274 AnimationPlayer* AnimationHost::GetPlayerForLayerId(int layer_id) const { |
262 DCHECK(layer_id); | 275 DCHECK(layer_id); |
| 276 base::TimeTicks start_time = base::TimeTicks::Now(); |
263 auto iter = layer_to_player_map_.find(layer_id); | 277 auto iter = layer_to_player_map_.find(layer_id); |
| 278 find_player_for_layer_id_stats_ += base::TimeTicks::Now() - start_time; |
264 return iter == layer_to_player_map_.end() ? nullptr : iter->second; | 279 return iter == layer_to_player_map_.end() ? nullptr : iter->second; |
265 } | 280 } |
266 | 281 |
267 void AnimationHost::SetSupportsScrollAnimations( | 282 void AnimationHost::SetSupportsScrollAnimations( |
268 bool supports_scroll_animations) { | 283 bool supports_scroll_animations) { |
269 animation_registrar_->set_supports_scroll_animations( | 284 animation_registrar_->set_supports_scroll_animations( |
270 supports_scroll_animations); | 285 supports_scroll_animations); |
271 } | 286 } |
272 | 287 |
273 bool AnimationHost::SupportsScrollAnimations() const { | 288 bool AnimationHost::SupportsScrollAnimations() const { |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 int layer_id, | 509 int layer_id, |
495 const gfx::Vector2dF& scroll_delta, | 510 const gfx::Vector2dF& scroll_delta, |
496 const gfx::ScrollOffset& max_scroll_offset, | 511 const gfx::ScrollOffset& max_scroll_offset, |
497 base::TimeTicks frame_monotonic_time) { | 512 base::TimeTicks frame_monotonic_time) { |
498 DCHECK(scroll_offset_animations_); | 513 DCHECK(scroll_offset_animations_); |
499 return scroll_offset_animations_->ScrollAnimationUpdateTarget( | 514 return scroll_offset_animations_->ScrollAnimationUpdateTarget( |
500 layer_id, scroll_delta, max_scroll_offset, frame_monotonic_time); | 515 layer_id, scroll_delta, max_scroll_offset, frame_monotonic_time); |
501 } | 516 } |
502 | 517 |
503 } // namespace cc | 518 } // namespace cc |
OLD | NEW |