OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef PairwiseInterpolation_h |
| 6 #define PairwiseInterpolation_h |
| 7 |
| 8 #include "core/animation/PrimitiveInterpolation.h" |
| 9 #include "core/animation/StackableInterpolation.h" |
| 10 #include "core/animation/TypedInterpolationValue.h" |
| 11 |
| 12 namespace blink { |
| 13 |
| 14 class PairwiseInterpolation : public StackableInterpolation { |
| 15 public: |
| 16 static PassRefPtr<PairwiseInterpolation> maybeCreate(const InterpolationType
& type, InterpolationValue&& start, InterpolationValue&& end) |
| 17 { |
| 18 PairwiseInterpolationValue merge = type.maybeMergeSingles(start.clone(),
end.clone()); |
| 19 if (!merge) |
| 20 return nullptr; |
| 21 return adoptRef(new PairwiseInterpolation(type, std::move(start), std::m
ove(end), std::move(merge))); |
| 22 } |
| 23 |
| 24 bool isPairwiseInterpolation() const final { return true; } |
| 25 |
| 26 PropertyHandle getProperty() const final |
| 27 { |
| 28 return m_property; |
| 29 } |
| 30 |
| 31 protected: |
| 32 PairwiseInterpolation(const InterpolationType& type, InterpolationValue&& st
art, InterpolationValue&& end, PairwiseInterpolationValue&& merge) |
| 33 : m_property(type.getProperty()) |
| 34 , m_start(TypedInterpolationValue::create(type, std::move(start))) |
| 35 , m_end(TypedInterpolationValue::create(type, std::move(end))) |
| 36 , m_pairwisePrimitiveInterpolation(PairwisePrimitiveInterpolation::creat
e(type, std::move(merge))) |
| 37 , m_currentValue(m_pairwisePrimitiveInterpolation->initialValue()) |
| 38 { } |
| 39 |
| 40 void interpolateImpl() final |
| 41 { |
| 42 if (m_currentFraction == 0) |
| 43 m_currentValue->mutableValue() = m_start->value().clone(); |
| 44 else if (m_currentFraction == 1) |
| 45 m_currentValue->mutableValue() = m_end->value().clone(); |
| 46 else |
| 47 m_pairwisePrimitiveInterpolation->interpolateValue(m_currentFraction
, m_currentValue); |
| 48 } |
| 49 |
| 50 std::unique_ptr<TypedInterpolationValue> maybeConvertUnderlyingValue(const I
nterpolationEnvironment&) const final |
| 51 { |
| 52 NOTREACHED(); |
| 53 return nullptr; |
| 54 } |
| 55 |
| 56 const TypedInterpolationValue* ensureValidInterpolation(const InterpolationE
nvironment&, const UnderlyingValueOwner&) const final |
| 57 { |
| 58 return m_currentValue.get(); |
| 59 } |
| 60 |
| 61 double underlyingFraction() const final |
| 62 { |
| 63 return 0; |
| 64 } |
| 65 |
| 66 const PropertyHandle m_property; |
| 67 const std::unique_ptr<TypedInterpolationValue> m_start; |
| 68 const std::unique_ptr<TypedInterpolationValue> m_end; |
| 69 const std::unique_ptr<PairwisePrimitiveInterpolation> m_pairwisePrimitiveInt
erpolation; |
| 70 std::unique_ptr<TypedInterpolationValue> m_currentValue; |
| 71 }; |
| 72 |
| 73 } // namespace blink |
| 74 |
| 75 #endif // PairwiseInterpolation_h |
OLD | NEW |