From 24bf21b89469a7175d66add2affd6fe765d3a075 Mon Sep 17 00:00:00 2001 From: Alan Viverette Date: Thu, 10 Mar 2016 15:52:00 -0500 Subject: [PATCH] Ensure Outline consistently sets the radius to be undefined Radius should only be defined when the rect is also defined. Also updates ArcShape to not return an outline, since it may be convex. Bug: 27593976 Bug: 27592381 Change-Id: I99010b139361607af6ec8cab26c9aa1d4dcbba77 --- graphics/java/android/graphics/Outline.java | 9 ++++++--- .../java/android/graphics/drawable/shapes/ArcShape.java | 7 +++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/graphics/java/android/graphics/Outline.java b/graphics/java/android/graphics/Outline.java index 99fa9fe2b3b2b..d3124545ae84d 100644 --- a/graphics/java/android/graphics/Outline.java +++ b/graphics/java/android/graphics/Outline.java @@ -32,13 +32,15 @@ import android.graphics.drawable.Drawable; * @see Drawable#getOutline(Outline) */ public final class Outline { + private static final float RADIUS_UNDEFINED = -1.0f; + /** @hide */ public Path mPath; /** @hide */ public Rect mRect; /** @hide */ - public float mRadius; + public float mRadius = RADIUS_UNDEFINED; /** @hide */ public float mAlpha; @@ -63,7 +65,7 @@ public final class Outline { public void setEmpty() { mPath = null; mRect = null; - mRadius = 0; + mRadius = RADIUS_UNDEFINED; } /** @@ -223,6 +225,7 @@ public final class Outline { mPath.reset(); mPath.addOval(left, top, right, bottom, Path.Direction.CW); mRect = null; + mRadius = RADIUS_UNDEFINED; } /** @@ -249,7 +252,7 @@ public final class Outline { mPath.set(convexPath); mRect = null; - mRadius = -1.0f; + mRadius = RADIUS_UNDEFINED; } /** diff --git a/graphics/java/android/graphics/drawable/shapes/ArcShape.java b/graphics/java/android/graphics/drawable/shapes/ArcShape.java index 84731b0d3819d..c4b239f20da41 100644 --- a/graphics/java/android/graphics/drawable/shapes/ArcShape.java +++ b/graphics/java/android/graphics/drawable/shapes/ArcShape.java @@ -17,6 +17,7 @@ package android.graphics.drawable.shapes; import android.graphics.Canvas; +import android.graphics.Outline; import android.graphics.Paint; /** @@ -46,5 +47,11 @@ public class ArcShape extends RectShape { public void draw(Canvas canvas, Paint paint) { canvas.drawArc(rect(), mStart, mSweep, true, paint); } + + @Override + public void getOutline(Outline outline) { + // Since we don't support concave outlines, arc shape does not attempt + // to provide an outline. + } }