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

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

Issue 1276183004: Oilpan: Unship oilpan from temporary animation objects (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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 ListSVGInterpolation_h 5 #ifndef ListSVGInterpolation_h
6 #define ListSVGInterpolation_h 6 #define ListSVGInterpolation_h
7 7
8 #include "core/animation/SVGInterpolation.h" 8 #include "core/animation/SVGInterpolation.h"
9 #include "core/svg/properties/SVGAnimatedProperty.h" 9 #include "core/svg/properties/SVGAnimatedProperty.h"
10 #include "core/svg/properties/SVGProperty.h" 10 #include "core/svg/properties/SVGProperty.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 template<typename InterpolationType, typename NonInterpolableType> 14 template<typename InterpolationType, typename NonInterpolableType>
15 class ListSVGInterpolationImpl : public SVGInterpolation { 15 class ListSVGInterpolationImpl : public SVGInterpolation {
16 public: 16 public:
17 typedef typename InterpolationType::ListType ListType; 17 typedef typename InterpolationType::ListType ListType;
18 typedef typename InterpolationType::ListType::ItemPropertyType ItemPropertyT ype; 18 typedef typename InterpolationType::ListType::ItemPropertyType ItemPropertyT ype;
19 19
20 static PassRefPtrWillBeRawPtr<ListSVGInterpolationImpl<InterpolationType, No nInterpolableType>> maybeCreate(SVGPropertyBase* start, SVGPropertyBase* end, Pa ssRefPtrWillBeRawPtr<SVGAnimatedPropertyBase> attribute) 20 static PassRefPtr<ListSVGInterpolationImpl<InterpolationType, NonInterpolabl eType>> maybeCreate(SVGPropertyBase* start, SVGPropertyBase* end, PassRefPtrWill BeRawPtr<SVGAnimatedPropertyBase> attribute)
21 { 21 {
22 ASSERT(start->type() == ListType::classType()); 22 ASSERT(start->type() == ListType::classType());
23 ASSERT(end->type() == ListType::classType()); 23 ASSERT(end->type() == ListType::classType());
24 24
25 ListType* startList = static_cast<ListType*>(start); 25 ListType* startList = static_cast<ListType*>(start);
26 ListType* endList = static_cast<ListType*>(end); 26 ListType* endList = static_cast<ListType*>(end);
27 if (startList->length() != endList->length()) 27 if (startList->length() != endList->length())
28 return nullptr; 28 return nullptr;
29 29
30 size_t length = startList->length(); 30 size_t length = startList->length();
31 for (size_t i = 0; i < length; i++) { 31 for (size_t i = 0; i < length; i++) {
32 if (!InterpolationType::canCreateFrom(startList->at(i), endList->at( i))) { 32 if (!InterpolationType::canCreateFrom(startList->at(i), endList->at( i))) {
33 return nullptr; 33 return nullptr;
34 } 34 }
35 } 35 }
36 36
37 Vector<NonInterpolableType> nonInterpolableData(length); 37 Vector<NonInterpolableType> nonInterpolableData(length);
38 OwnPtrWillBeRawPtr<InterpolableList> startValue = InterpolableList::crea te(length); 38 OwnPtr<InterpolableList> startValue = InterpolableList::create(length);
39 OwnPtrWillBeRawPtr<InterpolableList> endValue = InterpolableList::create (length); 39 OwnPtr<InterpolableList> endValue = InterpolableList::create(length);
40 for (size_t i = 0; i < length; i++) { 40 for (size_t i = 0; i < length; i++) {
41 startValue->set(i, InterpolationType::toInterpolableValue(startList- >at(i), attribute.get(), &nonInterpolableData.at(i))); 41 startValue->set(i, InterpolationType::toInterpolableValue(startList- >at(i), attribute.get(), &nonInterpolableData.at(i)));
42 endValue->set(i, InterpolationType::toInterpolableValue(endList->at( i), attribute.get(), nullptr)); 42 endValue->set(i, InterpolationType::toInterpolableValue(endList->at( i), attribute.get(), nullptr));
43 } 43 }
44 44
45 return adoptRefWillBeNoop(new ListSVGInterpolationImpl<InterpolationType , NonInterpolableType>(startValue.release(), endValue.release(), attribute, nonI nterpolableData)); 45 return adoptRef(new ListSVGInterpolationImpl<InterpolationType, NonInter polableType>(startValue.release(), endValue.release(), attribute, nonInterpolabl eData));
46 } 46 }
47 47
48 private: 48 private:
49 ListSVGInterpolationImpl(PassOwnPtrWillBeRawPtr<InterpolableValue> start, Pa ssOwnPtrWillBeRawPtr<InterpolableValue> end, PassRefPtrWillBeRawPtr<SVGAnimatedP ropertyBase> attribute, Vector<NonInterpolableType> nonInterpolableData) 49 ListSVGInterpolationImpl(PassOwnPtr<InterpolableValue> start, PassOwnPtr<Int erpolableValue> end, PassRefPtrWillBeRawPtr<SVGAnimatedPropertyBase> attribute, Vector<NonInterpolableType> nonInterpolableData)
50 : SVGInterpolation(start, end, attribute) 50 : SVGInterpolation(start, end, attribute)
51 { 51 {
52 m_nonInterpolableData.swap(nonInterpolableData); 52 m_nonInterpolableData.swap(nonInterpolableData);
53 } 53 }
54 54
55 static PassRefPtrWillBeRawPtr<ListType> fromInterpolableValue(const Interpol ableValue& value, const Vector<NonInterpolableType>& m_nonInterpolableData, cons t SVGElement* element, const SVGAnimatedPropertyBase* attribute) 55 static PassRefPtrWillBeRawPtr<ListType> fromInterpolableValue(const Interpol ableValue& value, const Vector<NonInterpolableType>& m_nonInterpolableData, cons t SVGElement* element, const SVGAnimatedPropertyBase* attribute)
56 { 56 {
57 const InterpolableList& listValue = toInterpolableList(value); 57 const InterpolableList& listValue = toInterpolableList(value);
58 RefPtrWillBeRawPtr<ListType> result = InterpolationType::createList(*att ribute); 58 RefPtrWillBeRawPtr<ListType> result = InterpolationType::createList(*att ribute);
59 for (size_t i = 0; i < listValue.length(); i++) 59 for (size_t i = 0; i < listValue.length(); i++)
60 result->append(InterpolationType::fromInterpolableValue(*listValue.g et(i), m_nonInterpolableData.at(i), element)); 60 result->append(InterpolationType::fromInterpolableValue(*listValue.g et(i), m_nonInterpolableData.at(i), element));
61 return result.release(); 61 return result.release();
62 } 62 }
63 63
64 virtual PassRefPtrWillBeRawPtr<SVGPropertyBase> interpolatedValue(SVGElement & element) const 64 virtual PassRefPtrWillBeRawPtr<SVGPropertyBase> interpolatedValue(SVGElement & element) const
65 { 65 {
66 return fromInterpolableValue(*m_cachedValue, m_nonInterpolableData, &ele ment, attribute()); 66 return fromInterpolableValue(*m_cachedValue, m_nonInterpolableData, &ele ment, attribute());
67 } 67 }
68 68
69 Vector<NonInterpolableType> m_nonInterpolableData; 69 Vector<NonInterpolableType> m_nonInterpolableData;
70 }; 70 };
71 71
72 template<typename InterpolationType> 72 template<typename InterpolationType>
73 class ListSVGInterpolationImpl<InterpolationType, void> : public SVGInterpolatio n { 73 class ListSVGInterpolationImpl<InterpolationType, void> : public SVGInterpolatio n {
74 public: 74 public:
75 typedef typename InterpolationType::ListType ListType; 75 typedef typename InterpolationType::ListType ListType;
76 76
77 static PassRefPtrWillBeRawPtr<ListSVGInterpolationImpl<InterpolationType, vo id>> maybeCreate(SVGPropertyBase* start, SVGPropertyBase* end, PassRefPtrWillBeR awPtr<SVGAnimatedPropertyBase> attribute) 77 static PassRefPtr<ListSVGInterpolationImpl<InterpolationType, void>> maybeCr eate(SVGPropertyBase* start, SVGPropertyBase* end, PassRefPtrWillBeRawPtr<SVGAni matedPropertyBase> attribute)
78 { 78 {
79 ASSERT(start->type() == ListType::classType()); 79 ASSERT(start->type() == ListType::classType());
80 ASSERT(end->type() == ListType::classType()); 80 ASSERT(end->type() == ListType::classType());
81 81
82 ListType* startList = static_cast<ListType*>(start); 82 ListType* startList = static_cast<ListType*>(start);
83 ListType* endList = static_cast<ListType*>(end); 83 ListType* endList = static_cast<ListType*>(end);
84 if (startList->length() != endList->length()) 84 if (startList->length() != endList->length())
85 return nullptr; 85 return nullptr;
86 86
87 return adoptRefWillBeNoop(new ListSVGInterpolationImpl<InterpolationType , void>(toInterpolableValue(startList), toInterpolableValue(endList), attribute) ); 87 return adoptRef(new ListSVGInterpolationImpl<InterpolationType, void>(to InterpolableValue(startList), toInterpolableValue(endList), attribute));
88 }
89
90 DEFINE_INLINE_VIRTUAL_TRACE()
91 {
92 SVGInterpolation::trace(visitor);
93 } 88 }
94 89
95 private: 90 private:
96 ListSVGInterpolationImpl(PassOwnPtrWillBeRawPtr<InterpolableValue> start, Pa ssOwnPtrWillBeRawPtr<InterpolableValue> end, PassRefPtrWillBeRawPtr<SVGAnimatedP ropertyBase> attribute) 91 ListSVGInterpolationImpl(PassOwnPtr<InterpolableValue> start, PassOwnPtr<Int erpolableValue> end, PassRefPtrWillBeRawPtr<SVGAnimatedPropertyBase> attribute)
97 : SVGInterpolation(start, end, attribute) 92 : SVGInterpolation(start, end, attribute)
98 { 93 {
99 } 94 }
100 95
101 static PassOwnPtrWillBeRawPtr<InterpolableValue> toInterpolableValue(ListTyp e* listValue) 96 static PassOwnPtr<InterpolableValue> toInterpolableValue(ListType* listValue )
102 { 97 {
103 size_t length = listValue->length(); 98 size_t length = listValue->length();
104 OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(l ength); 99 OwnPtr<InterpolableList> result = InterpolableList::create(length);
105 for (size_t i = 0; i < length; i++) 100 for (size_t i = 0; i < length; i++)
106 result->set(i, InterpolationType::toInterpolableValue(listValue->at( i))); 101 result->set(i, InterpolationType::toInterpolableValue(listValue->at( i)));
107 return result.release(); 102 return result.release();
108 } 103 }
109 104
110 static PassRefPtrWillBeRawPtr<ListType> fromInterpolableValue(const Interpol ableValue& value) 105 static PassRefPtrWillBeRawPtr<ListType> fromInterpolableValue(const Interpol ableValue& value)
111 { 106 {
112 const InterpolableList& listValue = toInterpolableList(value); 107 const InterpolableList& listValue = toInterpolableList(value);
113 RefPtrWillBeRawPtr<ListType> result = ListType::create(); 108 RefPtrWillBeRawPtr<ListType> result = ListType::create();
114 for (size_t i = 0; i < listValue.length(); i++) { 109 for (size_t i = 0; i < listValue.length(); i++) {
115 result->append(InterpolationType::fromInterpolableValue(*listValue.g et(i))); 110 result->append(InterpolationType::fromInterpolableValue(*listValue.g et(i)));
116 } 111 }
117 return result.release(); 112 return result.release();
118 } 113 }
119 114
120 virtual PassRefPtrWillBeRawPtr<SVGPropertyBase> interpolatedValue(SVGElement & element) const 115 virtual PassRefPtrWillBeRawPtr<SVGPropertyBase> interpolatedValue(SVGElement & element) const
121 { 116 {
122 return fromInterpolableValue(*m_cachedValue); 117 return fromInterpolableValue(*m_cachedValue);
123 } 118 }
124 }; 119 };
125 120
126 template<typename InterpolationType> 121 template<typename InterpolationType>
127 class ListSVGInterpolation { 122 class ListSVGInterpolation {
128 public: 123 public:
129 static PassRefPtrWillBeRawPtr<ListSVGInterpolationImpl<InterpolationType, ty pename InterpolationType::NonInterpolableType>> maybeCreate(SVGPropertyBase* st art, SVGPropertyBase* end, PassRefPtrWillBeRawPtr<SVGAnimatedPropertyBase> attri bute) 124 static PassRefPtr<ListSVGInterpolationImpl<InterpolationType, typename Inter polationType::NonInterpolableType>> maybeCreate(SVGPropertyBase* start, SVGProp ertyBase* end, PassRefPtrWillBeRawPtr<SVGAnimatedPropertyBase> attribute)
130 { 125 {
131 return ListSVGInterpolationImpl<InterpolationType, typename Interpolatio nType::NonInterpolableType>::maybeCreate(start, end, attribute); 126 return ListSVGInterpolationImpl<InterpolationType, typename Interpolatio nType::NonInterpolableType>::maybeCreate(start, end, attribute);
132 } 127 }
133 }; 128 };
134 129
135 } // namespace blink 130 } // namespace blink
136 131
137 #endif // ListSVGInterpolation_h 132 #endif // ListSVGInterpolation_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698