Home | History | Annotate | Download | only in interpolation
      1 // Copyright 2014 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 Interpolation_h
      6 #define Interpolation_h
      7 
      8 #include "core/animation/InterpolableValue.h"
      9 #include "platform/heap/Handle.h"
     10 
     11 namespace WebCore {
     12 
     13 class Interpolation : public RefCountedWillBeGarbageCollected<Interpolation> {
     14     DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(Interpolation);
     15 public:
     16     static PassRefPtrWillBeRawPtr<Interpolation> create(PassOwnPtrWillBeRawPtr<InterpolableValue> start, PassOwnPtrWillBeRawPtr<InterpolableValue> end)
     17     {
     18         return adoptRefWillBeNoop(new Interpolation(start, end));
     19     }
     20 
     21     void interpolate(int iteration, double fraction) const;
     22 
     23     virtual bool isStyleInterpolation() const { return false; }
     24     virtual bool isLegacyStyleInterpolation() const { return false; }
     25 
     26     virtual void trace(Visitor*);
     27 
     28 protected:
     29     const OwnPtrWillBeMember<InterpolableValue> m_start;
     30     const OwnPtrWillBeMember<InterpolableValue> m_end;
     31 
     32     mutable double m_cachedFraction;
     33     mutable int m_cachedIteration;
     34     mutable OwnPtrWillBeMember<InterpolableValue> m_cachedValue;
     35 
     36     Interpolation(PassOwnPtrWillBeRawPtr<InterpolableValue> start, PassOwnPtrWillBeRawPtr<InterpolableValue> end);
     37 
     38 private:
     39     InterpolableValue* getCachedValueForTesting() const { return m_cachedValue.get(); }
     40 
     41     friend class AnimationInterpolableValueTest;
     42     friend class AnimationInterpolationEffectTest;
     43 };
     44 
     45 }
     46 
     47 #endif
     48