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

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

Issue 1226293002: Fix virtual/override/final usage in Source/core/{animation,css,style}/. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 5 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 | Annotate | Revision Log
OLDNEW
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/InterpolationValue.h" 8 #include "core/animation/InterpolationValue.h"
9 #include "platform/heap/Handle.h" 9 #include "platform/heap/Handle.h"
10 #include "wtf/Vector.h" 10 #include "wtf/Vector.h"
(...skipping 10 matching lines...) Expand all
21 virtual ~PrimitiveInterpolation() { } 21 virtual ~PrimitiveInterpolation() { }
22 22
23 virtual void interpolate(double fraction, OwnPtrWillBeMember<InterpolationVa lue>& result) const = 0; 23 virtual void interpolate(double fraction, OwnPtrWillBeMember<InterpolationVa lue>& result) const = 0;
24 24
25 DEFINE_INLINE_VIRTUAL_TRACE() { } 25 DEFINE_INLINE_VIRTUAL_TRACE() { }
26 }; 26 };
27 27
28 // Represents a pair of keyframes that are compatible for "smooth" interpolation eg. "0px" and "100px". 28 // Represents a pair of keyframes that are compatible for "smooth" interpolation eg. "0px" and "100px".
29 class PairwisePrimitiveInterpolation : public PrimitiveInterpolation { 29 class PairwisePrimitiveInterpolation : public PrimitiveInterpolation {
30 public: 30 public:
31 virtual ~PairwisePrimitiveInterpolation() { } 31 ~PairwisePrimitiveInterpolation() override { }
32 32
33 static PassOwnPtrWillBeRawPtr<PairwisePrimitiveInterpolation> create(const I nterpolationType& type, PassOwnPtrWillBeRawPtr<InterpolableValue> start, PassOwn PtrWillBeRawPtr<InterpolableValue> end, PassRefPtrWillBeRawPtr<NonInterpolableVa lue> nonInterpolableValue) 33 static PassOwnPtrWillBeRawPtr<PairwisePrimitiveInterpolation> create(const I nterpolationType& type, PassOwnPtrWillBeRawPtr<InterpolableValue> start, PassOwn PtrWillBeRawPtr<InterpolableValue> end, PassRefPtrWillBeRawPtr<NonInterpolableVa lue> nonInterpolableValue)
34 { 34 {
35 return adoptPtrWillBeNoop(new PairwisePrimitiveInterpolation(type, start , end, nonInterpolableValue)); 35 return adoptPtrWillBeNoop(new PairwisePrimitiveInterpolation(type, start , end, nonInterpolableValue));
36 } 36 }
37 37
38 PassOwnPtrWillBeRawPtr<InterpolationValue> initialValue() const 38 PassOwnPtrWillBeRawPtr<InterpolationValue> initialValue() const
39 { 39 {
40 return InterpolationValue::create(m_type, m_start->clone(), m_nonInterpo lableValue); 40 return InterpolationValue::create(m_type, m_start->clone(), m_nonInterpo lableValue);
41 } 41 }
42 42
43 DEFINE_INLINE_VIRTUAL_TRACE() 43 DEFINE_INLINE_VIRTUAL_TRACE()
44 { 44 {
45 visitor->trace(m_start); 45 visitor->trace(m_start);
46 visitor->trace(m_end); 46 visitor->trace(m_end);
47 visitor->trace(m_nonInterpolableValue); 47 visitor->trace(m_nonInterpolableValue);
48 PrimitiveInterpolation::trace(visitor); 48 PrimitiveInterpolation::trace(visitor);
49 } 49 }
50 50
51 private: 51 private:
52 PairwisePrimitiveInterpolation(const InterpolationType& type, PassOwnPtrWill BeRawPtr<InterpolableValue> start, PassOwnPtrWillBeRawPtr<InterpolableValue> end , PassRefPtrWillBeRawPtr<NonInterpolableValue> nonInterpolableValue) 52 PairwisePrimitiveInterpolation(const InterpolationType& type, PassOwnPtrWill BeRawPtr<InterpolableValue> start, PassOwnPtrWillBeRawPtr<InterpolableValue> end , PassRefPtrWillBeRawPtr<NonInterpolableValue> nonInterpolableValue)
53 : m_type(type) 53 : m_type(type)
54 , m_start(start) 54 , m_start(start)
55 , m_end(end) 55 , m_end(end)
56 , m_nonInterpolableValue(nonInterpolableValue) 56 , m_nonInterpolableValue(nonInterpolableValue)
57 { } 57 { }
58 58
59 virtual void interpolate(double fraction, OwnPtrWillBeMember<InterpolationVa lue>& result) const override final 59 void interpolate(double fraction, OwnPtrWillBeMember<InterpolationValue>& re sult) const final
60 { 60 {
61 ASSERT(result); 61 ASSERT(result);
62 ASSERT(&result->type() == &m_type); 62 ASSERT(&result->type() == &m_type);
63 ASSERT(result->nonInterpolableValue() == m_nonInterpolableValue.get()); 63 ASSERT(result->nonInterpolableValue() == m_nonInterpolableValue.get());
64 m_start->interpolate(*m_end, fraction, result->interpolableValue()); 64 m_start->interpolate(*m_end, fraction, result->interpolableValue());
65 } 65 }
66 66
67 const InterpolationType& m_type; 67 const InterpolationType& m_type;
68 OwnPtrWillBeMember<InterpolableValue> m_start; 68 OwnPtrWillBeMember<InterpolableValue> m_start;
69 OwnPtrWillBeMember<InterpolableValue> m_end; 69 OwnPtrWillBeMember<InterpolableValue> m_end;
70 RefPtrWillBeMember<NonInterpolableValue> m_nonInterpolableValue; 70 RefPtrWillBeMember<NonInterpolableValue> m_nonInterpolableValue;
71 }; 71 };
72 72
73 // Represents a pair of incompatible keyframes that fall back to 50% flip behavi our eg. "auto" and "0px". 73 // Represents a pair of incompatible keyframes that fall back to 50% flip behavi our eg. "auto" and "0px".
74 class FlipPrimitiveInterpolation : public PrimitiveInterpolation { 74 class FlipPrimitiveInterpolation : public PrimitiveInterpolation {
75 public: 75 public:
76 virtual ~FlipPrimitiveInterpolation() { } 76 ~FlipPrimitiveInterpolation() override { }
77 77
78 static PassOwnPtrWillBeRawPtr<FlipPrimitiveInterpolation> create(PassOwnPtrW illBeRawPtr<InterpolationValue> start, PassOwnPtrWillBeRawPtr<InterpolationValue > end) 78 static PassOwnPtrWillBeRawPtr<FlipPrimitiveInterpolation> create(PassOwnPtrW illBeRawPtr<InterpolationValue> start, PassOwnPtrWillBeRawPtr<InterpolationValue > end)
79 { 79 {
80 return adoptPtrWillBeNoop(new FlipPrimitiveInterpolation(start, end)); 80 return adoptPtrWillBeNoop(new FlipPrimitiveInterpolation(start, end));
81 } 81 }
82 82
83 DEFINE_INLINE_VIRTUAL_TRACE() 83 DEFINE_INLINE_VIRTUAL_TRACE()
84 { 84 {
85 visitor->trace(m_start); 85 visitor->trace(m_start);
86 visitor->trace(m_end); 86 visitor->trace(m_end);
87 PrimitiveInterpolation::trace(visitor); 87 PrimitiveInterpolation::trace(visitor);
88 } 88 }
89 89
90 private: 90 private:
91 FlipPrimitiveInterpolation(PassOwnPtrWillBeRawPtr<InterpolationValue> start, PassOwnPtrWillBeRawPtr<InterpolationValue> end) 91 FlipPrimitiveInterpolation(PassOwnPtrWillBeRawPtr<InterpolationValue> start, PassOwnPtrWillBeRawPtr<InterpolationValue> end)
92 : m_start(start) 92 : m_start(start)
93 , m_end(end) 93 , m_end(end)
94 , m_lastFraction(std::numeric_limits<double>::quiet_NaN()) 94 , m_lastFraction(std::numeric_limits<double>::quiet_NaN())
95 { 95 {
96 ASSERT(m_start); 96 ASSERT(m_start);
97 ASSERT(m_end); 97 ASSERT(m_end);
98 } 98 }
99 99
100 virtual void interpolate(double fraction, OwnPtrWillBeMember<InterpolationVa lue>& result) const override final 100 void interpolate(double fraction, OwnPtrWillBeMember<InterpolationValue>& re sult) const final
101 { 101 {
102 // TODO(alancutter): Remove this optimisation once Oilpan is default. 102 // TODO(alancutter): Remove this optimisation once Oilpan is default.
103 if (!std::isnan(m_lastFraction) && (fraction < 0.5) == (m_lastFraction < 0.5)) 103 if (!std::isnan(m_lastFraction) && (fraction < 0.5) == (m_lastFraction < 0.5))
104 return; 104 return;
105 result = ((fraction < 0.5) ? m_start : m_end)->clone(); 105 result = ((fraction < 0.5) ? m_start : m_end)->clone();
106 m_lastFraction = fraction; 106 m_lastFraction = fraction;
107 } 107 }
108 108
109 OwnPtrWillBeMember<InterpolationValue> m_start; 109 OwnPtrWillBeMember<InterpolationValue> m_start;
110 OwnPtrWillBeMember<InterpolationValue> m_end; 110 OwnPtrWillBeMember<InterpolationValue> m_end;
111 mutable double m_lastFraction; 111 mutable double m_lastFraction;
112 }; 112 };
113 113
114 } // namespace blink 114 } // namespace blink
115 115
116 #endif // PrimitiveInterpolation_h 116 #endif // PrimitiveInterpolation_h
OLDNEW
« no previous file with comments | « Source/core/animation/PathSVGInterpolation.h ('k') | Source/core/animation/RectSVGInterpolation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698