Preliminary support for clipRect(Rect, Op)
This adds basic support for clip regions. It is currently disabled at compile time. Enabling clip regions will require setting up a stencil buffer. Change-Id: I638616a972276e38737f8ac0633692c3845eaa74
This commit is contained in:
parent
78b3490a9a
commit
b8a2e98cd7
|
@ -55,43 +55,51 @@ public:
|
|||
void set(uint32_t w, uint32_t h);
|
||||
|
||||
Region& orSelf(const Rect& rhs);
|
||||
Region& xorSelf(const Rect& rhs);
|
||||
Region& andSelf(const Rect& rhs);
|
||||
Region& subtractSelf(const Rect& rhs);
|
||||
|
||||
// boolean operators, applied on this
|
||||
Region& orSelf(const Region& rhs);
|
||||
Region& xorSelf(const Region& rhs);
|
||||
Region& andSelf(const Region& rhs);
|
||||
Region& subtractSelf(const Region& rhs);
|
||||
|
||||
// boolean operators
|
||||
const Region merge(const Rect& rhs) const;
|
||||
const Region mergeExclusive(const Rect& rhs) const;
|
||||
const Region intersect(const Rect& rhs) const;
|
||||
const Region subtract(const Rect& rhs) const;
|
||||
|
||||
// boolean operators
|
||||
const Region merge(const Region& rhs) const;
|
||||
const Region mergeExclusive(const Region& rhs) const;
|
||||
const Region intersect(const Region& rhs) const;
|
||||
const Region subtract(const Region& rhs) const;
|
||||
|
||||
// these translate rhs first
|
||||
Region& translateSelf(int dx, int dy);
|
||||
Region& orSelf(const Region& rhs, int dx, int dy);
|
||||
Region& xorSelf(const Region& rhs, int dx, int dy);
|
||||
Region& andSelf(const Region& rhs, int dx, int dy);
|
||||
Region& subtractSelf(const Region& rhs, int dx, int dy);
|
||||
|
||||
// these translate rhs first
|
||||
const Region translate(int dx, int dy) const;
|
||||
const Region merge(const Region& rhs, int dx, int dy) const;
|
||||
const Region mergeExclusive(const Region& rhs, int dx, int dy) const;
|
||||
const Region intersect(const Region& rhs, int dx, int dy) const;
|
||||
const Region subtract(const Region& rhs, int dx, int dy) const;
|
||||
|
||||
// convenience operators overloads
|
||||
inline const Region operator | (const Region& rhs) const;
|
||||
inline const Region operator ^ (const Region& rhs) const;
|
||||
inline const Region operator & (const Region& rhs) const;
|
||||
inline const Region operator - (const Region& rhs) const;
|
||||
inline const Region operator + (const Point& pt) const;
|
||||
|
||||
inline Region& operator |= (const Region& rhs);
|
||||
inline Region& operator ^= (const Region& rhs);
|
||||
inline Region& operator &= (const Region& rhs);
|
||||
inline Region& operator -= (const Region& rhs);
|
||||
inline Region& operator += (const Point& pt);
|
||||
|
@ -158,6 +166,9 @@ private:
|
|||
const Region Region::operator | (const Region& rhs) const {
|
||||
return merge(rhs);
|
||||
}
|
||||
const Region Region::operator ^ (const Region& rhs) const {
|
||||
return mergeExclusive(rhs);
|
||||
}
|
||||
const Region Region::operator & (const Region& rhs) const {
|
||||
return intersect(rhs);
|
||||
}
|
||||
|
@ -172,6 +183,9 @@ const Region Region::operator + (const Point& pt) const {
|
|||
Region& Region::operator |= (const Region& rhs) {
|
||||
return orSelf(rhs);
|
||||
}
|
||||
Region& Region::operator ^= (const Region& rhs) {
|
||||
return xorSelf(rhs);
|
||||
}
|
||||
Region& Region::operator &= (const Region& rhs) {
|
||||
return andSelf(rhs);
|
||||
}
|
||||
|
|
|
@ -126,6 +126,9 @@ void Region::addRectUnchecked(int l, int t, int r, int b)
|
|||
Region& Region::orSelf(const Rect& r) {
|
||||
return operationSelf(r, op_or);
|
||||
}
|
||||
Region& Region::xorSelf(const Rect& r) {
|
||||
return operationSelf(r, op_xor);
|
||||
}
|
||||
Region& Region::andSelf(const Rect& r) {
|
||||
return operationSelf(r, op_and);
|
||||
}
|
||||
|
@ -143,6 +146,9 @@ Region& Region::operationSelf(const Rect& r, int op) {
|
|||
Region& Region::orSelf(const Region& rhs) {
|
||||
return operationSelf(rhs, op_or);
|
||||
}
|
||||
Region& Region::xorSelf(const Region& rhs) {
|
||||
return operationSelf(rhs, op_xor);
|
||||
}
|
||||
Region& Region::andSelf(const Region& rhs) {
|
||||
return operationSelf(rhs, op_and);
|
||||
}
|
||||
|
@ -165,6 +171,9 @@ Region& Region::translateSelf(int x, int y) {
|
|||
const Region Region::merge(const Rect& rhs) const {
|
||||
return operation(rhs, op_or);
|
||||
}
|
||||
const Region Region::mergeExclusive(const Rect& rhs) const {
|
||||
return operation(rhs, op_xor);
|
||||
}
|
||||
const Region Region::intersect(const Rect& rhs) const {
|
||||
return operation(rhs, op_and);
|
||||
}
|
||||
|
@ -182,6 +191,9 @@ const Region Region::operation(const Rect& rhs, int op) const {
|
|||
const Region Region::merge(const Region& rhs) const {
|
||||
return operation(rhs, op_or);
|
||||
}
|
||||
const Region Region::mergeExclusive(const Region& rhs) const {
|
||||
return operation(rhs, op_xor);
|
||||
}
|
||||
const Region Region::intersect(const Region& rhs) const {
|
||||
return operation(rhs, op_and);
|
||||
}
|
||||
|
@ -205,6 +217,9 @@ const Region Region::translate(int x, int y) const {
|
|||
Region& Region::orSelf(const Region& rhs, int dx, int dy) {
|
||||
return operationSelf(rhs, dx, dy, op_or);
|
||||
}
|
||||
Region& Region::xorSelf(const Region& rhs, int dx, int dy) {
|
||||
return operationSelf(rhs, dx, dy, op_xor);
|
||||
}
|
||||
Region& Region::andSelf(const Region& rhs, int dx, int dy) {
|
||||
return operationSelf(rhs, dx, dy, op_and);
|
||||
}
|
||||
|
@ -222,6 +237,9 @@ Region& Region::operationSelf(const Region& rhs, int dx, int dy, int op) {
|
|||
const Region Region::merge(const Region& rhs, int dx, int dy) const {
|
||||
return operation(rhs, dx, dy, op_or);
|
||||
}
|
||||
const Region Region::mergeExclusive(const Region& rhs, int dx, int dy) const {
|
||||
return operation(rhs, dx, dy, op_xor);
|
||||
}
|
||||
const Region Region::intersect(const Region& rhs, int dx, int dy) const {
|
||||
return operation(rhs, dx, dy, op_and);
|
||||
}
|
||||
|
@ -421,6 +439,7 @@ void Region::boolean_operation(int op, Region& dst,
|
|||
SkRegion::Op sk_op;
|
||||
switch (op) {
|
||||
case op_or: sk_op = SkRegion::kUnion_Op; name="OR"; break;
|
||||
case op_xor: sk_op = SkRegion::kUnion_XOR; name="XOR"; break;
|
||||
case op_and: sk_op = SkRegion::kIntersect_Op; name="AND"; break;
|
||||
case op_nand: sk_op = SkRegion::kDifference_Op; name="NAND"; break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue