8 #ifndef SkRRect_DEFINED
9 #define SkRRect_DEFINED
73 kLastType = kComplex_Type,
77 SkASSERT(this->isValid());
78 return static_cast<Type>(fType);
83 inline bool isEmpty()
const {
return kEmpty_Type == this->getType(); }
84 inline bool isRect()
const {
return kRect_Type == this->getType(); }
85 inline bool isOval()
const {
return kOval_Type == this->getType(); }
86 inline bool isSimple()
const {
return kSimple_Type == this->getType(); }
87 inline bool isNinePatch()
const {
return kNinePatch_Type == this->getType(); }
88 inline bool isComplex()
const {
return kComplex_Type == this->getType(); }
127 if (!this->initializeRect(rect)) {
131 memset(fRadii, 0,
sizeof(fRadii));
134 SkASSERT(this->isValid());
291 return a.fRect == b.fRect &&
SkScalarsEqual(&a.fRadii[0].fX, &b.fRadii[0].fX, 8);
304 return a.fRect != b.fRect || !
SkScalarsEqual(&a.fRadii[0].fX, &b.fRadii[0].fX, 8);
342 this->inset(dx, dy,
this);
361 this->inset(-dx, -dy, dst);
379 this->inset(-dx, -dy,
this);
388 fRect.offset(dx, dy);
398 return SkRRect(fRect.makeOffset(dx, dy), fRadii, fType);
422 static constexpr
size_t kSizeInMemory = 12 *
sizeof(
SkScalar);
486 static bool AreRectAndRadiiValid(
const SkRect&,
const SkVector[4]);
488 SkRRect(
const SkRect& rect,
const SkVector radii[4], int32_t type)
490 , fRadii{radii[0], radii[1], radii[2], radii[3]}
497 bool initializeRect(
const SkRect&);
506 SkVector fRadii[4] = {{0, 0}, {0, 0}, {0,0}, {0,0}};
508 int32_t fType = kEmpty_Type;
513 friend class SkRRectPriv;
float SkScalar
Definition: SkScalar.h:14
static bool SkScalarsEqual(const SkScalar a[], const SkScalar b[], int n)
Definition: SkScalar.h:163
SkMatrix holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:53
SkPath contain geometry.
Definition: SkPath.h:58
SkRRect describes a rounded rectangle with a bounds and a pair of radii for each corner.
Definition: SkRRect.h:35
void dump() const
Writes text representation of SkRRect to standard output.
Definition: SkRRect.h:476
SkVector getSimpleRadii() const
Returns top-left corner radii.
Definition: SkRRect.h:111
void outset(SkScalar dx, SkScalar dy, SkRRect *dst) const
Outsets dst bounds by dx and dy, and adjusts radii by dx and dy.
Definition: SkRRect.h:360
bool isOval() const
Definition: SkRRect.h:85
Type getType() const
Definition: SkRRect.h:76
void dumpHex() const
Writes text representation of SkRRect to standard output.
Definition: SkRRect.h:483
SkVector radii(Corner corner) const
Returns scalar pair for radius of curve on x-axis and y-axis for one corner.
Definition: SkRRect.h:271
Type
Definition: SkRRect.h:66
@ kOval_Type
non-zero width and height filled with radii
Definition: SkRRect.h:69
@ kSimple_Type
non-zero width and height with equal radii
Definition: SkRRect.h:70
@ kEmpty_Type
zero width or height
Definition: SkRRect.h:67
@ kNinePatch_Type
non-zero width and height with axis-aligned radii
Definition: SkRRect.h:71
@ kRect_Type
non-zero width and height, and zeroed radii
Definition: SkRRect.h:68
@ kComplex_Type
non-zero width and height with arbitrary radii
Definition: SkRRect.h:72
SkRRect()=default
Initializes bounds at (0, 0), the origin, with zero width and height.
SkRRect & operator=(const SkRRect &rrect)=default
Copies rrect bounds and corner radii.
friend bool operator==(const SkRRect &a, const SkRRect &b)
Returns true if bounds and radii in a are equal to bounds and radii in b.
Definition: SkRRect.h:290
SkString dumpToString(bool asHex) const
static SkRRect MakeOval(const SkRect &oval)
Sets bounds to oval, x-axis radii to half oval.width(), and all y-axis radii to half oval....
Definition: SkRRect.h:162
const SkRect & getBounds() const
Returns bounds.
Definition: SkRRect.h:279
void inset(SkScalar dx, SkScalar dy, SkRRect *dst) const
Copies SkRRect to dst, then insets dst bounds by dx and dy, and adjusts dst radii by dx and dy.
friend bool operator!=(const SkRRect &a, const SkRRect &b)
Returns true if bounds and radii in a are not equal to bounds and radii in b.
Definition: SkRRect.h:303
SkRRect(const SkRRect &rrect)=default
Initializes to copy of rrect bounds and corner radii.
void setEmpty()
Sets bounds to zero width and height at (0, 0), the origin.
Definition: SkRRect.h:118
size_t readFromMemory(const void *buffer, size_t length)
Reads SkRRect from buffer, reading kSizeInMemory bytes.
Corner
Definition: SkRRect.h:251
@ kUpperLeft_Corner
index of top-left corner radii
Definition: SkRRect.h:252
@ kLowerRight_Corner
index of bottom-right corner radii
Definition: SkRRect.h:254
@ kUpperRight_Corner
index of top-right corner radii
Definition: SkRRect.h:253
@ kLowerLeft_Corner
index of bottom-left corner radii
Definition: SkRRect.h:255
const SkRect & rect() const
Returns bounds.
Definition: SkRRect.h:264
bool transform(const SkMatrix &matrix, SkRRect *dst) const
Transforms by SkRRect by matrix, storing result in dst.
static SkRRect MakeRect(const SkRect &r)
Initializes to copy of r bounds and zeroes corner radii.
Definition: SkRRect.h:149
bool isNinePatch() const
Definition: SkRRect.h:87
size_t writeToMemory(void *buffer) const
Writes SkRRect to buffer.
void dump(bool asHex) const
Writes text representation of SkRRect to standard output.
void setOval(const SkRect &oval)
Sets bounds to oval, x-axis radii to half oval.width(), and all y-axis radii to half oval....
SkScalar width() const
Returns span on the x-axis.
Definition: SkRRect.h:95
void offset(SkScalar dx, SkScalar dy)
Translates SkRRect by (dx, dy).
Definition: SkRRect.h:387
static SkRRect MakeRectXY(const SkRect &rect, SkScalar xRad, SkScalar yRad)
Sets to rounded rectangle with the same radii for all four corners.
Definition: SkRRect.h:180
void outset(SkScalar dx, SkScalar dy)
Outsets bounds by dx and dy, and adjusts radii by dx and dy.
Definition: SkRRect.h:378
bool isRect() const
Definition: SkRRect.h:84
void setRectRadii(const SkRect &rect, const SkVector radii[4])
Sets bounds to rect.
bool contains(const SkRect &rect) const
Returns true if rect is inside the bounds and corner radii, and if SkRRect and rect are not empty.
Type type() const
Definition: SkRRect.h:81
bool isEmpty() const
Definition: SkRRect.h:83
SkRRect makeOffset(SkScalar dx, SkScalar dy) const
Returns SkRRect translated by (dx, dy).
Definition: SkRRect.h:397
void setRectXY(const SkRect &rect, SkScalar xRad, SkScalar yRad)
Sets to rounded rectangle with the same radii for all four corners.
SkScalar height() const
Returns span on the y-axis.
Definition: SkRRect.h:102
void setNinePatch(const SkRect &rect, SkScalar leftRad, SkScalar topRad, SkScalar rightRad, SkScalar bottomRad)
Sets bounds to rect.
void inset(SkScalar dx, SkScalar dy)
Insets bounds by dx and dy, and adjusts radii by dx and dy.
Definition: SkRRect.h:341
bool isSimple() const
Definition: SkRRect.h:86
bool isComplex() const
Definition: SkRRect.h:88
bool isValid() const
Returns true if bounds and radii values are finite and describe a SkRRect SkRRect::Type that matches ...
void setRect(const SkRect &rect)
Sets bounds to sorted rect, and sets corner radii to zero.
Definition: SkRRect.h:126
static SkRRect MakeEmpty()
Initializes bounds at (0, 0), the origin, with zero width and height.
Definition: SkRRect.h:142
Light weight class for managing strings.
Definition: SkString.h:118
SkRect holds four float coordinates describing the upper and lower bounds of a rectangle.
Definition: SkRect.h:582
static constexpr SkRect MakeEmpty()
Returns constructed SkRect set to (0, 0, 0, 0).
Definition: SkRect.h:595