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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "cc/animation/animation.h" | 9 #include "cc/animation/animation.h" |
10 #include "cc/animation/animation_delegate.h" | 10 #include "cc/animation/animation_delegate.h" |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
358 for (size_t i = 0; i < animations_.size(); ++i) { | 358 for (size_t i = 0; i < animations_.size(); ++i) { |
359 if (animations_[i]->group() == event.group_id && | 359 if (animations_[i]->group() == event.group_id && |
360 animations_[i]->target_property() == event.target_property) { | 360 animations_[i]->target_property() == event.target_property) { |
361 animations_[i]->SetRunState(Animation::Aborted, event.monotonic_time); | 361 animations_[i]->SetRunState(Animation::Aborted, event.monotonic_time); |
362 } | 362 } |
363 } | 363 } |
364 } | 364 } |
365 | 365 |
366 void LayerAnimationController::NotifyAnimationPropertyUpdate( | 366 void LayerAnimationController::NotifyAnimationPropertyUpdate( |
367 const AnimationEvent& event) { | 367 const AnimationEvent& event) { |
368 bool notify_active_observers = true; | |
369 bool notify_pending_observers = true; | |
ajuma
2014/08/05 13:05:57
These variables act as a form of documentation all
shreyas.g
2014/08/05 13:41:52
Done. Makes sense. Will keep that in mind for futu
| |
370 switch (event.target_property) { | 368 switch (event.target_property) { |
371 case Animation::Opacity: | 369 case Animation::Opacity: |
372 NotifyObserversOpacityAnimated( | 370 NotifyObserversOpacityAnimated(event.opacity, true, true); |
373 event.opacity, notify_active_observers, notify_pending_observers); | |
374 break; | 371 break; |
375 case Animation::Transform: | 372 case Animation::Transform: |
376 NotifyObserversTransformAnimated( | 373 NotifyObserversTransformAnimated(event.transform, true, true); |
377 event.transform, notify_active_observers, notify_pending_observers); | |
378 break; | 374 break; |
379 default: | 375 default: |
380 NOTREACHED(); | 376 NOTREACHED(); |
381 } | 377 } |
382 } | 378 } |
383 | 379 |
384 void LayerAnimationController::AddValueObserver( | 380 void LayerAnimationController::AddValueObserver( |
385 LayerAnimationValueObserver* observer) { | 381 LayerAnimationValueObserver* observer) { |
386 if (!value_observers_.HasObserver(observer)) | 382 if (!value_observers_.HasObserver(observer)) |
387 value_observers_.AddObserver(observer); | 383 value_observers_.AddObserver(observer); |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
917 | 913 |
918 void LayerAnimationController::NotifyObserversOpacityAnimated( | 914 void LayerAnimationController::NotifyObserversOpacityAnimated( |
919 float opacity, | 915 float opacity, |
920 bool notify_active_observers, | 916 bool notify_active_observers, |
921 bool notify_pending_observers) { | 917 bool notify_pending_observers) { |
922 if (value_observers_.might_have_observers()) { | 918 if (value_observers_.might_have_observers()) { |
923 ObserverListBase<LayerAnimationValueObserver>::Iterator it( | 919 ObserverListBase<LayerAnimationValueObserver>::Iterator it( |
924 value_observers_); | 920 value_observers_); |
925 LayerAnimationValueObserver* obs; | 921 LayerAnimationValueObserver* obs; |
926 while ((obs = it.GetNext()) != NULL) { | 922 while ((obs = it.GetNext()) != NULL) { |
927 if ((notify_active_observers && obs->IsActive()) || | 923 if ((notify_active_observers && notify_pending_observers) || |
924 (notify_active_observers && obs->IsActive()) || | |
928 (notify_pending_observers && !obs->IsActive())) | 925 (notify_pending_observers && !obs->IsActive())) |
929 obs->OnOpacityAnimated(opacity); | 926 obs->OnOpacityAnimated(opacity); |
930 } | 927 } |
931 } | 928 } |
932 } | 929 } |
933 | 930 |
934 void LayerAnimationController::NotifyObserversTransformAnimated( | 931 void LayerAnimationController::NotifyObserversTransformAnimated( |
935 const gfx::Transform& transform, | 932 const gfx::Transform& transform, |
936 bool notify_active_observers, | 933 bool notify_active_observers, |
937 bool notify_pending_observers) { | 934 bool notify_pending_observers) { |
938 if (value_observers_.might_have_observers()) { | 935 if (value_observers_.might_have_observers()) { |
939 ObserverListBase<LayerAnimationValueObserver>::Iterator it( | 936 ObserverListBase<LayerAnimationValueObserver>::Iterator it( |
940 value_observers_); | 937 value_observers_); |
941 LayerAnimationValueObserver* obs; | 938 LayerAnimationValueObserver* obs; |
942 while ((obs = it.GetNext()) != NULL) { | 939 while ((obs = it.GetNext()) != NULL) { |
943 if ((notify_active_observers && obs->IsActive()) || | 940 if ((notify_active_observers && notify_pending_observers) || |
941 (notify_active_observers && obs->IsActive()) || | |
944 (notify_pending_observers && !obs->IsActive())) | 942 (notify_pending_observers && !obs->IsActive())) |
945 obs->OnTransformAnimated(transform); | 943 obs->OnTransformAnimated(transform); |
946 } | 944 } |
947 } | 945 } |
948 } | 946 } |
949 | 947 |
950 void LayerAnimationController::NotifyObserversFilterAnimated( | 948 void LayerAnimationController::NotifyObserversFilterAnimated( |
951 const FilterOperations& filters, | 949 const FilterOperations& filters, |
952 bool notify_active_observers, | 950 bool notify_active_observers, |
953 bool notify_pending_observers) { | 951 bool notify_pending_observers) { |
954 if (value_observers_.might_have_observers()) { | 952 if (value_observers_.might_have_observers()) { |
955 ObserverListBase<LayerAnimationValueObserver>::Iterator it( | 953 ObserverListBase<LayerAnimationValueObserver>::Iterator it( |
956 value_observers_); | 954 value_observers_); |
957 LayerAnimationValueObserver* obs; | 955 LayerAnimationValueObserver* obs; |
958 while ((obs = it.GetNext()) != NULL) { | 956 while ((obs = it.GetNext()) != NULL) { |
959 if ((notify_active_observers && obs->IsActive()) || | 957 if ((notify_active_observers && notify_pending_observers) || |
958 (notify_active_observers && obs->IsActive()) || | |
960 (notify_pending_observers && !obs->IsActive())) | 959 (notify_pending_observers && !obs->IsActive())) |
961 obs->OnFilterAnimated(filters); | 960 obs->OnFilterAnimated(filters); |
962 } | 961 } |
963 } | 962 } |
964 } | 963 } |
965 | 964 |
966 void LayerAnimationController::NotifyObserversScrollOffsetAnimated( | 965 void LayerAnimationController::NotifyObserversScrollOffsetAnimated( |
967 const gfx::Vector2dF& scroll_offset, | 966 const gfx::Vector2dF& scroll_offset, |
968 bool notify_active_observers, | 967 bool notify_active_observers, |
969 bool notify_pending_observers) { | 968 bool notify_pending_observers) { |
970 if (value_observers_.might_have_observers()) { | 969 if (value_observers_.might_have_observers()) { |
971 ObserverListBase<LayerAnimationValueObserver>::Iterator it( | 970 ObserverListBase<LayerAnimationValueObserver>::Iterator it( |
972 value_observers_); | 971 value_observers_); |
973 LayerAnimationValueObserver* obs; | 972 LayerAnimationValueObserver* obs; |
974 while ((obs = it.GetNext()) != NULL) { | 973 while ((obs = it.GetNext()) != NULL) { |
975 if ((notify_active_observers && obs->IsActive()) || | 974 if ((notify_active_observers && notify_pending_observers) || |
975 (notify_active_observers && obs->IsActive()) || | |
976 (notify_pending_observers && !obs->IsActive())) | 976 (notify_pending_observers && !obs->IsActive())) |
977 obs->OnScrollOffsetAnimated(scroll_offset); | 977 obs->OnScrollOffsetAnimated(scroll_offset); |
978 } | 978 } |
979 } | 979 } |
980 } | 980 } |
981 | 981 |
982 void LayerAnimationController::NotifyObserversAnimationWaitingForDeletion() { | 982 void LayerAnimationController::NotifyObserversAnimationWaitingForDeletion() { |
983 FOR_EACH_OBSERVER(LayerAnimationValueObserver, | 983 FOR_EACH_OBSERVER(LayerAnimationValueObserver, |
984 value_observers_, | 984 value_observers_, |
985 OnAnimationWaitingForDeletion()); | 985 OnAnimationWaitingForDeletion()); |
(...skipping 14 matching lines...) Expand all Loading... | |
1000 value_observers_); | 1000 value_observers_); |
1001 LayerAnimationValueObserver* obs; | 1001 LayerAnimationValueObserver* obs; |
1002 while ((obs = it.GetNext()) != NULL) | 1002 while ((obs = it.GetNext()) != NULL) |
1003 if (obs->IsActive()) | 1003 if (obs->IsActive()) |
1004 return true; | 1004 return true; |
1005 } | 1005 } |
1006 return false; | 1006 return false; |
1007 } | 1007 } |
1008 | 1008 |
1009 } // namespace cc | 1009 } // namespace cc |
OLD | NEW |