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
diff --git a/libs/ui/Region.cpp b/libs/ui/Region.cpp
index 8cd047a..6e2e731 100644
--- a/libs/ui/Region.cpp
+++ b/libs/ui/Region.cpp
@@ -126,6 +126,9 @@
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::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 @@
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::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 @@
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 @@
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 @@
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;
}