 |
Skia
2D Graphics Library
|
Go to the documentation of this file.
8 #ifndef SkRRect_DEFINED
9 #define SkRRect_DEFINED
69 kLastType = kComplex_Type,
74 return static_cast<Type>(fType);
79 inline bool isEmpty()
const {
return kEmpty_Type == this->getType(); }
80 inline bool isRect()
const {
return kRect_Type == this->getType(); }
81 inline bool isOval()
const {
return kOval_Type == this->getType(); }
82 inline bool isSimple()
const {
return kSimple_Type == this->getType(); }
83 inline bool isNinePatch()
const {
return kNinePatch_Type == this->getType(); }
84 inline bool isComplex()
const {
return kComplex_Type == this->getType(); }
123 if (!this->initializeRect(rect)) {
127 memset(fRadii, 0,
sizeof(fRadii));
338 this->inset(dx, dy,
this);
357 this->inset(-dx, -dy, dst);
375 this->inset(-dx, -dy,
this);
384 fRect.offset(dx, dy);
394 return SkRRect(fRect.makeOffset(dx, dy), fRadii, fType);
418 static constexpr
size_t kSizeInMemory = 12 *
sizeof(
SkScalar);
482 static bool AreRectAndRadiiValid(
const SkRect&,
const SkVector[4]);
486 , fRadii{radii[0], radii[1], radii[2], radii[3]}
493 bool initializeRect(
const SkRect&);
502 SkVector fRadii[4] = {{0, 0}, {0, 0}, {0,0}, {0,0}};
504 int32_t fType = kEmpty_Type;
509 friend class SkRRectPriv;
void setEmpty()
Sets bounds to zero width and height at (0, 0), the origin.
Definition: SkRRect.h:114
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.
void offset(SkScalar dx, SkScalar dy)
Translates SkRRect by (dx, dy).
Definition: SkRRect.h:383
void inset(SkScalar dx, SkScalar dy)
Insets bounds by dx and dy, and adjusts radii by dx and dy.
Definition: SkRRect.h:337
Type
Definition: SkRRect.h:62
SkVector getSimpleRadii() const
Returns top-left corner radii.
Definition: SkRRect.h:107
static constexpr SkRect SK_WARN_UNUSED_RESULT MakeEmpty()
Returns constructed SkRect set to (0, 0, 0, 0).
Definition: SkRect.h:585
SkVector radii(Corner corner) const
Returns scalar pair for radius of curve on x-axis and y-axis for one corner.
Definition: SkRRect.h:267
bool isEmpty() const
Definition: SkRRect.h:79
Type getType() const
Definition: SkRRect.h:72
void setNinePatch(const SkRect &rect, SkScalar leftRad, SkScalar topRad, SkScalar rightRad, SkScalar bottomRad)
Sets bounds to rect.
void setOval(const SkRect &oval)
Sets bounds to oval, x-axis radii to half oval.width(), and all y-axis radii to half oval....
@ kNinePatch_Type
non-zero width and height with axis-aligned radii
Definition: SkRRect.h:67
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:286
void dumpHex() const
Writes text representation of SkRRect to standard output.
Definition: SkRRect.h:479
bool isNinePatch() const
Definition: SkRRect.h:83
SkScalar height() const
Returns span on the y-axis.
Definition: SkRRect.h:98
bool transform(const SkMatrix &matrix, SkRRect *dst) const
Transforms by SkRRect by matrix, storing result in dst.
void setRectRadii(const SkRect &rect, const SkVector radii[4])
Sets bounds to rect.
Type type() const
Definition: SkRRect.h:77
@ kOval_Type
non-zero width and height filled with radii
Definition: SkRRect.h:65
SkRRect(const SkRRect &rrect)=default
Initializes to copy of rrect bounds and corner radii.
@ kLowerLeft_Corner
index of bottom-left corner radii
Definition: SkRRect.h:251
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.
Definition: SkPoint.h:160
SkRRect()=default
Initializes bounds at (0, 0), the origin, with zero width and height.
void dump(bool asHex) const
Writes text representation of SkRRect to standard output.
#define SK_API
Definition: SkTypes.h:181
#define SkASSERT(cond)
Definition: SkTypes.h:460
SkScalar width() const
Returns span on the x-axis.
Definition: SkRRect.h:91
bool isRect() const
Definition: SkRRect.h:80
@ kUpperLeft_Corner
index of top-left corner radii
Definition: SkRRect.h:248
SkRRect SK_WARN_UNUSED_RESULT makeOffset(SkScalar dx, SkScalar dy) const
Returns SkRRect translated by (dx, dy).
Definition: SkRRect.h:393
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:176
SkRRect & operator=(const SkRRect &rrect)=default
Copies rrect bounds and corner radii.
bool isComplex() const
Definition: SkRRect.h:84
bool isOval() const
Definition: SkRRect.h:81
@ kUpperRight_Corner
index of top-right corner radii
Definition: SkRRect.h:249
void setRect(const SkRect &rect)
Sets bounds to sorted rect, and sets corner radii to zero.
Definition: SkRRect.h:122
static bool SkScalarsEqual(const SkScalar a[], const SkScalar b[], int n)
Definition: SkScalar.h:184
void outset(SkScalar dx, SkScalar dy)
Outsets bounds by dx and dy, and adjusts radii by dx and dy.
Definition: SkRRect.h:374
static SkRRect MakeEmpty()
Initializes bounds at (0, 0), the origin, with zero width and height.
Definition: SkRRect.h:138
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:158
float SkScalar
Definition: SkScalar.h:16
static SkRRect MakeRect(const SkRect &r)
Initializes to copy of r bounds and zeroes corner radii.
Definition: SkRRect.h:145
void dump() const
Writes text representation of SkRRect to standard output.
Definition: SkRRect.h:472
bool isValid() const
Returns true if bounds and radii values are finite and describe a SkRRect SkRRect::Type that matches ...
SkScalar fX
x-axis value
Definition: SkPoint.h:161
Definition: SkMatrix.h:48
@ kLowerRight_Corner
index of bottom-right corner radii
Definition: SkRRect.h:250
SkString dumpToString(bool asHex) const
@ kRect_Type
non-zero width and height, and zeroed radii
Definition: SkRRect.h:64
#define SK_WARN_UNUSED_RESULT
Definition: SkTypes.h:60
const SkRect & getBounds() const
Returns bounds.
Definition: SkRRect.h:275
Definition: SkString.h:116
const SkRect & rect() const
Returns bounds.
Definition: SkRRect.h:260
Corner
Definition: SkRRect.h:247
size_t readFromMemory(const void *buffer, size_t length)
Reads SkRRect from buffer, reading kSizeInMemory bytes.
bool isSimple() const
Definition: SkRRect.h:82
@ kSimple_Type
non-zero width and height with equal radii
Definition: SkRRect.h:66
@ kComplex_Type
non-zero width and height with arbitrary radii
Definition: SkRRect.h:68
void setRectXY(const SkRect &rect, SkScalar xRad, SkScalar yRad)
Sets to rounded rectangle with the same radii for all four corners.
@ kEmpty_Type
zero width or height
Definition: SkRRect.h:63
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:356
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:299
size_t writeToMemory(void *buffer) const
Writes SkRRect to buffer.