OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above | 8 * 1. Redistributions of source code must retain the above |
9 * copyright notice, this list of conditions and the following | 9 * copyright notice, this list of conditions and the following |
10 * disclaimer. | 10 * disclaimer. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 } | 53 } |
54 | 54 |
55 bool BasicShape::canBlend(const BasicShape* other) const | 55 bool BasicShape::canBlend(const BasicShape* other) const |
56 { | 56 { |
57 // FIXME: Support animations between different shapes in the future. | 57 // FIXME: Support animations between different shapes in the future. |
58 if (!other || !isSameType(*other)) | 58 if (!other || !isSameType(*other)) |
59 return false; | 59 return false; |
60 | 60 |
61 // Just polygons with same number of vertices can be animated. | 61 // Just polygons with same number of vertices can be animated. |
62 if (type() == BasicShape::BasicShapePolygonType | 62 if (type() == BasicShape::BasicShapePolygonType |
63 && (static_cast<const BasicShapePolygon*>(this)->values().size() != stat
ic_cast<const BasicShapePolygon*>(other)->values().size() | 63 && (toBasicShapePolygon(this)->values().size() != toBasicShapePolygon(ot
her)->values().size() |
64 || static_cast<const BasicShapePolygon*>(this)->windRule() != static_cas
t<const BasicShapePolygon*>(other)->windRule())) | 64 || toBasicShapePolygon(this)->windRule() != toBasicShapePolygon(other)->
windRule())) |
65 return false; | 65 return false; |
66 | 66 |
67 // Circles with keywords for radii or center coordinates cannot be animated. | 67 // Circles with keywords for radii or center coordinates cannot be animated. |
68 if (type() == BasicShape::BasicShapeCircleType) { | 68 if (type() == BasicShape::BasicShapeCircleType) { |
69 const BasicShapeCircle* thisCircle = static_cast<const BasicShapeCircle*
>(this); | 69 if (!toBasicShapeCircle(this)->radius().canBlend(toBasicShapeCircle(othe
r)->radius())) |
70 const BasicShapeCircle* otherCircle = static_cast<const BasicShapeCircle
*>(other); | |
71 if (!thisCircle->radius().canBlend(otherCircle->radius())) | |
72 return false; | 70 return false; |
73 } | 71 } |
74 | 72 |
75 // Ellipses with keywords for radii or center coordinates cannot be animated
. | 73 // Ellipses with keywords for radii or center coordinates cannot be animated
. |
76 if (type() != BasicShape::BasicShapeEllipseType) | 74 if (type() != BasicShape::BasicShapeEllipseType) |
77 return true; | 75 return true; |
78 | 76 |
79 const BasicShapeEllipse* thisEllipse = static_cast<const BasicShapeEllipse*>
(this); | 77 return (toBasicShapeEllipse(this)->radiusX().canBlend(toBasicShapeEllipse(ot
her)->radiusX()) |
80 const BasicShapeEllipse* otherEllipse = static_cast<const BasicShapeEllipse*
>(other); | 78 && toBasicShapeEllipse(this)->radiusY().canBlend(toBasicShapeEllipse(oth
er)->radiusY())); |
81 return (thisEllipse->radiusX().canBlend(otherEllipse->radiusX()) | |
82 && thisEllipse->radiusY().canBlend(otherEllipse->radiusY())); | |
83 } | 79 } |
84 | 80 |
85 bool BasicShapeCircle::operator==(const BasicShape& o) const | 81 bool BasicShapeCircle::operator==(const BasicShape& o) const |
86 { | 82 { |
87 if (!isSameType(o)) | 83 if (!isSameType(o)) |
88 return false; | 84 return false; |
89 const BasicShapeCircle& other = toBasicShapeCircle(o); | 85 const BasicShapeCircle& other = toBasicShapeCircle(o); |
90 return m_centerX == other.m_centerX && m_centerY == other.m_centerY && m_rad
ius == other.m_radius; | 86 return m_centerX == other.m_centerX && m_centerY == other.m_centerY && m_rad
ius == other.m_radius; |
91 } | 87 } |
92 | 88 |
(...skipping 20 matching lines...) Expand all Loading... |
113 center.x() - radius + boundingBox.x(), | 109 center.x() - radius + boundingBox.x(), |
114 center.y() - radius + boundingBox.y(), | 110 center.y() - radius + boundingBox.y(), |
115 radius * 2, | 111 radius * 2, |
116 radius * 2 | 112 radius * 2 |
117 )); | 113 )); |
118 } | 114 } |
119 | 115 |
120 PassRefPtr<BasicShape> BasicShapeCircle::blend(const BasicShape* other, double p
rogress) const | 116 PassRefPtr<BasicShape> BasicShapeCircle::blend(const BasicShape* other, double p
rogress) const |
121 { | 117 { |
122 ASSERT(type() == other->type()); | 118 ASSERT(type() == other->type()); |
123 const BasicShapeCircle* o = static_cast<const BasicShapeCircle*>(other); | 119 const BasicShapeCircle* o = toBasicShapeCircle(other); |
124 RefPtr<BasicShapeCircle> result = BasicShapeCircle::create(); | 120 RefPtr<BasicShapeCircle> result = BasicShapeCircle::create(); |
125 | 121 |
126 result->setCenterX(m_centerX.blend(o->centerX(), progress)); | 122 result->setCenterX(m_centerX.blend(o->centerX(), progress)); |
127 result->setCenterY(m_centerY.blend(o->centerY(), progress)); | 123 result->setCenterY(m_centerY.blend(o->centerY(), progress)); |
128 result->setRadius(m_radius.blend(o->radius(), progress)); | 124 result->setRadius(m_radius.blend(o->radius(), progress)); |
129 return result.release(); | 125 return result.release(); |
130 } | 126 } |
131 | 127 |
132 bool BasicShapeEllipse::operator==(const BasicShape& o) const | 128 bool BasicShapeEllipse::operator==(const BasicShape& o) const |
133 { | 129 { |
(...skipping 25 matching lines...) Expand all Loading... |
159 center.x() - radiusX + boundingBox.x(), | 155 center.x() - radiusX + boundingBox.x(), |
160 center.y() - radiusY + boundingBox.y(), | 156 center.y() - radiusY + boundingBox.y(), |
161 radiusX * 2, | 157 radiusX * 2, |
162 radiusY * 2 | 158 radiusY * 2 |
163 )); | 159 )); |
164 } | 160 } |
165 | 161 |
166 PassRefPtr<BasicShape> BasicShapeEllipse::blend(const BasicShape* other, double
progress) const | 162 PassRefPtr<BasicShape> BasicShapeEllipse::blend(const BasicShape* other, double
progress) const |
167 { | 163 { |
168 ASSERT(type() == other->type()); | 164 ASSERT(type() == other->type()); |
169 const BasicShapeEllipse* o = static_cast<const BasicShapeEllipse*>(other); | 165 const BasicShapeEllipse* o = toBasicShapeEllipse(other); |
170 RefPtr<BasicShapeEllipse> result = BasicShapeEllipse::create(); | 166 RefPtr<BasicShapeEllipse> result = BasicShapeEllipse::create(); |
171 | 167 |
172 if (m_radiusX.type() != BasicShapeRadius::Value || o->radiusX().type() != Ba
sicShapeRadius::Value | 168 if (m_radiusX.type() != BasicShapeRadius::Value || o->radiusX().type() != Ba
sicShapeRadius::Value |
173 || m_radiusY.type() != BasicShapeRadius::Value || o->radiusY().type() !=
BasicShapeRadius::Value) { | 169 || m_radiusY.type() != BasicShapeRadius::Value || o->radiusY().type() !=
BasicShapeRadius::Value) { |
174 result->setCenterX(o->centerX()); | 170 result->setCenterX(o->centerX()); |
175 result->setCenterY(o->centerY()); | 171 result->setCenterY(o->centerY()); |
176 result->setRadiusX(o->radiusX()); | 172 result->setRadiusX(o->radiusX()); |
177 result->setRadiusY(o->radiusY()); | 173 result->setRadiusY(o->radiusY()); |
178 return result; | 174 return result; |
179 } | 175 } |
(...skipping 20 matching lines...) Expand all Loading... |
200 path.addLineTo(FloatPoint(floatValueForLength(m_values.at(i), boundingBo
x.width()) + boundingBox.x(), | 196 path.addLineTo(FloatPoint(floatValueForLength(m_values.at(i), boundingBo
x.width()) + boundingBox.x(), |
201 floatValueForLength(m_values.at(i + 1), boundingBox.height()) + boun
dingBox.y())); | 197 floatValueForLength(m_values.at(i + 1), boundingBox.height()) + boun
dingBox.y())); |
202 } | 198 } |
203 path.closeSubpath(); | 199 path.closeSubpath(); |
204 } | 200 } |
205 | 201 |
206 PassRefPtr<BasicShape> BasicShapePolygon::blend(const BasicShape* other, double
progress) const | 202 PassRefPtr<BasicShape> BasicShapePolygon::blend(const BasicShape* other, double
progress) const |
207 { | 203 { |
208 ASSERT(other && isSameType(*other)); | 204 ASSERT(other && isSameType(*other)); |
209 | 205 |
210 const BasicShapePolygon* o = static_cast<const BasicShapePolygon*>(other); | 206 const BasicShapePolygon* o = toBasicShapePolygon(other); |
211 ASSERT(m_values.size() == o->values().size()); | 207 ASSERT(m_values.size() == o->values().size()); |
212 ASSERT(!(m_values.size() % 2)); | 208 ASSERT(!(m_values.size() % 2)); |
213 | 209 |
214 size_t length = m_values.size(); | 210 size_t length = m_values.size(); |
215 RefPtr<BasicShapePolygon> result = BasicShapePolygon::create(); | 211 RefPtr<BasicShapePolygon> result = BasicShapePolygon::create(); |
216 if (!length) | 212 if (!length) |
217 return result.release(); | 213 return result.release(); |
218 | 214 |
219 result->setWindRule(o->windRule()); | 215 result->setWindRule(o->windRule()); |
220 | 216 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 && m_top == other.m_top | 271 && m_top == other.m_top |
276 && m_bottom == other.m_bottom | 272 && m_bottom == other.m_bottom |
277 && m_left == other.m_left | 273 && m_left == other.m_left |
278 && m_topLeftRadius == other.m_topLeftRadius | 274 && m_topLeftRadius == other.m_topLeftRadius |
279 && m_topRightRadius == other.m_topRightRadius | 275 && m_topRightRadius == other.m_topRightRadius |
280 && m_bottomRightRadius == other.m_bottomRightRadius | 276 && m_bottomRightRadius == other.m_bottomRightRadius |
281 && m_bottomLeftRadius == other.m_bottomLeftRadius; | 277 && m_bottomLeftRadius == other.m_bottomLeftRadius; |
282 } | 278 } |
283 | 279 |
284 } | 280 } |
OLD | NEW |