| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 keyframe->setPropertyValue(id, value); | 144 keyframe->setPropertyValue(id, value); |
| 145 keyframe->setComposite(AnimationEffect::CompositeReplace); | 145 keyframe->setComposite(AnimationEffect::CompositeReplace); |
| 146 keyframe->setOffset(offset); | 146 keyframe->setOffset(offset); |
| 147 keyframe->setEasing(LinearTimingFunction::preset()); | 147 keyframe->setEasing(LinearTimingFunction::preset()); |
| 148 return keyframe; | 148 return keyframe; |
| 149 } | 149 } |
| 150 | 150 |
| 151 PassRefPtrWillBeRawPtr<Keyframe> createDefaultKeyframe(CSSPropertyID id, Ani
mationEffect::CompositeOperation op, double offset = 0) | 151 PassRefPtrWillBeRawPtr<Keyframe> createDefaultKeyframe(CSSPropertyID id, Ani
mationEffect::CompositeOperation op, double offset = 0) |
| 152 { | 152 { |
| 153 RefPtrWillBeRawPtr<AnimatableValue> value = nullptr; | 153 RefPtrWillBeRawPtr<AnimatableValue> value = nullptr; |
| 154 if (id == CSSPropertyWebkitTransform) | 154 if (id == CSSPropertyTransform) |
| 155 value = AnimatableTransform::create(TransformOperations()); | 155 value = AnimatableTransform::create(TransformOperations()); |
| 156 else | 156 else |
| 157 value = AnimatableDouble::create(10.0); | 157 value = AnimatableDouble::create(10.0); |
| 158 | 158 |
| 159 RefPtrWillBeRawPtr<Keyframe> keyframe = createReplaceOpKeyframe(id, valu
e.get(), offset); | 159 RefPtrWillBeRawPtr<Keyframe> keyframe = createReplaceOpKeyframe(id, valu
e.get(), offset); |
| 160 keyframe->setComposite(op); | 160 keyframe->setComposite(op); |
| 161 return keyframe; | 161 return keyframe; |
| 162 } | 162 } |
| 163 | 163 |
| 164 PassOwnPtrWillBeRawPtr<KeyframeEffectModel::KeyframeVector> createCompositab
leFloatKeyframeVector(size_t n) | 164 PassOwnPtrWillBeRawPtr<KeyframeEffectModel::KeyframeVector> createCompositab
leFloatKeyframeVector(size_t n) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 } | 211 } |
| 212 | 212 |
| 213 }; | 213 }; |
| 214 | 214 |
| 215 // ----------------------------------------------------------------------- | 215 // ----------------------------------------------------------------------- |
| 216 // ----------------------------------------------------------------------- | 216 // ----------------------------------------------------------------------- |
| 217 | 217 |
| 218 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorKey
frameMultipleCSSProperties) | 218 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorKey
frameMultipleCSSProperties) |
| 219 { | 219 { |
| 220 RefPtrWillBeRawPtr<Keyframe> keyframeGoodMultiple = createDefaultKeyframe(CS
SPropertyOpacity, AnimationEffect::CompositeReplace); | 220 RefPtrWillBeRawPtr<Keyframe> keyframeGoodMultiple = createDefaultKeyframe(CS
SPropertyOpacity, AnimationEffect::CompositeReplace); |
| 221 keyframeGoodMultiple->setPropertyValue(CSSPropertyWebkitTransform, Animatabl
eTransform::create(TransformOperations()).get()); | 221 keyframeGoodMultiple->setPropertyValue(CSSPropertyTransform, AnimatableTrans
form::create(TransformOperations()).get()); |
| 222 EXPECT_TRUE(isCandidateHelperForSingleKeyframe(keyframeGoodMultiple.get())); | 222 EXPECT_TRUE(isCandidateHelperForSingleKeyframe(keyframeGoodMultiple.get())); |
| 223 | 223 |
| 224 RefPtrWillBeRawPtr<Keyframe> keyframeBadMultipleOp = createDefaultKeyframe(C
SSPropertyOpacity, AnimationEffect::CompositeAdd); | 224 RefPtrWillBeRawPtr<Keyframe> keyframeBadMultipleOp = createDefaultKeyframe(C
SSPropertyOpacity, AnimationEffect::CompositeAdd); |
| 225 keyframeBadMultipleOp->setPropertyValue(CSSPropertyWebkitTransform, Animatab
leDouble::create(10.0).get()); | 225 keyframeBadMultipleOp->setPropertyValue(CSSPropertyTransform, AnimatableDoub
le::create(10.0).get()); |
| 226 EXPECT_FALSE(isCandidateHelperForSingleKeyframe(keyframeBadMultipleOp.get())
); | 226 EXPECT_FALSE(isCandidateHelperForSingleKeyframe(keyframeBadMultipleOp.get())
); |
| 227 | 227 |
| 228 RefPtrWillBeRawPtr<Keyframe> keyframeBadMultipleID = createDefaultKeyframe(C
SSPropertyColor, AnimationEffect::CompositeReplace); | 228 RefPtrWillBeRawPtr<Keyframe> keyframeBadMultipleID = createDefaultKeyframe(C
SSPropertyColor, AnimationEffect::CompositeReplace); |
| 229 keyframeBadMultipleID->setPropertyValue(CSSPropertyOpacity, AnimatableDouble
::create(10.0).get()); | 229 keyframeBadMultipleID->setPropertyValue(CSSPropertyOpacity, AnimatableDouble
::create(10.0).get()); |
| 230 EXPECT_FALSE(isCandidateHelperForSingleKeyframe(keyframeBadMultipleID.get())
); | 230 EXPECT_FALSE(isCandidateHelperForSingleKeyframe(keyframeBadMultipleID.get())
); |
| 231 } | 231 } |
| 232 | 232 |
| 233 TEST_F(AnimationCompositorAnimationsTest, isNotCandidateForCompositorAnimationTr
ansformDependsOnBoxSize) | 233 TEST_F(AnimationCompositorAnimationsTest, isNotCandidateForCompositorAnimationTr
ansformDependsOnBoxSize) |
| 234 { | 234 { |
| 235 TransformOperations ops; | 235 TransformOperations ops; |
| 236 ops.operations().append(TranslateTransformOperation::create(Length(2, WebCor
e::Fixed), Length(2, WebCore::Fixed), TransformOperation::TranslateX)); | 236 ops.operations().append(TranslateTransformOperation::create(Length(2, WebCor
e::Fixed), Length(2, WebCore::Fixed), TransformOperation::TranslateX)); |
| 237 RefPtrWillBeRawPtr<Keyframe> goodKeyframe = createReplaceOpKeyframe(CSSPrope
rtyWebkitTransform, AnimatableTransform::create(ops).get()); | 237 RefPtrWillBeRawPtr<Keyframe> goodKeyframe = createReplaceOpKeyframe(CSSPrope
rtyTransform, AnimatableTransform::create(ops).get()); |
| 238 EXPECT_TRUE(isCandidateHelperForSingleKeyframe(goodKeyframe.get())); | 238 EXPECT_TRUE(isCandidateHelperForSingleKeyframe(goodKeyframe.get())); |
| 239 | 239 |
| 240 ops.operations().append(TranslateTransformOperation::create(Length(50, WebCo
re::Percent), Length(2, WebCore::Fixed), TransformOperation::TranslateX)); | 240 ops.operations().append(TranslateTransformOperation::create(Length(50, WebCo
re::Percent), Length(2, WebCore::Fixed), TransformOperation::TranslateX)); |
| 241 RefPtrWillBeRawPtr<Keyframe> badKeyframe = createReplaceOpKeyframe(CSSProper
tyWebkitTransform, AnimatableTransform::create(ops).get()); | 241 RefPtrWillBeRawPtr<Keyframe> badKeyframe = createReplaceOpKeyframe(CSSProper
tyTransform, AnimatableTransform::create(ops).get()); |
| 242 EXPECT_FALSE(isCandidateHelperForSingleKeyframe(badKeyframe.get())); | 242 EXPECT_FALSE(isCandidateHelperForSingleKeyframe(badKeyframe.get())); |
| 243 | 243 |
| 244 TransformOperations ops2; | 244 TransformOperations ops2; |
| 245 Length calcLength = Length(100, WebCore::Percent).blend(Length(100, WebCore:
:Fixed), 0.5, WebCore::ValueRangeAll); | 245 Length calcLength = Length(100, WebCore::Percent).blend(Length(100, WebCore:
:Fixed), 0.5, WebCore::ValueRangeAll); |
| 246 ops2.operations().append(TranslateTransformOperation::create(calcLength, Len
gth(0, WebCore::Fixed), TransformOperation::TranslateX)); | 246 ops2.operations().append(TranslateTransformOperation::create(calcLength, Len
gth(0, WebCore::Fixed), TransformOperation::TranslateX)); |
| 247 RefPtrWillBeRawPtr<Keyframe> badKeyframe2 = createReplaceOpKeyframe(CSSPrope
rtyWebkitTransform, AnimatableTransform::create(ops2).get()); | 247 RefPtrWillBeRawPtr<Keyframe> badKeyframe2 = createReplaceOpKeyframe(CSSPrope
rtyTransform, AnimatableTransform::create(ops2).get()); |
| 248 EXPECT_FALSE(isCandidateHelperForSingleKeyframe(badKeyframe2.get())); | 248 EXPECT_FALSE(isCandidateHelperForSingleKeyframe(badKeyframe2.get())); |
| 249 } | 249 } |
| 250 | 250 |
| 251 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorKey
frameEffectModelMultipleFramesOkay) | 251 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorKey
frameEffectModelMultipleFramesOkay) |
| 252 { | 252 { |
| 253 KeyframeEffectModel::KeyframeVector framesSame; | 253 KeyframeEffectModel::KeyframeVector framesSame; |
| 254 framesSame.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect:
:CompositeReplace, 0.0).get()); | 254 framesSame.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect:
:CompositeReplace, 0.0).get()); |
| 255 framesSame.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect:
:CompositeReplace, 1.0).get()); | 255 framesSame.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect:
:CompositeReplace, 1.0).get()); |
| 256 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *KeyframeEffectMod
el::create(framesSame).get())); | 256 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *KeyframeEffectMod
el::create(framesSame).get())); |
| 257 | 257 |
| 258 KeyframeEffectModel::KeyframeVector framesMixed; | 258 KeyframeEffectModel::KeyframeVector framesMixed; |
| 259 framesMixed.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect
::CompositeReplace, 0.0).get()); | 259 framesMixed.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect
::CompositeReplace, 0.0).get()); |
| 260 framesMixed.append(createDefaultKeyframe(CSSPropertyWebkitTransform, Animati
onEffect::CompositeReplace, 1.0).get()); | 260 framesMixed.append(createDefaultKeyframe(CSSPropertyTransform, AnimationEffe
ct::CompositeReplace, 1.0).get()); |
| 261 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *KeyframeEffectMod
el::create(framesMixed).get())); | 261 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *KeyframeEffectMod
el::create(framesMixed).get())); |
| 262 } | 262 } |
| 263 | 263 |
| 264 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorKey
frameEffectModel) | 264 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorKey
frameEffectModel) |
| 265 { | 265 { |
| 266 KeyframeEffectModel::KeyframeVector framesSame; | 266 KeyframeEffectModel::KeyframeVector framesSame; |
| 267 framesSame.append(createDefaultKeyframe(CSSPropertyColor, AnimationEffect::C
ompositeReplace, 0.0).get()); | 267 framesSame.append(createDefaultKeyframe(CSSPropertyColor, AnimationEffect::C
ompositeReplace, 0.0).get()); |
| 268 framesSame.append(createDefaultKeyframe(CSSPropertyColor, AnimationEffect::C
ompositeReplace, 1.0).get()); | 268 framesSame.append(createDefaultKeyframe(CSSPropertyColor, AnimationEffect::C
ompositeReplace, 1.0).get()); |
| 269 EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *KeyframeEffectMo
del::create(framesSame).get())); | 269 EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *KeyframeEffectMo
del::create(framesSame).get())); |
| 270 | 270 |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 // Go! | 900 // Go! |
| 901 setCompositorForTesting(mockCompositor); | 901 setCompositorForTesting(mockCompositor); |
| 902 Vector<OwnPtr<blink::WebAnimation> > result; | 902 Vector<OwnPtr<blink::WebAnimation> > result; |
| 903 getAnimationOnCompositor(m_timing, *effect.get(), result); | 903 getAnimationOnCompositor(m_timing, *effect.get(), result); |
| 904 EXPECT_EQ(1U, result.size()); | 904 EXPECT_EQ(1U, result.size()); |
| 905 result[0].clear(); | 905 result[0].clear(); |
| 906 } | 906 } |
| 907 | 907 |
| 908 | 908 |
| 909 } // namespace WebCore | 909 } // namespace WebCore |
| OLD | NEW |