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
diff --git a/core/java/android/view/RenderNode.java b/core/java/android/view/RenderNode.java
index 4ffb3d3..ab4cbcf 100644
--- a/core/java/android/view/RenderNode.java
+++ b/core/java/android/view/RenderNode.java
@@ -307,18 +307,22 @@
      *
      * 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 3973f2f..aa81b91 100644
--- a/graphics/java/android/graphics/Outline.java
+++ b/graphics/java/android/graphics/Outline.java
@@ -37,22 +37,26 @@
 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 @@
             return;
         }
 
-        mMode = MODE_RECT;
+        mMode = MODE_ROUND_RECT;
         mRect.set(left, top, right, bottom);
         mRadius = radius;
         mPath.rewind();
@@ -199,7 +203,7 @@
      *         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 @@
      * 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 f577785..5ebf545 100644
--- a/libs/hwui/RenderProperties.cpp
+++ b/libs/hwui/RenderProperties.cpp
@@ -155,6 +155,23 @@
         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() {