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/hwui/Snapshot.h b/libs/hwui/Snapshot.h
index c94af7e..b2bc879 100644
--- a/libs/hwui/Snapshot.h
+++ b/libs/hwui/Snapshot.h
@@ -181,7 +181,7 @@
mat4* transform;
/**
- * Current clip region. The clip is stored in canvas-space coordinates,
+ * Current clip rect. The clip is stored in canvas-space coordinates,
* (screen-space coordinates in the regular case.)
*
* This is a reference to a rect owned by this snapshot or another
@@ -190,6 +190,17 @@
Rect* clipRect;
/**
+ * Current clip region. The clip is stored in canvas-space coordinates,
+ * (screen-space coordinates in the regular case.)
+ *
+ * This is a reference to a region owned by this snapshot or another
+ * snapshot. This pointer must not be freed. See ::mClipRegionRoot.
+ *
+ * This field is used only if STENCIL_BUFFER_SIZE is > 0.
+ */
+ Region* clipRegion;
+
+ /**
* The ancestor layer's dirty region.
*
* This is a reference to a region owned by a layer. This pointer must
@@ -198,10 +209,22 @@
Region* region;
private:
+ void ensureClipRegion();
+ void copyClipRectFromRegion();
+
+ bool clipRegionOr(float left, float top, float right, float bottom);
+ bool clipRegionXor(float left, float top, float right, float bottom);
+ bool clipRegionAnd(float left, float top, float right, float bottom);
+ bool clipRegionNand(float left, float top, float right, float bottom);
+
mat4 mTransformRoot;
Rect mClipRectRoot;
Rect mLocalClip;
+#if STENCIL_BUFFER_SIZE
+ Region mClipRegionRoot;
+#endif
+
}; // class Snapshot
}; // namespace uirenderer