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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 result->setRadius(o->radius()); | 168 result->setRadius(o->radius()); |
169 return result; | 169 return result; |
170 } | 170 } |
171 | 171 |
172 result->setCenterX(m_centerX.blend(o->centerX(), progress)); | 172 result->setCenterX(m_centerX.blend(o->centerX(), progress)); |
173 result->setCenterY(m_centerY.blend(o->centerY(), progress)); | 173 result->setCenterY(m_centerY.blend(o->centerY(), progress)); |
174 result->setRadius(m_radius.blend(o->radius(), progress)); | 174 result->setRadius(m_radius.blend(o->radius(), progress)); |
175 return result.release(); | 175 return result.release(); |
176 } | 176 } |
177 | 177 |
178 void BasicShapeEllipse::path(Path& path, const FloatRect& boundingBox) | 178 void DeprecatedBasicShapeEllipse::path(Path& path, const FloatRect& boundingBox) |
179 { | 179 { |
180 ASSERT(path.isEmpty()); | 180 ASSERT(path.isEmpty()); |
181 float centerX = floatValueForLength(m_centerX, boundingBox.width()); | 181 float centerX = floatValueForLength(m_centerX, boundingBox.width()); |
182 float centerY = floatValueForLength(m_centerY, boundingBox.height()); | 182 float centerY = floatValueForLength(m_centerY, boundingBox.height()); |
183 float radiusX = floatValueForLength(m_radiusX, boundingBox.width()); | 183 float radiusX = floatValueForLength(m_radiusX, boundingBox.width()); |
184 float radiusY = floatValueForLength(m_radiusY, boundingBox.height()); | 184 float radiusY = floatValueForLength(m_radiusY, boundingBox.height()); |
185 path.addEllipse(FloatRect( | 185 path.addEllipse(FloatRect( |
186 centerX - radiusX + boundingBox.x(), | 186 centerX - radiusX + boundingBox.x(), |
187 centerY - radiusY + boundingBox.y(), | 187 centerY - radiusY + boundingBox.y(), |
188 radiusX * 2, | 188 radiusX * 2, |
189 radiusY * 2 | 189 radiusY * 2 |
190 )); | 190 )); |
191 } | 191 } |
192 | 192 |
193 PassRefPtr<BasicShape> BasicShapeEllipse::blend(const BasicShape* other, double
progress) const | 193 bool DeprecatedBasicShapeEllipse::operator==(const BasicShape& o) const |
| 194 { |
| 195 if (!isSameType(o)) |
| 196 return false; |
| 197 const DeprecatedBasicShapeEllipse& other = toDeprecatedBasicShapeEllipse(o); |
| 198 return m_centerX == other.m_centerX && m_centerY == other.m_centerY && m_rad
iusX == other.m_radiusX && m_radiusY == m_radiusY; |
| 199 } |
| 200 |
| 201 PassRefPtr<BasicShape> DeprecatedBasicShapeEllipse::blend(const BasicShape* othe
r, double progress) const |
194 { | 202 { |
195 ASSERT(other && isSameType(*other)); | 203 ASSERT(other && isSameType(*other)); |
196 | 204 |
197 const BasicShapeEllipse* o = static_cast<const BasicShapeEllipse*>(other); | 205 const DeprecatedBasicShapeEllipse* o = static_cast<const DeprecatedBasicShap
eEllipse*>(other); |
198 RefPtr<BasicShapeEllipse> result = BasicShapeEllipse::create(); | 206 RefPtr<DeprecatedBasicShapeEllipse> result = DeprecatedBasicShapeEllipse::cr
eate(); |
199 result->setCenterX(m_centerX.blend(o->centerX(), progress, ValueRangeAll)); | 207 result->setCenterX(m_centerX.blend(o->centerX(), progress, ValueRangeAll)); |
200 result->setCenterY(m_centerY.blend(o->centerY(), progress, ValueRangeAll)); | 208 result->setCenterY(m_centerY.blend(o->centerY(), progress, ValueRangeAll)); |
201 result->setRadiusX(m_radiusX.blend(o->radiusX(), progress, ValueRangeNonNega
tive)); | 209 result->setRadiusX(m_radiusX.blend(o->radiusX(), progress, ValueRangeNonNega
tive)); |
202 result->setRadiusY(m_radiusY.blend(o->radiusY(), progress, ValueRangeNonNega
tive)); | 210 result->setRadiusY(m_radiusY.blend(o->radiusY(), progress, ValueRangeNonNega
tive)); |
203 return result.release(); | 211 return result.release(); |
204 } | 212 } |
205 | 213 |
206 bool BasicShapeEllipse::operator==(const BasicShape& o) const | 214 bool BasicShapeEllipse::operator==(const BasicShape& o) const |
207 { | 215 { |
208 if (!isSameType(o)) | 216 if (!isSameType(o)) |
209 return false; | 217 return false; |
210 const BasicShapeEllipse& other = toBasicShapeEllipse(o); | 218 const BasicShapeEllipse& other = toBasicShapeEllipse(o); |
211 return m_centerX == other.m_centerX && m_centerY == other.m_centerY && m_rad
iusX == other.m_radiusX && m_radiusY == other.m_radiusY; | 219 return m_centerX == other.m_centerX && m_centerY == other.m_centerY && m_rad
iusX == other.m_radiusX && m_radiusY == other.m_radiusY; |
212 } | 220 } |
213 | 221 |
| 222 void BasicShapeEllipse::path(Path& path, const FloatRect& boundingBox) |
| 223 { |
| 224 ASSERT(path.isEmpty()); |
| 225 // FIXME Complete implementation of path. Bug 124619. |
| 226 // Compute closest-side and farthest-side from boundingBox. |
| 227 // Compute top, left, bottom, right from boundingBox. |
| 228 if (m_radiusX.type() != BasicShapeRadius::Value || m_radiusY.type() != Basic
ShapeRadius::Value) |
| 229 return; |
| 230 if (m_centerX.keyword() != BasicShapeCenterCoordinate::None || m_centerY.key
word() != BasicShapeCenterCoordinate::None) |
| 231 return; |
| 232 |
| 233 float diagonal = sqrtf((boundingBox.width() * boundingBox.width() + bounding
Box.height() * boundingBox.height()) / 2); |
| 234 float centerX = floatValueForLength(m_centerX.length(), boundingBox.width())
; |
| 235 float centerY = floatValueForLength(m_centerY.length(), boundingBox.height()
); |
| 236 float radiusX = floatValueForLength(m_radiusX.value(), diagonal); |
| 237 float radiusY = floatValueForLength(m_radiusY.value(), diagonal); |
| 238 path.addEllipse(FloatRect( |
| 239 centerX - radiusX + boundingBox.x(), |
| 240 centerY - radiusY + boundingBox.y(), |
| 241 radiusX * 2, |
| 242 radiusY * 2 |
| 243 )); |
| 244 } |
| 245 |
| 246 PassRefPtr<BasicShape> BasicShapeEllipse::blend(const BasicShape* other, double
progress) const |
| 247 { |
| 248 ASSERT(type() == other->type()); |
| 249 const BasicShapeEllipse* o = static_cast<const BasicShapeEllipse*>(other); |
| 250 RefPtr<BasicShapeEllipse> result = BasicShapeEllipse::create(); |
| 251 |
| 252 if (m_radiusX.type() != BasicShapeRadius::Value || o->radiusX().type() != Ba
sicShapeRadius::Value |
| 253 || m_radiusY.type() != BasicShapeRadius::Value || o->radiusY().type() !=
BasicShapeRadius::Value) { |
| 254 result->setCenterX(o->centerX()); |
| 255 result->setCenterY(o->centerY()); |
| 256 result->setRadiusX(o->radiusX()); |
| 257 result->setRadiusY(o->radiusY()); |
| 258 return result; |
| 259 } |
| 260 |
| 261 result->setCenterX(m_centerX.blend(o->centerX(), progress)); |
| 262 result->setCenterY(m_centerY.blend(o->centerY(), progress)); |
| 263 result->setRadiusX(m_radiusX.blend(o->radiusX(), progress)); |
| 264 result->setRadiusY(m_radiusY.blend(o->radiusY(), progress)); |
| 265 return result.release(); |
| 266 } |
| 267 |
214 void BasicShapePolygon::path(Path& path, const FloatRect& boundingBox) | 268 void BasicShapePolygon::path(Path& path, const FloatRect& boundingBox) |
215 { | 269 { |
216 ASSERT(path.isEmpty()); | 270 ASSERT(path.isEmpty()); |
217 ASSERT(!(m_values.size() % 2)); | 271 ASSERT(!(m_values.size() % 2)); |
218 size_t length = m_values.size(); | 272 size_t length = m_values.size(); |
219 | 273 |
220 if (!length) | 274 if (!length) |
221 return; | 275 return; |
222 | 276 |
223 path.moveTo(FloatPoint(floatValueForLength(m_values.at(0), boundingBox.width
()) + boundingBox.x(), | 277 path.moveTo(FloatPoint(floatValueForLength(m_values.at(0), boundingBox.width
()) + boundingBox.x(), |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 } | 349 } |
296 | 350 |
297 bool BasicShapeInsetRectangle::operator==(const BasicShape& o) const | 351 bool BasicShapeInsetRectangle::operator==(const BasicShape& o) const |
298 { | 352 { |
299 if (!isSameType(o)) | 353 if (!isSameType(o)) |
300 return false; | 354 return false; |
301 const BasicShapeInsetRectangle& other = toBasicShapeInsetRectangle(o); | 355 const BasicShapeInsetRectangle& other = toBasicShapeInsetRectangle(o); |
302 return m_right == other.m_right && m_top == other.m_top && m_bottom == other
.m_bottom && m_left == other.m_left && m_cornerRadiusX == other.m_cornerRadiusX
&& m_cornerRadiusY == other.m_cornerRadiusY; | 356 return m_right == other.m_right && m_top == other.m_top && m_bottom == other
.m_bottom && m_left == other.m_left && m_cornerRadiusX == other.m_cornerRadiusX
&& m_cornerRadiusY == other.m_cornerRadiusY; |
303 } | 357 } |
304 } | 358 } |
OLD | NEW |