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