Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/GraphicsLayerTest.cpp

Issue 1739743003: Blink Compositor Animation: Erase old animation system. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compilation. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 CompositorAnimationPlayer* compositorPlayer() const override 111 CompositorAnimationPlayer* compositorPlayer() const override
112 { 112 {
113 return m_compositorPlayer.get(); 113 return m_compositorPlayer.get();
114 } 114 }
115 115
116 OwnPtr<CompositorAnimationPlayer> m_compositorPlayer; 116 OwnPtr<CompositorAnimationPlayer> m_compositorPlayer;
117 }; 117 };
118 118
119 TEST_F(GraphicsLayerTest, updateLayerShouldFlattenTransformWithAnimations) 119 TEST_F(GraphicsLayerTest, updateLayerShouldFlattenTransformWithAnimations)
120 { 120 {
121 ASSERT_FALSE(m_platformLayer->hasActiveAnimation()); 121 ASSERT_FALSE(m_platformLayer->hasActiveAnimationForTesting());
122 122
123 OwnPtr<CompositorFloatAnimationCurve> curve = adoptPtr(CompositorFactory::cu rrent().createFloatAnimationCurve()); 123 OwnPtr<CompositorFloatAnimationCurve> curve = adoptPtr(CompositorFactory::cu rrent().createFloatAnimationCurve());
124 curve->add(CompositorFloatKeyframe(0.0, 0.0)); 124 curve->add(CompositorFloatKeyframe(0.0, 0.0));
125 OwnPtr<CompositorAnimation> floatAnimation(adoptPtr(CompositorFactory::curre nt().createAnimation(*curve, CompositorTargetProperty::OPACITY))); 125 OwnPtr<CompositorAnimation> floatAnimation(adoptPtr(CompositorFactory::curre nt().createAnimation(*curve, CompositorTargetProperty::OPACITY)));
126 int animationId = floatAnimation->id(); 126 int animationId = floatAnimation->id();
127 127
128 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) { 128 OwnPtr<CompositorAnimationTimeline> compositorTimeline = adoptPtr(Compositor Factory::current().createAnimationTimeline());
Ian Vollick 2016/02/29 13:21:37 Can you please remind me how this got enabled duri
loyso (OOO) 2016/02/29 22:39:28 See content/test/test_blink_web_unit_test_support.
129 OwnPtr<CompositorAnimationTimeline> compositorTimeline = adoptPtr(Compos itorFactory::current().createAnimationTimeline()); 129 AnimationPlayerForTesting player;
130 AnimationPlayerForTesting player;
131 130
132 layerTreeView()->attachCompositorAnimationTimeline(compositorTimeline->a nimationTimeline()); 131 layerTreeView()->attachCompositorAnimationTimeline(compositorTimeline->anima tionTimeline());
133 compositorTimeline->playerAttached(player); 132 compositorTimeline->playerAttached(player);
134 133
135 player.compositorPlayer()->attachLayer(m_platformLayer); 134 player.compositorPlayer()->attachLayer(m_platformLayer);
136 ASSERT_TRUE(player.compositorPlayer()->isLayerAttached()); 135 ASSERT_TRUE(player.compositorPlayer()->isLayerAttached());
137 136
138 player.compositorPlayer()->addAnimation(floatAnimation.leakPtr()); 137 player.compositorPlayer()->addAnimation(floatAnimation.leakPtr());
139 138
140 ASSERT_TRUE(m_platformLayer->hasActiveAnimation()); 139 ASSERT_TRUE(m_platformLayer->hasActiveAnimationForTesting());
141 140
142 m_graphicsLayer->setShouldFlattenTransform(false); 141 m_graphicsLayer->setShouldFlattenTransform(false);
143 142
144 m_platformLayer = m_graphicsLayer->platformLayer(); 143 m_platformLayer = m_graphicsLayer->platformLayer();
145 ASSERT_TRUE(m_platformLayer); 144 ASSERT_TRUE(m_platformLayer);
146 145
147 ASSERT_TRUE(m_platformLayer->hasActiveAnimation()); 146 ASSERT_TRUE(m_platformLayer->hasActiveAnimationForTesting());
148 player.compositorPlayer()->removeAnimation(animationId); 147 player.compositorPlayer()->removeAnimation(animationId);
149 ASSERT_FALSE(m_platformLayer->hasActiveAnimation()); 148 ASSERT_FALSE(m_platformLayer->hasActiveAnimationForTesting());
150 149
151 m_graphicsLayer->setShouldFlattenTransform(true); 150 m_graphicsLayer->setShouldFlattenTransform(true);
152 151
153 m_platformLayer = m_graphicsLayer->platformLayer(); 152 m_platformLayer = m_graphicsLayer->platformLayer();
154 ASSERT_TRUE(m_platformLayer); 153 ASSERT_TRUE(m_platformLayer);
155 154
156 ASSERT_FALSE(m_platformLayer->hasActiveAnimation()); 155 ASSERT_FALSE(m_platformLayer->hasActiveAnimationForTesting());
157 156
158 player.compositorPlayer()->detachLayer(); 157 player.compositorPlayer()->detachLayer();
159 ASSERT_FALSE(player.compositorPlayer()->isLayerAttached()); 158 ASSERT_FALSE(player.compositorPlayer()->isLayerAttached());
160 159
161 compositorTimeline->playerDestroyed(player); 160 compositorTimeline->playerDestroyed(player);
162 layerTreeView()->detachCompositorAnimationTimeline(compositorTimeline->a nimationTimeline()); 161 layerTreeView()->detachCompositorAnimationTimeline(compositorTimeline->anima tionTimeline());
163 } else {
164 ASSERT_TRUE(m_platformLayer->addAnimation(floatAnimation->releaseCCAnima tion()));
165
166 ASSERT_TRUE(m_platformLayer->hasActiveAnimation());
167
168 m_graphicsLayer->setShouldFlattenTransform(false);
169
170 m_platformLayer = m_graphicsLayer->platformLayer();
171 ASSERT_TRUE(m_platformLayer);
172
173 ASSERT_TRUE(m_platformLayer->hasActiveAnimation());
174 m_platformLayer->removeAnimation(animationId);
175 ASSERT_FALSE(m_platformLayer->hasActiveAnimation());
176
177 m_graphicsLayer->setShouldFlattenTransform(true);
178
179 m_platformLayer = m_graphicsLayer->platformLayer();
180 ASSERT_TRUE(m_platformLayer);
181
182 ASSERT_FALSE(m_platformLayer->hasActiveAnimation());
183 }
184 } 162 }
185 163
186 class FakeScrollableArea : public NoBaseWillBeGarbageCollectedFinalized<FakeScro llableArea>, public ScrollableArea { 164 class FakeScrollableArea : public NoBaseWillBeGarbageCollectedFinalized<FakeScro llableArea>, public ScrollableArea {
187 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(FakeScrollableArea); 165 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(FakeScrollableArea);
188 public: 166 public:
189 static PassOwnPtrWillBeRawPtr<FakeScrollableArea> create() 167 static PassOwnPtrWillBeRawPtr<FakeScrollableArea> create()
190 { 168 {
191 return adoptPtrWillBeNoop(new FakeScrollableArea); 169 return adoptPtrWillBeNoop(new FakeScrollableArea);
192 } 170 }
193 171
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 209
232 WebDoublePoint scrollPosition(7, 9); 210 WebDoublePoint scrollPosition(7, 9);
233 m_platformLayer->setScrollPositionDouble(scrollPosition); 211 m_platformLayer->setScrollPositionDouble(scrollPosition);
234 m_graphicsLayer->didScroll(); 212 m_graphicsLayer->didScroll();
235 213
236 EXPECT_FLOAT_EQ(scrollPosition.x, scrollableArea->scrollPositionDouble().x() ); 214 EXPECT_FLOAT_EQ(scrollPosition.x, scrollableArea->scrollPositionDouble().x() );
237 EXPECT_FLOAT_EQ(scrollPosition.y, scrollableArea->scrollPositionDouble().y() ); 215 EXPECT_FLOAT_EQ(scrollPosition.y, scrollableArea->scrollPositionDouble().y() );
238 } 216 }
239 217
240 } // namespace blink 218 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698