OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2013 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 void setBottomLeft(const FloatSize& size) { m_bottomLeft = size; } | 69 void setBottomLeft(const FloatSize& size) { m_bottomLeft = size; } |
70 void setBottomRight(const FloatSize& size) { m_bottomRight = size; } | 70 void setBottomRight(const FloatSize& size) { m_bottomRight = size; } |
71 const FloatSize& topLeft() const { return m_topLeft; } | 71 const FloatSize& topLeft() const { return m_topLeft; } |
72 const FloatSize& topRight() const { return m_topRight; } | 72 const FloatSize& topRight() const { return m_topRight; } |
73 const FloatSize& bottomLeft() const { return m_bottomLeft; } | 73 const FloatSize& bottomLeft() const { return m_bottomLeft; } |
74 const FloatSize& bottomRight() const { return m_bottomRight; } | 74 const FloatSize& bottomRight() const { return m_bottomRight; } |
75 | 75 |
76 bool isZero() const; | 76 bool isZero() const; |
77 | 77 |
78 void scale(float factor); | 78 void scale(float factor); |
79 // Multiply all radii by |factor| and floor the result to the nearest intege
r. | 79 // Multiply all radii by |factor| and floor the result to the nearest |
| 80 // integer. |
80 void scaleAndFloor(float factor); | 81 void scaleAndFloor(float factor); |
81 | 82 |
82 void expand(float topWidth, | 83 void expand(float topWidth, |
83 float bottomWidth, | 84 float bottomWidth, |
84 float leftWidth, | 85 float leftWidth, |
85 float rightWidth); | 86 float rightWidth); |
86 void expand(float size) { expand(size, size, size, size); } | 87 void expand(float size) { expand(size, size, size, size); } |
87 | 88 |
88 void shrink(float topWidth, | 89 void shrink(float topWidth, |
89 float bottomWidth, | 90 float bottomWidth, |
(...skipping 29 matching lines...) Expand all Loading... |
119 bool isRounded() const { return !m_radii.isZero(); } | 120 bool isRounded() const { return !m_radii.isZero(); } |
120 bool isEmpty() const { return m_rect.isEmpty(); } | 121 bool isEmpty() const { return m_rect.isEmpty(); } |
121 | 122 |
122 void setRect(const FloatRect& rect) { m_rect = rect; } | 123 void setRect(const FloatRect& rect) { m_rect = rect; } |
123 void setRadii(const Radii& radii) { m_radii = radii; } | 124 void setRadii(const Radii& radii) { m_radii = radii; } |
124 | 125 |
125 void move(const FloatSize& size) { m_rect.move(size); } | 126 void move(const FloatSize& size) { m_rect.move(size); } |
126 void inflateWithRadii(int size); | 127 void inflateWithRadii(int size); |
127 void inflate(float size) { m_rect.inflate(size); } | 128 void inflate(float size) { m_rect.inflate(size); } |
128 | 129 |
129 // expandRadii() does not have any effect on corner radii which have zero widt
h or height. This is because the process of expanding | 130 // expandRadii() does not have any effect on corner radii which have zero |
130 // the radius of a corner is not allowed to make sharp corners non-sharp. This
applies when "spreading" a shadow or | 131 // width or height. This is because the process of expanding the radius of a |
131 // a box shape. | 132 // corner is not allowed to make sharp corners non-sharp. This applies when |
| 133 // "spreading" a shadow or a box shape. |
132 void expandRadii(float size) { m_radii.expand(size); } | 134 void expandRadii(float size) { m_radii.expand(size); } |
133 void shrinkRadii(float size) { m_radii.shrink(size); } | 135 void shrinkRadii(float size) { m_radii.shrink(size); } |
134 | 136 |
135 // Returns a quickly computed rect enclosed by the rounded rect. | 137 // Returns a quickly computed rect enclosed by the rounded rect. |
136 FloatRect radiusCenterRect() const; | 138 FloatRect radiusCenterRect() const; |
137 | 139 |
138 FloatRect topLeftCorner() const { | 140 FloatRect topLeftCorner() const { |
139 return FloatRect(m_rect.x(), m_rect.y(), m_radii.topLeft().width(), | 141 return FloatRect(m_rect.x(), m_rect.y(), m_radii.topLeft().width(), |
140 m_radii.topLeft().height()); | 142 m_radii.topLeft().height()); |
141 } | 143 } |
(...skipping 22 matching lines...) Expand all Loading... |
164 bool includeLogicalLeftEdge, | 166 bool includeLogicalLeftEdge, |
165 bool includeLogicalRightEdge); | 167 bool includeLogicalRightEdge); |
166 | 168 |
167 // Tests whether the quad intersects any part of this rounded rectangle. | 169 // Tests whether the quad intersects any part of this rounded rectangle. |
168 // This only works for convex quads. | 170 // This only works for convex quads. |
169 bool intersectsQuad(const FloatQuad&) const; | 171 bool intersectsQuad(const FloatQuad&) const; |
170 | 172 |
171 void adjustRadii(); | 173 void adjustRadii(); |
172 bool isRenderable() const; | 174 bool isRenderable() const; |
173 | 175 |
174 // Constrains the radii to be no more than the size of rect(); radii outside o
f this range are not | 176 // Constrains the radii to be no more than the size of rect(); radii outside |
175 // defined. | 177 // of this range are not defined. In addition, the radii of the corners are |
176 // In addition, the radii of the corners are floored to the nearest integer. | 178 // floored to the nearest integer. |
177 // FIXME: the flooring should not be necessary. At the moment it causes backgr
ound bleed in some cases. | 179 // FIXME: the flooring should not be necessary. At the moment it causes |
178 // FIXME: this code is almost the same as adjustRadii()/isRenderable(). Get ri
d of one of them. | 180 // background bleed in some cases. |
| 181 // FIXME: this code is almost the same as adjustRadii()/isRenderable(). Get |
| 182 // rid of one of them. |
179 void constrainRadii(); | 183 void constrainRadii(); |
180 | 184 |
181 operator SkRRect() const; | 185 operator SkRRect() const; |
182 | 186 |
183 String toString() const; | 187 String toString() const; |
184 | 188 |
185 private: | 189 private: |
186 FloatRect m_rect; | 190 FloatRect m_rect; |
187 Radii m_radii; | 191 Radii m_radii; |
188 }; | 192 }; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 } | 229 } |
226 | 230 |
227 // Redeclared here to avoid ODR issues. | 231 // Redeclared here to avoid ODR issues. |
228 // See platform/testing/GeometryPrinters.h. | 232 // See platform/testing/GeometryPrinters.h. |
229 void PrintTo(const FloatRoundedRect&, std::ostream*); | 233 void PrintTo(const FloatRoundedRect&, std::ostream*); |
230 void PrintTo(const FloatRoundedRect::Radii&, std::ostream*); | 234 void PrintTo(const FloatRoundedRect::Radii&, std::ostream*); |
231 | 235 |
232 } // namespace blink | 236 } // namespace blink |
233 | 237 |
234 #endif // FloatRoundedRect_h | 238 #endif // FloatRoundedRect_h |
OLD | NEW |