Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: Source/core/animation/Interpolation.h

Issue 194673002: Web Animations: Refactor KeyframeEffectModel to work via an InterpolationEffect. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@interpolationWrap
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 Interpolation_h 5 #ifndef Interpolation_h
6 #define Interpolation_h 6 #define Interpolation_h
7 7
8 #include "core/animation/InterpolableValue.h" 8 #include "core/animation/InterpolableValue.h"
9 #include "core/css/resolver/StyleResolverState.h"
10 #include "wtf/RefCounted.h" 9 #include "wtf/RefCounted.h"
11 10
12 namespace WebCore { 11 namespace WebCore {
13 12
13 class StyleResolverState;
14
14 class Interpolation : public RefCounted<Interpolation> { 15 class Interpolation : public RefCounted<Interpolation> {
15 public: 16 public:
16 static PassRefPtr<Interpolation> create(PassOwnPtr<InterpolableValue> start, PassOwnPtr<InterpolableValue> end) 17 static PassRefPtr<Interpolation> create(PassOwnPtr<InterpolableValue> start, PassOwnPtr<InterpolableValue> end)
17 { 18 {
18 return adoptRef(new Interpolation(start, end)); 19 return adoptRef(new Interpolation(start, end));
19 } 20 }
20 21
21 void interpolate(int iteration, double fraction) const; 22 void interpolate(int iteration, double fraction) const;
22 23
24 virtual bool isStyleInterpolation() const { return false; }
25 virtual bool isLegacyStyleInterpolation() const { return false; }
26
27 virtual ~Interpolation()
28 { }
29
23 protected: 30 protected:
24 const OwnPtr<InterpolableValue> m_start; 31 const OwnPtr<InterpolableValue> m_start;
25 const OwnPtr<InterpolableValue> m_end; 32 const OwnPtr<InterpolableValue> m_end;
26 33
27 mutable double m_cachedFraction; 34 mutable double m_cachedFraction;
28 mutable int m_cachedIteration; 35 mutable int m_cachedIteration;
29 mutable OwnPtr<InterpolableValue> m_cachedValue; 36 mutable OwnPtr<InterpolableValue> m_cachedValue;
30 37
31 Interpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<InterpolableVa lue> end); 38 Interpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<InterpolableVa lue> end);
32 39
33 private: 40 private:
34 InterpolableValue* getCachedValueForTesting() const { return m_cachedValue.g et(); } 41 InterpolableValue* getCachedValueForTesting() const { return m_cachedValue.g et(); }
35 42
36 friend class AnimationInterpolableValueTest; 43 friend class AnimationInterpolableValueTest;
37 friend class AnimationInterpolationEffectTest; 44 friend class AnimationInterpolationEffectTest;
45
38 }; 46 };
39 47
40 class StyleInterpolation : public Interpolation { 48 class StyleInterpolation : public Interpolation {
41 public: 49 public:
42 // 1) convert m_cachedValue into an X 50 // 1) convert m_cachedValue into an X
43 // 2) shove X into StyleResolverState 51 // 2) shove X into StyleResolverState
44 // X can be: 52 // X can be:
45 // (1) a CSSValue (and applied via StyleBuilder::applyProperty) 53 // (1) a CSSValue (and applied via StyleBuilder::applyProperty)
46 // (2) an AnimatableValue (and applied via // AnimatedStyleBuilder::applyPro perty) 54 // (2) an AnimatableValue (and applied via // AnimatedStyleBuilder::applyPro perty)
47 // (3) a custom value that is inserted directly into the StyleResolverState. 55 // (3) a custom value that is inserted directly into the StyleResolverState.
48 virtual void apply(StyleResolverState&) = 0; 56 virtual void apply(StyleResolverState&) const = 0;
57
58 virtual bool isStyleInterpolation() const OVERRIDE FINAL { return true; }
59
60 CSSPropertyID id() const { return m_id; }
49 61
50 protected: 62 protected:
51 CSSPropertyID m_id; 63 CSSPropertyID m_id;
52 64
53 StyleInterpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<Interpola bleValue> end, CSSPropertyID id) 65 StyleInterpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<Interpola bleValue> end, CSSPropertyID id)
54 : Interpolation(start, end) 66 : Interpolation(start, end)
55 , m_id(id) 67 , m_id(id)
56 { } 68 { }
57 }; 69 };
58 70
71 class LegacyStyleInterpolation : public StyleInterpolation {
72 public:
73 static PassRefPtr<LegacyStyleInterpolation> create(PassRefPtr<AnimatableValu e> start, PassRefPtr<AnimatableValue> end, CSSPropertyID id)
74 {
75 return adoptRef(new LegacyStyleInterpolation(InterpolableAnimatableValue ::create(start), InterpolableAnimatableValue::create(end), id));
76 }
77
78 virtual void apply(StyleResolverState&) const;
79
80 virtual bool isLegacyStyleInterpolation() const OVERRIDE FINAL { return true ; }
81 AnimatableValue* currentValue() const
82 {
83 InterpolableAnimatableValue *value = static_cast<InterpolableAnimatableV alue *>(m_cachedValue.get());
84 return value->value();
85 }
86
87 private:
88 LegacyStyleInterpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<Int erpolableValue> end, CSSPropertyID id)
89 : StyleInterpolation(start, end, id)
90 { }
91 };
92
93 DEFINE_TYPE_CASTS(StyleInterpolation, Interpolation, value, value->isStyleInterp olation(), value.isStyleInterpolation());
94 DEFINE_TYPE_CASTS(LegacyStyleInterpolation, Interpolation, value, value->isLegac yStyleInterpolation(), value.isLegacyStyleInterpolation());
95
59 } 96 }
60 #endif 97 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698