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