Home | History | Annotate | Download | only in animation
      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 InterpolationEffect_h
      6 #define InterpolationEffect_h
      7 
      8 #include "core/animation/Interpolation.h"
      9 #include "platform/animation/TimingFunction.h"
     10 #include "wtf/PassOwnPtr.h"
     11 #include "wtf/RefCounted.h"
     12 
     13 namespace blink {
     14 
     15 class InterpolationEffect : public RefCountedWillBeGarbageCollected<InterpolationEffect> {
     16 public:
     17     static PassRefPtrWillBeRawPtr<InterpolationEffect> create() { return adoptRefWillBeNoop(new InterpolationEffect()); }
     18 
     19     PassOwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > getActiveInterpolations(double fraction, double iterationDuration) const;
     20 
     21     void addInterpolation(PassRefPtrWillBeRawPtr<Interpolation> interpolation, PassRefPtr<TimingFunction> easing, double start, double end, double applyFrom, double applyTo)
     22     {
     23         m_interpolations.append(InterpolationRecord::create(interpolation, easing, start, end, applyFrom, applyTo));
     24     }
     25 
     26     void trace(Visitor*);
     27 
     28 private:
     29     InterpolationEffect()
     30     {
     31     }
     32 
     33     class InterpolationRecord : public NoBaseWillBeGarbageCollectedFinalized<InterpolationRecord> {
     34     public:
     35         RefPtrWillBeMember<Interpolation> m_interpolation;
     36         RefPtr<TimingFunction> m_easing;
     37         double m_start;
     38         double m_end;
     39         double m_applyFrom;
     40         double m_applyTo;
     41 
     42         static PassOwnPtrWillBeRawPtr<InterpolationRecord> create(PassRefPtrWillBeRawPtr<Interpolation> interpolation, PassRefPtr<TimingFunction> easing, double start, double end, double applyFrom, double applyTo)
     43         {
     44             return adoptPtrWillBeNoop(new InterpolationRecord(interpolation, easing, start, end, applyFrom, applyTo));
     45         }
     46 
     47         void trace(Visitor*);
     48 
     49     private:
     50         InterpolationRecord(PassRefPtrWillBeRawPtr<Interpolation> interpolation, PassRefPtr<TimingFunction> easing, double start, double end, double applyFrom, double applyTo)
     51             : m_interpolation(interpolation)
     52             , m_easing(easing)
     53             , m_start(start)
     54             , m_end(end)
     55             , m_applyFrom(applyFrom)
     56             , m_applyTo(applyTo)
     57         {
     58         }
     59     };
     60 
     61     WillBeHeapVector<OwnPtrWillBeMember<InterpolationRecord> > m_interpolations;
     62 };
     63 
     64 }
     65 
     66 #endif
     67