Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: include/core/SkRRect.h

Issue 202163004: Revert of Add nine patch type to SkRRect. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/core/SkRRect.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
82 //!< A fully general (non-empty) RR. Some of the x and/or y radii are 74 //!< A fully general (non-empty) RR. Some of the x and/or y radii are
83 //!< different from the others and there must be one corner where 75 //!< different from the others and there must be one corner where
84 //!< both radii are non-zero. 76 //!< both radii are non-zero.
85 kComplex_Type, 77 kComplex_Type,
86 }; 78 };
87 79
88 /** 80 /**
89 * Returns the RR's sub type. 81 * Returns the RR's sub type.
90 */ 82 */
91 Type getType() const { 83 Type getType() const {
92 SkDEBUGCODE(this->validate();) 84 SkDEBUGCODE(this->validate();)
93 85
94 if (kUnknown_Type == fType) { 86 if (kUnknown_Type == fType) {
95 this->computeType(); 87 this->computeType();
96 } 88 }
97 SkASSERT(kUnknown_Type != fType); 89 SkASSERT(kUnknown_Type != fType);
98 return fType; 90 return 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 {
108 return this->isSimple() && fRadii[0].fX == fRadii[0].fY; 100 return this->isSimple() && fRadii[0].fX == fRadii[0].fY;
109 } 101 }
110 inline bool isNinePatch() const { return kNinePatch_Type == this->getType(); }
111 inline bool isComplex() const { return kComplex_Type == this->getType(); } 102 inline bool isComplex() const { return kComplex_Type == this->getType(); }
112 103
113 bool allCornersCircular() const; 104 bool allCornersCircular() const;
114 105
106 /**
107 * Are both x-radii the same on the two left corners, and similar for the to p, right, and
108 * bottom. When this is the case the four ellipse centers form a rectangle.
109 */
110 bool isNinePatch() const {
111 return fRadii[kUpperLeft_Corner].fX == fRadii[kLowerLeft_Corner].fX &&
112 fRadii[kUpperRight_Corner].fX == fRadii[kLowerRight_Corner].fX &&
113 fRadii[kUpperLeft_Corner].fY == fRadii[kUpperRight_Corner].fY &&
114 fRadii[kLowerLeft_Corner].fY == fRadii[kLowerRight_Corner].fY;
115 }
116
115 SkScalar width() const { return fRect.width(); } 117 SkScalar width() const { return fRect.width(); }
116 SkScalar height() const { return fRect.height(); } 118 SkScalar height() const { return fRect.height(); }
117 119
118 /** 120 /**
119 * Set this RR to the empty rectangle (0,0,0,0) with 0 x & y radii. 121 * Set this RR to the empty rectangle (0,0,0,0) with 0 x & y radii.
120 */ 122 */
121 void setEmpty() { 123 void setEmpty() {
122 fRect.setEmpty(); 124 fRect.setEmpty();
123 memset(fRadii, 0, sizeof(fRadii)); 125 memset(fRadii, 0, sizeof(fRadii));
124 fType = kEmpty_Type; 126 fType = kEmpty_Type;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 165
164 SkDEBUGCODE(this->validate();) 166 SkDEBUGCODE(this->validate();)
165 } 167 }
166 168
167 /** 169 /**
168 * Initialize the RR with the same radii for all four corners. 170 * Initialize the RR with the same radii for all four corners.
169 */ 171 */
170 void setRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad); 172 void setRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad);
171 173
172 /** 174 /**
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 /**
179 * Initialize the RR with potentially different radii for all four corners. 175 * Initialize the RR with potentially different radii for all four corners.
180 */ 176 */
181 void setRectRadii(const SkRect& rect, const SkVector radii[4]); 177 void setRectRadii(const SkRect& rect, const SkVector radii[4]);
182 178
183 // The radii are stored in UL, UR, LR, LL order. 179 // The radii are stored in UL, UR, LR, LL order.
184 enum Corner { 180 enum Corner {
185 kUpperLeft_Corner, 181 kUpperLeft_Corner,
186 kUpperRight_Corner, 182 kUpperRight_Corner,
187 kLowerRight_Corner, 183 kLowerRight_Corner,
188 kLowerLeft_Corner 184 kLowerLeft_Corner
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 // uninitialized data 297 // uninitialized data
302 298
303 void computeType() const; 299 void computeType() const;
304 bool checkCornerContainment(SkScalar x, SkScalar y) const; 300 bool checkCornerContainment(SkScalar x, SkScalar y) const;
305 301
306 // to access fRadii directly 302 // to access fRadii directly
307 friend class SkPath; 303 friend class SkPath;
308 }; 304 };
309 305
310 #endif 306 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkRRect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698