OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 void simulateFrame(double time) | 249 void simulateFrame(double time) |
250 { | 250 { |
251 m_document->animationClock().updateTime(time); | 251 m_document->animationClock().updateTime(time); |
252 m_document->compositorPendingAnimations().update(false); | 252 m_document->compositorPendingAnimations().update(false); |
253 m_timeline->serviceAnimations(TimingUpdateForAnimationFrame); | 253 m_timeline->serviceAnimations(TimingUpdateForAnimationFrame); |
254 } | 254 } |
255 }; | 255 }; |
256 | 256 |
257 class RenderObjectProxy : public RenderObject { | 257 class RenderObjectProxy : public RenderObject { |
258 public: | 258 public: |
| 259 static PassOwnPtrWillBeRawPtr<RenderObjectProxy> create(Node* node) |
| 260 { |
| 261 return adoptPtrWillBeNoop(new RenderObjectProxy(node)); |
| 262 } |
| 263 |
| 264 static void dispose(PassOwnPtrWillBeRawPtr<RenderObjectProxy> object) |
| 265 { |
| 266 object.leakPtr()->destroy(); |
| 267 } |
| 268 |
| 269 const char* renderName() const override { return nullptr; } |
| 270 void layout() override { } |
| 271 private: |
259 explicit RenderObjectProxy(Node* node) | 272 explicit RenderObjectProxy(Node* node) |
260 : RenderObject(node) | 273 : RenderObject(node) |
261 { | 274 { |
262 } | 275 } |
263 | |
264 const char* renderName() const override { return nullptr; } | |
265 void layout() override { } | |
266 }; | 276 }; |
267 | 277 |
268 // ----------------------------------------------------------------------- | 278 // ----------------------------------------------------------------------- |
269 // ----------------------------------------------------------------------- | 279 // ----------------------------------------------------------------------- |
270 | 280 |
271 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorKey
frameMultipleCSSProperties) | 281 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorKey
frameMultipleCSSProperties) |
272 { | 282 { |
273 RefPtrWillBeRawPtr<AnimatableValueKeyframe> keyframeGoodMultiple = createDef
aultKeyframe(CSSPropertyOpacity, AnimationEffect::CompositeReplace); | 283 RefPtrWillBeRawPtr<AnimatableValueKeyframe> keyframeGoodMultiple = createDef
aultKeyframe(CSSPropertyOpacity, AnimationEffect::CompositeReplace); |
274 keyframeGoodMultiple->setPropertyValue(CSSPropertyTransform, AnimatableTrans
form::create(TransformOperations()).get()); | 284 keyframeGoodMultiple->setPropertyValue(CSSPropertyTransform, AnimatableTrans
form::create(TransformOperations()).get()); |
275 EXPECT_TRUE(duplicateSingleKeyframeAndTestIsCandidateOnResult(keyframeGoodMu
ltiple.get())); | 285 EXPECT_TRUE(duplicateSingleKeyframeAndTestIsCandidateOnResult(keyframeGoodMu
ltiple.get())); |
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 getAnimationOnCompositor(m_timing, *effect.get(), result); | 1193 getAnimationOnCompositor(m_timing, *effect.get(), result); |
1184 EXPECT_EQ(1U, result.size()); | 1194 EXPECT_EQ(1U, result.size()); |
1185 result[0].clear(); | 1195 result[0].clear(); |
1186 } | 1196 } |
1187 | 1197 |
1188 TEST_F(AnimationCompositorAnimationsTest, CancelIncompatibleCompositorAnimations
) | 1198 TEST_F(AnimationCompositorAnimationsTest, CancelIncompatibleCompositorAnimations
) |
1189 { | 1199 { |
1190 WebCompositorSupportMock mockCompositor; | 1200 WebCompositorSupportMock mockCompositor; |
1191 setCompositorForTesting(mockCompositor); | 1201 setCompositorForTesting(mockCompositor); |
1192 | 1202 |
1193 RefPtrWillBeRawPtr<Element> element = m_document->createElement("shared", AS
SERT_NO_EXCEPTION); | 1203 RefPtrWillBePersistent<Element> element = m_document->createElement("shared"
, ASSERT_NO_EXCEPTION); |
1194 | 1204 |
1195 RenderObjectProxy* renderer = new RenderObjectProxy(element.get()); | 1205 OwnPtrWillBePersistent<RenderObjectProxy> renderer = RenderObjectProxy::crea
te(element.get()); |
1196 element->setRenderer(renderer); | 1206 element->setRenderer(renderer.get()); |
1197 | 1207 |
1198 AnimatableValueKeyframeVector keyFrames; | 1208 AnimatableValueKeyframeVector keyFrames; |
1199 keyFrames.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect::
CompositeReplace, 0.0).get()); | 1209 keyFrames.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect::
CompositeReplace, 0.0).get()); |
1200 keyFrames.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect::
CompositeReplace, 1.0).get()); | 1210 keyFrames.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect::
CompositeReplace, 1.0).get()); |
1201 RefPtrWillBeRawPtr<AnimationEffect> animationEffect1 = AnimatableValueKeyfra
meEffectModel::create(keyFrames); | 1211 RefPtrWillBeRawPtr<AnimationEffect> animationEffect1 = AnimatableValueKeyfra
meEffectModel::create(keyFrames); |
1202 RefPtrWillBeRawPtr<AnimationEffect> animationEffect2 = AnimatableValueKeyfra
meEffectModel::create(keyFrames); | 1212 RefPtrWillBeRawPtr<AnimationEffect> animationEffect2 = AnimatableValueKeyfra
meEffectModel::create(keyFrames); |
1203 | 1213 |
1204 Timing timing; | 1214 Timing timing; |
1205 timing.iterationDuration = 1.f; | 1215 timing.iterationDuration = 1.f; |
1206 | 1216 |
1207 // The first player for opacity is ok to run on compositor. | 1217 // The first player for opacity is ok to run on compositor. |
1208 RefPtrWillBeRawPtr<Animation> animation1 = Animation::create(element.get(),
animationEffect1, timing); | 1218 RefPtrWillBeRawPtr<Animation> animation1 = Animation::create(element.get(),
animationEffect1, timing); |
1209 RefPtrWillBeRawPtr<AnimationPlayer> player1 = m_timeline->play(animation1.ge
t()); | 1219 RefPtrWillBePersistent<AnimationPlayer> player1 = m_timeline->play(animation
1.get()); |
1210 EXPECT_TRUE(CompositorAnimations::instance()->isCandidateForAnimationOnCompo
sitor(timing, *element.get(), player1.get(), *animationEffect1.get(), 1)); | 1220 EXPECT_TRUE(CompositorAnimations::instance()->isCandidateForAnimationOnCompo
sitor(timing, *element.get(), player1.get(), *animationEffect1.get(), 1)); |
1211 | 1221 |
1212 // simulate Animation::maybeStartAnimationOnCompositor | 1222 // simulate Animation::maybeStartAnimationOnCompositor |
1213 Vector<int> compositorAnimationIds; | 1223 Vector<int> compositorAnimationIds; |
1214 compositorAnimationIds.append(1); | 1224 compositorAnimationIds.append(1); |
1215 animation1->setCompositorAnimationIdsForTesting(compositorAnimationIds); | 1225 animation1->setCompositorAnimationIdsForTesting(compositorAnimationIds); |
1216 EXPECT_TRUE(player1->hasActiveAnimationsOnCompositor()); | 1226 EXPECT_TRUE(player1->hasActiveAnimationsOnCompositor()); |
1217 | 1227 |
1218 // The second player for opacity is not ok to run on compositor. | 1228 // The second player for opacity is not ok to run on compositor. |
1219 RefPtrWillBeRawPtr<Animation> animation2 = Animation::create(element.get(),
animationEffect2, timing); | 1229 RefPtrWillBeRawPtr<Animation> animation2 = Animation::create(element.get(),
animationEffect2, timing); |
1220 RefPtrWillBeRawPtr<AnimationPlayer> player2 = m_timeline->play(animation2.ge
t()); | 1230 RefPtrWillBePersistent<AnimationPlayer> player2 = m_timeline->play(animation
2.get()); |
1221 EXPECT_FALSE(CompositorAnimations::instance()->isCandidateForAnimationOnComp
ositor(timing, *element.get(), player2.get(), *animationEffect2.get(), 1)); | 1231 EXPECT_FALSE(CompositorAnimations::instance()->isCandidateForAnimationOnComp
ositor(timing, *element.get(), player2.get(), *animationEffect2.get(), 1)); |
1222 EXPECT_FALSE(player2->hasActiveAnimationsOnCompositor()); | 1232 EXPECT_FALSE(player2->hasActiveAnimationsOnCompositor()); |
1223 | 1233 |
1224 // A fallback to blink implementation needed, so cancel all compositor-side
opacity animations for this element. | 1234 // A fallback to blink implementation needed, so cancel all compositor-side
opacity animations for this element. |
1225 player2->cancelIncompatibleAnimationsOnCompositor(); | 1235 player2->cancelIncompatibleAnimationsOnCompositor(); |
1226 | 1236 |
1227 EXPECT_FALSE(player1->hasActiveAnimationsOnCompositor()); | 1237 EXPECT_FALSE(player1->hasActiveAnimationsOnCompositor()); |
1228 EXPECT_FALSE(player2->hasActiveAnimationsOnCompositor()); | 1238 EXPECT_FALSE(player2->hasActiveAnimationsOnCompositor()); |
1229 | 1239 |
1230 simulateFrame(0); | 1240 simulateFrame(0); |
1231 EXPECT_EQ(2U, element->activeAnimations()->players().size()); | 1241 EXPECT_EQ(2U, element->activeAnimations()->players().size()); |
1232 simulateFrame(1.); | 1242 simulateFrame(1.); |
1233 | 1243 |
1234 element->setRenderer(nullptr); | 1244 element->setRenderer(nullptr); |
1235 delete renderer; | 1245 RenderObjectProxy::dispose(renderer.release()); |
1236 renderer = nullptr; | |
1237 | 1246 |
1238 player1.release(); | 1247 player1.release(); |
1239 player2.release(); | 1248 player2.release(); |
1240 Heap::collectAllGarbage(); | 1249 Heap::collectAllGarbage(); |
1241 EXPECT_TRUE(element->activeAnimations()->players().isEmpty()); | 1250 EXPECT_TRUE(element->activeAnimations()->players().isEmpty()); |
1242 } | 1251 } |
1243 | 1252 |
1244 } // namespace blink | 1253 } // namespace blink |
OLD | NEW |