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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 Negative radii are not allowed (they are clamped to zero). | 45 Negative radii are not allowed (they are clamped to zero). |
46 If the corner curves overlap they will be proportionally reduced to fit. | 46 If the corner curves overlap they will be proportionally reduced to fit. |
47 */ | 47 */ |
48 class SK_API SkRRect { | 48 class SK_API SkRRect { |
49 public: | 49 public: |
50 /** | 50 /** |
51 * Enum to capture the various possible subtypes of RR. Accessed | 51 * Enum to capture the various possible subtypes of RR. Accessed |
52 * by type(). The subtypes become progressively less restrictive. | 52 * by type(). The subtypes become progressively less restrictive. |
53 */ | 53 */ |
54 enum Type { | 54 enum Type { |
55 // !< Internal indicator that the sub type must be computed. | |
56 kUnknown_Type = -1, | |
57 | |
58 // !< The RR is empty | 55 // !< The RR is empty |
59 kEmpty_Type, | 56 kEmpty_Type, |
60 | 57 |
61 //!< The RR is actually a (non-empty) rect (i.e., at least one radius | 58 //!< The RR is actually a (non-empty) rect (i.e., at least one radius |
62 //!< at each corner is zero) | 59 //!< at each corner is zero) |
63 kRect_Type, | 60 kRect_Type, |
64 | 61 |
65 //!< The RR is actually a (non-empty) oval (i.e., all x radii are equal | 62 //!< 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 | 63 //!< and >= width/2 and all the y radii are equal and >= height/2 |
67 kOval_Type, | 64 kOval_Type, |
(...skipping 15 matching lines...) Expand all Loading... |
83 //!< different from the others and there must be one corner where | 80 //!< different from the others and there must be one corner where |
84 //!< both radii are non-zero. | 81 //!< both radii are non-zero. |
85 kComplex_Type, | 82 kComplex_Type, |
86 }; | 83 }; |
87 | 84 |
88 /** | 85 /** |
89 * Returns the RR's sub type. | 86 * Returns the RR's sub type. |
90 */ | 87 */ |
91 Type getType() const { | 88 Type getType() const { |
92 SkDEBUGCODE(this->validate();) | 89 SkDEBUGCODE(this->validate();) |
93 | |
94 if (kUnknown_Type == fType) { | |
95 this->computeType(); | |
96 } | |
97 SkASSERT(kUnknown_Type != fType); | |
98 return static_cast<Type>(fType); | 90 return static_cast<Type>(fType); |
99 } | 91 } |
100 | 92 |
101 Type type() const { return this->getType(); } | 93 Type type() const { return this->getType(); } |
102 | 94 |
103 inline bool isEmpty() const { return kEmpty_Type == this->getType(); } | 95 inline bool isEmpty() const { return kEmpty_Type == this->getType(); } |
104 inline bool isRect() const { return kRect_Type == this->getType(); } | 96 inline bool isRect() const { return kRect_Type == this->getType(); } |
105 inline bool isOval() const { return kOval_Type == this->getType(); } | 97 inline bool isOval() const { return kOval_Type == this->getType(); } |
106 inline bool isSimple() const { return kSimple_Type == this->getType(); } | 98 inline bool isSimple() const { return kSimple_Type == this->getType(); } |
107 inline bool isSimpleCircular() const { | 99 inline bool isSimpleCircular() const { |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 | 286 |
295 void dump(bool asHex) const; | 287 void dump(bool asHex) const; |
296 void dump() const { this->dump(false); } | 288 void dump() const { this->dump(false); } |
297 void dumpHex() const { this->dump(true); } | 289 void dumpHex() const { this->dump(true); } |
298 | 290 |
299 private: | 291 private: |
300 SkRect fRect; | 292 SkRect fRect; |
301 // Radii order is UL, UR, LR, LL. Use Corner enum to index into fRadii[] | 293 // Radii order is UL, UR, LR, LL. Use Corner enum to index into fRadii[] |
302 SkVector fRadii[4]; | 294 SkVector fRadii[4]; |
303 // use an explicitly sized type so we're sure the class is dense (no uniniti
alized bytes) | 295 // use an explicitly sized type so we're sure the class is dense (no uniniti
alized bytes) |
304 mutable int32_t fType; | 296 int32_t fType; |
305 // TODO: add padding so we can use memcpy for flattening and not copy | 297 // TODO: add padding so we can use memcpy for flattening and not copy |
306 // uninitialized data | 298 // uninitialized data |
307 | 299 |
308 void computeType() const; | 300 void computeType(); |
309 bool checkCornerContainment(SkScalar x, SkScalar y) const; | 301 bool checkCornerContainment(SkScalar x, SkScalar y) const; |
310 | 302 |
311 // to access fRadii directly | 303 // to access fRadii directly |
312 friend class SkPath; | 304 friend class SkPath; |
313 }; | 305 }; |
314 | 306 |
315 #endif | 307 #endif |
OLD | NEW |