Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
SkIRect Struct Reference

#include <SkRect.h>

Public Member Functions

constexpr int32_t left () const
 
constexpr int32_t top () const
 
constexpr int32_t right () const
 
constexpr int32_t bottom () const
 
constexpr int32_t x () const
 
constexpr int32_t y () const
 
constexpr SkIPoint topLeft () const
 
constexpr int32_t width () const
 
constexpr int32_t height () const
 
constexpr SkISize size () const
 
constexpr int64_t width64 () const
 
constexpr int64_t height64 () const
 
bool isEmpty64 () const
 
bool isEmpty () const
 
void setEmpty ()
 
void setLTRB (int32_t left, int32_t top, int32_t right, int32_t bottom)
 
void setXYWH (int32_t x, int32_t y, int32_t width, int32_t height)
 
void setWH (int32_t width, int32_t height)
 
void setSize (SkISize size)
 
constexpr SkIRect makeOffset (int32_t dx, int32_t dy) const
 
constexpr SkIRect makeOffset (SkIVector offset) const
 
SkIRect makeInset (int32_t dx, int32_t dy) const
 
SkIRect makeOutset (int32_t dx, int32_t dy) const
 
void offset (int32_t dx, int32_t dy)
 
void offset (const SkIPoint &delta)
 
void offsetTo (int32_t newX, int32_t newY)
 
void inset (int32_t dx, int32_t dy)
 
void outset (int32_t dx, int32_t dy)
 
void adjust (int32_t dL, int32_t dT, int32_t dR, int32_t dB)
 
bool contains (int32_t x, int32_t y) const
 
bool contains (const SkIRect &r) const
 
bool contains (const SkRect &r) const
 
bool containsNoEmptyCheck (const SkIRect &r) const
 
bool intersect (const SkIRect &r)
 
bool intersect (const SkIRect &a, const SkIRect &b)
 
void join (const SkIRect &r)
 
void sort ()
 
SkIRect makeSorted () const
 

Static Public Member Functions

static constexpr SkIRect MakeEmpty ()
 
static constexpr SkIRect MakeWH (int32_t w, int32_t h)
 
static constexpr SkIRect MakeSize (const SkISize &size)
 
static constexpr SkIRect MakePtSize (SkIPoint pt, SkISize size)
 
static constexpr SkIRect MakeLTRB (int32_t l, int32_t t, int32_t r, int32_t b)
 
static constexpr SkIRect MakeXYWH (int32_t x, int32_t y, int32_t w, int32_t h)
 
static bool Intersects (const SkIRect &a, const SkIRect &b)
 

Public Attributes

int32_t fLeft = 0
 smaller x-axis bounds
 
int32_t fTop = 0
 smaller y-axis bounds
 
int32_t fRight = 0
 larger x-axis bounds
 
int32_t fBottom = 0
 larger y-axis bounds
 

Friends

bool operator== (const SkIRect &a, const SkIRect &b)
 
bool operator!= (const SkIRect &a, const SkIRect &b)
 

Detailed Description

SkIRect holds four 32-bit integer coordinates describing the upper and lower bounds of a rectangle. SkIRect may be created from outer bounds or from position, width, and height. SkIRect describes an area; if its right is less than or equal to its left, or if its bottom is less than or equal to its top, it is considered empty.

Definition at line 32 of file SkRect.h.

Member Function Documentation

◆ adjust()

void SkIRect::adjust ( int32_t  dL,
int32_t  dT,
int32_t  dR,
int32_t  dB 
)
inline

Adjusts SkIRect by adding dL to fLeft, dT to fTop, dR to fRight, and dB to fBottom.

If dL is positive, narrows SkIRect on the left. If negative, widens it on the left. If dT is positive, shrinks SkIRect on the top. If negative, lengthens it on the top. If dR is positive, narrows SkIRect on the right. If negative, widens it on the right. If dB is positive, shrinks SkIRect on the bottom. If negative, lengthens it on the bottom.

The resulting SkIRect is not checked for validity. Thus, if the resulting SkIRect left is greater than right, the SkIRect will be considered empty. Call sort() after this call if that is not the desired behavior.

Parameters
dLoffset added to fLeft
dToffset added to fTop
dRoffset added to fRight
dBoffset added to fBottom

Definition at line 446 of file SkRect.h.

446 {
447 fLeft = Sk32_sat_add(fLeft, dL);
448 fTop = Sk32_sat_add(fTop, dT);
451 }
static constexpr int32_t Sk32_sat_add(int32_t a, int32_t b)
Definition SkSafe32.h:20
int32_t fBottom
larger y-axis bounds
Definition SkRect.h:36
int32_t fTop
smaller y-axis bounds
Definition SkRect.h:34
int32_t fLeft
smaller x-axis bounds
Definition SkRect.h:33
int32_t fRight
larger x-axis bounds
Definition SkRect.h:35

◆ bottom()

constexpr int32_t SkIRect::bottom ( ) const
inlineconstexpr

Returns bottom edge of SkIRect, if sorted. Call isEmpty() to see if SkIRect may be invalid, and sort() to reverse fTop and fBottom if needed.

Returns
fBottom

Definition at line 134 of file SkRect.h.

134{ return fBottom; }

◆ contains() [1/3]

bool SkIRect::contains ( const SkIRect r) const
inline

Returns true if SkIRect contains r. Returns false if SkIRect is empty or r is empty.

SkIRect contains r when SkIRect area completely includes r area.

Parameters
rSkIRect contained
Returns
true if all sides of SkIRect are outside r

Definition at line 475 of file SkRect.h.

475 {
476 return !r.isEmpty() && !this->isEmpty() && // check for empties
477 fLeft <= r.fLeft && fTop <= r.fTop &&
478 fRight >= r.fRight && fBottom >= r.fBottom;
479 }
bool isEmpty() const
Definition SkRect.h:202

◆ contains() [2/3]

bool SkIRect::contains ( const SkRect r) const
inline

Returns true if SkIRect contains r. Returns false if SkIRect is empty or r is empty.

SkIRect contains r when SkIRect area completely includes r area.

Parameters
rSkRect contained
Returns
true if all sides of SkIRect are outside r

Definition at line 1368 of file SkRect.h.

1368 {
1369 return !r.isEmpty() && !this->isEmpty() && // check for empties
1370 fLeft <= r.fLeft && fTop <= r.fTop &&
1371 fRight >= r.fRight && fBottom >= r.fBottom;
1372}
SkScalar fBottom
larger y-axis bounds
Definition extension.cpp:17
SkScalar fLeft
smaller x-axis bounds
Definition extension.cpp:14
SkScalar fRight
larger x-axis bounds
Definition extension.cpp:16
bool isEmpty() const
Definition SkRect.h:693
SkScalar fTop
smaller y-axis bounds
Definition extension.cpp:15

◆ contains() [3/3]

bool SkIRect::contains ( int32_t  x,
int32_t  y 
) const
inline

Returns true if: fLeft <= x < fRight && fTop <= y < fBottom. Returns false if SkIRect is empty.

Considers input to describe constructed SkIRect: (x, y, x + 1, y + 1) and returns true if constructed area is completely enclosed by SkIRect area.

Parameters
xtest SkIPoint x-coordinate
ytest SkIPoint y-coordinate
Returns
true if (x, y) is inside SkIRect

Definition at line 463 of file SkRect.h.

463 {
464 return x >= fLeft && x < fRight && y >= fTop && y < fBottom;
465 }
constexpr int32_t x() const
Definition SkRect.h:141
constexpr int32_t y() const
Definition SkRect.h:148

◆ containsNoEmptyCheck()

bool SkIRect::containsNoEmptyCheck ( const SkIRect r) const
inline

Returns true if SkIRect contains construction. Asserts if SkIRect is empty or construction is empty, and if SK_DEBUG is defined.

Return is undefined if SkIRect is empty or construction is empty.

Parameters
rSkIRect contained
Returns
true if all sides of SkIRect are outside r

Definition at line 499 of file SkRect.h.

499 {
501 SkASSERT(r.fLeft < r.fRight && r.fTop < r.fBottom);
502 return fLeft <= r.fLeft && fTop <= r.fTop && fRight >= r.fRight && fBottom >= r.fBottom;
503 }
#define SkASSERT(cond)
Definition SkAssert.h:116

◆ height()

constexpr int32_t SkIRect::height ( ) const
inlineconstexpr

Returns span on the y-axis. This does not check if SkIRect is sorted, or if result fits in 32-bit signed integer; result may be negative.

Returns
fBottom minus fTop

Definition at line 165 of file SkRect.h.

static constexpr int32_t Sk32_can_overflow_sub(int32_t a, int32_t b)
Definition SkSafe32.h:33

◆ height64()

constexpr int64_t SkIRect::height64 ( ) const
inlineconstexpr

Returns span on the y-axis. This does not check if SkIRect is sorted, so the result may be negative. This is safer than calling height() since height() might overflow in its calculation.

Returns
fBottom minus fTop cast to int64_t

Definition at line 188 of file SkRect.h.

188{ return (int64_t)fBottom - (int64_t)fTop; }

◆ inset()

void SkIRect::inset ( int32_t  dx,
int32_t  dy 
)
inline

Insets SkIRect by (dx,dy).

If dx is positive, makes SkIRect narrower. If dx is negative, makes SkIRect wider. If dy is positive, makes SkIRect shorter. If dy is negative, makes SkIRect taller.

Parameters
dxoffset added to fLeft and subtracted from fRight
dyoffset added to fTop and subtracted from fBottom

Definition at line 411 of file SkRect.h.

411 {
412 fLeft = Sk32_sat_add(fLeft, dx);
413 fTop = Sk32_sat_add(fTop, dy);
416 }
static constexpr int32_t Sk32_sat_sub(int32_t a, int32_t b)
Definition SkSafe32.h:24

◆ intersect() [1/2]

bool SkIRect::intersect ( const SkIRect a,
const SkIRect b 
)

Returns true if a intersects b, and sets SkIRect to intersection. Returns false if a does not intersect b, and leaves SkIRect unchanged.

Returns false if either a or b is empty, leaving SkIRect unchanged.

Parameters
aSkIRect to intersect
bSkIRect to intersect
Returns
true if a and b have area in common

Definition at line 17 of file SkRect.cpp.

17 {
18 SkIRect tmp = {
19 std::max(a.fLeft, b.fLeft),
20 std::max(a.fTop, b.fTop),
21 std::min(a.fRight, b.fRight),
22 std::min(a.fBottom, b.fBottom)
23 };
24 if (tmp.isEmpty()) {
25 return false;
26 }
27 *this = tmp;
28 return true;
29}
static bool b
struct MyStruct a[10]

◆ intersect() [2/2]

bool SkIRect::intersect ( const SkIRect r)
inline

Returns true if SkIRect intersects r, and sets SkIRect to intersection. Returns false if SkIRect does not intersect r, and leaves SkIRect unchanged.

Returns false if either r or SkIRect is empty, leaving SkIRect unchanged.

Parameters
rlimit of result
Returns
true if r and SkIRect have area in common

Definition at line 513 of file SkRect.h.

513 {
514 return this->intersect(*this, r);
515 }
bool intersect(const SkIRect &r)
Definition SkRect.h:513

◆ Intersects()

static bool SkIRect::Intersects ( const SkIRect a,
const SkIRect b 
)
inlinestatic

Returns true if a intersects b. Returns false if either a or b is empty, or do not intersect.

Parameters
aSkIRect to intersect
bSkIRect to intersect
Returns
true if a and b have area in common

Definition at line 535 of file SkRect.h.

535 {
536 return SkIRect{}.intersect(a, b);
537 }

◆ isEmpty()

bool SkIRect::isEmpty ( ) const
inline

Returns true if width() or height() are zero or negative.

Returns
true if width() or height() are zero or negative

Definition at line 202 of file SkRect.h.

202 {
203 int64_t w = this->width64();
204 int64_t h = this->height64();
205 if (w <= 0 || h <= 0) {
206 return true;
207 }
208 // Return true if either exceeds int32_t
209 return !SkTFitsIn<int32_t>(w | h);
210 }
SkScalar w
SkScalar h
constexpr int64_t height64() const
Definition SkRect.h:188
constexpr int64_t width64() const
Definition SkRect.h:180

◆ isEmpty64()

bool SkIRect::isEmpty64 ( ) const
inline

Returns true if fLeft is equal to or greater than fRight, or if fTop is equal to or greater than fBottom. Call sort() to reverse rectangles with negative width64() or height64().

Returns
true if width64() or height64() are zero or negative

Definition at line 196 of file SkRect.h.

196{ return fRight <= fLeft || fBottom <= fTop; }

◆ join()

void SkIRect::join ( const SkIRect r)

Sets SkIRect to the union of itself and r.

Has no effect if r is empty. Otherwise, if SkIRect is empty, sets SkIRect to r.

Parameters
rexpansion SkIRect

example: https://fiddle.skia.org/c/@IRect_join_2

Definition at line 31 of file SkRect.cpp.

31 {
32 // do nothing if the params are empty
33 if (r.fLeft >= r.fRight || r.fTop >= r.fBottom) {
34 return;
35 }
36
37 // if we are empty, just assign
38 if (fLeft >= fRight || fTop >= fBottom) {
39 *this = r;
40 } else {
41 if (r.fLeft < fLeft) fLeft = r.fLeft;
42 if (r.fTop < fTop) fTop = r.fTop;
43 if (r.fRight > fRight) fRight = r.fRight;
44 if (r.fBottom > fBottom) fBottom = r.fBottom;
45 }
46}

◆ left()

constexpr int32_t SkIRect::left ( ) const
inlineconstexpr

Returns left edge of SkIRect, if sorted. Call sort() to reverse fLeft and fRight if needed.

Returns
fLeft

Definition at line 113 of file SkRect.h.

113{ return fLeft; }

◆ MakeEmpty()

static constexpr SkIRect SkIRect::MakeEmpty ( )
inlinestaticconstexpr

Returns constructed SkIRect set to (0, 0, 0, 0). Many other rectangles are empty; if left is equal to or greater than right, or if top is equal to or greater than bottom. Setting all members to zero is a convenience, but does not designate a special empty rectangle.

Returns
bounds (0, 0, 0, 0)

Definition at line 45 of file SkRect.h.

45 {
46 return SkIRect{0, 0, 0, 0};
47 }

◆ makeInset()

SkIRect SkIRect::makeInset ( int32_t  dx,
int32_t  dy 
) const
inline

Returns SkIRect, inset by (dx, dy).

If dx is negative, SkIRect returned is wider. If dx is positive, SkIRect returned is narrower. If dy is negative, SkIRect returned is taller. If dy is positive, SkIRect returned is shorter.

Parameters
dxoffset added to fLeft and subtracted from fRight
dyoffset added to fTop and subtracted from fBottom
Returns
SkIRect inset symmetrically left and right, top and bottom

Definition at line 332 of file SkRect.h.

332 {
333 return {
336 };
337 }

◆ MakeLTRB()

SkIRect::MakeLTRB ( int32_t  l,
int32_t  t,
int32_t  r,
int32_t  b 
)
inlinestaticconstexpr

Returns constructed SkIRect set to (l, t, r, b). Does not sort input; SkIRect may result in fLeft greater than fRight, or fTop greater than fBottom.

Parameters
linteger stored in fLeft
tinteger stored in fTop
rinteger stored in fRight
binteger stored in fBottom
Returns
bounds (l, t, r, b)

Definition at line 91 of file SkRect.h.

91 {
92 return SkIRect{l, t, r, b};
93 }

◆ makeOffset() [1/2]

constexpr SkIRect SkIRect::makeOffset ( int32_t  dx,
int32_t  dy 
) const
inlineconstexpr

Returns SkIRect offset by (dx, dy).

If dx is negative, SkIRect returned is moved to the left. If dx is positive, SkIRect returned is moved to the right. If dy is negative, SkIRect returned is moved upward. If dy is positive, SkIRect returned is moved downward.

Parameters
dxoffset added to fLeft and fRight
dyoffset added to fTop and fBottom
Returns
SkIRect offset by dx and dy, with original width and height

Definition at line 300 of file SkRect.h.

300 {
301 return {
304 };
305 }

◆ makeOffset() [2/2]

constexpr SkIRect SkIRect::makeOffset ( SkIVector  offset) const
inlineconstexpr

Returns SkIRect offset by (offset.x(), offset.y()).

If offset.x() is negative, SkIRect returned is moved to the left. If offset.x() is positive, SkIRect returned is moved to the right. If offset.y() is negative, SkIRect returned is moved upward. If offset.y() is positive, SkIRect returned is moved downward.

Parameters
offsettranslation vector
Returns
SkIRect translated by offset, with original width and height

Definition at line 317 of file SkRect.h.

317 {
318 return this->makeOffset(offset.x(), offset.y());
319 }
Point offset
constexpr int32_t x() const
constexpr SkIRect makeOffset(int32_t dx, int32_t dy) const
Definition SkRect.h:300

◆ makeOutset()

SkIRect SkIRect::makeOutset ( int32_t  dx,
int32_t  dy 
) const
inline

Returns SkIRect, outset by (dx, dy).

If dx is negative, SkIRect returned is narrower. If dx is positive, SkIRect returned is wider. If dy is negative, SkIRect returned is shorter. If dy is positive, SkIRect returned is taller.

Parameters
dxoffset subtracted to fLeft and added from fRight
dyoffset subtracted to fTop and added from fBottom
Returns
SkIRect outset symmetrically left and right, top and bottom

Definition at line 350 of file SkRect.h.

350 {
351 return {
354 };
355 }

◆ MakePtSize()

static constexpr SkIRect SkIRect::MakePtSize ( SkIPoint  pt,
SkISize  size 
)
inlinestaticconstexpr

Returns constructed SkIRect set to (pt.x(), pt.y(), pt.x() + size.width(), pt.y() + size.height()). Does not validate input; size.width() or size.height() may be negative.

Parameters
ptvalues for SkIRect fLeft and fTop
sizevalues for SkIRect width and height
Returns
bounds at pt with width and height of size

Definition at line 78 of file SkRect.h.

78 {
79 return MakeXYWH(pt.x(), pt.y(), size.width(), size.height());
80 }
constexpr int32_t y() const
constexpr SkISize size() const
Definition SkRect.h:172
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
Definition SkRect.h:104
constexpr int32_t width() const
Definition SkSize.h:36
constexpr int32_t height() const
Definition SkSize.h:37

◆ MakeSize()

static constexpr SkIRect SkIRect::MakeSize ( const SkISize size)
inlinestaticconstexpr

Returns constructed SkIRect set to (0, 0, size.width(), size.height()). Does not validate input; size.width() or size.height() may be negative.

Parameters
sizevalues for SkIRect width and height
Returns
bounds (0, 0, size.width(), size.height())

Definition at line 66 of file SkRect.h.

66 {
67 return SkIRect{0, 0, size.fWidth, size.fHeight};
68 }
int32_t fHeight
Definition SkSize.h:18
int32_t fWidth
Definition SkSize.h:17

◆ makeSorted()

SkIRect SkIRect::makeSorted ( ) const
inline

Returns SkIRect with fLeft and fRight swapped if fLeft is greater than fRight; and with fTop and fBottom swapped if fTop is greater than fBottom. Result may be empty; and width() and height() will be zero or positive.

Returns
sorted SkIRect

Definition at line 569 of file SkRect.h.

569 {
570 return MakeLTRB(std::min(fLeft, fRight), std::min(fTop, fBottom),
571 std::max(fLeft, fRight), std::max(fTop, fBottom));
572 }
static constexpr SkIRect MakeLTRB(int32_t l, int32_t t, int32_t r, int32_t b)
Definition SkRect.h:91

◆ MakeWH()

Type::kYUV Type::kRGBA SkIRect::MakeWH ( int32_t  w,
int32_t  h 
)
inlinestaticconstexpr

Returns constructed SkIRect set to (0, 0, w, h). Does not validate input; w or h may be negative.

Parameters
wwidth of constructed SkIRect
hheight of constructed SkIRect
Returns
bounds (0, 0, w, h)

Definition at line 56 of file SkRect.h.

56 {
57 return SkIRect{0, 0, w, h};
58 }

◆ MakeXYWH()

Type::kYUV SkIRect::MakeXYWH ( int32_t  x,
int32_t  y,
int32_t  w,
int32_t  h 
)
inlinestaticconstexpr

Returns constructed SkIRect set to: (x, y, x + w, y + h). Does not validate input; w or h may be negative.

Parameters
xstored in fLeft
ystored in fTop
wadded to x and stored in fRight
hadded to y and stored in fBottom
Returns
bounds at (x, y) with width w and height h

Definition at line 104 of file SkRect.h.

104 {
105 return { x, y, Sk32_sat_add(x, w), Sk32_sat_add(y, h) };
106 }

◆ offset() [1/2]

void SkIRect::offset ( const SkIPoint delta)
inline

Offsets SkIRect by adding delta.fX to fLeft, fRight; and by adding delta.fY to fTop, fBottom.

If delta.fX is negative, moves SkIRect returned to the left. If delta.fX is positive, moves SkIRect returned to the right. If delta.fY is negative, moves SkIRect returned upward. If delta.fY is positive, moves SkIRect returned downward.

Parameters
deltaoffset added to SkIRect

Definition at line 384 of file SkRect.h.

384 {
385 this->offset(delta.fX, delta.fY);
386 }
int32_t fX
x-axis value

◆ offset() [2/2]

void SkIRect::offset ( int32_t  dx,
int32_t  dy 
)
inline

Offsets SkIRect by adding dx to fLeft, fRight; and by adding dy to fTop, fBottom.

If dx is negative, moves SkIRect returned to the left. If dx is positive, moves SkIRect returned to the right. If dy is negative, moves SkIRect returned upward. If dy is positive, moves SkIRect returned downward.

Parameters
dxoffset added to fLeft and fRight
dyoffset added to fTop and fBottom

Definition at line 367 of file SkRect.h.

367 {
368 fLeft = Sk32_sat_add(fLeft, dx);
369 fTop = Sk32_sat_add(fTop, dy);
372 }

◆ offsetTo()

void SkIRect::offsetTo ( int32_t  newX,
int32_t  newY 
)
inline

Offsets SkIRect so that fLeft equals newX, and fTop equals newY. width and height are unchanged.

Parameters
newXstored in fLeft, preserving width()
newYstored in fTop, preserving height()

Definition at line 394 of file SkRect.h.

394 {
395 fRight = Sk64_pin_to_s32((int64_t)fRight + newX - fLeft);
396 fBottom = Sk64_pin_to_s32((int64_t)fBottom + newY - fTop);
397 fLeft = newX;
398 fTop = newY;
399 }
static constexpr int32_t Sk64_pin_to_s32(int64_t x)
Definition SkSafe32.h:16

◆ outset()

void SkIRect::outset ( int32_t  dx,
int32_t  dy 
)
inline

Outsets SkIRect by (dx, dy).

If dx is positive, makes SkIRect wider. If dx is negative, makes SkIRect narrower. If dy is positive, makes SkIRect taller. If dy is negative, makes SkIRect shorter.

Parameters
dxsubtracted to fLeft and added from fRight
dysubtracted to fTop and added from fBottom

Definition at line 428 of file SkRect.h.

428{ this->inset(-dx, -dy); }
void inset(int32_t dx, int32_t dy)
Definition SkRect.h:411

◆ right()

constexpr int32_t SkIRect::right ( ) const
inlineconstexpr

Returns right edge of SkIRect, if sorted. Call sort() to reverse fLeft and fRight if needed.

Returns
fRight

Definition at line 127 of file SkRect.h.

127{ return fRight; }

◆ setEmpty()

void SkIRect::setEmpty ( )
inline

Sets SkIRect to (0, 0, 0, 0).

Many other rectangles are empty; if left is equal to or greater than right, or if top is equal to or greater than bottom. Setting all members to zero is a convenience, but does not designate a special empty rectangle.

Definition at line 242 of file SkRect.h.

242{ memset(this, 0, sizeof(*this)); }

◆ setLTRB()

void SkIRect::setLTRB ( int32_t  left,
int32_t  top,
int32_t  right,
int32_t  bottom 
)
inline

Sets SkIRect to (left, top, right, bottom). left and right are not sorted; left is not necessarily less than right. top and bottom are not sorted; top is not necessarily less than bottom.

Parameters
leftstored in fLeft
topstored in fTop
rightstored in fRight
bottomstored in fBottom

Definition at line 253 of file SkRect.h.

253 {
254 fLeft = left;
255 fTop = top;
256 fRight = right;
257 fBottom = bottom;
258 }
constexpr int32_t top() const
Definition SkRect.h:120
constexpr int32_t bottom() const
Definition SkRect.h:134
constexpr int32_t right() const
Definition SkRect.h:127
constexpr int32_t left() const
Definition SkRect.h:113

◆ setSize()

void SkIRect::setSize ( SkISize  size)
inline

Definition at line 282 of file SkRect.h.

282 {
283 fLeft = 0;
284 fTop = 0;
285 fRight = size.width();
286 fBottom = size.height();
287 }

◆ setWH()

void SkIRect::setWH ( int32_t  width,
int32_t  height 
)
inline

Definition at line 275 of file SkRect.h.

275 {
276 fLeft = 0;
277 fTop = 0;
278 fRight = width;
279 fBottom = height;
280 }
int32_t height
int32_t width

◆ setXYWH()

void SkIRect::setXYWH ( int32_t  x,
int32_t  y,
int32_t  width,
int32_t  height 
)
inline

Sets SkIRect to: (x, y, x + width, y + height). Does not validate input; width or height may be negative.

Parameters
xstored in fLeft
ystored in fTop
widthadded to x and stored in fRight
heightadded to y and stored in fBottom

Definition at line 268 of file SkRect.h.

268 {
269 fLeft = x;
270 fTop = y;
273 }

◆ size()

constexpr SkISize SkIRect::size ( ) const
inlineconstexpr

Returns spans on the x-axis and y-axis. This does not check if SkIRect is sorted, or if result fits in 32-bit signed integer; result may be negative.

Returns
SkISize (width, height)

Definition at line 172 of file SkRect.h.

172{ return SkISize::Make(this->width(), this->height()); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20

◆ sort()

void SkIRect::sort ( )
inline

Swaps fLeft and fRight if fLeft is greater than fRight; and swaps fTop and fBottom if fTop is greater than fBottom. Result may be empty, and width() and height() will be zero or positive.

Definition at line 553 of file SkRect.h.

553 {
554 using std::swap;
555 if (fLeft > fRight) {
556 swap(fLeft, fRight);
557 }
558 if (fTop > fBottom) {
559 swap(fTop, fBottom);
560 }
561 }
void swap(sk_sp< T > &a, sk_sp< T > &b)
Definition SkRefCnt.h:341

◆ top()

constexpr int32_t SkIRect::top ( ) const
inlineconstexpr

Returns top edge of SkIRect, if sorted. Call isEmpty() to see if SkIRect may be invalid, and sort() to reverse fTop and fBottom if needed.

Returns
fTop

Definition at line 120 of file SkRect.h.

120{ return fTop; }

◆ topLeft()

constexpr SkIPoint SkIRect::topLeft ( ) const
inlineconstexpr

Definition at line 151 of file SkRect.h.

151{ return {fLeft, fTop}; }

◆ width()

constexpr int32_t SkIRect::width ( ) const
inlineconstexpr

Returns span on the x-axis. This does not check if SkIRect is sorted, or if result fits in 32-bit signed integer; result may be negative.

Returns
fRight minus fLeft

Definition at line 158 of file SkRect.h.

◆ width64()

constexpr int64_t SkIRect::width64 ( ) const
inlineconstexpr

Returns span on the x-axis. This does not check if SkIRect is sorted, so the result may be negative. This is safer than calling width() since width() might overflow in its calculation.

Returns
fRight minus fLeft cast to int64_t

Definition at line 180 of file SkRect.h.

180{ return (int64_t)fRight - (int64_t)fLeft; }

◆ x()

constexpr int32_t SkIRect::x ( ) const
inlineconstexpr

Returns left edge of SkIRect, if sorted. Call isEmpty() to see if SkIRect may be invalid, and sort() to reverse fLeft and fRight if needed.

Returns
fLeft

Definition at line 141 of file SkRect.h.

141{ return fLeft; }

◆ y()

constexpr int32_t SkIRect::y ( ) const
inlineconstexpr

Returns top edge of SkIRect, if sorted. Call isEmpty() to see if SkIRect may be invalid, and sort() to reverse fTop and fBottom if needed.

Returns
fTop

Definition at line 148 of file SkRect.h.

148{ return fTop; }

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( const SkIRect a,
const SkIRect b 
)
friend

Returns true if any member in a: fLeft, fTop, fRight, and fBottom; is not identical to the corresponding member in b.

Parameters
aSkIRect to compare
bSkIRect to compare
Returns
true if members are not equal

Definition at line 231 of file SkRect.h.

231 {
232 return a.fLeft != b.fLeft || a.fTop != b.fTop ||
233 a.fRight != b.fRight || a.fBottom != b.fBottom;
234 }

◆ operator==

bool operator== ( const SkIRect a,
const SkIRect b 
)
friend

Returns true if all members in a: fLeft, fTop, fRight, and fBottom; are identical to corresponding members in b.

Parameters
aSkIRect to compare
bSkIRect to compare
Returns
true if members are equal

Definition at line 219 of file SkRect.h.

219 {
220 return a.fLeft == b.fLeft && a.fTop == b.fTop &&
221 a.fRight == b.fRight && a.fBottom == b.fBottom;
222 }

Member Data Documentation

◆ fBottom

int32_t SkIRect::fBottom = 0

larger y-axis bounds

Definition at line 36 of file SkRect.h.

◆ fLeft

int32_t SkIRect::fLeft = 0

smaller x-axis bounds

Definition at line 33 of file SkRect.h.

◆ fRight

int32_t SkIRect::fRight = 0

larger x-axis bounds

Definition at line 35 of file SkRect.h.

◆ fTop

int32_t SkIRect::fTop = 0

smaller y-axis bounds

Definition at line 34 of file SkRect.h.


The documentation for this struct was generated from the following files: