 Chromium Code Reviews
 Chromium Code Reviews Issue 1587073011:
  Plumb NotifyAnimationAborted from the compositor to blink animation delegate.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1587073011:
  Plumb NotifyAnimationAborted from the compositor to blink animation delegate.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| 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 "cc/animation/animation.h" | 9 #include "cc/animation/animation.h" | 
| 10 #include "cc/animation/animation_curve.h" | 10 #include "cc/animation/animation_curve.h" | 
| (...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1023 EXPECT_FALSE(controller_impl->scroll_offset_animation_was_interrupted()); | 1023 EXPECT_FALSE(controller_impl->scroll_offset_animation_was_interrupted()); | 
| 1024 EXPECT_FALSE(controller->scroll_offset_animation_was_interrupted()); | 1024 EXPECT_FALSE(controller->scroll_offset_animation_was_interrupted()); | 
| 1025 | 1025 | 
| 1026 controller_impl->ActivateAnimations(); | 1026 controller_impl->ActivateAnimations(); | 
| 1027 EXPECT_FALSE(controller_impl->scroll_offset_animation_was_interrupted()); | 1027 EXPECT_FALSE(controller_impl->scroll_offset_animation_was_interrupted()); | 
| 1028 } | 1028 } | 
| 1029 | 1029 | 
| 1030 class FakeAnimationDelegate : public AnimationDelegate { | 1030 class FakeAnimationDelegate : public AnimationDelegate { | 
| 1031 public: | 1031 public: | 
| 1032 FakeAnimationDelegate() | 1032 FakeAnimationDelegate() | 
| 1033 : started_(false), finished_(false), start_time_(base::TimeTicks()) {} | 1033 : started_(false), finished_(false), start_time_(base::TimeTicks()) {} | 
| 
ajuma
2016/01/15 16:49:54
aborted_ needs to be initialized
 | |
| 1034 | 1034 | 
| 1035 void NotifyAnimationStarted(TimeTicks monotonic_time, | 1035 void NotifyAnimationStarted(TimeTicks monotonic_time, | 
| 1036 Animation::TargetProperty target_property, | 1036 Animation::TargetProperty target_property, | 
| 1037 int group) override { | 1037 int group) override { | 
| 1038 started_ = true; | 1038 started_ = true; | 
| 1039 start_time_ = monotonic_time; | 1039 start_time_ = monotonic_time; | 
| 1040 } | 1040 } | 
| 1041 | 1041 | 
| 1042 void NotifyAnimationFinished(TimeTicks monotonic_time, | 1042 void NotifyAnimationFinished(TimeTicks monotonic_time, | 
| 1043 Animation::TargetProperty target_property, | 1043 Animation::TargetProperty target_property, | 
| 1044 int group) override { | 1044 int group) override { | 
| 1045 finished_ = true; | 1045 finished_ = true; | 
| 1046 } | 1046 } | 
| 1047 | 1047 | 
| 1048 void NotifyAnimationAborted(TimeTicks monotonic_time, | |
| 1049 Animation::TargetProperty target_property, | |
| 1050 int group) override { | |
| 1051 aborted_ = true; | |
| 1052 } | |
| 1053 | |
| 1048 bool started() { return started_; } | 1054 bool started() { return started_; } | 
| 1049 | 1055 | 
| 1050 bool finished() { return finished_; } | 1056 bool finished() { return finished_; } | 
| 1051 | 1057 | 
| 1058 bool aborted() { return aborted_; } | |
| 1059 | |
| 1052 TimeTicks start_time() { return start_time_; } | 1060 TimeTicks start_time() { return start_time_; } | 
| 1053 | 1061 | 
| 1054 private: | 1062 private: | 
| 1055 bool started_; | 1063 bool started_; | 
| 1056 bool finished_; | 1064 bool finished_; | 
| 1065 bool aborted_; | |
| 1057 TimeTicks start_time_; | 1066 TimeTicks start_time_; | 
| 1058 }; | 1067 }; | 
| 1059 | 1068 | 
| 1060 // Tests that impl-only animations lead to start and finished notifications | 1069 // Tests that impl-only animations lead to start and finished notifications | 
| 1061 // on the impl thread controller's animation delegate. | 1070 // on the impl thread controller's animation delegate. | 
| 1062 TEST(LayerAnimationControllerTest, | 1071 TEST(LayerAnimationControllerTest, | 
| 1063 NotificationsForImplOnlyAnimationsAreSentToImplThreadDelegate) { | 1072 NotificationsForImplOnlyAnimationsAreSentToImplThreadDelegate) { | 
| 1064 FakeLayerAnimationValueObserver dummy_impl; | 1073 FakeLayerAnimationValueObserver dummy_impl; | 
| 1065 scoped_refptr<LayerAnimationController> controller_impl( | 1074 scoped_refptr<LayerAnimationController> controller_impl( | 
| 1066 LayerAnimationController::Create(0)); | 1075 LayerAnimationController::Create(0)); | 
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1861 // An animation aborted on the impl thread should get deleted on both threads. | 1870 // An animation aborted on the impl thread should get deleted on both threads. | 
| 1862 TEST(LayerAnimationControllerTest, ImplThreadAbortedAnimationGetsDeleted) { | 1871 TEST(LayerAnimationControllerTest, ImplThreadAbortedAnimationGetsDeleted) { | 
| 1863 FakeLayerAnimationValueObserver dummy_impl; | 1872 FakeLayerAnimationValueObserver dummy_impl; | 
| 1864 scoped_refptr<LayerAnimationController> controller_impl( | 1873 scoped_refptr<LayerAnimationController> controller_impl( | 
| 1865 LayerAnimationController::Create(0)); | 1874 LayerAnimationController::Create(0)); | 
| 1866 controller_impl->AddValueObserver(&dummy_impl); | 1875 controller_impl->AddValueObserver(&dummy_impl); | 
| 1867 FakeLayerAnimationValueObserver dummy; | 1876 FakeLayerAnimationValueObserver dummy; | 
| 1868 scoped_refptr<LayerAnimationController> controller( | 1877 scoped_refptr<LayerAnimationController> controller( | 
| 1869 LayerAnimationController::Create(0)); | 1878 LayerAnimationController::Create(0)); | 
| 1870 controller->AddValueObserver(&dummy); | 1879 controller->AddValueObserver(&dummy); | 
| 1880 FakeAnimationDelegate delegate; | |
| 1881 controller->set_layer_animation_delegate(&delegate); | |
| 1871 | 1882 | 
| 1872 int animation_id = | 1883 int animation_id = | 
| 1873 AddOpacityTransitionToController(controller.get(), 1.0, 0.f, 1.f, false); | 1884 AddOpacityTransitionToController(controller.get(), 1.0, 0.f, 1.f, false); | 
| 1874 | 1885 | 
| 1875 controller->PushAnimationUpdatesTo(controller_impl.get()); | 1886 controller->PushAnimationUpdatesTo(controller_impl.get()); | 
| 1876 controller_impl->ActivateAnimations(); | 1887 controller_impl->ActivateAnimations(); | 
| 1877 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); | 1888 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); | 
| 1878 | 1889 | 
| 1879 controller_impl->AbortAnimations(Animation::OPACITY); | 1890 controller_impl->AbortAnimations(Animation::OPACITY); | 
| 1880 EXPECT_EQ(Animation::ABORTED, | 1891 EXPECT_EQ(Animation::ABORTED, | 
| 1881 controller_impl->GetAnimation(Animation::OPACITY)->run_state()); | 1892 controller_impl->GetAnimation(Animation::OPACITY)->run_state()); | 
| 1882 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); | 1893 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); | 
| 1883 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); | 1894 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); | 
| 1884 | 1895 | 
| 1885 AnimationEventsVector events; | 1896 AnimationEventsVector events; | 
| 1886 controller_impl->Animate(kInitialTickTime); | 1897 controller_impl->Animate(kInitialTickTime); | 
| 1887 controller_impl->UpdateState(true, &events); | 1898 controller_impl->UpdateState(true, &events); | 
| 1888 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); | 1899 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); | 
| 1889 EXPECT_EQ(1u, events.size()); | 1900 EXPECT_EQ(1u, events.size()); | 
| 1890 EXPECT_EQ(AnimationEvent::ABORTED, events[0].type); | 1901 EXPECT_EQ(AnimationEvent::ABORTED, events[0].type); | 
| 1891 EXPECT_EQ(Animation::WAITING_FOR_DELETION, | 1902 EXPECT_EQ(Animation::WAITING_FOR_DELETION, | 
| 1892 controller_impl->GetAnimation(Animation::OPACITY)->run_state()); | 1903 controller_impl->GetAnimation(Animation::OPACITY)->run_state()); | 
| 1893 | 1904 | 
| 1894 controller->NotifyAnimationAborted(events[0]); | 1905 controller->NotifyAnimationAborted(events[0]); | 
| 1895 EXPECT_EQ(Animation::ABORTED, | 1906 EXPECT_EQ(Animation::ABORTED, | 
| 1896 controller->GetAnimation(Animation::OPACITY)->run_state()); | 1907 controller->GetAnimation(Animation::OPACITY)->run_state()); | 
| 1908 EXPECT_TRUE(delegate.aborted()); | |
| 1897 | 1909 | 
| 1898 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 1910 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 
| 1899 controller->UpdateState(true, nullptr); | 1911 controller->UpdateState(true, nullptr); | 
| 1900 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); | 1912 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); | 
| 1901 EXPECT_EQ(Animation::WAITING_FOR_DELETION, | 1913 EXPECT_EQ(Animation::WAITING_FOR_DELETION, | 
| 1902 controller->GetAnimation(Animation::OPACITY)->run_state()); | 1914 controller->GetAnimation(Animation::OPACITY)->run_state()); | 
| 1903 | 1915 | 
| 1904 controller->PushAnimationUpdatesTo(controller_impl.get()); | 1916 controller->PushAnimationUpdatesTo(controller_impl.get()); | 
| 1905 controller_impl->ActivateAnimations(); | 1917 controller_impl->ActivateAnimations(); | 
| 1906 EXPECT_FALSE(controller->GetAnimationById(animation_id)); | 1918 EXPECT_FALSE(controller->GetAnimationById(animation_id)); | 
| (...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3003 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty( | 3015 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty( | 
| 3004 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); | 3016 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); | 
| 3005 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( | 3017 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( | 
| 3006 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); | 3018 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); | 
| 3007 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( | 3019 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( | 
| 3008 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); | 3020 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); | 
| 3009 } | 3021 } | 
| 3010 | 3022 | 
| 3011 } // namespace | 3023 } // namespace | 
| 3012 } // namespace cc | 3024 } // namespace cc | 
| OLD | NEW |