diff options
author | Chris Craik <ccraik@google.com> | 2014-03-26 17:40:31 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-03-26 17:40:32 +0000 |
commit | 62828dfca2b009d42a414b60117d7f34034841f8 (patch) | |
tree | 5a0ad6c78c7a1ebca79d8e85fa0c5cdea76efcfa /libs/hwui/RenderProperties.cpp | |
parent | 564a0cd87c47ec53790c93197842969a6aab262c (diff) | |
parent | 8c271ca63b62061fd22cfee78fd6a574b44476fd (diff) | |
download | frameworks_base-62828dfca2b009d42a414b60117d7f34034841f8.zip frameworks_base-62828dfca2b009d42a414b60117d7f34034841f8.tar.gz frameworks_base-62828dfca2b009d42a414b60117d7f34034841f8.tar.bz2 |
Merge "Add private circular reveal API on View/RenderNode"
Diffstat (limited to 'libs/hwui/RenderProperties.cpp')
-rw-r--r-- | libs/hwui/RenderProperties.cpp | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/libs/hwui/RenderProperties.cpp b/libs/hwui/RenderProperties.cpp index ca291a6..3975a76 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 */ |