| OLD | NEW | 
|    1 // Copyright 2015 The Chromium Authors. All rights reserved. |    1 // Copyright 2015 The Chromium Authors. All rights reserved. | 
|    2 // Use of this source code is governed by a BSD-style license that can be |    2 // Use of this source code is governed by a BSD-style license that can be | 
|    3 // found in the LICENSE file. |    3 // found in the LICENSE file. | 
|    4  |    4  | 
|    5 #ifndef PrimitiveInterpolation_h |    5 #ifndef PrimitiveInterpolation_h | 
|    6 #define PrimitiveInterpolation_h |    6 #define PrimitiveInterpolation_h | 
|    7  |    7  | 
 |    8 #include "core/animation/PairwiseInterpolationValue.h" | 
|    8 #include "core/animation/TypedInterpolationValue.h" |    9 #include "core/animation/TypedInterpolationValue.h" | 
|    9 #include "platform/animation/AnimationUtilities.h" |   10 #include "platform/animation/AnimationUtilities.h" | 
|   10 #include "platform/heap/Handle.h" |   11 #include "platform/heap/Handle.h" | 
|   11 #include "wtf/PtrUtil.h" |   12 #include "wtf/PtrUtil.h" | 
|   12 #include "wtf/Vector.h" |   13 #include "wtf/Vector.h" | 
|   13 #include <cmath> |   14 #include <cmath> | 
|   14 #include <memory> |   15 #include <memory> | 
|   15  |   16  | 
|   16 namespace blink { |   17 namespace blink { | 
|   17  |   18  | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
|   31  |   32  | 
|   32 protected: |   33 protected: | 
|   33     PrimitiveInterpolation() { } |   34     PrimitiveInterpolation() { } | 
|   34 }; |   35 }; | 
|   35  |   36  | 
|   36 // Represents a pair of keyframes that are compatible for "smooth" interpolation
      eg. "0px" and "100px". |   37 // Represents a pair of keyframes that are compatible for "smooth" interpolation
      eg. "0px" and "100px". | 
|   37 class PairwisePrimitiveInterpolation : public PrimitiveInterpolation { |   38 class PairwisePrimitiveInterpolation : public PrimitiveInterpolation { | 
|   38 public: |   39 public: | 
|   39     ~PairwisePrimitiveInterpolation() override { } |   40     ~PairwisePrimitiveInterpolation() override { } | 
|   40  |   41  | 
|   41     static std::unique_ptr<PairwisePrimitiveInterpolation> create(const Interpol
     ationType& type, std::unique_ptr<InterpolableValue> start, std::unique_ptr<Inter
     polableValue> end, PassRefPtr<NonInterpolableValue> nonInterpolableValue) |   42     static std::unique_ptr<PairwisePrimitiveInterpolation> create(const Interpol
     ationType& type, PairwiseInterpolationValue&& pairwiseInterpolationValue) | 
|   42     { |   43     { | 
|   43         return wrapUnique(new PairwisePrimitiveInterpolation(type, std::move(sta
     rt), std::move(end), nonInterpolableValue)); |   44         return wrapUnique(new PairwisePrimitiveInterpolation(type, std::move(pai
     rwiseInterpolationValue))); | 
|   44     } |   45     } | 
|   45  |   46  | 
|   46     const InterpolationType& type() const { return m_type; } |   47     const InterpolationType& type() const { return m_type; } | 
|   47  |   48  | 
|   48     std::unique_ptr<TypedInterpolationValue> initialValue() const |   49     std::unique_ptr<TypedInterpolationValue> initialValue() const | 
|   49     { |   50     { | 
|   50         return TypedInterpolationValue::create(m_type, m_start->clone(), m_nonIn
     terpolableValue); |   51         return TypedInterpolationValue::create(m_type, InterpolationValue(m_pair
     wise.startInterpolableValue->clone(), m_pairwise.nonInterpolableValue)); | 
|   51     } |  | 
|   52  |  | 
|   53 private: |  | 
|   54     PairwisePrimitiveInterpolation(const InterpolationType& type, std::unique_pt
     r<InterpolableValue> start, std::unique_ptr<InterpolableValue> end, PassRefPtr<N
     onInterpolableValue> nonInterpolableValue) |  | 
|   55         : m_type(type) |  | 
|   56         , m_start(std::move(start)) |  | 
|   57         , m_end(std::move(end)) |  | 
|   58         , m_nonInterpolableValue(nonInterpolableValue) |  | 
|   59     { |  | 
|   60         ASSERT(m_start); |  | 
|   61         ASSERT(m_end); |  | 
|   62     } |   52     } | 
|   63  |   53  | 
|   64     void interpolateValue(double fraction, std::unique_ptr<TypedInterpolationVal
     ue>& result) const final |   54     void interpolateValue(double fraction, std::unique_ptr<TypedInterpolationVal
     ue>& result) const final | 
|   65     { |   55     { | 
|   66         ASSERT(result); |   56         DCHECK(result); | 
|   67         ASSERT(&result->type() == &m_type); |   57         DCHECK(&result->type() == &m_type); | 
|   68         ASSERT(result->getNonInterpolableValue() == m_nonInterpolableValue.get()
     ); |   58         DCHECK(result->getNonInterpolableValue() == m_pairwise.nonInterpolableVa
     lue.get()); | 
|   69         m_start->interpolate(*m_end, fraction, *result->mutableValue().interpola
     bleValue); |   59         m_pairwise.startInterpolableValue->interpolate( | 
 |   60             *m_pairwise.endInterpolableValue, fraction, *result->mutableValue().
     interpolableValue); | 
 |   61     } | 
 |   62  | 
 |   63 private: | 
 |   64     PairwisePrimitiveInterpolation(const InterpolationType& type, PairwiseInterp
     olationValue&& pairwiseInterpolationValue) | 
 |   65         : m_type(type) | 
 |   66         , m_pairwise(std::move(pairwiseInterpolationValue)) | 
 |   67     { | 
 |   68         DCHECK(m_pairwise); | 
|   70     } |   69     } | 
|   71  |   70  | 
|   72     double interpolateUnderlyingFraction(double start, double end, double fracti
     on) const final { return blend(start, end, fraction); } |   71     double interpolateUnderlyingFraction(double start, double end, double fracti
     on) const final { return blend(start, end, fraction); } | 
|   73  |   72  | 
|   74     const InterpolationType& m_type; |   73     const InterpolationType& m_type; | 
|   75     std::unique_ptr<InterpolableValue> m_start; |   74     PairwiseInterpolationValue m_pairwise; | 
|   76     std::unique_ptr<InterpolableValue> m_end; |  | 
|   77     RefPtr<NonInterpolableValue> m_nonInterpolableValue; |  | 
|   78 }; |   75 }; | 
|   79  |   76  | 
|   80 // Represents a pair of incompatible keyframes that fall back to 50% flip behavi
     our eg. "auto" and "0px". |   77 // Represents a pair of incompatible keyframes that fall back to 50% flip behavi
     our eg. "auto" and "0px". | 
|   81 class FlipPrimitiveInterpolation : public PrimitiveInterpolation { |   78 class FlipPrimitiveInterpolation : public PrimitiveInterpolation { | 
|   82 public: |   79 public: | 
|   83     ~FlipPrimitiveInterpolation() override { } |   80     ~FlipPrimitiveInterpolation() override { } | 
|   84  |   81  | 
|   85     static std::unique_ptr<FlipPrimitiveInterpolation> create(std::unique_ptr<Ty
     pedInterpolationValue> start, std::unique_ptr<TypedInterpolationValue> end) |   82     static std::unique_ptr<FlipPrimitiveInterpolation> create(std::unique_ptr<Ty
     pedInterpolationValue> start, std::unique_ptr<TypedInterpolationValue> end) | 
|   86     { |   83     { | 
|   87         return wrapUnique(new FlipPrimitiveInterpolation(std::move(start), std::
     move(end))); |   84         return wrapUnique(new FlipPrimitiveInterpolation(std::move(start), std::
     move(end))); | 
| (...skipping 21 matching lines...) Expand all  Loading... | 
|  109     bool isFlip() const final { return true; } |  106     bool isFlip() const final { return true; } | 
|  110  |  107  | 
|  111     std::unique_ptr<TypedInterpolationValue> m_start; |  108     std::unique_ptr<TypedInterpolationValue> m_start; | 
|  112     std::unique_ptr<TypedInterpolationValue> m_end; |  109     std::unique_ptr<TypedInterpolationValue> m_end; | 
|  113     mutable double m_lastFraction; |  110     mutable double m_lastFraction; | 
|  114 }; |  111 }; | 
|  115  |  112  | 
|  116 } // namespace blink |  113 } // namespace blink | 
|  117  |  114  | 
|  118 #endif // PrimitiveInterpolation_h |  115 #endif // PrimitiveInterpolation_h | 
| OLD | NEW |