diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/Outline.h | 16 | ||||
-rw-r--r-- | libs/hwui/RenderNode.cpp | 10 |
2 files changed, 21 insertions, 5 deletions
diff --git a/libs/hwui/Outline.h b/libs/hwui/Outline.h index 83426e8..6dacd5e 100644 --- a/libs/hwui/Outline.h +++ b/libs/hwui/Outline.h @@ -28,18 +28,20 @@ public: Outline() : mShouldClip(false) , mType(kOutlineType_None) - , mRadius(0) {} + , mRadius(0) + , mAlpha(0.0f) {} - void setRoundRect(int left, int top, int right, int bottom, float radius) { + void setRoundRect(int left, int top, int right, int bottom, float radius, float alpha) { mType = kOutlineType_RoundRect; mBounds.set(left, top, right, bottom); mRadius = radius; mPath.reset(); mPath.addRoundRect(SkRect::MakeLTRB(left, top, right, bottom), radius, radius); + mAlpha = alpha; } - void setConvexPath(const SkPath* outline) { + void setConvexPath(const SkPath* outline, float alpha) { if (!outline) { setEmpty(); return; @@ -47,22 +49,29 @@ public: mType = kOutlineType_ConvexPath; mPath = *outline; mBounds.set(outline->getBounds()); + mAlpha = alpha; } void setEmpty() { mType = kOutlineType_Empty; mPath.reset(); + mAlpha = 0.0f; } void setNone() { mType = kOutlineType_None; mPath.reset(); + mAlpha = 0.0f; } bool isEmpty() const { return mType == kOutlineType_Empty; } + float getAlpha() const { + return mAlpha; + } + void setShouldClip(bool clip) { mShouldClip = clip; } @@ -103,6 +112,7 @@ private: OutlineType mType; Rect mBounds; float mRadius; + float mAlpha; SkPath mPath; }; diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp index 0662ca2..fa1b21d 100644 --- a/libs/hwui/RenderNode.cpp +++ b/libs/hwui/RenderNode.cpp @@ -594,7 +594,12 @@ void RenderNode::buildZSortedChildList(Vector<ZDrawRenderNodeOpPair>& zTranslate template <class T> void RenderNode::issueDrawShadowOperation(const Matrix4& transformFromParent, T& handler) { - if (properties().getAlpha() <= 0.0f || !properties().getOutline().getPath()) return; + if (properties().getAlpha() <= 0.0f + || properties().getOutline().getAlpha() <= 0.0f + || !properties().getOutline().getPath()) { + // no shadow to draw + return; + } mat4 shadowMatrixXY(transformFromParent); applyViewPropertyTransforms(shadowMatrixXY); @@ -607,8 +612,9 @@ void RenderNode::issueDrawShadowOperation(const Matrix4& transformFromParent, T& const SkPath* revealClipPath = properties().getRevealClip().getPath(); if (revealClipPath && revealClipPath->isEmpty()) return; + float casterAlpha = properties().getAlpha() * properties().getOutline().getAlpha(); DisplayListOp* shadowOp = new (handler.allocator()) DrawShadowOp( - shadowMatrixXY, shadowMatrixZ, properties().getAlpha(), + shadowMatrixXY, shadowMatrixZ, casterAlpha, outlinePath, revealClipPath); handler(shadowOp, PROPERTY_SAVECOUNT, properties().getClipToBounds()); } |