8 #ifndef SkRegion_DEFINED
9 #define SkRegion_DEFINED
12 #include "include/private/base/SkAPI.h"
13 #include "include/private/base/SkAssert.h"
14 #include "include/private/base/SkDebug.h"
15 #include "include/private/base/SkTypeTraits.h"
19 #include <type_traits>
31 typedef int32_t RunType;
106 return !(*
this == other);
123 return !this->isEmpty();
146 bool isEmpty()
const {
return fRunHead == emptyRunHeadPtr(); }
152 bool isRect()
const {
return fRunHead == kRectRunHeadPtr; }
158 bool isComplex()
const {
return !this->isEmpty() && !this->isRect(); }
311 SkASSERT(this->isEmpty() == fBounds.isEmpty());
314 fRunHead == kRectRunHeadPtr &&
316 fBounds.fLeft <= r.
fLeft && fBounds.fTop <= r.
fTop &&
328 return this->isEmpty() || rect.
isEmpty() ||
340 return this->isEmpty() || rgn.
isEmpty() ||
373 kLastOp = kReplace_Op,
376 static const int kOpCnt = kLastOp + 1;
385 if (this->isRect() && kIntersect_Op == op) {
386 if (!fBounds.intersect(rect)) {
387 return this->setEmpty();
391 return this->op(*
this, rect, op);
435 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
488 bool done()
const {
return fDone; }
511 const SkRegion::RunType* fRuns;
587 bool next(
int* left,
int* right);
590 const SkRegion::RunType* fRuns;
619 static constexpr
int kOpCount = kReplace_Op + 1;
624 static constexpr
int kRectRegionRuns = 7;
629 static constexpr RunHead* kRectRunHeadPtr =
nullptr;
632 void allocateRuns(
int count);
633 void allocateRuns(
int count,
int ySpanCount,
int intervalCount);
634 void allocateRuns(
const RunHead& src);
636 SkDEBUGCODE(
void dump()
const;)
641 static_assert(::sk_is_trivially_relocatable<decltype(fBounds)>::value);
642 static_assert(::sk_is_trivially_relocatable<decltype(fRunHead)>::value);
651 const RunType* getRuns(RunType tmpStorage[],
int* intervals)
const;
656 bool setRuns(RunType runs[],
int count);
658 int count_runtype_values(
int* itop,
int* ibot)
const;
660 bool isValid()
const;
662 static void BuildRectRuns(
const SkIRect& bounds,
663 RunType runs[kRectRegionRuns]);
667 static bool RunsAreARect(
const SkRegion::RunType runs[],
int count,
676 friend struct RunHead;
679 friend class SkRegionPriv;
680 friend class SkRgnBuilder;
681 friend class SkFlatRegion;
SkPath contain geometry.
Definition: SkPath.h:58
Returns the sequence of rectangles, sorted along y-axis, then x-axis, that make up SkRegion intersect...
Definition: SkRegion.h:520
const SkIRect & rect() const
Returns SkIRect element in SkRegion, intersected with clip passed to SkRegion::Cliperator constructor...
Definition: SkRegion.h:551
Cliperator(const SkRegion ®ion, const SkIRect &clip)
Sets SkRegion::Cliperator to return elements of SkIRect array in SkRegion within clip.
bool done()
Returns true if SkRegion::Cliperator is pointing to final SkIRect in SkRegion.
Definition: SkRegion.h:537
void next()
Advances iterator to next SkIRect in SkRegion contained by clip.
Returns sequence of rectangles, sorted along y-axis, then x-axis, that make up SkRegion.
Definition: SkRegion.h:447
bool done() const
Returns true if SkRegion::Iterator is pointing to final SkIRect in SkRegion.
Definition: SkRegion.h:488
const SkRegion * rgn() const
Returns SkRegion if set; otherwise, returns nullptr.
Definition: SkRegion.h:507
bool rewind()
SkPoint SkRegion::Iterator to start of SkRegion.
void reset(const SkRegion ®ion)
Resets iterator, using the new SkRegion.
const SkIRect & rect() const
Returns SkIRect element in SkRegion.
Definition: SkRegion.h:501
Iterator(const SkRegion ®ion)
Sets SkRegion::Iterator to return elements of SkIRect array in region.
void next()
Advances SkRegion::Iterator to next SkIRect in SkRegion if it is not done.
Iterator()
Initializes SkRegion::Iterator with an empty SkRegion.
Definition: SkRegion.h:456
Returns the line segment ends within SkRegion that intersect a horizontal line.
Definition: SkRegion.h:563
bool next(int *left, int *right)
Advances iterator to next span intersecting SkRegion within line segment provided in constructor.
Spanerator(const SkRegion ®ion, int y, int left, int right)
Sets SkRegion::Spanerator to return line segments in SkRegion on scan line.
SkRegion describes the set of pixels used to clip SkCanvas.
Definition: SkRegion.h:30
void translate(int dx, int dy)
Offsets SkRegion by ivector (dx, dy).
Definition: SkRegion.h:349
bool getBoundaryPath(SkPath *path) const
Appends outline of SkRegion to path.
bool op(const SkRegion &rgn, const SkIRect &rect, Op op)
Replaces SkRegion with the result of rgn op rect.
size_t readFromMemory(const void *buffer, size_t length)
Constructs SkRegion from buffer of size length.
~SkRegion()
Releases ownership of any shared data and deletes data if SkRegion is sole owner.
bool set(const SkRegion &src)
Sets SkRegion to src, and returns true if src bounds is not empty.
Definition: SkRegion.h:121
bool setEmpty()
Constructs an empty SkRegion.
bool contains(int32_t x, int32_t y) const
Returns true if SkIPoint (x, y) is inside SkRegion.
bool operator==(const SkRegion &other) const
Compares SkRegion and other; returns true if they enclose exactly the same area.
Op
Definition: SkRegion.h:366
@ kReverseDifference_Op
operand minus target
Definition: SkRegion.h:371
@ kUnion_Op
target unioned with operand
Definition: SkRegion.h:369
@ kReplace_Op
replace target with operand
Definition: SkRegion.h:372
@ kIntersect_Op
target intersected with operand
Definition: SkRegion.h:368
@ kDifference_Op
target minus operand
Definition: SkRegion.h:367
@ kXOR_Op
target exclusive or with operand
Definition: SkRegion.h:370
SkRegion()
Constructs an empty SkRegion.
bool setRects(const SkIRect rects[], int count)
Constructs SkRegion as the union of SkIRect in rects array.
bool op(const SkRegion &rgna, const SkRegion &rgnb, Op op)
Replaces SkRegion with the result of rgna op rgnb.
bool isComplex() const
Returns true if SkRegion is described by more than one rectangle.
Definition: SkRegion.h:158
const SkIRect & getBounds() const
Returns minimum and maximum axes values of SkIRect array.
Definition: SkRegion.h:165
friend struct RunHead
Definition: SkRegion.h:676
int computeRegionComplexity() const
Returns a value that increases with the number of elements in SkRegion.
bool isRect() const
Returns true if SkRegion is one SkIRect with positive dimensions.
Definition: SkRegion.h:152
bool contains(const SkIRect &other) const
Returns true if other is completely inside SkRegion.
void translate(int dx, int dy, SkRegion *dst) const
Offsets SkRegion by ivector (dx, dy), writing result to dst.
bool quickContains(const SkIRect &r) const
Returns true if SkRegion is a single rectangle and contains r.
Definition: SkRegion.h:310
bool op(const SkIRect &rect, Op op)
Replaces SkRegion with the result of SkRegion op rect.
Definition: SkRegion.h:384
bool setRect(const SkIRect &rect)
Constructs a rectangular SkRegion matching the bounds of rect.
bool contains(const SkRegion &other) const
Returns true if other is completely inside SkRegion.
bool quickReject(const SkRegion &rgn) const
Returns true if SkRegion does not intersect rgn.
Definition: SkRegion.h:339
bool intersects(const SkRegion &other) const
Returns true if SkRegion intersects other.
bool isEmpty() const
Returns true if SkRegion is empty.
Definition: SkRegion.h:146
bool setPath(const SkPath &path, const SkRegion &clip)
Constructs SkRegion to match outline of path within clip.
std::true_type sk_is_trivially_relocatable
Definition: SkRegion.h:616
void swap(SkRegion &other)
Exchanges SkIRect array of SkRegion and other.
bool setRegion(const SkRegion ®ion)
Constructs a copy of an existing region.
SkRegion(const SkIRect &rect)
Constructs a rectangular SkRegion matching the bounds of rect.
bool quickReject(const SkIRect &rect) const
Returns true if SkRegion does not intersect rect.
Definition: SkRegion.h:327
SkRegion(const SkRegion ®ion)
Constructs a copy of an existing region.
bool operator!=(const SkRegion &other) const
Compares SkRegion and other; returns true if they do not enclose the same area.
Definition: SkRegion.h:105
size_t writeToMemory(void *buffer) const
Writes SkRegion to buffer, and returns number of bytes written.
bool op(const SkRegion &rgn, Op op)
Replaces SkRegion with the result of SkRegion op rgn.
Definition: SkRegion.h:400
bool op(const SkIRect &rect, const SkRegion &rgn, Op op)
Replaces SkRegion with the result of rect op rgn.
bool intersects(const SkIRect &rect) const
Returns true if SkRegion intersects rect.
SkRegion & operator=(const SkRegion ®ion)
Constructs a copy of an existing region.
SkIRect holds four 32-bit integer coordinates describing the upper and lower bounds of a rectangle.
Definition: SkRect.h:32
static bool Intersects(const SkIRect &a, const SkIRect &b)
Returns true if a intersects b.
Definition: SkRect.h:535
int32_t fBottom
larger y-axis bounds
Definition: SkRect.h:36
int32_t fTop
smaller y-axis bounds
Definition: SkRect.h:34
bool isEmpty() const
Returns true if width() or height() are zero or negative.
Definition: SkRect.h:202
int32_t fLeft
smaller x-axis bounds
Definition: SkRect.h:33
int32_t fRight
larger x-axis bounds
Definition: SkRect.h:35