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

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

Issue 212213007: Oilpan: Move InterpolableValue's hierarchy to oilpan's heap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/core/animation/InterpolableValue.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 InterpolableValue_h 5 #ifndef InterpolableValue_h
6 #define InterpolableValue_h 6 #define InterpolableValue_h
7 7
8 #include "core/animation/AnimatableValue.h" 8 #include "core/animation/AnimatableValue.h"
9 #include "wtf/OwnPtr.h" 9 #include "wtf/OwnPtr.h"
10 #include "wtf/PassOwnPtr.h" 10 #include "wtf/PassOwnPtr.h"
11 #include "wtf/Vector.h"
11 12
12 namespace WebCore { 13 namespace WebCore {
13 14
14 class InterpolableValue { 15 class InterpolableValue : public NoBaseWillBeGarbageCollected<InterpolableValue> {
16 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(InterpolableValue);
15 public: 17 public:
16 virtual bool isNumber() const { return false; } 18 virtual bool isNumber() const { return false; }
17 virtual bool isBool() const { return false; } 19 virtual bool isBool() const { return false; }
18 virtual bool isList() const { return false; } 20 virtual bool isList() const { return false; }
19 virtual bool isAnimatableValue() const { return false; } 21 virtual bool isAnimatableValue() const { return false; }
20 22
21 virtual ~InterpolableValue() { } 23 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const = 0;
22 virtual PassOwnPtr<InterpolableValue> clone() const = 0; 24
25 virtual void trace(Visitor*) = 0;
23 26
24 private: 27 private:
25 virtual PassOwnPtr<InterpolableValue> interpolate(const InterpolableValue &t o, const double progress) const = 0; 28 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> interpolate(const Interpol ableValue &to, const double progress) const = 0;
26 29
27 friend class Interpolation; 30 friend class Interpolation;
28 31
29 // Keep interpolate private, but allow calls within the hierarchy without 32 // Keep interpolate private, but allow calls within the hierarchy without
30 // knowledge of type. 33 // knowledge of type.
31 friend class InterpolableNumber; 34 friend class InterpolableNumber;
32 friend class InterpolableBool; 35 friend class InterpolableBool;
33 friend class InterpolableList; 36 friend class InterpolableList;
34 }; 37 };
35 38
36 class InterpolableNumber : public InterpolableValue { 39 class InterpolableNumber : public InterpolableValue {
37 public: 40 public:
38 static PassOwnPtr<InterpolableNumber> create(double value) 41 static PassOwnPtrWillBeRawPtr<InterpolableNumber> create(double value)
39 { 42 {
40 return adoptPtr(new InterpolableNumber(value)); 43 return adoptPtrWillBeNoop(new InterpolableNumber(value));
41 } 44 }
42 45
43 virtual bool isNumber() const OVERRIDE FINAL { return true; } 46 virtual bool isNumber() const OVERRIDE FINAL { return true; }
44 double value() const { return m_value; } 47 double value() const { return m_value; }
45 virtual PassOwnPtr<InterpolableValue> clone() const OVERRIDE FINAL { return create(m_value); } 48 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const OVERRIDE FIN AL { return create(m_value); }
49
50 virtual void trace(Visitor*) OVERRIDE { }
46 51
47 private: 52 private:
48 virtual PassOwnPtr<InterpolableValue> interpolate(const InterpolableValue &t o, const double progress) const OVERRIDE FINAL; 53 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> interpolate(const Interpol ableValue &to, const double progress) const OVERRIDE FINAL;
49 double m_value; 54 double m_value;
50 55
51 InterpolableNumber(double value) 56 explicit InterpolableNumber(double value)
52 : m_value(value) 57 : m_value(value)
53 { } 58 {
59 }
54 60
55 }; 61 };
56 62
57 class InterpolableBool : public InterpolableValue { 63 class InterpolableBool : public InterpolableValue {
58 public: 64 public:
59 static PassOwnPtr<InterpolableBool> create(bool value) 65 static PassOwnPtrWillBeRawPtr<InterpolableBool> create(bool value)
60 { 66 {
61 return adoptPtr(new InterpolableBool(value)); 67 return adoptPtrWillBeNoop(new InterpolableBool(value));
62 } 68 }
63 69
64 virtual bool isBool() const OVERRIDE FINAL { return true; } 70 virtual bool isBool() const OVERRIDE FINAL { return true; }
65 bool value() const { return m_value; } 71 bool value() const { return m_value; }
66 virtual PassOwnPtr<InterpolableValue> clone() const OVERRIDE FINAL { return create(m_value); } 72 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const OVERRIDE FIN AL { return create(m_value); }
73
74 virtual void trace(Visitor*) OVERRIDE { }
67 75
68 private: 76 private:
69 virtual PassOwnPtr<InterpolableValue> interpolate(const InterpolableValue &t o, const double progress) const OVERRIDE FINAL; 77 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> interpolate(const Interpol ableValue &to, const double progress) const OVERRIDE FINAL;
70 bool m_value; 78 bool m_value;
71 79
72 InterpolableBool(bool value) 80 explicit InterpolableBool(bool value)
73 : m_value(value) 81 : m_value(value)
74 { } 82 {
83 }
75 84
76 }; 85 };
77 86
78 class InterpolableList : public InterpolableValue { 87 class InterpolableList : public InterpolableValue {
79 public: 88 public:
80 static PassOwnPtr<InterpolableList> create(const InterpolableList &other) 89 static PassOwnPtrWillBeRawPtr<InterpolableList> create(const InterpolableLis t &other)
81 { 90 {
82 return adoptPtr(new InterpolableList(other)); 91 return adoptPtrWillBeNoop(new InterpolableList(other));
83 } 92 }
84 93
85 static PassOwnPtr<InterpolableList> create(size_t size) 94 static PassOwnPtrWillBeRawPtr<InterpolableList> create(size_t size)
86 { 95 {
87 return adoptPtr(new InterpolableList(size)); 96 return adoptPtrWillBeNoop(new InterpolableList(size));
88 } 97 }
89 98
90 virtual bool isList() const OVERRIDE FINAL { return true; } 99 virtual bool isList() const OVERRIDE FINAL { return true; }
91 void set(size_t position, PassOwnPtr<InterpolableValue> value) 100 void set(size_t position, PassOwnPtrWillBeRawPtr<InterpolableValue> value)
92 { 101 {
93 ASSERT(position < m_size); 102 ASSERT(position < m_size);
94 m_values.get()[position] = value; 103 m_values[position] = value;
95 } 104 }
96 const InterpolableValue* get(size_t position) const 105 const InterpolableValue* get(size_t position) const
97 { 106 {
98 ASSERT(position < m_size); 107 ASSERT(position < m_size);
99 return m_values.get()[position].get(); 108 return m_values[position].get();
100 } 109 }
101 size_t length() const { return m_size; } 110 size_t length() const { return m_size; }
102 virtual PassOwnPtr<InterpolableValue> clone() const OVERRIDE FINAL { return create(*this); } 111 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const OVERRIDE FIN AL { return create(*this); }
112
113 virtual void trace(Visitor*) OVERRIDE;
103 114
104 private: 115 private:
105 virtual PassOwnPtr<InterpolableValue> interpolate(const InterpolableValue &o ther, const double progress) const OVERRIDE FINAL; 116 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> interpolate(const Interpol ableValue &other, const double progress) const OVERRIDE FINAL;
106 InterpolableList(size_t size) 117 explicit InterpolableList(size_t size)
107 : m_size(size) 118 : m_size(size)
108 { 119 {
109 m_values = adoptArrayPtr(new OwnPtr<InterpolableValue>[size]); 120 m_values.reserveCapacity(m_size);
121 m_values.resize(m_size);
110 } 122 }
111 123
112 InterpolableList(const InterpolableList& other) 124 InterpolableList(const InterpolableList& other)
113 : m_size(other.m_size) 125 : m_size(other.m_size)
114 { 126 {
115 m_values = adoptArrayPtr(new OwnPtr<InterpolableValue>[m_size]); 127 m_values.reserveCapacity(m_size);
128 m_values.resize(m_size);
116 for (size_t i = 0; i < m_size; i++) 129 for (size_t i = 0; i < m_size; i++)
117 set(i, other.m_values.get()[i]->clone()); 130 set(i, other.m_values[i]->clone());
118 } 131 }
119 132
120 size_t m_size; 133 size_t m_size;
121 OwnPtr<OwnPtr<InterpolableValue>[]> m_values; 134 WillBeHeapVector<OwnPtrWillBeMember<InterpolableValue> > m_values;
haraken 2014/03/27 01:27:36 dstockwell@, shanes@: Would you just check that ch
122 }; 135 };
123 136
124 // FIXME: Remove this when we can. 137 // FIXME: Remove this when we can.
125 class InterpolableAnimatableValue : public InterpolableValue { 138 class InterpolableAnimatableValue : public InterpolableValue {
126 public: 139 public:
127 static PassOwnPtr<InterpolableAnimatableValue> create(PassRefPtrWillBeRawPtr <AnimatableValue> value) 140 static PassOwnPtrWillBeRawPtr<InterpolableAnimatableValue> create(PassRefPtr WillBeRawPtr<AnimatableValue> value)
128 { 141 {
129 return adoptPtr(new InterpolableAnimatableValue(value)); 142 return adoptPtrWillBeNoop(new InterpolableAnimatableValue(value));
130 } 143 }
131 144
132 virtual bool isAnimatableValue() const OVERRIDE FINAL { return true; } 145 virtual bool isAnimatableValue() const OVERRIDE FINAL { return true; }
133 AnimatableValue* value() const { return m_value.get(); } 146 AnimatableValue* value() const { return m_value.get(); }
134 virtual PassOwnPtr<InterpolableValue> clone() const OVERRIDE FINAL { return create(m_value); } 147 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const OVERRIDE FIN AL { return create(m_value); }
148
149 virtual void trace(Visitor*) OVERRIDE;
135 150
136 private: 151 private:
137 virtual PassOwnPtr<InterpolableValue> interpolate(const InterpolableValue &o ther, const double progress) const OVERRIDE FINAL; 152 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> interpolate(const Interpol ableValue &other, const double progress) const OVERRIDE FINAL;
138 RefPtrWillBePersistent<AnimatableValue> m_value; 153 RefPtrWillBeMember<AnimatableValue> m_value;
139 154
140 InterpolableAnimatableValue(PassRefPtrWillBeRawPtr<AnimatableValue> value) 155 InterpolableAnimatableValue(PassRefPtrWillBeRawPtr<AnimatableValue> value)
141 : m_value(value) 156 : m_value(value)
142 { } 157 {
158 }
143 }; 159 };
144 160
145 DEFINE_TYPE_CASTS(InterpolableNumber, InterpolableValue, value, value->isNumber( ), value.isNumber()); 161 DEFINE_TYPE_CASTS(InterpolableNumber, InterpolableValue, value, value->isNumber( ), value.isNumber());
146 DEFINE_TYPE_CASTS(InterpolableBool, InterpolableValue, value, value->isBool(), v alue.isBool()); 162 DEFINE_TYPE_CASTS(InterpolableBool, InterpolableValue, value, value->isBool(), v alue.isBool());
147 DEFINE_TYPE_CASTS(InterpolableList, InterpolableValue, value, value->isList(), v alue.isList()); 163 DEFINE_TYPE_CASTS(InterpolableList, InterpolableValue, value, value->isList(), v alue.isList());
148 DEFINE_TYPE_CASTS(InterpolableAnimatableValue, InterpolableValue, value, value-> isAnimatableValue(), value.isAnimatableValue()); 164 DEFINE_TYPE_CASTS(InterpolableAnimatableValue, InterpolableValue, value, value-> isAnimatableValue(), value.isAnimatableValue());
149 165
150 } 166 }
151 167
152 #endif 168 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/core/animation/InterpolableValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698