Skia
2DGraphicsLibrary
|
SkIRect holds four 32 bit integer coordinates for a rectangle. More...
#include <SkRect.h>
Public Member Functions | |
int | left () const |
int | top () const |
int | right () const |
int | bottom () const |
int | x () const |
return the left edge of the rect | |
int | y () const |
return the top edge of the rect | |
int | width () const |
Returns the rectangle's width. More... | |
int | height () const |
Returns the rectangle's height. More... | |
SkISize | size () const |
int | centerX () const |
Since the center of an integer rect may fall on a factional value, this method is defined to return (right + left) >> 1. More... | |
int | centerY () const |
Since the center of an integer rect may fall on a factional value, this method is defined to return (bottom + top) >> 1. More... | |
bool | isEmpty () const |
Return true if the rectangle's width or height are <= 0. | |
bool | isLargest () const |
bool | is16Bit () const |
void | setEmpty () |
Set the rectangle to (0,0,0,0) | |
void | set (int32_t left, int32_t top, int32_t right, int32_t bottom) |
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 | setLargest () |
Make the largest representable rectangle. | |
void | setLargestInverted () |
Make the largest representable rectangle, but inverted (e.g. More... | |
SkIRect | makeOffset (int32_t dx, int32_t dy) const |
Return a new IRect, built as an offset of this rect. | |
SkIRect | makeInset (int32_t dx, int32_t dy) const |
Return a new IRect, built as an inset of this rect. | |
SkIRect | makeOutset (int32_t dx, int32_t dy) const |
Return a new Rect, built as an outset of this rect. | |
void | offset (int32_t dx, int32_t dy) |
Offset set the rectangle by adding dx to its left and right, and adding dy to its top and bottom. | |
void | offset (const SkIPoint &delta) |
void | offsetTo (int32_t newX, int32_t newY) |
Offset this rect such its new x() and y() will equal newX and newY. | |
void | inset (int32_t dx, int32_t dy) |
Inset the rectangle by (dx,dy). More... | |
void | outset (int32_t dx, int32_t dy) |
Outset the rectangle by (dx,dy). More... | |
bool | quickReject (int l, int t, int r, int b) const |
bool | contains (int32_t x, int32_t y) const |
Returns true if (x,y) is inside the rectangle and the rectangle is not empty. More... | |
bool | contains (int32_t left, int32_t top, int32_t right, int32_t bottom) const |
Returns true if the 4 specified sides of a rectangle are inside or equal to this rectangle. More... | |
bool | contains (const SkIRect &r) const |
Returns true if the specified rectangle r is inside or equal to this rectangle. | |
bool | contains (const SkRect &r) const |
Returns true if the specified rectangle r is inside or equal to this rectangle. | |
bool | containsNoEmptyCheck (int32_t left, int32_t top, int32_t right, int32_t bottom) const |
Return true if this rectangle contains the specified rectangle. More... | |
bool | containsNoEmptyCheck (const SkIRect &r) const |
bool | intersect (const SkIRect &r) |
If r intersects this rectangle, return true and set this rectangle to that intersection, otherwise return false and do not change this rectangle. More... | |
bool SK_WARN_UNUSED_RESULT | intersect (const SkIRect &a, const SkIRect &b) |
If rectangles a and b intersect, return true and set this rectangle to that intersection, otherwise return false and do not change this rectangle. More... | |
bool SK_WARN_UNUSED_RESULT | intersectNoEmptyCheck (const SkIRect &a, const SkIRect &b) |
If rectangles a and b intersect, return true and set this rectangle to that intersection, otherwise return false and do not change this rectangle. More... | |
bool | intersect (int32_t left, int32_t top, int32_t right, int32_t bottom) |
If the rectangle specified by left,top,right,bottom intersects this rectangle, return true and set this rectangle to that intersection, otherwise return false and do not change this rectangle. More... | |
void | join (int32_t left, int32_t top, int32_t right, int32_t bottom) |
Update this rectangle to enclose itself and the specified rectangle. More... | |
void | join (const SkIRect &r) |
Update this rectangle to enclose itself and the specified rectangle. More... | |
void | sort () |
Swap top/bottom or left/right if there are flipped. More... | |
SkIRect | makeSorted () const |
Return a new Rect that is the sorted version of this rect (left <= right, top <= bottom). | |
Static Public Member Functions | |
static SkIRect SK_WARN_UNUSED_RESULT | MakeEmpty () |
static SkIRect SK_WARN_UNUSED_RESULT | MakeLargest () |
static SkIRect SK_WARN_UNUSED_RESULT | MakeWH (int32_t w, int32_t h) |
static SkIRect SK_WARN_UNUSED_RESULT | MakeSize (const SkISize &size) |
static SkIRect SK_WARN_UNUSED_RESULT | MakeLTRB (int32_t l, int32_t t, int32_t r, int32_t b) |
static SkIRect SK_WARN_UNUSED_RESULT | MakeXYWH (int32_t x, int32_t y, int32_t w, int32_t h) |
static bool | Intersects (const SkIRect &a, const SkIRect &b) |
Returns true if a and b are not empty, and they intersect. | |
static bool | IntersectsNoEmptyCheck (const SkIRect &a, const SkIRect &b) |
Returns true if a and b intersect. More... | |
static const SkIRect &SK_WARN_UNUSED_RESULT | EmptyIRect () |
Public Attributes | |
int32_t | fLeft |
int32_t | fTop |
int32_t | fRight |
int32_t | fBottom |
Friends | |
bool | operator== (const SkIRect &a, const SkIRect &b) |
bool | operator!= (const SkIRect &a, const SkIRect &b) |
SkIRect holds four 32 bit integer coordinates for a rectangle.
|
inline |
Since the center of an integer rect may fall on a factional value, this method is defined to return (right + left) >> 1.
This is a specific "truncation" of the average, which is different than (right + left) / 2 when the sum is negative.
|
inline |
Since the center of an integer rect may fall on a factional value, this method is defined to return (bottom + top) >> 1.
This is a specific "truncation" of the average, which is different than (bottom + top) / 2 when the sum is negative.
|
inline |
Returns true if (x,y) is inside the rectangle and the rectangle is not empty.
The left and top are considered to be inside, while the right and bottom are not. Thus for the rectangle (0, 0, 5, 10), the points (0,0) and (0,9) are inside, while (-1,0) and (5,9) are not.
|
inline |
Returns true if the 4 specified sides of a rectangle are inside or equal to this rectangle.
If either rectangle is empty, contains() returns false.
|
inline |
Return true if this rectangle contains the specified rectangle.
For speed, this method does not check if either this or the specified rectangles are empty, and if either is, its return value is undefined. In the debugging build however, we assert that both this and the specified rectangles are non-empty.
|
inline |
Returns the rectangle's height.
This does not check for a valid rect (i.e. top <= bottom) so the result may be negative.
|
inline |
Inset the rectangle by (dx,dy).
If dx is positive, then the sides are moved inwards, making the rectangle narrower. If dx is negative, then the sides are moved outwards, making the rectangle wider. The same holds true for dy and the top and bottom.
|
inline |
If r intersects this rectangle, return true and set this rectangle to that intersection, otherwise return false and do not change this rectangle.
If either rectangle is empty, do nothing and return false.
If rectangles a and b intersect, return true and set this rectangle to that intersection, otherwise return false and do not change this rectangle.
If either rectangle is empty, do nothing and return false.
|
inline |
If the rectangle specified by left,top,right,bottom intersects this rectangle, return true and set this rectangle to that intersection, otherwise return false and do not change this rectangle.
If either rectangle is empty, do nothing and return false.
|
inline |
If rectangles a and b intersect, return true and set this rectangle to that intersection, otherwise return false and do not change this rectangle.
For speed, no check to see if a or b are empty is performed. If either is, then the return result is undefined. In the debug build, we assert that both rectangles are non-empty.
Returns true if a and b intersect.
debug-asserts that neither are empty.
void SkIRect::join | ( | int32_t | left, |
int32_t | top, | ||
int32_t | right, | ||
int32_t | bottom | ||
) |
Update this rectangle to enclose itself and the specified rectangle.
If this rectangle is empty, just set it to the specified rectangle. If the specified rectangle is empty, do nothing.
|
inline |
Update this rectangle to enclose itself and the specified rectangle.
If this rectangle is empty, just set it to the specified rectangle. If the specified rectangle is empty, do nothing.
|
inline |
Outset the rectangle by (dx,dy).
If dx is positive, then the sides are moved outwards, making the rectangle wider. If dx is negative, then the sides are moved inwards, making the rectangle narrower. The same holds true for dy and the top and bottom.
|
inline |
Make the largest representable rectangle, but inverted (e.g.
fLeft will be max 32bit and right will be min 32bit).
|
inline |
Swap top/bottom or left/right if there are flipped.
This can be called if the edges are computed separately, and may have crossed over each other. When this returns, left <= right && top <= bottom
|
inline |
Returns the rectangle's width.
This does not check for a valid rect (i.e. left <= right) so the result may be negative.