From faa79ff9d964de940660d2226d5b06ded9294597 Mon Sep 17 00:00:00 2001 From: Chris Craik Date: Mon, 1 Dec 2014 13:44:21 -0800 Subject: Clip outline to View clip bounds for shadow computation bug:18509823 This allows animations of View clipBounds (and other callers of setClipBounds) to affect shadows, instead of leaving them floating. Change-Id: I249fa4b371a170cb0c54001f5b0e0097e109b8b8 --- libs/hwui/RenderNode.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'libs') diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp index bbba2dd..810e487 100644 --- a/libs/hwui/RenderNode.cpp +++ b/libs/hwui/RenderNode.cpp @@ -680,13 +680,32 @@ void RenderNode::issueDrawShadowOperation(const Matrix4& transformFromParent, T& float casterAlpha = properties().getAlpha() * properties().getOutline().getAlpha(); + + // holds temporary SkPath to store the result of intersections + SkPath* frameAllocatedPath = NULL; const SkPath* outlinePath = casterOutlinePath; + + // intersect the outline with the reveal clip, if present if (revealClipPath) { - // if we can't simply use the caster's path directly, create a temporary one - SkPath* frameAllocatedPath = handler.allocPathForFrame(); + frameAllocatedPath = handler.allocPathForFrame(); + + Op(*outlinePath, *revealClipPath, kIntersect_PathOp, frameAllocatedPath); + outlinePath = frameAllocatedPath; + } + + // intersect the outline with the clipBounds, if present + if (properties().getClippingFlags() & CLIP_TO_CLIP_BOUNDS) { + if (!frameAllocatedPath) { + frameAllocatedPath = handler.allocPathForFrame(); + } + + Rect clipBounds; + properties().getClippingRectForFlags(CLIP_TO_CLIP_BOUNDS, &clipBounds); + SkPath clipBoundsPath; + clipBoundsPath.addRect(clipBounds.left, clipBounds.top, + clipBounds.right, clipBounds.bottom); - // intersect the outline with the convex reveal clip - Op(*casterOutlinePath, *revealClipPath, kIntersect_PathOp, frameAllocatedPath); + Op(*outlinePath, clipBoundsPath, kIntersect_PathOp, frameAllocatedPath); outlinePath = frameAllocatedPath; } -- cgit v1.1