| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkRRect_DEFINED | 8 #ifndef SkRRect_DEFINED |
| 9 #define SkRRect_DEFINED | 9 #define SkRRect_DEFINED |
| 10 | 10 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 //!< The RR is actually a (non-empty) oval (i.e., all x radii are equal | 65 //!< The RR is actually a (non-empty) oval (i.e., all x radii are equal |
| 66 //!< and >= width/2 and all the y radii are equal and >= height/2 | 66 //!< and >= width/2 and all the y radii are equal and >= height/2 |
| 67 kOval_Type, | 67 kOval_Type, |
| 68 | 68 |
| 69 //!< The RR is non-empty and all the x radii are equal & all y radii | 69 //!< The RR is non-empty and all the x radii are equal & all y radii |
| 70 //!< are equal but it is not an oval (i.e., there are lines between | 70 //!< are equal but it is not an oval (i.e., there are lines between |
| 71 //!< the curves) nor a rect (i.e., both radii are non-zero) | 71 //!< the curves) nor a rect (i.e., both radii are non-zero) |
| 72 kSimple_Type, | 72 kSimple_Type, |
| 73 | 73 |
| 74 //!< The RR is non-empty and the two left x radii are equal, the two top |
| 75 //!< y radii are equal, and the same for the right and bottom but it is |
| 76 //!< neither an rect, oval, nor a simple RR. It is called "nine patch" |
| 77 //!< because the centers of the corner ellipses form an axis aligned |
| 78 //!< rect with edges that divide the RR into an 9 rectangular patches: |
| 79 //!< an interior patch, four edge patches, and four corner patches. |
| 80 kNinePatch_Type, |
| 81 |
| 74 //!< A fully general (non-empty) RR. Some of the x and/or y radii are | 82 //!< A fully general (non-empty) RR. Some of the x and/or y radii are |
| 75 //!< different from the others and there must be one corner where | 83 //!< different from the others and there must be one corner where |
| 76 //!< both radii are non-zero. | 84 //!< both radii are non-zero. |
| 77 kComplex_Type, | 85 kComplex_Type, |
| 78 }; | 86 }; |
| 79 | 87 |
| 80 /** | 88 /** |
| 81 * Returns the RR's sub type. | 89 * Returns the RR's sub type. |
| 82 */ | 90 */ |
| 83 Type getType() const { | 91 Type getType() const { |
| 84 SkDEBUGCODE(this->validate();) | 92 SkDEBUGCODE(this->validate();) |
| 85 | 93 |
| 86 if (kUnknown_Type == fType) { | 94 if (kUnknown_Type == fType) { |
| 87 this->computeType(); | 95 this->computeType(); |
| 88 } | 96 } |
| 89 SkASSERT(kUnknown_Type != fType); | 97 SkASSERT(kUnknown_Type != fType); |
| 90 return fType; | 98 return fType; |
| 91 } | 99 } |
| 92 | 100 |
| 93 Type type() const { return this->getType(); } | 101 Type type() const { return this->getType(); } |
| 94 | 102 |
| 95 inline bool isEmpty() const { return kEmpty_Type == this->getType(); } | 103 inline bool isEmpty() const { return kEmpty_Type == this->getType(); } |
| 96 inline bool isRect() const { return kRect_Type == this->getType(); } | 104 inline bool isRect() const { return kRect_Type == this->getType(); } |
| 97 inline bool isOval() const { return kOval_Type == this->getType(); } | 105 inline bool isOval() const { return kOval_Type == this->getType(); } |
| 98 inline bool isSimple() const { return kSimple_Type == this->getType(); } | 106 inline bool isSimple() const { return kSimple_Type == this->getType(); } |
| 99 inline bool isSimpleCircular() const { | 107 inline bool isSimpleCircular() const { |
| 100 return this->isSimple() && fRadii[0].fX == fRadii[0].fY; | 108 return this->isSimple() && fRadii[0].fX == fRadii[0].fY; |
| 101 } | 109 } |
| 110 inline bool isNinePatch() const { return kNinePatch_Type == this->getType();
} |
| 102 inline bool isComplex() const { return kComplex_Type == this->getType(); } | 111 inline bool isComplex() const { return kComplex_Type == this->getType(); } |
| 103 | 112 |
| 104 bool allCornersCircular() const; | 113 bool allCornersCircular() const; |
| 105 | 114 |
| 106 SkScalar width() const { return fRect.width(); } | 115 SkScalar width() const { return fRect.width(); } |
| 107 SkScalar height() const { return fRect.height(); } | 116 SkScalar height() const { return fRect.height(); } |
| 108 | 117 |
| 109 /** | 118 /** |
| 110 * Set this RR to the empty rectangle (0,0,0,0) with 0 x & y radii. | 119 * Set this RR to the empty rectangle (0,0,0,0) with 0 x & y radii. |
| 111 */ | 120 */ |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 163 |
| 155 SkDEBUGCODE(this->validate();) | 164 SkDEBUGCODE(this->validate();) |
| 156 } | 165 } |
| 157 | 166 |
| 158 /** | 167 /** |
| 159 * Initialize the RR with the same radii for all four corners. | 168 * Initialize the RR with the same radii for all four corners. |
| 160 */ | 169 */ |
| 161 void setRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad); | 170 void setRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad); |
| 162 | 171 |
| 163 /** | 172 /** |
| 173 * Initialize the rr with one radius per-side. |
| 174 */ |
| 175 void setNinePatch(const SkRect& rect, SkScalar leftRad, SkScalar topRad, |
| 176 SkScalar rightRad, SkScalar bottomRad); |
| 177 |
| 178 /** |
| 164 * Initialize the RR with potentially different radii for all four corners. | 179 * Initialize the RR with potentially different radii for all four corners. |
| 165 */ | 180 */ |
| 166 void setRectRadii(const SkRect& rect, const SkVector radii[4]); | 181 void setRectRadii(const SkRect& rect, const SkVector radii[4]); |
| 167 | 182 |
| 168 // The radii are stored in UL, UR, LR, LL order. | 183 // The radii are stored in UL, UR, LR, LL order. |
| 169 enum Corner { | 184 enum Corner { |
| 170 kUpperLeft_Corner, | 185 kUpperLeft_Corner, |
| 171 kUpperRight_Corner, | 186 kUpperRight_Corner, |
| 172 kLowerRight_Corner, | 187 kLowerRight_Corner, |
| 173 kLowerLeft_Corner | 188 kLowerLeft_Corner |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 // uninitialized data | 301 // uninitialized data |
| 287 | 302 |
| 288 void computeType() const; | 303 void computeType() const; |
| 289 bool checkCornerContainment(SkScalar x, SkScalar y) const; | 304 bool checkCornerContainment(SkScalar x, SkScalar y) const; |
| 290 | 305 |
| 291 // to access fRadii directly | 306 // to access fRadii directly |
| 292 friend class SkPath; | 307 friend class SkPath; |
| 293 }; | 308 }; |
| 294 | 309 |
| 295 #endif | 310 #endif |
| OLD | NEW |