8 #ifndef SkRRect_DEFINED
9 #define SkRRect_DEFINED
92 SkASSERT(this->isValid());
93 return static_cast<Type>(fType);
96 Type type()
const {
return this->getType(); }
98 inline bool isEmpty()
const {
return kEmpty_Type == this->getType(); }
99 inline bool isRect()
const {
return kRect_Type == this->getType(); }
100 inline bool isOval()
const {
return kOval_Type == this->getType(); }
101 inline bool isSimple()
const {
return kSimple_Type == this->getType(); }
104 inline bool isSimpleCircular()
const {
105 return this->isSimple() && SkScalarNearlyEqual(fRadii[0].fX, fRadii[0].fY);
107 inline bool isCircle()
const {
108 return this->isOval() && SkScalarNearlyEqual(fRadii[0].fX, fRadii[0].fY);
110 inline bool isNinePatch()
const {
return kNinePatch_Type == this->getType(); }
111 inline bool isComplex()
const {
return kComplex_Type == this->getType(); }
113 bool allCornersCircular(SkScalar tolerance = SK_ScalarNearlyZero)
const;
115 SkScalar width()
const {
return fRect.width(); }
116 SkScalar height()
const {
return fRect.height(); }
123 memset(fRadii, 0,
sizeof(fRadii));
126 SkASSERT(this->isValid());
136 if (fRect.isEmpty()) {
141 memset(fRadii, 0,
sizeof(fRadii));
144 SkASSERT(this->isValid());
165 static SkRRect MakeRectXY(
const SkRect& rect, SkScalar xRad, SkScalar yRad) {
179 if (fRect.isEmpty()) {
184 SkScalar xRad = SkScalarHalf(fRect.width());
185 SkScalar yRad = SkScalarHalf(fRect.height());
187 for (
int i = 0; i < 4; ++i) {
188 fRadii[i].set(xRad, yRad);
192 SkASSERT(this->isValid());
198 void setRectXY(
const SkRect& rect, SkScalar xRad, SkScalar yRad);
203 void setNinePatch(
const SkRect& rect, SkScalar leftRad, SkScalar topRad,
204 SkScalar rightRad, SkScalar bottomRad);
219 const SkRect& rect()
const {
return fRect; }
220 const SkVector& radii(Corner corner)
const {
return fRadii[corner]; }
221 const SkRect& getBounds()
const {
return fRect; }
228 SkASSERT(!this->isComplex());
233 return a.fRect == b.fRect &&
239 return a.fRect != b.fRect ||
252 void inset(SkScalar dx, SkScalar dy,
SkRRect* dst)
const;
254 void inset(SkScalar dx, SkScalar dy) {
255 this->inset(dx, dy,
this);
267 this->inset(-dx, -dy, dst);
269 void outset(SkScalar dx, SkScalar dy) {
270 this->inset(-dx, -dy,
this);
277 fRect.offset(dx, dy);
280 SkRRect SK_WARN_UNUSED_RESULT makeOffset(SkScalar dx, SkScalar dy)
const {
281 return SkRRect(fRect.makeOffset(dx, dy), fRadii, fType);
288 bool contains(
const SkRect& rect)
const;
290 bool isValid()
const;
293 kSizeInMemory = 12 *
sizeof(SkScalar)
301 size_t writeToMemory(
void* buffer)
const;
314 size_t readFromMemory(
const void* buffer,
size_t length);
327 void dump(
bool asHex)
const;
328 void dump()
const { this->dump(
false); }
329 void dumpHex()
const { this->dump(
true); }
334 , fRadii{radii[0], radii[1], radii[2], radii[3]}
346 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:47
The SkPath class encapsulates compound (multiple contour) geometric paths consisting of straight line...
Definition: SkPath.h:25
void sort()
Swap top/bottom or left/right if there are flipped (i.e.
Definition: SkRect.h:900
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:57
Definition: SkPoint.h:156
The SkMatrix class holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:28
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:276
Type getType() const
Returns the RR's sub type.
Definition: SkRRect.h:91
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:266
const SkVector & getSimpleRadii() const
When a rrect is simple, all of its radii are equal.
Definition: SkRRect.h:227
void setOval(const SkRect &oval)
Set this RR to match the supplied oval.
Definition: SkRRect.h:175
void setEmpty()
Set this RR to the empty rectangle (0,0,0,0) with 0 x & y radii.
Definition: SkRRect.h:121
void setRect(const SkRect &rect)
Set this RR to match the supplied rect.
Definition: SkRRect.h:132