Skia
2D Graphics Library
|
SkRegion describes the set of pixels used to clip SkCanvas. More...
#include <SkRegion.h>
Classes | |
class | Cliperator |
Returns the sequence of rectangles, sorted along y-axis, then x-axis, that make up SkRegion intersected with the specified clip rectangle. More... | |
class | Iterator |
Returns sequence of rectangles, sorted along y-axis, then x-axis, that make up SkRegion. More... | |
class | Spanerator |
Returns the line segment ends within SkRegion that intersect a horizontal line. More... | |
Public Types | |
enum | Op { kDifference_Op , kIntersect_Op , kUnion_Op , kXOR_Op , kReverseDifference_Op , kReplace_Op , kLastOp = kReplace_Op } |
using | sk_is_trivially_relocatable = std::true_type |
Public Member Functions | |
SkRegion () | |
Constructs an empty SkRegion. More... | |
SkRegion (const SkRegion ®ion) | |
Constructs a copy of an existing region. More... | |
SkRegion (const SkIRect &rect) | |
Constructs a rectangular SkRegion matching the bounds of rect. More... | |
~SkRegion () | |
Releases ownership of any shared data and deletes data if SkRegion is sole owner. More... | |
SkRegion & | operator= (const SkRegion ®ion) |
Constructs a copy of an existing region. More... | |
bool | operator== (const SkRegion &other) const |
Compares SkRegion and other; returns true if they enclose exactly the same area. More... | |
bool | operator!= (const SkRegion &other) const |
Compares SkRegion and other; returns true if they do not enclose the same area. More... | |
bool | set (const SkRegion &src) |
Sets SkRegion to src, and returns true if src bounds is not empty. More... | |
void | swap (SkRegion &other) |
Exchanges SkIRect array of SkRegion and other. More... | |
bool | isEmpty () const |
Returns true if SkRegion is empty. More... | |
bool | isRect () const |
Returns true if SkRegion is one SkIRect with positive dimensions. More... | |
bool | isComplex () const |
Returns true if SkRegion is described by more than one rectangle. More... | |
const SkIRect & | getBounds () const |
Returns minimum and maximum axes values of SkIRect array. More... | |
int | computeRegionComplexity () const |
Returns a value that increases with the number of elements in SkRegion. More... | |
bool | getBoundaryPath (SkPath *path) const |
Appends outline of SkRegion to path. More... | |
bool | setEmpty () |
Constructs an empty SkRegion. More... | |
bool | setRect (const SkIRect &rect) |
Constructs a rectangular SkRegion matching the bounds of rect. More... | |
bool | setRects (const SkIRect rects[], int count) |
Constructs SkRegion as the union of SkIRect in rects array. More... | |
bool | setRegion (const SkRegion ®ion) |
Constructs a copy of an existing region. More... | |
bool | setPath (const SkPath &path, const SkRegion &clip) |
Constructs SkRegion to match outline of path within clip. More... | |
bool | intersects (const SkIRect &rect) const |
Returns true if SkRegion intersects rect. More... | |
bool | intersects (const SkRegion &other) const |
Returns true if SkRegion intersects other. More... | |
bool | contains (int32_t x, int32_t y) const |
Returns true if SkIPoint (x, y) is inside SkRegion. More... | |
bool | contains (const SkIRect &other) const |
Returns true if other is completely inside SkRegion. More... | |
bool | contains (const SkRegion &other) const |
Returns true if other is completely inside SkRegion. More... | |
bool | quickContains (const SkIRect &r) const |
Returns true if SkRegion is a single rectangle and contains r. More... | |
bool | quickReject (const SkIRect &rect) const |
Returns true if SkRegion does not intersect rect. More... | |
bool | quickReject (const SkRegion &rgn) const |
Returns true if SkRegion does not intersect rgn. More... | |
void | translate (int dx, int dy) |
Offsets SkRegion by ivector (dx, dy). More... | |
void | translate (int dx, int dy, SkRegion *dst) const |
Offsets SkRegion by ivector (dx, dy), writing result to dst. More... | |
bool | op (const SkIRect &rect, Op op) |
Replaces SkRegion with the result of SkRegion op rect. More... | |
bool | op (const SkRegion &rgn, Op op) |
Replaces SkRegion with the result of SkRegion op rgn. More... | |
bool | op (const SkIRect &rect, const SkRegion &rgn, Op op) |
Replaces SkRegion with the result of rect op rgn. More... | |
bool | op (const SkRegion &rgn, const SkIRect &rect, Op op) |
Replaces SkRegion with the result of rgn op rect. More... | |
bool | op (const SkRegion &rgna, const SkRegion &rgnb, Op op) |
Replaces SkRegion with the result of rgna op rgnb. More... | |
size_t | writeToMemory (void *buffer) const |
Writes SkRegion to buffer, and returns number of bytes written. More... | |
size_t | readFromMemory (const void *buffer, size_t length) |
Constructs SkRegion from buffer of size length. More... | |
Static Public Attributes | |
static const int | kOpCnt = kLastOp + 1 |
Friends | |
struct | RunHead |
class | Iterator |
class | Spanerator |
class | SkRegionPriv |
class | SkRgnBuilder |
class | SkFlatRegion |
SkRegion describes the set of pixels used to clip SkCanvas.
SkRegion is compact, efficiently storing a single integer rectangle, or a run length encoded array of rectangles. SkRegion may reduce the current SkCanvas clip, or may be drawn as one or more integer rectangles. SkRegion iterator returns the scan lines or rectangles contained by it, optionally intersecting a bounding rectangle.
using SkRegion::sk_is_trivially_relocatable = std::true_type |
enum SkRegion::Op |
SkRegion::SkRegion | ( | ) |
Constructs an empty SkRegion.
SkRegion is set to empty bounds at (0, 0) with zero width and height.
example: https://fiddle.skia.org/c/@Region_empty_constructor
SkRegion::SkRegion | ( | const SkRegion & | region | ) |
Constructs a copy of an existing region.
Copy constructor makes two regions identical by value. Internally, region and the returned result share pointer values. The underlying SkRect array is copied when modified.
Creating a SkRegion copy is very efficient and never allocates memory. SkRegion are always copied by value from the interface; the underlying shared pointers are not exposed.
region | SkRegion to copy by value |
example: https://fiddle.skia.org/c/@Region_copy_const_SkRegion
|
explicit |
Constructs a rectangular SkRegion matching the bounds of rect.
rect | bounds of constructed SkRegion |
example: https://fiddle.skia.org/c/@Region_copy_const_SkIRect
SkRegion::~SkRegion | ( | ) |
Releases ownership of any shared data and deletes data if SkRegion is sole owner.
int SkRegion::computeRegionComplexity | ( | ) | const |
Returns a value that increases with the number of elements in SkRegion.
Returns zero if SkRegion is empty. Returns one if SkRegion equals SkIRect; otherwise, returns value greater than one indicating that SkRegion is complex.
Call to compare SkRegion for relative complexity.
example: https://fiddle.skia.org/c/@Region_computeRegionComplexity
bool SkRegion::contains | ( | const SkIRect & | other | ) | const |
bool SkRegion::contains | ( | const SkRegion & | other | ) | const |
bool SkRegion::contains | ( | int32_t | x, |
int32_t | y | ||
) | const |
bool SkRegion::getBoundaryPath | ( | SkPath * | path | ) | const |
|
inline |
bool SkRegion::intersects | ( | const SkIRect & | rect | ) | const |
bool SkRegion::intersects | ( | const SkRegion & | other | ) | const |
|
inline |
|
inline |
Returns true if SkRegion is empty.
Empty SkRegion has bounds width or height less than or equal to zero. SkRegion() constructs empty SkRegion; setEmpty() and setRect() with dimensionless data make SkRegion empty.
|
inline |
|
inline |
Constructs a copy of an existing region.
Makes two regions identical by value. Internally, region and the returned result share pointer values. The underlying SkRect array is copied when modified.
Creating a SkRegion copy is very efficient and never allocates memory. SkRegion are always copied by value from the interface; the underlying shared pointers are not exposed.
region | SkRegion to copy by value |
bool SkRegion::operator== | ( | const SkRegion & | other | ) | const |
|
inline |
|
inline |
|
inline |
size_t SkRegion::readFromMemory | ( | const void * | buffer, |
size_t | length | ||
) |
Constructs SkRegion from buffer of size length.
Returns bytes read. Returned value will be multiple of four or zero if length was too small.
buffer | storage for binary data |
length | size of buffer |
|
inline |
Sets SkRegion to src, and returns true if src bounds is not empty.
This makes SkRegion and src identical by value. Internally, SkRegion and src share pointer values. The underlying SkRect array is copied when modified.
Creating a SkRegion copy is very efficient and never allocates memory. SkRegion are always copied by value from the interface; the underlying shared pointers are not exposed.
src | SkRegion to copy |
bool SkRegion::setEmpty | ( | ) |
bool SkRegion::setRect | ( | const SkIRect & | rect | ) |
bool SkRegion::setRects | ( | const SkIRect | rects[], |
int | count | ||
) |
bool SkRegion::setRegion | ( | const SkRegion & | region | ) |
Constructs a copy of an existing region.
Makes two regions identical by value. Internally, region and the returned result share pointer values. The underlying SkRect array is copied when modified.
Creating a SkRegion copy is very efficient and never allocates memory. SkRegion are always copied by value from the interface; the underlying shared pointers are not exposed.
region | SkRegion to copy by value |
void SkRegion::swap | ( | SkRegion & | other | ) |
Exchanges SkIRect array of SkRegion and other.
swap() internally exchanges pointers, so it is lightweight and does not allocate memory.
swap() usage has largely been replaced by operator=(const SkRegion& region). SkPath do not copy their content on assignment until they are written to, making assignment as efficient as swap().
other | operator=(const SkRegion& region) set |
|
inline |
void SkRegion::translate | ( | int | dx, |
int | dy, | ||
SkRegion * | dst | ||
) | const |
size_t SkRegion::writeToMemory | ( | void * | buffer | ) | const |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
static |