summaryrefslogtreecommitdiff
path: root/libs/hwui/RenderProperties.cpp
diff options
context:
space:
mode:
author Chris Craik <ccraik@google.com> 2014-03-25 10:33:01 -0700
committer Chris Craik <ccraik@google.com> 2014-03-25 16:03:48 -0700
commit8c271ca63b62061fd22cfee78fd6a574b44476fd (patch)
treee4b6a9d863aec687273be89373d2fc432cf29c30 /libs/hwui/RenderProperties.cpp
parent5e44cadfd69c210c11f80cfe599718617a0e6676 (diff)
Add private circular reveal API on View/RenderNode
Change-Id: I139c8e12b354083149a665f6768f3f6931a8dd15
Diffstat (limited to 'libs/hwui/RenderProperties.cpp')
-rw-r--r--libs/hwui/RenderProperties.cpp41
1 files changed, 40 insertions, 1 deletions
diff --git a/libs/hwui/RenderProperties.cpp b/libs/hwui/RenderProperties.cpp
index ca291a6e53c8..3975a766a8e5 100644
--- a/libs/hwui/RenderProperties.cpp
+++ b/libs/hwui/RenderProperties.cpp
@@ -22,6 +22,8 @@
#include <SkCanvas.h>
#include <SkMatrix.h>
+#include <SkPath.h>
+#include <SkPathOps.h>
#include "Matrix.h"
@@ -51,13 +53,15 @@ RenderProperties::PrimitiveFields::PrimitiveFields()
RenderProperties::ComputedFields::ComputedFields()
: mTransformMatrix(NULL)
, mTransformCamera(NULL)
- , mTransformMatrix3D(NULL) {
+ , mTransformMatrix3D(NULL)
+ , mClipPath(NULL) {
}
RenderProperties::ComputedFields::~ComputedFields() {
delete mTransformMatrix;
delete mTransformCamera;
delete mTransformMatrix3D;
+ delete mClipPath;
}
RenderProperties::RenderProperties()
@@ -80,6 +84,7 @@ RenderProperties& RenderProperties::operator=(const RenderProperties& other) {
// Update the computed fields
updateMatrix();
+ updateClipPath();
}
return *this;
}
@@ -181,5 +186,39 @@ void RenderProperties::updateMatrix() {
}
}
+void RenderProperties::updateClipPath() {
+ const SkPath* outlineClipPath = mPrimitiveFields.mOutline.willClip()
+ ? mPrimitiveFields.mOutline.getPath() : NULL;
+ const SkPath* revealClipPath = mPrimitiveFields.mRevealClip.getPath();
+
+ if (!outlineClipPath && !revealClipPath) {
+ // mComputedFields.mClipPath doesn't need to be updated, since it won't be used
+ return;
+ }
+
+ if (mComputedFields.mClipPath == NULL) {
+ mComputedFields.mClipPath = new SkPath();
+ }
+ SkPath* clipPath = mComputedFields.mClipPath;
+ mComputedFields.mClipPathOp = SkRegion::kIntersect_Op;
+
+ if (outlineClipPath && revealClipPath) {
+ SkPathOp op = kIntersect_PathOp;
+ if (mPrimitiveFields.mRevealClip.isInverseClip()) {
+ op = kDifference_PathOp; // apply difference step in the Op below, instead of draw time
+ }
+
+ Op(*outlineClipPath, *revealClipPath, op, clipPath);
+ } else if (outlineClipPath) {
+ *clipPath = *outlineClipPath;
+ } else {
+ *clipPath = *revealClipPath;
+ if (mPrimitiveFields.mRevealClip.isInverseClip()) {
+ // apply difference step at draw time
+ mComputedFields.mClipPathOp = SkRegion::kDifference_Op;
+ }
+ }
+}
+
} /* namespace uirenderer */
} /* namespace android */