| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/test/animation_test_common.h" | 5 #include "cc/test/animation_test_common.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "cc/animation/animation_host.h" | 8 #include "cc/animation/animation_host.h" |
| 9 #include "cc/animation/animation_id_provider.h" | 9 #include "cc/animation/animation_id_provider.h" |
| 10 #include "cc/animation/animation_player.h" | 10 #include "cc/animation/animation_player.h" |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 } | 302 } |
| 303 | 303 |
| 304 void AddAnimationToElementWithExistingPlayer( | 304 void AddAnimationToElementWithExistingPlayer( |
| 305 ElementId element_id, | 305 ElementId element_id, |
| 306 scoped_refptr<AnimationTimeline> timeline, | 306 scoped_refptr<AnimationTimeline> timeline, |
| 307 std::unique_ptr<Animation> animation) { | 307 std::unique_ptr<Animation> animation) { |
| 308 scoped_refptr<ElementAnimations> element_animations = | 308 scoped_refptr<ElementAnimations> element_animations = |
| 309 timeline->animation_host()->GetElementAnimationsForElementId(element_id); | 309 timeline->animation_host()->GetElementAnimationsForElementId(element_id); |
| 310 DCHECK(element_animations); | 310 DCHECK(element_animations); |
| 311 DCHECK(element_animations->players_list().might_have_observers()); | 311 DCHECK(element_animations->players_list().might_have_observers()); |
| 312 ElementAnimations::PlayersList::Iterator it( | 312 AnimationPlayer* player = &*element_animations->players_list().begin(); |
| 313 &element_animations->players_list()); | |
| 314 AnimationPlayer* player = it.GetNext(); | |
| 315 DCHECK(player); | 313 DCHECK(player); |
| 316 player->AddAnimation(std::move(animation)); | 314 player->AddAnimation(std::move(animation)); |
| 317 } | 315 } |
| 318 | 316 |
| 319 void RemoveAnimationFromElementWithExistingPlayer( | 317 void RemoveAnimationFromElementWithExistingPlayer( |
| 320 ElementId element_id, | 318 ElementId element_id, |
| 321 scoped_refptr<AnimationTimeline> timeline, | 319 scoped_refptr<AnimationTimeline> timeline, |
| 322 int animation_id) { | 320 int animation_id) { |
| 323 scoped_refptr<ElementAnimations> element_animations = | 321 scoped_refptr<ElementAnimations> element_animations = |
| 324 timeline->animation_host()->GetElementAnimationsForElementId(element_id); | 322 timeline->animation_host()->GetElementAnimationsForElementId(element_id); |
| 325 DCHECK(element_animations); | 323 DCHECK(element_animations); |
| 326 DCHECK(element_animations->players_list().might_have_observers()); | 324 DCHECK(element_animations->players_list().might_have_observers()); |
| 327 ElementAnimations::PlayersList::Iterator it( | 325 AnimationPlayer* player = &*element_animations->players_list().begin(); |
| 328 &element_animations->players_list()); | |
| 329 AnimationPlayer* player = it.GetNext(); | |
| 330 DCHECK(player); | 326 DCHECK(player); |
| 331 player->RemoveAnimation(animation_id); | 327 player->RemoveAnimation(animation_id); |
| 332 } | 328 } |
| 333 | 329 |
| 334 Animation* GetAnimationFromElementWithExistingPlayer( | 330 Animation* GetAnimationFromElementWithExistingPlayer( |
| 335 ElementId element_id, | 331 ElementId element_id, |
| 336 scoped_refptr<AnimationTimeline> timeline, | 332 scoped_refptr<AnimationTimeline> timeline, |
| 337 int animation_id) { | 333 int animation_id) { |
| 338 scoped_refptr<ElementAnimations> element_animations = | 334 scoped_refptr<ElementAnimations> element_animations = |
| 339 timeline->animation_host()->GetElementAnimationsForElementId(element_id); | 335 timeline->animation_host()->GetElementAnimationsForElementId(element_id); |
| 340 DCHECK(element_animations); | 336 DCHECK(element_animations); |
| 341 DCHECK(element_animations->players_list().might_have_observers()); | 337 DCHECK(element_animations->players_list().might_have_observers()); |
| 342 ElementAnimations::PlayersList::Iterator it( | 338 AnimationPlayer* player = &*element_animations->players_list().begin(); |
| 343 &element_animations->players_list()); | |
| 344 AnimationPlayer* player = it.GetNext(); | |
| 345 DCHECK(player); | 339 DCHECK(player); |
| 346 return player->GetAnimationById(animation_id); | 340 return player->GetAnimationById(animation_id); |
| 347 } | 341 } |
| 348 | 342 |
| 349 int AddAnimatedFilterToElementWithPlayer( | 343 int AddAnimatedFilterToElementWithPlayer( |
| 350 ElementId element_id, | 344 ElementId element_id, |
| 351 scoped_refptr<AnimationTimeline> timeline, | 345 scoped_refptr<AnimationTimeline> timeline, |
| 352 double duration, | 346 double duration, |
| 353 float start_brightness, | 347 float start_brightness, |
| 354 float end_brightness) { | 348 float end_brightness) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 scoped_refptr<AnimationPlayer> player = | 394 scoped_refptr<AnimationPlayer> player = |
| 401 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); | 395 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); |
| 402 timeline->AttachPlayer(player); | 396 timeline->AttachPlayer(player); |
| 403 player->AttachElement(element_id); | 397 player->AttachElement(element_id); |
| 404 DCHECK(player->element_animations()); | 398 DCHECK(player->element_animations()); |
| 405 return AddOpacityTransitionToPlayer(player.get(), duration, start_opacity, | 399 return AddOpacityTransitionToPlayer(player.get(), duration, start_opacity, |
| 406 end_opacity, use_timing_function); | 400 end_opacity, use_timing_function); |
| 407 } | 401 } |
| 408 | 402 |
| 409 } // namespace cc | 403 } // namespace cc |
| OLD | NEW |