| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 return m_centerX == other.m_centerX && m_centerY == other.m_centerY && m_rad
ius == other.m_radius; | 73 return m_centerX == other.m_centerX && m_centerY == other.m_centerY && m_rad
ius == other.m_radius; |
| 74 } | 74 } |
| 75 | 75 |
| 76 float BasicShapeCircle::floatValueForRadiusInBox(FloatSize boxSize) const | 76 float BasicShapeCircle::floatValueForRadiusInBox(FloatSize boxSize) const |
| 77 { | 77 { |
| 78 if (m_radius.type() == BasicShapeRadius::Value) | 78 if (m_radius.type() == BasicShapeRadius::Value) |
| 79 return floatValueForLength(m_radius.value(), hypotf(boxSize.width(), box
Size.height()) / sqrtf(2)); | 79 return floatValueForLength(m_radius.value(), hypotf(boxSize.width(), box
Size.height()) / sqrtf(2)); |
| 80 | 80 |
| 81 FloatPoint center = floatPointForCenterCoordinate(m_centerX, m_centerY, boxS
ize); | 81 FloatPoint center = floatPointForCenterCoordinate(m_centerX, m_centerY, boxS
ize); |
| 82 | 82 |
| 83 float widthDelta = std::abs(boxSize.width() - center.x()); |
| 84 float heightDelta = std::abs(boxSize.height() - center.y()); |
| 83 if (m_radius.type() == BasicShapeRadius::ClosestSide) | 85 if (m_radius.type() == BasicShapeRadius::ClosestSide) |
| 84 return std::min(std::min(center.x(), boxSize.width() - center.x()), std:
:min(center.y(), boxSize.height() - center.y())); | 86 return std::min(std::min(std::abs(center.x()), widthDelta), std::min(std
::abs(center.y()), heightDelta)); |
| 85 | 87 |
| 86 // If radius.type() == BasicShapeRadius::FarthestSide. | 88 // If radius.type() == BasicShapeRadius::FarthestSide. |
| 87 return std::max(std::max(center.x(), boxSize.width() - center.x()), std::max
(center.y(), boxSize.height() - center.y())); | 89 return std::max(std::max(center.x(), widthDelta), std::max(center.y(), heigh
tDelta)); |
| 88 } | 90 } |
| 89 | 91 |
| 90 void BasicShapeCircle::path(Path& path, const FloatRect& boundingBox) | 92 void BasicShapeCircle::path(Path& path, const FloatRect& boundingBox) |
| 91 { | 93 { |
| 92 ASSERT(path.isEmpty()); | 94 ASSERT(path.isEmpty()); |
| 93 FloatPoint center = floatPointForCenterCoordinate(m_centerX, m_centerY, boun
dingBox.size()); | 95 FloatPoint center = floatPointForCenterCoordinate(m_centerX, m_centerY, boun
dingBox.size()); |
| 94 float radius = floatValueForRadiusInBox(boundingBox.size()); | 96 float radius = floatValueForRadiusInBox(boundingBox.size()); |
| 95 path.addEllipse(FloatRect( | 97 path.addEllipse(FloatRect( |
| 96 center.x() - radius + boundingBox.x(), | 98 center.x() - radius + boundingBox.x(), |
| 97 center.y() - radius + boundingBox.y(), | 99 center.y() - radius + boundingBox.y(), |
| (...skipping 20 matching lines...) Expand all Loading... |
| 118 return false; | 120 return false; |
| 119 const BasicShapeEllipse& other = toBasicShapeEllipse(o); | 121 const BasicShapeEllipse& other = toBasicShapeEllipse(o); |
| 120 return m_centerX == other.m_centerX && m_centerY == other.m_centerY && m_rad
iusX == other.m_radiusX && m_radiusY == other.m_radiusY; | 122 return m_centerX == other.m_centerX && m_centerY == other.m_centerY && m_rad
iusX == other.m_radiusX && m_radiusY == other.m_radiusY; |
| 121 } | 123 } |
| 122 | 124 |
| 123 float BasicShapeEllipse::floatValueForRadiusInBox(const BasicShapeRadius& radius
, float center, float boxWidthOrHeight) const | 125 float BasicShapeEllipse::floatValueForRadiusInBox(const BasicShapeRadius& radius
, float center, float boxWidthOrHeight) const |
| 124 { | 126 { |
| 125 if (radius.type() == BasicShapeRadius::Value) | 127 if (radius.type() == BasicShapeRadius::Value) |
| 126 return floatValueForLength(radius.value(), boxWidthOrHeight); | 128 return floatValueForLength(radius.value(), boxWidthOrHeight); |
| 127 | 129 |
| 130 float widthOrHeightDelta = std::abs(boxWidthOrHeight - center); |
| 128 if (radius.type() == BasicShapeRadius::ClosestSide) | 131 if (radius.type() == BasicShapeRadius::ClosestSide) |
| 129 return std::min(center, boxWidthOrHeight - center); | 132 return std::min(std::abs(center), widthOrHeightDelta); |
| 130 | 133 |
| 131 ASSERT(radius.type() == BasicShapeRadius::FarthestSide); | 134 ASSERT(radius.type() == BasicShapeRadius::FarthestSide); |
| 132 return std::max(center, boxWidthOrHeight - center); | 135 return std::max(center, widthOrHeightDelta); |
| 133 } | 136 } |
| 134 | 137 |
| 135 void BasicShapeEllipse::path(Path& path, const FloatRect& boundingBox) | 138 void BasicShapeEllipse::path(Path& path, const FloatRect& boundingBox) |
| 136 { | 139 { |
| 137 ASSERT(path.isEmpty()); | 140 ASSERT(path.isEmpty()); |
| 138 FloatPoint center = floatPointForCenterCoordinate(m_centerX, m_centerY, boun
dingBox.size()); | 141 FloatPoint center = floatPointForCenterCoordinate(m_centerX, m_centerY, boun
dingBox.size()); |
| 139 float radiusX = floatValueForRadiusInBox(m_radiusX, center.x(), boundingBox.
width()); | 142 float radiusX = floatValueForRadiusInBox(m_radiusX, center.x(), boundingBox.
width()); |
| 140 float radiusY = floatValueForRadiusInBox(m_radiusY, center.y(), boundingBox.
height()); | 143 float radiusY = floatValueForRadiusInBox(m_radiusY, center.y(), boundingBox.
height()); |
| 141 path.addEllipse(FloatRect( | 144 path.addEllipse(FloatRect( |
| 142 center.x() - radiusX + boundingBox.x(), | 145 center.x() - radiusX + boundingBox.x(), |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 && m_top == other.m_top | 278 && m_top == other.m_top |
| 276 && m_bottom == other.m_bottom | 279 && m_bottom == other.m_bottom |
| 277 && m_left == other.m_left | 280 && m_left == other.m_left |
| 278 && m_topLeftRadius == other.m_topLeftRadius | 281 && m_topLeftRadius == other.m_topLeftRadius |
| 279 && m_topRightRadius == other.m_topRightRadius | 282 && m_topRightRadius == other.m_topRightRadius |
| 280 && m_bottomRightRadius == other.m_bottomRightRadius | 283 && m_bottomRightRadius == other.m_bottomRightRadius |
| 281 && m_bottomLeftRadius == other.m_bottomLeftRadius; | 284 && m_bottomLeftRadius == other.m_bottomLeftRadius; |
| 282 } | 285 } |
| 283 | 286 |
| 284 } | 287 } |
| OLD | NEW |