diff options
author | 2016-04-04 13:40:39 -0700 | |
---|---|---|
committer | 2016-04-04 13:40:39 -0700 | |
commit | 136d1af1cc67f51e8523189260a7c4a22cc02768 (patch) | |
tree | b6621baa2c2aa3356acfe13a23cf8d6c26f99db6 | |
parent | ebdb34d67aead66e5388c8cb501eb34668d7cec3 (diff) |
Fix how outlines are sent to rendernode
bug:27918183
Fixes an issue where all convex outlines were pushed as empty rects to
RenderNode.
Also adds outline/reveal clip property logging, so such issues are
easier to debug in the future.
Change-Id: Ic4a996ecd09a8ef84cdf8b963bdb4853c7f6d180
-rw-r--r-- | core/java/android/view/RenderNode.java | 22 | ||||
-rw-r--r-- | graphics/java/android/graphics/Outline.java | 20 | ||||
-rw-r--r-- | libs/hwui/RenderProperties.cpp | 17 |
3 files changed, 42 insertions, 17 deletions
diff --git a/core/java/android/view/RenderNode.java b/core/java/android/view/RenderNode.java index 4ffb3d3b64bf..ab4cbcf21bed 100644 --- a/core/java/android/view/RenderNode.java +++ b/core/java/android/view/RenderNode.java @@ -307,18 +307,22 @@ public class RenderNode { * * Deep copies the data into native to simplify reference ownership. */ - public boolean setOutline(Outline outline) { + public boolean setOutline(@Nullable Outline outline) { if (outline == null) { return nSetOutlineNone(mNativeRenderNode); - } else if (outline.isEmpty()) { - return nSetOutlineEmpty(mNativeRenderNode); - } else if (outline.mRect != null) { - return nSetOutlineRoundRect(mNativeRenderNode, outline.mRect.left, outline.mRect.top, - outline.mRect.right, outline.mRect.bottom, outline.mRadius, outline.mAlpha); - } else if (outline.mPath != null) { - return nSetOutlineConvexPath(mNativeRenderNode, outline.mPath.mNativePath, - outline.mAlpha); } + + switch(outline.mMode) { + case Outline.MODE_EMPTY: + return nSetOutlineEmpty(mNativeRenderNode); + case Outline.MODE_ROUND_RECT: + return nSetOutlineRoundRect(mNativeRenderNode, outline.mRect.left, outline.mRect.top, + outline.mRect.right, outline.mRect.bottom, outline.mRadius, outline.mAlpha); + case Outline.MODE_CONVEX_PATH: + return nSetOutlineConvexPath(mNativeRenderNode, outline.mPath.mNativePath, + outline.mAlpha); + } + throw new IllegalArgumentException("Unrecognized outline?"); } diff --git a/graphics/java/android/graphics/Outline.java b/graphics/java/android/graphics/Outline.java index 3973f2ff428b..aa81b9196fe1 100644 --- a/graphics/java/android/graphics/Outline.java +++ b/graphics/java/android/graphics/Outline.java @@ -37,22 +37,26 @@ import java.lang.annotation.RetentionPolicy; public final class Outline { private static final float RADIUS_UNDEFINED = Float.NEGATIVE_INFINITY; - private static final int MODE_EMPTY = 0; - private static final int MODE_RECT = 1; - private static final int MODE_CONVEX_PATH = 2; + /** @hide */ + public static final int MODE_EMPTY = 0; + /** @hide */ + public static final int MODE_ROUND_RECT = 1; + /** @hide */ + public static final int MODE_CONVEX_PATH = 2; /** @hide */ @Retention(RetentionPolicy.SOURCE) @IntDef(flag = false, value = { MODE_EMPTY, - MODE_RECT, + MODE_ROUND_RECT, MODE_CONVEX_PATH, }) public @interface Mode {} + /** @hide */ @Mode - private int mMode = MODE_EMPTY; + public int mMode = MODE_EMPTY; /** @hide */ public final Path mPath = new Path(); @@ -176,7 +180,7 @@ public final class Outline { return; } - mMode = MODE_RECT; + mMode = MODE_ROUND_RECT; mRect.set(left, top, right, bottom); mRadius = radius; mPath.rewind(); @@ -199,7 +203,7 @@ public final class Outline { * bounds, or {@code false} if no outline bounds are set */ public boolean getRect(@NonNull Rect outRect) { - if (mMode != MODE_RECT) { + if (mMode != MODE_ROUND_RECT) { return false; } outRect.set(mRect); @@ -270,7 +274,7 @@ public final class Outline { * Offsets the Outline by (dx,dy) */ public void offset(int dx, int dy) { - if (mMode == MODE_RECT) { + if (mMode == MODE_ROUND_RECT) { mRect.offset(dx, dy); } else if (mMode == MODE_CONVEX_PATH) { mPath.offset(dx, dy); diff --git a/libs/hwui/RenderProperties.cpp b/libs/hwui/RenderProperties.cpp index f577785110d3..5ebf5458da18 100644 --- a/libs/hwui/RenderProperties.cpp +++ b/libs/hwui/RenderProperties.cpp @@ -155,6 +155,23 @@ void RenderProperties::debugOutputProperties(const int level) const { ALOGD("%*s(ClipRect %d, %d, %d, %d)", level * 2, "", (int)clipRect.left, (int)clipRect.top, (int)clipRect.right, (int)clipRect.bottom); } + + if (getRevealClip().willClip()) { + Rect bounds; + getRevealClip().getBounds(&bounds); + ALOGD("%*s(Clip to reveal clip with bounds %.2f %.2f %.2f %.2f)", level * 2, "", + RECT_ARGS(bounds)); + } + + auto& outline = mPrimitiveFields.mOutline; + if (outline.getShouldClip()) { + if (outline.isEmpty()) { + ALOGD("%*s(Clip to empty outline)", level * 2, ""); + } else if (outline.willClip()) { + ALOGD("%*s(Clip to outline with bounds %.2f %.2f %.2f %.2f)", level * 2, "", + RECT_ARGS(outline.getBounds())); + } + } } void RenderProperties::updateMatrix() { |