10 #ifndef SkRegion_DEFINED
11 #define SkRegion_DEFINED
22 #define SkRegion_gEmptyRunHeadPtr ((SkRegion::RunHead*)-1)
23 #define SkRegion_gRectRunHeadPtr 0
32 typedef int32_t RunType;
34 kRunTypeSentinel = 0x7FFFFFFF
48 bool operator==(
const SkRegion& other)
const;
54 return !(*
this == other);
63 return !this->isEmpty();
73 bool isEmpty()
const {
return fRunHead == SkRegion_gEmptyRunHeadPtr; }
76 bool isRect()
const {
return fRunHead == SkRegion_gRectRunHeadPtr; }
79 bool isComplex()
const {
return !this->isEmpty() && !this->isRect(); }
95 int computeRegionComplexity()
const;
102 bool getBoundaryPath(
SkPath* path)
const;
120 bool setRect(int32_t left, int32_t top, int32_t right, int32_t bottom);
128 bool setRects(
const SkIRect rects[],
int count);
148 bool intersects(
const SkIRect&)
const;
154 bool intersects(
const SkRegion&)
const;
159 bool contains(int32_t x, int32_t y)
const;
167 bool contains(
const SkIRect&)
const;
175 bool contains(
const SkRegion&)
const;
184 return this->quickContains(r.fLeft, r.fTop, r.fRight, r.fBottom);
195 int32_t bottom)
const {
196 SkASSERT(this->isEmpty() == fBounds.isEmpty());
198 return left < right && top < bottom &&
199 fRunHead == SkRegion_gRectRunHeadPtr &&
201 fBounds.fLeft <= left && fBounds.fTop <= top &&
202 fBounds.fRight >= right && fBounds.fBottom >= bottom;
211 return this->isEmpty() || rect.
isEmpty() ||
221 return this->isEmpty() || rgn.
isEmpty() ||
234 void translate(
int dx,
int dy,
SkRegion* dst)
const;
248 kLastOp = kReplace_Op
251 static const int kOpCnt = kLastOp + 1;
259 if (this->isRect() && kIntersect_Op == op) {
260 if (!fBounds.intersect(rect)) {
261 return this->setEmpty();
265 return this->op(*
this, rect, op);
273 bool op(
int left,
int top,
int right,
int bottom,
Op op) {
275 rect.set(left, top, right, bottom);
276 return this->op(*
this, rect, op);
307 #ifdef SK_BUILD_FOR_ANDROID
319 Iterator() : fRgn(NULL), fDone(
true) {}
325 bool done()
const {
return fDone; }
327 const SkIRect& rect()
const {
return fRect; }
329 const SkRegion* rgn()
const {
return fRgn; }
333 const RunType* fRuns;
345 bool done() {
return fDone; }
347 const SkIRect& rect()
const {
return fRect; }
363 bool next(
int* left,
int* right);
366 const SkRegion::RunType* fRuns;
375 size_t writeToMemory(
void* buffer)
const;
384 size_t readFromMemory(
const void* buffer,
size_t length);
390 static const SkRegion& GetEmptyRegion();
392 SkDEBUGCODE(
void dump()
const;)
393 SkDEBUGCODE(
void validate()
const;)
394 SkDEBUGCODE(
static void UnitTest();)
397 SkDEBUGCODE(
bool debugSetRuns(
const RunType runs[],
int count);)
401 kOpCount = kReplace_Op + 1
411 friend class android::Region;
416 void allocateRuns(
int count);
417 void allocateRuns(
int count,
int ySpanCount,
int intervalCount);
418 void allocateRuns(
const RunHead& src);
430 const RunType* getRuns(RunType tmpStorage[],
int* intervals)
const;
435 bool setRuns(RunType runs[],
int count);
437 int count_runtype_values(
int* itop,
int* ibot)
const;
439 bool isValid()
const;
441 static void BuildRectRuns(
const SkIRect& bounds,
442 RunType runs[kRectRegionRuns]);
446 static bool RunsAreARect(
const SkRegion::RunType runs[],
int count,
455 friend struct RunHead;
456 friend class Iterator;
457 friend class Spanerator;
458 friend class SkRgnBuilder;
459 friend class SkFlatRegion;
bool quickContains(const SkIRect &r) const
Return true if this region is a single rectangle (not complex) and the specified rectangle is contain...
Definition: SkRegion.h:183
static bool Intersects(const SkIRect &a, const SkIRect &b)
Returns true if a and b are not empty, and they intersect.
Definition: SkRect.h:344
The SkPath class encapsulates compound (multiple contour) geometric paths consisting of straight line...
Definition: SkPath.h:25
bool isRect() const
Return true if this region is a single, non-empty rectangle.
Definition: SkRegion.h:76
bool isEmpty() const
Return true if this region is empty.
Definition: SkRegion.h:73
union (inclusive-or) the two regions
Definition: SkRegion.h:242
Returns the sequence of rectangles, sorted in Y and X, that make up this region intersected with the ...
Definition: SkRegion.h:342
bool set(const SkRegion &src)
Replace this region with the specified region, and return true if the resulting region is non-empty...
Definition: SkRegion.h:61
bool quickReject(const SkRegion &rgn) const
Return true if this region, or rgn, is empty, or if their bounds do not intersect.
Definition: SkRegion.h:220
subtract the op region from the first region
Definition: SkRegion.h:240
bool op(int left, int top, int right, int bottom, Op op)
Set this region to the result of applying the Op to this region and the specified rectangle: this = (...
Definition: SkRegion.h:273
Returns the sequence of runs that make up this region for the specified Y scanline, clipped to the specified left and right X values.
Definition: SkRegion.h:360
Returns the sequence of rectangles, sorted in Y and X, that make up this region.
Definition: SkRegion.h:317
void translate(int dx, int dy)
Translate the region by the specified (dx, dy) amount.
Definition: SkRegion.h:226
exclusive-or the two regions
Definition: SkRegion.h:243
bool quickContains(int32_t left, int32_t top, int32_t right, int32_t bottom) const
Return true if this region is a single rectangle (not complex) and the specified rectangle is contain...
Definition: SkRegion.h:194
bool isEmpty() const
Return true if the rectangle's width or height are <= 0.
Definition: SkRect.h:103
bool isComplex() const
Return true if this region consists of more than 1 rectangular area.
Definition: SkRegion.h:79
const SkIRect & getBounds() const
Return the bounds of this region.
Definition: SkRegion.h:85
bool op(const SkIRect &rect, Op op)
Set this region to the result of applying the Op to this region and the specified rectangle: this = (...
Definition: SkRegion.h:258
The SkRegion class encapsulates the geometric region used to specify clipping areas for drawing...
Definition: SkRegion.h:30
replace the dst region with the op region
Definition: SkRegion.h:246
bool op(const SkRegion &rgn, Op op)
Set this region to the result of applying the Op to this region and the specified region: this = (thi...
Definition: SkRegion.h:284
subtract the first region from the op region
Definition: SkRegion.h:245
intersect the two regions
Definition: SkRegion.h:241
SkIRect holds four 32 bit integer coordinates for a rectangle.
Definition: SkRect.h:20
Op
The logical operations that can be performed when combining two regions.
Definition: SkRegion.h:239
bool quickReject(const SkIRect &rect) const
Return true if this region is empty, or if the specified rectangle does not intersect the region...
Definition: SkRegion.h:210
bool operator!=(const SkRegion &other) const
Return true if the two regions are not equal.
Definition: SkRegion.h:53