| 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/animation/layer_animation_controller.h" | 5 #include "cc/animation/layer_animation_controller.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "cc/output/filter_operations.h" | 21 #include "cc/output/filter_operations.h" |
| 22 #include "ui/gfx/geometry/box_f.h" | 22 #include "ui/gfx/geometry/box_f.h" |
| 23 #include "ui/gfx/transform.h" | 23 #include "ui/gfx/transform.h" |
| 24 | 24 |
| 25 namespace cc { | 25 namespace cc { |
| 26 | 26 |
| 27 LayerAnimationController::LayerAnimationController(int id) | 27 LayerAnimationController::LayerAnimationController(int id) |
| 28 : host_(0), | 28 : host_(0), |
| 29 id_(id), | 29 id_(id), |
| 30 is_active_(false), | 30 is_active_(false), |
| 31 event_observer_(nullptr), |
| 31 value_observer_(nullptr), | 32 value_observer_(nullptr), |
| 32 value_provider_(nullptr), | 33 value_provider_(nullptr), |
| 33 layer_animation_delegate_(nullptr), | 34 layer_animation_delegate_(nullptr), |
| 34 needs_active_value_observations_(false), | 35 needs_active_value_observations_(false), |
| 35 needs_pending_value_observations_(false), | 36 needs_pending_value_observations_(false), |
| 36 needs_to_start_animations_(false), | 37 needs_to_start_animations_(false), |
| 37 scroll_offset_animation_was_interrupted_(false), | 38 scroll_offset_animation_was_interrupted_(false), |
| 38 potentially_animating_transform_for_active_observers_(false), | 39 potentially_animating_transform_for_active_observers_(false), |
| 39 potentially_animating_transform_for_pending_observers_(false) {} | 40 potentially_animating_transform_for_pending_observers_(false) {} |
| 40 | 41 |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 host_ = host; | 384 host_ = host; |
| 384 if (host_) | 385 if (host_) |
| 385 host_->RegisterAnimationController(this); | 386 host_->RegisterAnimationController(this); |
| 386 | 387 |
| 387 UpdateActivation(FORCE_ACTIVATION); | 388 UpdateActivation(FORCE_ACTIVATION); |
| 388 } | 389 } |
| 389 | 390 |
| 390 void LayerAnimationController::NotifyAnimationStarted( | 391 void LayerAnimationController::NotifyAnimationStarted( |
| 391 const AnimationEvent& event) { | 392 const AnimationEvent& event) { |
| 392 if (event.is_impl_only) { | 393 if (event.is_impl_only) { |
| 393 FOR_EACH_OBSERVER(LayerAnimationEventObserver, event_observers_, | 394 if (event_observer_) |
| 394 OnAnimationStarted(event)); | 395 event_observer_->OnAnimationStarted(event); |
| 395 if (layer_animation_delegate_) | 396 if (layer_animation_delegate_) |
| 396 layer_animation_delegate_->NotifyAnimationStarted( | 397 layer_animation_delegate_->NotifyAnimationStarted( |
| 397 event.monotonic_time, event.target_property, event.group_id); | 398 event.monotonic_time, event.target_property, event.group_id); |
| 398 return; | 399 return; |
| 399 } | 400 } |
| 400 | 401 |
| 401 for (size_t i = 0; i < animations_.size(); ++i) { | 402 for (size_t i = 0; i < animations_.size(); ++i) { |
| 402 if (animations_[i]->group() == event.group_id && | 403 if (animations_[i]->group() == event.group_id && |
| 403 animations_[i]->target_property() == event.target_property && | 404 animations_[i]->target_property() == event.target_property && |
| 404 animations_[i]->needs_synchronized_start_time()) { | 405 animations_[i]->needs_synchronized_start_time()) { |
| 405 animations_[i]->set_needs_synchronized_start_time(false); | 406 animations_[i]->set_needs_synchronized_start_time(false); |
| 406 if (!animations_[i]->has_set_start_time()) | 407 if (!animations_[i]->has_set_start_time()) |
| 407 animations_[i]->set_start_time(event.monotonic_time); | 408 animations_[i]->set_start_time(event.monotonic_time); |
| 408 | 409 |
| 409 FOR_EACH_OBSERVER(LayerAnimationEventObserver, event_observers_, | 410 if (event_observer_) |
| 410 OnAnimationStarted(event)); | 411 event_observer_->OnAnimationStarted(event); |
| 411 if (layer_animation_delegate_) | 412 if (layer_animation_delegate_) |
| 412 layer_animation_delegate_->NotifyAnimationStarted( | 413 layer_animation_delegate_->NotifyAnimationStarted( |
| 413 event.monotonic_time, event.target_property, event.group_id); | 414 event.monotonic_time, event.target_property, event.group_id); |
| 414 | 415 |
| 415 return; | 416 return; |
| 416 } | 417 } |
| 417 } | 418 } |
| 418 } | 419 } |
| 419 | 420 |
| 420 void LayerAnimationController::NotifyAnimationFinished( | 421 void LayerAnimationController::NotifyAnimationFinished( |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 break; | 482 break; |
| 482 case TargetProperty::TRANSFORM: | 483 case TargetProperty::TRANSFORM: |
| 483 NotifyObserversTransformAnimated( | 484 NotifyObserversTransformAnimated( |
| 484 event.transform, notify_active_observers, notify_pending_observers); | 485 event.transform, notify_active_observers, notify_pending_observers); |
| 485 break; | 486 break; |
| 486 default: | 487 default: |
| 487 NOTREACHED(); | 488 NOTREACHED(); |
| 488 } | 489 } |
| 489 } | 490 } |
| 490 | 491 |
| 491 void LayerAnimationController::AddEventObserver( | 492 void LayerAnimationController::SetEventObserver( |
| 492 LayerAnimationEventObserver* observer) { | 493 LayerAnimationEventObserver* observer) { |
| 493 if (!event_observers_.HasObserver(observer)) | 494 event_observer_ = observer; |
| 494 event_observers_.AddObserver(observer); | |
| 495 } | |
| 496 | |
| 497 void LayerAnimationController::RemoveEventObserver( | |
| 498 LayerAnimationEventObserver* observer) { | |
| 499 event_observers_.RemoveObserver(observer); | |
| 500 } | 495 } |
| 501 | 496 |
| 502 bool LayerAnimationController::HasFilterAnimationThatInflatesBounds() const { | 497 bool LayerAnimationController::HasFilterAnimationThatInflatesBounds() const { |
| 503 for (size_t i = 0; i < animations_.size(); ++i) { | 498 for (size_t i = 0; i < animations_.size(); ++i) { |
| 504 if (!animations_[i]->is_finished() && | 499 if (!animations_[i]->is_finished() && |
| 505 animations_[i]->target_property() == TargetProperty::FILTER && | 500 animations_[i]->target_property() == TargetProperty::FILTER && |
| 506 animations_[i] | 501 animations_[i] |
| 507 ->curve() | 502 ->curve() |
| 508 ->ToFilterAnimationCurve() | 503 ->ToFilterAnimationCurve() |
| 509 ->HasFilterThatMovesPixels()) | 504 ->HasFilterThatMovesPixels()) |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1248 needs_pending_value_observations(); | 1243 needs_pending_value_observations(); |
| 1249 } | 1244 } |
| 1250 | 1245 |
| 1251 bool LayerAnimationController::HasActiveValueObserver() { | 1246 bool LayerAnimationController::HasActiveValueObserver() { |
| 1252 if (!value_observer_) | 1247 if (!value_observer_) |
| 1253 return false; | 1248 return false; |
| 1254 return needs_active_value_observations(); | 1249 return needs_active_value_observations(); |
| 1255 } | 1250 } |
| 1256 | 1251 |
| 1257 } // namespace cc | 1252 } // namespace cc |
| OLD | NEW |