8 #ifndef SkRRect_DEFINED
9 #define SkRRect_DEFINED
93 SkDEBUGCODE(this->validate();)
94 return static_cast<Type>(fType);
97 Type type()
const {
return this->getType(); }
99 inline bool isEmpty()
const {
return kEmpty_Type == this->getType(); }
100 inline bool isRect()
const {
return kRect_Type == this->getType(); }
101 inline bool isOval()
const {
return kOval_Type == this->getType(); }
102 inline bool isSimple()
const {
return kSimple_Type == this->getType(); }
105 inline bool isSimpleCircular()
const {
106 return this->isSimple() && SkScalarNearlyEqual(fRadii[0].fX, fRadii[0].fY);
108 inline bool isCircle()
const {
109 return this->isOval() && SkScalarNearlyEqual(fRadii[0].fX, fRadii[0].fY);
111 inline bool isNinePatch()
const {
return kNinePatch_Type == this->getType(); }
112 inline bool isComplex()
const {
return kComplex_Type == this->getType(); }
114 bool allCornersCircular()
const;
116 SkScalar width()
const {
return fRect.width(); }
117 SkScalar height()
const {
return fRect.height(); }
124 memset(fRadii, 0,
sizeof(fRadii));
127 SkDEBUGCODE(this->validate();)
137 if (fRect.isEmpty()) {
142 memset(fRadii, 0,
sizeof(fRadii));
145 SkDEBUGCODE(this->validate();)
166 static SkRRect MakeRectXY(
const SkRect& rect, SkScalar xRad, SkScalar yRad) {
180 if (fRect.isEmpty()) {
185 SkScalar xRad = SkScalarHalf(fRect.width());
186 SkScalar yRad = SkScalarHalf(fRect.height());
188 for (
int i = 0; i < 4; ++i) {
189 fRadii[i].set(xRad, yRad);
193 SkDEBUGCODE(this->validate();)
199 void setRectXY(
const SkRect& rect, SkScalar xRad, SkScalar yRad);
204 void setNinePatch(
const SkRect& rect, SkScalar leftRad, SkScalar topRad,
205 SkScalar rightRad, SkScalar bottomRad);
220 const SkRect& rect()
const {
return fRect; }
221 const SkVector& radii(Corner corner)
const {
return fRadii[corner]; }
222 const SkRect& getBounds()
const {
return fRect; }
229 SkASSERT(!this->isComplex());
234 return a.fRect == b.fRect &&
240 return a.fRect != b.fRect ||
253 void inset(SkScalar dx, SkScalar dy,
SkRRect* dst)
const;
255 void inset(SkScalar dx, SkScalar dy) {
256 this->inset(dx, dy,
this);
268 this->inset(-dx, -dy, dst);
270 void outset(SkScalar dx, SkScalar dy) {
271 this->inset(-dx, -dy,
this);
278 fRect.offset(dx, dy);
281 SkRRect SK_WARN_UNUSED_RESULT makeOffset(SkScalar dx, SkScalar dy)
const {
282 return SkRRect(fRect.makeOffset(dx, dy), fRadii, fType);
289 bool contains(
const SkRect& rect)
const;
291 SkDEBUGCODE(
void validate()
const;)
294 kSizeInMemory = 12 *
sizeof(SkScalar)
302 size_t writeToMemory(
void* buffer)
const;
315 size_t readFromMemory(
const void* buffer,
size_t length);
328 void dump(
bool asHex)
const;
329 void dump()
const { this->dump(
false); }
330 void dumpHex()
const { this->dump(
true); }
335 , fRadii{radii[0], radii[1], radii[2], radii[3]}
347 bool checkCornerContainment(SkScalar x, SkScalar y)
const;
The SkRRect class represents a rounded rect with a potentially different radii for each corner...
Definition: SkRRect.h:48
The SkPath class encapsulates compound (multiple contour) geometric paths consisting of straight line...
Definition: SkPath.h:27
void sort()
Swap top/bottom or left/right if there are flipped (i.e.
Definition: SkRect.h:878
void setRectXY(const SkRect &rect, SkScalar xRad, SkScalar yRad)
Initialize the RR with the same radii for all four corners.
Type
Enum to capture the various possible subtypes of RR.
Definition: SkRRect.h:58
Definition: SkPoint.h:156
The SkMatrix class holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:26
const SkScalar * asScalars() const
cast-safe way to treat the point as an array of (2) SkScalars.
Definition: SkPoint.h:547
void offset(SkScalar dx, SkScalar dy)
Translate the rrect by (dx, dy).
Definition: SkRRect.h:277
Type getType() const
Returns the RR's sub type.
Definition: SkRRect.h:92
void outset(SkScalar dx, SkScalar dy, SkRRect *dst) const
Call outset on the bounds, and adjust the radii to reflect what happens in stroking: If the corner is...
Definition: SkRRect.h:267
const SkVector & getSimpleRadii() const
When a rrect is simple, all of its radii are equal.
Definition: SkRRect.h:228
void setOval(const SkRect &oval)
Set this RR to match the supplied oval.
Definition: SkRRect.h:176
void setEmpty()
Set this RR to the empty rectangle (0,0,0,0) with 0 x & y radii.
Definition: SkRRect.h:122
void setRect(const SkRect &rect)
Set this RR to match the supplied rect.
Definition: SkRRect.h:133