| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 namespace WebCore { | 55 namespace WebCore { |
| 56 | 56 |
| 57 using ::testing::CloneToPassOwnPtr; | 57 using ::testing::CloneToPassOwnPtr; |
| 58 using ::testing::ExpectationSet; | 58 using ::testing::ExpectationSet; |
| 59 using ::testing::Ref; | 59 using ::testing::Ref; |
| 60 using ::testing::Return; | 60 using ::testing::Return; |
| 61 using ::testing::_; | 61 using ::testing::_; |
| 62 | 62 |
| 63 class AnimationCompositorAnimationsTest : public AnimationCompositorAnimationsTe
stBase { | 63 class AnimationCompositorAnimationsTest : public AnimationCompositorAnimationsTe
stBase { |
| 64 | |
| 65 protected: | 64 protected: |
| 66 RefPtr<TimingFunction> m_linearTimingFunction; | 65 RefPtr<TimingFunction> m_linearTimingFunction; |
| 67 RefPtr<TimingFunction> m_cubicEaseTimingFunction; | 66 RefPtr<TimingFunction> m_cubicEaseTimingFunction; |
| 68 RefPtr<TimingFunction> m_cubicCustomTimingFunction; | 67 RefPtr<TimingFunction> m_cubicCustomTimingFunction; |
| 69 RefPtr<TimingFunction> m_stepTimingFunction; | 68 RefPtr<TimingFunction> m_stepTimingFunction; |
| 70 | 69 |
| 71 Timing m_timing; | 70 Timing m_timing; |
| 72 CompositorAnimationsImpl::CompositorTiming m_compositorTiming; | 71 CompositorAnimationsImpl::CompositorTiming m_compositorTiming; |
| 73 KeyframeEffectModel::KeyframeVector m_keyframeVector2; | 72 OwnPtrWillBePersistent<KeyframeEffectModel::KeyframeVector> m_keyframeVector
2; |
| 74 RefPtrWillBePersistent<KeyframeEffectModel> m_keyframeAnimationEffect2; | 73 RefPtrWillBePersistent<KeyframeEffectModel> m_keyframeAnimationEffect2; |
| 75 KeyframeEffectModel::KeyframeVector m_keyframeVector5; | 74 OwnPtrWillBePersistent<KeyframeEffectModel::KeyframeVector> m_keyframeVector
5; |
| 76 RefPtrWillBePersistent<KeyframeEffectModel> m_keyframeAnimationEffect5; | 75 RefPtrWillBePersistent<KeyframeEffectModel> m_keyframeAnimationEffect5; |
| 77 | 76 |
| 78 virtual void SetUp() | 77 virtual void SetUp() |
| 79 { | 78 { |
| 80 AnimationCompositorAnimationsTestBase::SetUp(); | 79 AnimationCompositorAnimationsTestBase::SetUp(); |
| 81 | 80 |
| 82 m_linearTimingFunction = LinearTimingFunction::create(); | 81 m_linearTimingFunction = LinearTimingFunction::create(); |
| 83 m_cubicEaseTimingFunction = CubicBezierTimingFunction::preset(CubicBezie
rTimingFunction::Ease); | 82 m_cubicEaseTimingFunction = CubicBezierTimingFunction::preset(CubicBezie
rTimingFunction::Ease); |
| 84 m_cubicCustomTimingFunction = CubicBezierTimingFunction::create(1, 2, 3,
4); | 83 m_cubicCustomTimingFunction = CubicBezierTimingFunction::create(1, 2, 3,
4); |
| 85 m_stepTimingFunction = StepsTimingFunction::create(1, StepsTimingFunctio
n::StepAtEnd); | 84 m_stepTimingFunction = StepsTimingFunction::create(1, StepsTimingFunctio
n::StepAtEnd); |
| 86 | 85 |
| 87 m_timing = createCompositableTiming(); | 86 m_timing = createCompositableTiming(); |
| 88 m_compositorTiming = CompositorAnimationsImpl::CompositorTiming(); | 87 m_compositorTiming = CompositorAnimationsImpl::CompositorTiming(); |
| 89 // Make sure the CompositableTiming is really compositable, otherwise | 88 // Make sure the CompositableTiming is really compositable, otherwise |
| 90 // most other tests will fail. | 89 // most other tests will fail. |
| 91 ASSERT(convertTimingForCompositor(m_timing, m_compositorTiming)); | 90 ASSERT(convertTimingForCompositor(m_timing, m_compositorTiming)); |
| 92 | 91 |
| 93 m_keyframeVector2 = createCompositableFloatKeyframeVector(2); | 92 m_keyframeVector2 = createCompositableFloatKeyframeVector(2); |
| 94 m_keyframeAnimationEffect2 = KeyframeEffectModel::create(m_keyframeVecto
r2); | 93 m_keyframeAnimationEffect2 = KeyframeEffectModel::create(*m_keyframeVect
or2.get()); |
| 95 | 94 |
| 96 m_keyframeVector5 = createCompositableFloatKeyframeVector(5); | 95 m_keyframeVector5 = createCompositableFloatKeyframeVector(5); |
| 97 m_keyframeAnimationEffect5 = KeyframeEffectModel::create(m_keyframeVecto
r5); | 96 m_keyframeAnimationEffect5 = KeyframeEffectModel::create(*m_keyframeVect
or5.get()); |
| 98 } | 97 } |
| 99 | 98 |
| 100 public: | 99 public: |
| 101 | 100 |
| 102 bool convertTimingForCompositor(const Timing& t, CompositorAnimationsImpl::C
ompositorTiming& out) | 101 bool convertTimingForCompositor(const Timing& t, CompositorAnimationsImpl::C
ompositorTiming& out) |
| 103 { | 102 { |
| 104 return CompositorAnimationsImpl::convertTimingForCompositor(t, out); | 103 return CompositorAnimationsImpl::convertTimingForCompositor(t, out); |
| 105 } | 104 } |
| 106 bool isCandidateForAnimationOnCompositor(const Timing& timing, const Animati
onEffect& effect) | 105 bool isCandidateForAnimationOnCompositor(const Timing& timing, const Animati
onEffect& effect) |
| 107 { | 106 { |
| 108 return CompositorAnimations::instance()->isCandidateForAnimationOnCompos
itor(timing, effect); | 107 return CompositorAnimations::instance()->isCandidateForAnimationOnCompos
itor(timing, effect); |
| 109 } | 108 } |
| 110 void getAnimationOnCompositor(Timing& timing, KeyframeEffectModel& effect, V
ector<OwnPtr<blink::WebAnimation> >& animations) | 109 void getAnimationOnCompositor(Timing& timing, KeyframeEffectModel& effect, V
ector<OwnPtr<blink::WebAnimation> >& animations) |
| 111 { | 110 { |
| 112 return CompositorAnimationsImpl::getAnimationOnCompositor(timing, effect
, animations); | 111 return CompositorAnimationsImpl::getAnimationOnCompositor(timing, effect
, animations); |
| 113 } | 112 } |
| 114 | 113 |
| 115 bool isCandidateHelperForSingleKeyframe(Keyframe* frame) | 114 bool isCandidateHelperForSingleKeyframe(Keyframe* frame) |
| 116 { | 115 { |
| 117 EXPECT_EQ(frame->offset(), 0); | 116 EXPECT_EQ(frame->offset(), 0); |
| 118 KeyframeEffectModel::KeyframeVector frames; | 117 KeyframeEffectModel::KeyframeVector frames; |
| 119 frames.append(frame); | 118 frames.append(frame); |
| 120 EXPECT_EQ(m_keyframeVector2[1]->offset(), 1.0); | 119 EXPECT_EQ((*m_keyframeVector2)[1]->offset(), 1.0); |
| 121 frames.append(m_keyframeVector2[1]); | 120 frames.append((*m_keyframeVector2)[1]); |
| 122 return isCandidateForAnimationOnCompositor(m_timing, *KeyframeEffectMode
l::create(frames).get()); | 121 return isCandidateForAnimationOnCompositor(m_timing, *KeyframeEffectMode
l::create(frames).get()); |
| 123 } | 122 } |
| 124 | 123 |
| 125 // ------------------------------------------------------------------- | 124 // ------------------------------------------------------------------- |
| 126 | 125 |
| 127 Timing createCompositableTiming() | 126 Timing createCompositableTiming() |
| 128 { | 127 { |
| 129 Timing timing; | 128 Timing timing; |
| 130 timing.startDelay = 0; | 129 timing.startDelay = 0; |
| 131 timing.fillMode = Timing::FillModeNone; | 130 timing.fillMode = Timing::FillModeNone; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 154 if (id == CSSPropertyWebkitTransform) | 153 if (id == CSSPropertyWebkitTransform) |
| 155 value = AnimatableTransform::create(TransformOperations()); | 154 value = AnimatableTransform::create(TransformOperations()); |
| 156 else | 155 else |
| 157 value = AnimatableDouble::create(10.0); | 156 value = AnimatableDouble::create(10.0); |
| 158 | 157 |
| 159 RefPtrWillBeRawPtr<Keyframe> keyframe = createReplaceOpKeyframe(id, valu
e.get(), offset); | 158 RefPtrWillBeRawPtr<Keyframe> keyframe = createReplaceOpKeyframe(id, valu
e.get(), offset); |
| 160 keyframe->setComposite(op); | 159 keyframe->setComposite(op); |
| 161 return keyframe; | 160 return keyframe; |
| 162 } | 161 } |
| 163 | 162 |
| 164 KeyframeEffectModel::KeyframeVector createCompositableFloatKeyframeVector(si
ze_t n) | 163 PassOwnPtrWillBeRawPtr<KeyframeEffectModel::KeyframeVector> createCompositab
leFloatKeyframeVector(size_t n) |
| 165 { | 164 { |
| 166 Vector<double> values; | 165 Vector<double> values; |
| 167 for (size_t i = 0; i < n; i++) { | 166 for (size_t i = 0; i < n; i++) { |
| 168 values.append(static_cast<double>(i)); | 167 values.append(static_cast<double>(i)); |
| 169 } | 168 } |
| 170 return createCompositableFloatKeyframeVector(values); | 169 return createCompositableFloatKeyframeVector(values); |
| 171 } | 170 } |
| 172 | 171 |
| 173 KeyframeEffectModel::KeyframeVector createCompositableFloatKeyframeVector(Ve
ctor<double>& values) | 172 PassOwnPtrWillBeRawPtr<KeyframeEffectModel::KeyframeVector> createCompositab
leFloatKeyframeVector(Vector<double>& values) |
| 174 { | 173 { |
| 175 KeyframeEffectModel::KeyframeVector frames; | 174 OwnPtrWillBeRawPtr<KeyframeEffectModel::KeyframeVector> frames = adoptPt
rWillBeNoop(new KeyframeEffectModel::KeyframeVector); |
| 176 for (size_t i = 0; i < values.size(); i++) { | 175 for (size_t i = 0; i < values.size(); i++) { |
| 177 double offset = 1.0 / (values.size() - 1) * i; | 176 double offset = 1.0 / (values.size() - 1) * i; |
| 178 RefPtr<AnimatableDouble> value = AnimatableDouble::create(values[i])
; | 177 RefPtr<AnimatableDouble> value = AnimatableDouble::create(values[i])
; |
| 179 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, value.get(
), offset).get()); | 178 frames->append(createReplaceOpKeyframe(CSSPropertyOpacity, value.get
(), offset).get()); |
| 180 } | 179 } |
| 181 return frames; | 180 return frames.release(); |
| 182 } | 181 } |
| 183 | 182 |
| 184 PassRefPtrWillBeRawPtr<KeyframeEffectModel> createKeyframeEffectModel(PassRe
fPtrWillBeRawPtr<Keyframe> prpFrom, PassRefPtrWillBeRawPtr<Keyframe> prpTo, Pass
RefPtrWillBeRawPtr<Keyframe> prpC = nullptr, PassRefPtrWillBeRawPtr<Keyframe> pr
pD = nullptr) | 183 PassRefPtrWillBeRawPtr<KeyframeEffectModel> createKeyframeEffectModel(PassRe
fPtrWillBeRawPtr<Keyframe> prpFrom, PassRefPtrWillBeRawPtr<Keyframe> prpTo, Pass
RefPtrWillBeRawPtr<Keyframe> prpC = nullptr, PassRefPtrWillBeRawPtr<Keyframe> pr
pD = nullptr) |
| 185 { | 184 { |
| 186 RefPtrWillBeRawPtr<Keyframe> from = prpFrom; | 185 RefPtrWillBeRawPtr<Keyframe> from = prpFrom; |
| 187 RefPtrWillBeRawPtr<Keyframe> to = prpTo; | 186 RefPtrWillBeRawPtr<Keyframe> to = prpTo; |
| 188 RefPtrWillBeRawPtr<Keyframe> c = prpC; | 187 RefPtrWillBeRawPtr<Keyframe> c = prpC; |
| 189 RefPtrWillBeRawPtr<Keyframe> d = prpD; | 188 RefPtrWillBeRawPtr<Keyframe> d = prpD; |
| 190 | 189 |
| 191 EXPECT_EQ(from->offset(), 0); | 190 EXPECT_EQ(from->offset(), 0); |
| (...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 // Go! | 1034 // Go! |
| 1036 setCompositorForTesting(mockCompositor); | 1035 setCompositorForTesting(mockCompositor); |
| 1037 Vector<OwnPtr<blink::WebAnimation> > result; | 1036 Vector<OwnPtr<blink::WebAnimation> > result; |
| 1038 getAnimationOnCompositor(m_timing, *effect.get(), result); | 1037 getAnimationOnCompositor(m_timing, *effect.get(), result); |
| 1039 EXPECT_EQ(1U, result.size()); | 1038 EXPECT_EQ(1U, result.size()); |
| 1040 result[0].clear(); | 1039 result[0].clear(); |
| 1041 } | 1040 } |
| 1042 | 1041 |
| 1043 | 1042 |
| 1044 } // namespace WebCore | 1043 } // namespace WebCore |
| OLD | NEW |