67 return SkIRect{0, 0, size.fWidth, size.fHeight};
79 return MakeXYWH(pt.
x(), pt.
y(), size.width(), size.height());
91 [[nodiscard]]
static constexpr SkIRect MakeLTRB(int32_t l, int32_t t, int32_t r, int32_t
b) {
113 constexpr int32_t
left()
const {
return fLeft; }
120 constexpr int32_t
top()
const {
return fTop; }
127 constexpr int32_t
right()
const {
return fRight; }
134 constexpr int32_t
bottom()
const {
return fBottom; }
141 constexpr int32_t
x()
const {
return fLeft; }
148 constexpr int32_t
y()
const {
return fTop; }
180 constexpr int64_t
width64()
const {
return (int64_t)fRight - (int64_t)fLeft; }
188 constexpr int64_t
height64()
const {
return (int64_t)fBottom - (int64_t)fTop; }
196 bool isEmpty64()
const {
return fRight <= fLeft || fBottom <= fTop; }
203 int64_t
w = this->width64();
204 int64_t
h = this->height64();
205 if (
w <= 0 ||
h <= 0) {
209 return !SkTFitsIn<int32_t>(
w |
h);
220 return a.fLeft ==
b.fLeft &&
a.fTop ==
b.fTop &&
221 a.fRight ==
b.fRight &&
a.fBottom ==
b.fBottom;
232 return a.fLeft !=
b.fLeft ||
a.fTop !=
b.fTop ||
233 a.fRight !=
b.fRight ||
a.fBottom !=
b.fBottom;
242 void setEmpty() { memset(
this, 0,
sizeof(*
this)); }
285 fRight = size.width();
286 fBottom = size.height();
411 void inset(int32_t dx, int32_t dy) {
446 void adjust(int32_t dL, int32_t dT, int32_t dR, int32_t dB) {
464 return x >= fLeft && x < fRight && y >= fTop &&
y < fBottom;
476 return !r.
isEmpty() && !this->isEmpty() &&
500 SkASSERT(fLeft < fRight && fTop < fBottom);
555 if (fLeft > fRight) {
558 if (fTop > fBottom) {
570 return MakeLTRB(std::min(fLeft, fRight), std::min(fTop, fBottom),
571 std::max(fLeft, fRight), std::max(fTop, fBottom));
596 return SkRect{0, 0, 0, 0};
624 return {0, 0,
static_cast<float>(
w),
static_cast<float>(
h)};
634 return SkRect{0, 0, size.fWidth, size.fHeight};
670 return MakeIWH(size.width(), size.height());
682 static_cast<float>(irect.
fLeft),
static_cast<float>(irect.
fTop),
683 static_cast<float>(irect.
fRight),
static_cast<float>(irect.
fBottom)
696 return !(fLeft < fRight && fTop < fBottom);
705 bool isSorted()
const {
return fLeft <= fRight && fTop <= fBottom; }
712 return SkIsFinite(fLeft, fTop, fRight, fBottom);
720 constexpr float x()
const {
return fLeft; }
727 constexpr float y()
const {
return fTop; }
734 constexpr float left()
const {
return fLeft; }
741 constexpr float top()
const {
return fTop; }
748 constexpr float right()
const {
return fRight; }
755 constexpr float bottom()
const {
return fBottom; }
762 constexpr float width()
const {
return fRight - fLeft; }
769 constexpr float height()
const {
return fBottom - fTop; }
792 constexpr SkPoint center()
const {
return {this->centerX(), this->centerY()}; }
805 return a.fLeft ==
b.fLeft &&
807 a.fRight ==
b.fRight &&
808 a.fBottom ==
b.fBottom;
834 void toQuad(
SkPoint quad[4])
const;
853 fBottom = src.fBottom;
882 (void)this->setBoundsCheck(pts,
count);
917 fLeft = std::min(p0.
fX, p1.
fX);
918 fRight = std::max(p0.
fX, p1.
fX);
919 fTop = std::min(p0.
fY, p1.
fY);
920 fBottom = std::max(p0.
fY, p1.
fY);
966 return MakeLTRB(fLeft + dx, fTop + dy, fRight + dx, fBottom + dy);
988 return MakeLTRB(fLeft + dx, fTop + dy, fRight - dx, fBottom - dy);
1003 return MakeLTRB(fLeft - dx, fTop - dy, fRight + dx, fBottom + dy);
1044 fRight += newX - fLeft;
1045 fBottom += newY - fTop;
1104 static bool Intersects(
float al,
float at,
float ar,
float ab,
1105 float bl,
float bt,
float br,
float bb) {
1106 float L = std::max(al, bl);
1107 float R = std::min(ar, br);
1108 float T = std::max(at, bt);
1109 float B = std::min(
ab, bb);
1110 return L <
R &&
T <
B;
1122 return Intersects(fLeft, fTop, fRight, fBottom,
1134 return Intersects(
a.fLeft,
a.fTop,
a.fRight,
a.fBottom,
1135 b.fLeft,
b.fTop,
b.fRight,
b.fBottom);
1147 void join(
const SkRect& r);
1161 if (fLeft >= fRight || fTop >= fBottom) {
1164 this->joinPossiblyEmptyRect(r);
1175 fLeft = std::min(fLeft, r.
left());
1176 fTop = std::min(fTop, r.
top());
1177 fRight = std::max(fRight, r.
right());
1178 fBottom = std::max(fBottom, r.
bottom());
1189 return x >= fLeft && x < fRight && y >= fTop &&
y < fBottom;
1202 return !r.
isEmpty() && !this->isEmpty() &&
1217 return !r.
isEmpty() && !this->isEmpty() &&
1255 dst->setLTRB(std::floor(fLeft), std::floor(fTop),
1256 std::ceil(fRight), std::ceil(fBottom));
1293 this->roundOut(&ir);
1315 if (fLeft > fRight) {
1316 swap(fLeft, fRight);
1319 if (fTop > fBottom) {
1320 swap(fTop, fBottom);
1331 return MakeLTRB(std::min(fLeft, fRight), std::min(fTop, fBottom),
1332 std::max(fLeft, fRight), std::max(fTop, fBottom));
1349 void dump(
bool asHex)
const;
static bool intersect(const SkPoint &p0, const SkPoint &n0, const SkPoint &p1, const SkPoint &n1, SkScalar *t)
static void round(SkPoint *p)
#define sk_float_ceil2int(x)
static bool SkIsFinite(T x, Pack... values)
#define sk_float_round2int(x)
static constexpr float sk_float_midpoint(float a, float b)
#define sk_float_floor2int(x)
static bool contains(const SkRect &r, SkPoint p)
static bool left(const SkPoint &p0, const SkPoint &p1)
static bool right(const SkPoint &p0, const SkPoint &p1)
void swap(sk_sp< T > &a, sk_sp< T > &b)
static constexpr int32_t Sk64_pin_to_s32(int64_t x)
static constexpr int32_t Sk32_sat_sub(int32_t a, int32_t b)
static constexpr int32_t Sk32_sat_add(int32_t a, int32_t b)
static constexpr int32_t Sk32_can_overflow_sub(int32_t a, int32_t b)
static void dump(const float m[20], SkYUVColorSpace cs, bool rgb2yuv)
static SkRect inset(const SkRect &r)
constexpr int32_t y() const
constexpr int32_t x() const
constexpr int64_t height64() const
constexpr int32_t x() const
friend bool operator!=(const SkIRect &a, const SkIRect &b)
void adjust(int32_t dL, int32_t dT, int32_t dR, int32_t dB)
SkIRect makeOutset(int32_t dx, int32_t dy) const
void inset(int32_t dx, int32_t dy)
bool contains(const SkIRect &r) const
constexpr int32_t y() const
void offset(const SkIPoint &delta)
bool intersect(const SkIRect &r)
static bool Intersects(const SkIRect &a, const SkIRect &b)
int32_t fBottom
larger y-axis bounds
constexpr int32_t top() const
static constexpr SkIRect MakeLTRB(int32_t l, int32_t t, int32_t r, int32_t b)
void offsetTo(int32_t newX, int32_t newY)
bool containsNoEmptyCheck(const SkIRect &r) const
constexpr SkISize size() const
constexpr int32_t bottom() const
constexpr int32_t height() const
constexpr int32_t right() const
int32_t fTop
smaller y-axis bounds
constexpr SkIRect makeOffset(SkIVector offset) const
static constexpr SkIRect MakeSize(const SkISize &size)
static constexpr SkIRect MakeEmpty()
constexpr int32_t width() const
friend bool operator==(const SkIRect &a, const SkIRect &b)
constexpr int64_t width64() const
void offset(int32_t dx, int32_t dy)
constexpr SkIRect makeOffset(int32_t dx, int32_t dy) const
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
void setXYWH(int32_t x, int32_t y, int32_t width, int32_t height)
constexpr SkIPoint topLeft() const
void setWH(int32_t width, int32_t height)
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
SkIRect makeInset(int32_t dx, int32_t dy) const
int32_t fLeft
smaller x-axis bounds
SkIRect makeSorted() const
void outset(int32_t dx, int32_t dy)
static constexpr SkIRect MakePtSize(SkIPoint pt, SkISize size)
constexpr int32_t left() const
void setLTRB(int32_t left, int32_t top, int32_t right, int32_t bottom)
bool contains(int32_t x, int32_t y) const
int32_t fRight
larger x-axis bounds
void setSize(SkISize size)
static constexpr SkISize Make(int32_t w, int32_t h)
constexpr float y() const
constexpr float x() const
constexpr SkRect makeOffset(SkVector v) const
SkRect makeSorted() const
static SkRect Make(const SkISize &size)
void offsetTo(float newX, float newY)
static constexpr SkRect MakeEmpty()
static bool Intersects(const SkRect &a, const SkRect &b)
SkScalar fBottom
larger y-axis bounds
bool contains(float x, float y) const
void joinNonEmptyArg(const SkRect &r)
constexpr float left() const
void offset(const SkPoint &delta)
static SkRect Make(const SkIRect &irect)
friend bool operator==(const SkRect &a, const SkRect &b)
void inset(float dx, float dy)
void setXYWH(float x, float y, float width, float height)
constexpr SkRect makeOffset(float dx, float dy) const
constexpr float top() const
void joinPossiblyEmptyRect(const SkRect &r)
void roundIn(SkIRect *dst) const
SkScalar fLeft
smaller x-axis bounds
constexpr float x() const
static SkRect MakeIWH(int w, int h)
void outset(float dx, float dy)
const float * asScalars() const
void roundOut(SkRect *dst) const
constexpr float y() const
SkRect makeOutset(float dx, float dy) const
void setWH(float width, float height)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
bool contains(const SkRect &r) const
bool intersects(const SkRect &r) const
SkRect makeInset(float dx, float dy) const
void set(const SkPoint &p0, const SkPoint &p1)
bool contains(const SkIRect &r) const
SkScalar fRight
larger x-axis bounds
void roundOut(SkIRect *dst) const
constexpr float centerX() const
void offset(float dx, float dy)
static constexpr SkRect MakeSize(const SkSize &size)
void round(SkIRect *dst) const
constexpr float height() const
constexpr float right() const
void setIWH(int32_t width, int32_t height)
void setLTRB(float left, float top, float right, float bottom)
void setBounds(const SkPoint pts[], int count)
constexpr float centerY() const
constexpr float width() const
constexpr SkPoint center() const
friend bool operator!=(const SkRect &a, const SkRect &b)
static constexpr SkRect MakeWH(float w, float h)
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
void set(const SkIRect &src)
constexpr float bottom() const
SkScalar fTop
smaller y-axis bounds