| 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 | 289 |
| 290 std::unique_ptr<Animation> animation(Animation::Create( | 290 std::unique_ptr<Animation> animation(Animation::Create( |
| 291 std::move(curve), id, AnimationIdProvider::NextGroupId(), | 291 std::move(curve), id, AnimationIdProvider::NextGroupId(), |
| 292 TargetProperty::OPACITY)); | 292 TargetProperty::OPACITY)); |
| 293 animation->set_needs_synchronized_start_time(true); | 293 animation->set_needs_synchronized_start_time(true); |
| 294 | 294 |
| 295 target->AddAnimation(std::move(animation)); | 295 target->AddAnimation(std::move(animation)); |
| 296 return id; | 296 return id; |
| 297 } | 297 } |
| 298 | 298 |
| 299 void AddAnimationToElementWithPlayer(ElementId element_id, | 299 void AddAnimationToLayerWithPlayer(int layer_id, |
| 300 scoped_refptr<AnimationTimeline> timeline, | 300 scoped_refptr<AnimationTimeline> timeline, |
| 301 std::unique_ptr<Animation> animation) { | 301 std::unique_ptr<Animation> animation) { |
| 302 scoped_refptr<AnimationPlayer> player = | 302 scoped_refptr<AnimationPlayer> player = |
| 303 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); | 303 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); |
| 304 timeline->AttachPlayer(player); | 304 timeline->AttachPlayer(player); |
| 305 player->AttachElement(element_id); | 305 player->AttachElement(layer_id); |
| 306 DCHECK(player->element_animations()); | 306 DCHECK(player->element_animations()); |
| 307 player->AddAnimation(std::move(animation)); | 307 player->AddAnimation(std::move(animation)); |
| 308 } | 308 } |
| 309 | 309 |
| 310 void AddAnimationToElementWithExistingPlayer( | 310 void AddAnimationToLayerWithExistingPlayer( |
| 311 ElementId element_id, | 311 int layer_id, |
| 312 scoped_refptr<AnimationTimeline> timeline, | 312 scoped_refptr<AnimationTimeline> timeline, |
| 313 std::unique_ptr<Animation> animation) { | 313 std::unique_ptr<Animation> animation) { |
| 314 scoped_refptr<ElementAnimations> element_animations = | 314 scoped_refptr<ElementAnimations> element_animations = |
| 315 timeline->animation_host()->GetElementAnimationsForElementId(element_id); | 315 timeline->animation_host()->GetElementAnimationsForElementId(layer_id); |
| 316 DCHECK(element_animations); | 316 DCHECK(element_animations); |
| 317 element_animations->AddAnimation(std::move(animation)); | 317 element_animations->AddAnimation(std::move(animation)); |
| 318 } | 318 } |
| 319 | 319 |
| 320 void RemoveAnimationFromElementWithExistingPlayer( | 320 void RemoveAnimationFromLayerWithExistingPlayer( |
| 321 ElementId element_id, | 321 int layer_id, |
| 322 scoped_refptr<AnimationTimeline> timeline, | 322 scoped_refptr<AnimationTimeline> timeline, |
| 323 int animation_id) { | 323 int animation_id) { |
| 324 scoped_refptr<ElementAnimations> element_animations = | 324 scoped_refptr<ElementAnimations> element_animations = |
| 325 timeline->animation_host()->GetElementAnimationsForElementId(element_id); | 325 timeline->animation_host()->GetElementAnimationsForElementId(layer_id); |
| 326 DCHECK(element_animations); | 326 DCHECK(element_animations); |
| 327 element_animations->RemoveAnimation(animation_id); | 327 element_animations->RemoveAnimation(animation_id); |
| 328 } | 328 } |
| 329 | 329 |
| 330 Animation* GetAnimationFromElementWithExistingPlayer( | 330 Animation* GetAnimationFromLayerWithExistingPlayer( |
| 331 ElementId element_id, | 331 int layer_id, |
| 332 scoped_refptr<AnimationTimeline> timeline, | 332 scoped_refptr<AnimationTimeline> timeline, |
| 333 int animation_id) { | 333 int animation_id) { |
| 334 scoped_refptr<ElementAnimations> element_animations = | 334 scoped_refptr<ElementAnimations> element_animations = |
| 335 timeline->animation_host()->GetElementAnimationsForElementId(element_id); | 335 timeline->animation_host()->GetElementAnimationsForElementId(layer_id); |
| 336 DCHECK(element_animations); | 336 DCHECK(element_animations); |
| 337 return element_animations->GetAnimationById(animation_id); | 337 return element_animations->GetAnimationById(animation_id); |
| 338 } | 338 } |
| 339 | 339 |
| 340 int AddAnimatedFilterToElementWithPlayer( | 340 int AddAnimatedFilterToLayerWithPlayer( |
| 341 ElementId element_id, | 341 int layer_id, |
| 342 scoped_refptr<AnimationTimeline> timeline, | 342 scoped_refptr<AnimationTimeline> timeline, |
| 343 double duration, | 343 double duration, |
| 344 float start_brightness, | 344 float start_brightness, |
| 345 float end_brightness) { | 345 float end_brightness) { |
| 346 scoped_refptr<AnimationPlayer> player = | 346 scoped_refptr<AnimationPlayer> player = |
| 347 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); | 347 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); |
| 348 timeline->AttachPlayer(player); | 348 timeline->AttachPlayer(player); |
| 349 player->AttachElement(element_id); | 349 player->AttachElement(layer_id); |
| 350 DCHECK(player->element_animations()); | 350 DCHECK(player->element_animations()); |
| 351 return AddAnimatedFilterToPlayer(player.get(), duration, start_brightness, | 351 return AddAnimatedFilterToPlayer(player.get(), duration, start_brightness, |
| 352 end_brightness); | 352 end_brightness); |
| 353 } | 353 } |
| 354 | 354 |
| 355 int AddAnimatedTransformToElementWithPlayer( | 355 int AddAnimatedTransformToLayerWithPlayer( |
| 356 ElementId element_id, | 356 int layer_id, |
| 357 scoped_refptr<AnimationTimeline> timeline, | 357 scoped_refptr<AnimationTimeline> timeline, |
| 358 double duration, | 358 double duration, |
| 359 int delta_x, | 359 int delta_x, |
| 360 int delta_y) { | 360 int delta_y) { |
| 361 scoped_refptr<AnimationPlayer> player = | 361 scoped_refptr<AnimationPlayer> player = |
| 362 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); | 362 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); |
| 363 timeline->AttachPlayer(player); | 363 timeline->AttachPlayer(player); |
| 364 player->AttachElement(element_id); | 364 player->AttachElement(layer_id); |
| 365 DCHECK(player->element_animations()); | 365 DCHECK(player->element_animations()); |
| 366 return AddAnimatedTransformToPlayer(player.get(), duration, delta_x, delta_y); | 366 return AddAnimatedTransformToPlayer(player.get(), duration, delta_x, delta_y); |
| 367 } | 367 } |
| 368 | 368 |
| 369 int AddAnimatedTransformToElementWithPlayer( | 369 int AddAnimatedTransformToLayerWithPlayer( |
| 370 ElementId element_id, | 370 int layer_id, |
| 371 scoped_refptr<AnimationTimeline> timeline, | 371 scoped_refptr<AnimationTimeline> timeline, |
| 372 double duration, | 372 double duration, |
| 373 TransformOperations start_operations, | 373 TransformOperations start_operations, |
| 374 TransformOperations operations) { | 374 TransformOperations operations) { |
| 375 scoped_refptr<AnimationPlayer> player = | 375 scoped_refptr<AnimationPlayer> player = |
| 376 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); | 376 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); |
| 377 timeline->AttachPlayer(player); | 377 timeline->AttachPlayer(player); |
| 378 player->AttachElement(element_id); | 378 player->AttachElement(layer_id); |
| 379 DCHECK(player->element_animations()); | 379 DCHECK(player->element_animations()); |
| 380 return AddAnimatedTransformToPlayer(player.get(), duration, start_operations, | 380 return AddAnimatedTransformToPlayer(player.get(), duration, start_operations, |
| 381 operations); | 381 operations); |
| 382 } | 382 } |
| 383 | 383 |
| 384 int AddOpacityTransitionToElementWithPlayer( | 384 int AddOpacityTransitionToLayerWithPlayer( |
| 385 ElementId element_id, | 385 int layer_id, |
| 386 scoped_refptr<AnimationTimeline> timeline, | 386 scoped_refptr<AnimationTimeline> timeline, |
| 387 double duration, | 387 double duration, |
| 388 float start_opacity, | 388 float start_opacity, |
| 389 float end_opacity, | 389 float end_opacity, |
| 390 bool use_timing_function) { | 390 bool use_timing_function) { |
| 391 scoped_refptr<AnimationPlayer> player = | 391 scoped_refptr<AnimationPlayer> player = |
| 392 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); | 392 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); |
| 393 timeline->AttachPlayer(player); | 393 timeline->AttachPlayer(player); |
| 394 player->AttachElement(element_id); | 394 player->AttachElement(layer_id); |
| 395 DCHECK(player->element_animations()); | 395 DCHECK(player->element_animations()); |
| 396 return AddOpacityTransitionToPlayer(player.get(), duration, start_opacity, | 396 return AddOpacityTransitionToPlayer(player.get(), duration, start_opacity, |
| 397 end_opacity, use_timing_function); | 397 end_opacity, use_timing_function); |
| 398 } | 398 } |
| 399 | 399 |
| 400 void AbortAnimationsOnElementWithPlayer( | 400 void AbortAnimationsOnLayerWithPlayer(int layer_id, |
| 401 ElementId element_id, | 401 scoped_refptr<AnimationTimeline> timeline, |
| 402 scoped_refptr<AnimationTimeline> timeline, | 402 TargetProperty::Type target_property) { |
| 403 TargetProperty::Type target_property) { | |
| 404 scoped_refptr<ElementAnimations> element_animations = | 403 scoped_refptr<ElementAnimations> element_animations = |
| 405 timeline->animation_host()->GetElementAnimationsForElementId(element_id); | 404 timeline->animation_host()->GetElementAnimationsForElementId(layer_id); |
| 406 DCHECK(element_animations); | 405 DCHECK(element_animations); |
| 407 element_animations->AbortAnimations(target_property); | 406 element_animations->AbortAnimations(target_property); |
| 408 } | 407 } |
| 409 | 408 |
| 410 } // namespace cc | 409 } // namespace cc |
| OLD | NEW |