| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 // Ellipses with keywords for radii or center coordinates cannot be animated
. | 78 // Ellipses with keywords for radii or center coordinates cannot be animated
. |
| 79 if (type() != BasicShape::BasicShapeEllipseType) | 79 if (type() != BasicShape::BasicShapeEllipseType) |
| 80 return true; | 80 return true; |
| 81 | 81 |
| 82 const BasicShapeEllipse* thisEllipse = static_cast<const BasicShapeEllipse*>
(this); | 82 const BasicShapeEllipse* thisEllipse = static_cast<const BasicShapeEllipse*>
(this); |
| 83 const BasicShapeEllipse* otherEllipse = static_cast<const BasicShapeEllipse*
>(other); | 83 const BasicShapeEllipse* otherEllipse = static_cast<const BasicShapeEllipse*
>(other); |
| 84 return (thisEllipse->radiusX().canBlend(otherEllipse->radiusX()) | 84 return (thisEllipse->radiusX().canBlend(otherEllipse->radiusX()) |
| 85 && thisEllipse->radiusY().canBlend(otherEllipse->radiusY())); | 85 && thisEllipse->radiusY().canBlend(otherEllipse->radiusY())); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void BasicShapeRectangle::path(Path& path, const FloatRect& boundingBox) | |
| 89 { | |
| 90 ASSERT(path.isEmpty()); | |
| 91 path.addRoundedRect( | |
| 92 FloatRect( | |
| 93 floatValueForLength(m_x, boundingBox.width()) + boundingBox.x(), | |
| 94 floatValueForLength(m_y, boundingBox.height()) + boundingBox.y(), | |
| 95 floatValueForLength(m_width, boundingBox.width()), | |
| 96 floatValueForLength(m_height, boundingBox.height()) | |
| 97 ), | |
| 98 FloatSize( | |
| 99 floatValueForLength(m_cornerRadiusX, boundingBox.width()), | |
| 100 floatValueForLength(m_cornerRadiusY, boundingBox.height()) | |
| 101 ) | |
| 102 ); | |
| 103 } | |
| 104 | |
| 105 PassRefPtr<BasicShape> BasicShapeRectangle::blend(const BasicShape* other, doubl
e progress) const | |
| 106 { | |
| 107 ASSERT(other && isSameType(*other)); | |
| 108 | |
| 109 const BasicShapeRectangle* o = static_cast<const BasicShapeRectangle*>(other
); | |
| 110 RefPtr<BasicShapeRectangle> result = BasicShapeRectangle::create(); | |
| 111 result->setX(m_x.blend(o->x(), progress, ValueRangeAll)); | |
| 112 result->setY(m_y.blend(o->y(), progress, ValueRangeAll)); | |
| 113 result->setWidth(m_width.blend(o->width(), progress, ValueRangeNonNegative))
; | |
| 114 result->setHeight(m_height.blend(o->height(), progress, ValueRangeNonNegativ
e)); | |
| 115 result->setCornerRadiusX(m_cornerRadiusX.blend(o->cornerRadiusX(), progress,
ValueRangeNonNegative)); | |
| 116 result->setCornerRadiusY(m_cornerRadiusY.blend(o->cornerRadiusY(), progress,
ValueRangeNonNegative)); | |
| 117 return result.release(); | |
| 118 } | |
| 119 | |
| 120 bool BasicShapeRectangle::operator==(const BasicShape& o) const | |
| 121 { | |
| 122 if (!isSameType(o)) | |
| 123 return false; | |
| 124 const BasicShapeRectangle& other = toBasicShapeRectangle(o); | |
| 125 return m_y == other.m_y && m_x == other.m_x && m_width == other.m_width && m
_height == other.m_height && m_cornerRadiusX == other.m_cornerRadiusX && m_corne
rRadiusY == other.m_cornerRadiusY; | |
| 126 } | |
| 127 | |
| 128 bool DeprecatedBasicShapeCircle::operator==(const BasicShape& o) const | |
| 129 { | |
| 130 if (!isSameType(o)) | |
| 131 return false; | |
| 132 const DeprecatedBasicShapeCircle& other = toDeprecatedBasicShapeCircle(o); | |
| 133 return m_centerX == other.m_centerX && m_centerY == other.m_centerY && m_rad
ius == other.m_radius; | |
| 134 } | |
| 135 | |
| 136 void DeprecatedBasicShapeCircle::path(Path& path, const FloatRect& boundingBox) | |
| 137 { | |
| 138 ASSERT(path.isEmpty()); | |
| 139 float diagonal = hypotf(boundingBox.width(), boundingBox.height()) / sqrtf(2
); | |
| 140 float centerX = floatValueForLength(m_centerX, boundingBox.width()); | |
| 141 float centerY = floatValueForLength(m_centerY, boundingBox.height()); | |
| 142 float radius = floatValueForLength(m_radius, diagonal); | |
| 143 path.addEllipse(FloatRect( | |
| 144 centerX - radius + boundingBox.x(), | |
| 145 centerY - radius + boundingBox.y(), | |
| 146 radius * 2, | |
| 147 radius * 2 | |
| 148 )); | |
| 149 } | |
| 150 | |
| 151 PassRefPtr<BasicShape> DeprecatedBasicShapeCircle::blend(const BasicShape* other
, double progress) const | |
| 152 { | |
| 153 ASSERT(other && isSameType(*other)); | |
| 154 | |
| 155 const DeprecatedBasicShapeCircle* o = static_cast<const DeprecatedBasicShape
Circle*>(other); | |
| 156 RefPtr<DeprecatedBasicShapeCircle> result = DeprecatedBasicShapeCircle::cre
ate(); | |
| 157 result->setCenterX(m_centerX.blend(o->centerX(), progress, ValueRangeAll)); | |
| 158 result->setCenterY(m_centerY.blend(o->centerY(), progress, ValueRangeAll)); | |
| 159 result->setRadius(m_radius.blend(o->radius(), progress, ValueRangeNonNegativ
e)); | |
| 160 return result.release(); | |
| 161 } | |
| 162 | |
| 163 bool BasicShapeCircle::operator==(const BasicShape& o) const | 88 bool BasicShapeCircle::operator==(const BasicShape& o) const |
| 164 { | 89 { |
| 165 if (!isSameType(o)) | 90 if (!isSameType(o)) |
| 166 return false; | 91 return false; |
| 167 const BasicShapeCircle& other = toBasicShapeCircle(o); | 92 const BasicShapeCircle& other = toBasicShapeCircle(o); |
| 168 return m_centerX == other.m_centerX && m_centerY == other.m_centerY && m_rad
ius == other.m_radius; | 93 return m_centerX == other.m_centerX && m_centerY == other.m_centerY && m_rad
ius == other.m_radius; |
| 169 } | 94 } |
| 170 | 95 |
| 171 float BasicShapeCircle::floatValueForRadiusInBox(FloatSize boxSize) const | 96 float BasicShapeCircle::floatValueForRadiusInBox(FloatSize boxSize) const |
| 172 { | 97 { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 200 ASSERT(type() == other->type()); | 125 ASSERT(type() == other->type()); |
| 201 const BasicShapeCircle* o = static_cast<const BasicShapeCircle*>(other); | 126 const BasicShapeCircle* o = static_cast<const BasicShapeCircle*>(other); |
| 202 RefPtr<BasicShapeCircle> result = BasicShapeCircle::create(); | 127 RefPtr<BasicShapeCircle> result = BasicShapeCircle::create(); |
| 203 | 128 |
| 204 result->setCenterX(m_centerX.blend(o->centerX(), progress)); | 129 result->setCenterX(m_centerX.blend(o->centerX(), progress)); |
| 205 result->setCenterY(m_centerY.blend(o->centerY(), progress)); | 130 result->setCenterY(m_centerY.blend(o->centerY(), progress)); |
| 206 result->setRadius(m_radius.blend(o->radius(), progress)); | 131 result->setRadius(m_radius.blend(o->radius(), progress)); |
| 207 return result.release(); | 132 return result.release(); |
| 208 } | 133 } |
| 209 | 134 |
| 210 void DeprecatedBasicShapeEllipse::path(Path& path, const FloatRect& boundingBox) | |
| 211 { | |
| 212 ASSERT(path.isEmpty()); | |
| 213 float centerX = floatValueForLength(m_centerX, boundingBox.width()); | |
| 214 float centerY = floatValueForLength(m_centerY, boundingBox.height()); | |
| 215 float radiusX = floatValueForLength(m_radiusX, boundingBox.width()); | |
| 216 float radiusY = floatValueForLength(m_radiusY, boundingBox.height()); | |
| 217 path.addEllipse(FloatRect( | |
| 218 centerX - radiusX + boundingBox.x(), | |
| 219 centerY - radiusY + boundingBox.y(), | |
| 220 radiusX * 2, | |
| 221 radiusY * 2 | |
| 222 )); | |
| 223 } | |
| 224 | |
| 225 bool DeprecatedBasicShapeEllipse::operator==(const BasicShape& o) const | |
| 226 { | |
| 227 if (!isSameType(o)) | |
| 228 return false; | |
| 229 const DeprecatedBasicShapeEllipse& other = toDeprecatedBasicShapeEllipse(o); | |
| 230 return m_centerX == other.m_centerX && m_centerY == other.m_centerY && m_rad
iusX == other.m_radiusX && m_radiusY == other.m_radiusY; | |
| 231 } | |
| 232 | |
| 233 PassRefPtr<BasicShape> DeprecatedBasicShapeEllipse::blend(const BasicShape* othe
r, double progress) const | |
| 234 { | |
| 235 ASSERT(other && isSameType(*other)); | |
| 236 | |
| 237 const DeprecatedBasicShapeEllipse* o = static_cast<const DeprecatedBasicShap
eEllipse*>(other); | |
| 238 RefPtr<DeprecatedBasicShapeEllipse> result = DeprecatedBasicShapeEllipse::cr
eate(); | |
| 239 result->setCenterX(m_centerX.blend(o->centerX(), progress, ValueRangeAll)); | |
| 240 result->setCenterY(m_centerY.blend(o->centerY(), progress, ValueRangeAll)); | |
| 241 result->setRadiusX(m_radiusX.blend(o->radiusX(), progress, ValueRangeNonNega
tive)); | |
| 242 result->setRadiusY(m_radiusY.blend(o->radiusY(), progress, ValueRangeNonNega
tive)); | |
| 243 return result.release(); | |
| 244 } | |
| 245 | |
| 246 bool BasicShapeEllipse::operator==(const BasicShape& o) const | 135 bool BasicShapeEllipse::operator==(const BasicShape& o) const |
| 247 { | 136 { |
| 248 if (!isSameType(o)) | 137 if (!isSameType(o)) |
| 249 return false; | 138 return false; |
| 250 const BasicShapeEllipse& other = toBasicShapeEllipse(o); | 139 const BasicShapeEllipse& other = toBasicShapeEllipse(o); |
| 251 return m_centerX == other.m_centerX && m_centerY == other.m_centerY && m_rad
iusX == other.m_radiusX && m_radiusY == other.m_radiusY; | 140 return m_centerX == other.m_centerX && m_centerY == other.m_centerY && m_rad
iusX == other.m_radiusX && m_radiusY == other.m_radiusY; |
| 252 } | 141 } |
| 253 | 142 |
| 254 float BasicShapeEllipse::floatValueForRadiusInBox(const BasicShapeRadius& radius
, float center, float boxWidthOrHeight) const | 143 float BasicShapeEllipse::floatValueForRadiusInBox(const BasicShapeRadius& radius
, float center, float boxWidthOrHeight) const |
| 255 { | 144 { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 } | 230 } |
| 342 | 231 |
| 343 bool BasicShapePolygon::operator==(const BasicShape& o) const | 232 bool BasicShapePolygon::operator==(const BasicShape& o) const |
| 344 { | 233 { |
| 345 if (!isSameType(o)) | 234 if (!isSameType(o)) |
| 346 return false; | 235 return false; |
| 347 const BasicShapePolygon& other = toBasicShapePolygon(o); | 236 const BasicShapePolygon& other = toBasicShapePolygon(o); |
| 348 return m_windRule == other.m_windRule && m_values == other.m_values; | 237 return m_windRule == other.m_windRule && m_values == other.m_values; |
| 349 } | 238 } |
| 350 | 239 |
| 351 void BasicShapeInsetRectangle::path(Path& path, const FloatRect& boundingBox) | |
| 352 { | |
| 353 ASSERT(path.isEmpty()); | |
| 354 float left = floatValueForLength(m_left, boundingBox.width()); | |
| 355 float top = floatValueForLength(m_top, boundingBox.height()); | |
| 356 path.addRoundedRect( | |
| 357 FloatRect( | |
| 358 left + boundingBox.x(), | |
| 359 top + boundingBox.y(), | |
| 360 std::max<float>(boundingBox.width() - left - floatValueForLength(m_r
ight, boundingBox.width()), 0), | |
| 361 std::max<float>(boundingBox.height() - top - floatValueForLength(m_b
ottom, boundingBox.height()), 0) | |
| 362 ), | |
| 363 FloatSize( | |
| 364 floatValueForLength(m_cornerRadiusX, boundingBox.width()), | |
| 365 floatValueForLength(m_cornerRadiusY, boundingBox.height()) | |
| 366 ) | |
| 367 ); | |
| 368 } | |
| 369 | |
| 370 PassRefPtr<BasicShape> BasicShapeInsetRectangle::blend(const BasicShape* other,
double progress) const | |
| 371 { | |
| 372 ASSERT(other && isSameType(*other)); | |
| 373 | |
| 374 const BasicShapeInsetRectangle* o = static_cast<const BasicShapeInsetRectang
le*>(other); | |
| 375 RefPtr<BasicShapeInsetRectangle> result = BasicShapeInsetRectangle::create(
); | |
| 376 result->setTop(m_top.blend(o->top(), progress, ValueRangeNonNegative)); | |
| 377 result->setRight(m_right.blend(o->right(), progress, ValueRangeNonNegative))
; | |
| 378 result->setBottom(m_bottom.blend(o->bottom(), progress, ValueRangeNonNegativ
e)); | |
| 379 result->setLeft(m_left.blend(o->left(), progress, ValueRangeNonNegative)); | |
| 380 result->setCornerRadiusX(m_cornerRadiusX.blend(o->cornerRadiusX(), progress,
ValueRangeNonNegative)); | |
| 381 result->setCornerRadiusY(m_cornerRadiusY.blend(o->cornerRadiusY(), progress,
ValueRangeNonNegative)); | |
| 382 return result.release(); | |
| 383 } | |
| 384 | |
| 385 bool BasicShapeInsetRectangle::operator==(const BasicShape& o) const | |
| 386 { | |
| 387 if (!isSameType(o)) | |
| 388 return false; | |
| 389 const BasicShapeInsetRectangle& other = toBasicShapeInsetRectangle(o); | |
| 390 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; | |
| 391 } | |
| 392 | |
| 393 static FloatSize floatSizeForLengthSize(const LengthSize& lengthSize, const Floa
tRect& boundingBox) | 240 static FloatSize floatSizeForLengthSize(const LengthSize& lengthSize, const Floa
tRect& boundingBox) |
| 394 { | 241 { |
| 395 return FloatSize(floatValueForLength(lengthSize.width(), boundingBox.width()
), | 242 return FloatSize(floatValueForLength(lengthSize.width(), boundingBox.width()
), |
| 396 floatValueForLength(lengthSize.height(), boundingBox.height())); | 243 floatValueForLength(lengthSize.height(), boundingBox.height())); |
| 397 } | 244 } |
| 398 | 245 |
| 399 void BasicShapeInset::path(Path& path, const FloatRect& boundingBox) | 246 void BasicShapeInset::path(Path& path, const FloatRect& boundingBox) |
| 400 { | 247 { |
| 401 ASSERT(path.isEmpty()); | 248 ASSERT(path.isEmpty()); |
| 402 float left = floatValueForLength(m_left, boundingBox.width()); | 249 float left = floatValueForLength(m_left, boundingBox.width()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 431 && m_top == other.m_top | 278 && m_top == other.m_top |
| 432 && m_bottom == other.m_bottom | 279 && m_bottom == other.m_bottom |
| 433 && m_left == other.m_left | 280 && m_left == other.m_left |
| 434 && m_topLeftRadius == other.m_topLeftRadius | 281 && m_topLeftRadius == other.m_topLeftRadius |
| 435 && m_topRightRadius == other.m_topRightRadius | 282 && m_topRightRadius == other.m_topRightRadius |
| 436 && m_bottomRightRadius == other.m_bottomRightRadius | 283 && m_bottomRightRadius == other.m_bottomRightRadius |
| 437 && m_bottomLeftRadius == other.m_bottomLeftRadius; | 284 && m_bottomLeftRadius == other.m_bottomLeftRadius; |
| 438 } | 285 } |
| 439 | 286 |
| 440 } | 287 } |
| OLD | NEW |