diff options
Diffstat (limited to 'graphics/java/android/graphics/Outline.java')
-rw-r--r-- | graphics/java/android/graphics/Outline.java | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/graphics/java/android/graphics/Outline.java b/graphics/java/android/graphics/Outline.java index 1fc056c3652f..5858e3988486 100644 --- a/graphics/java/android/graphics/Outline.java +++ b/graphics/java/android/graphics/Outline.java @@ -19,7 +19,7 @@ package android.graphics; import android.annotation.FloatRange; import android.annotation.IntDef; import android.annotation.NonNull; -import android.annotation.UnsupportedAppUsage; +import android.compat.annotation.UnsupportedAppUsage; import android.graphics.drawable.Drawable; import java.lang.annotation.Retention; @@ -43,7 +43,7 @@ public final class Outline { /** @hide */ public static final int MODE_ROUND_RECT = 1; /** @hide */ - public static final int MODE_CONVEX_PATH = 2; + public static final int MODE_PATH = 2; /** @hide */ @Retention(RetentionPolicy.SOURCE) @@ -51,7 +51,7 @@ public final class Outline { value = { MODE_EMPTY, MODE_ROUND_RECT, - MODE_CONVEX_PATH, + MODE_PATH, }) public @interface Mode {} @@ -60,7 +60,7 @@ public final class Outline { public int mMode = MODE_EMPTY; /** - * Only guaranteed to be non-null when mode == MODE_CONVEX_PATH + * Only guaranteed to be non-null when mode == MODE_PATH * * @hide */ @@ -124,7 +124,7 @@ public final class Outline { * @see android.view.View#setClipToOutline(boolean) */ public boolean canClip() { - return mMode != MODE_CONVEX_PATH; + return mMode != MODE_PATH; } /** @@ -157,7 +157,7 @@ public final class Outline { */ public void set(@NonNull Outline src) { mMode = src.mMode; - if (src.mMode == MODE_CONVEX_PATH) { + if (src.mMode == MODE_PATH) { if (mPath == null) { mPath = new Path(); } @@ -194,7 +194,7 @@ public final class Outline { return; } - if (mMode == MODE_CONVEX_PATH) { + if (mMode == MODE_PATH) { // rewind here to avoid thrashing the allocations, but could alternately clear ref mPath.rewind(); } @@ -213,7 +213,7 @@ public final class Outline { /** * Populates {@code outBounds} with the outline bounds, if set, and returns * {@code true}. If no outline bounds are set, or if a path has been set - * via {@link #setConvexPath(Path)}, returns {@code false}. + * via {@link #setPath(Path)}, returns {@code false}. * * @param outRect the rect to populate with the outline bounds, if set * @return {@code true} if {@code outBounds} was populated with outline @@ -229,7 +229,7 @@ public final class Outline { /** * Returns the rounded rect radius, if set, or a value less than 0 if a path has - * been set via {@link #setConvexPath(Path)}. A return value of {@code 0} + * been set via {@link #setPath(Path)}. A return value of {@code 0} * indicates a non-rounded rect. * * @return the rounded rect radius, or value < 0 @@ -259,7 +259,7 @@ public final class Outline { mPath.rewind(); } - mMode = MODE_CONVEX_PATH; + mMode = MODE_PATH; mPath.addOval(left, top, right, bottom, Path.Direction.CW); mRect.setEmpty(); mRadius = RADIUS_UNDEFINED; @@ -279,9 +279,24 @@ public final class Outline { * @param convexPath used to construct the Outline. As of * {@link android.os.Build.VERSION_CODES#Q}, it is no longer required to be * convex. + * + * @deprecated As of {@link android.os.Build.VERSION_CODES#Q}, the restriction + * that the path must be convex is removed. However, the API is misnamed until + * {@link android.os.Build.VERSION_CODES#R}, when {@link #setPath} is + * introduced. Use {@link #setPath} instead. */ + @Deprecated public void setConvexPath(@NonNull Path convexPath) { - if (convexPath.isEmpty()) { + setPath(convexPath); + } + + /** + * Sets the Outline to a {@link android.graphics.Path path}. + * + * @param path used to construct the Outline. + */ + public void setPath(@NonNull Path path) { + if (path.isEmpty()) { setEmpty(); return; } @@ -290,8 +305,8 @@ public final class Outline { mPath = new Path(); } - mMode = MODE_CONVEX_PATH; - mPath.set(convexPath); + mMode = MODE_PATH; + mPath.set(path); mRect.setEmpty(); mRadius = RADIUS_UNDEFINED; } @@ -302,7 +317,7 @@ public final class Outline { public void offset(int dx, int dy) { if (mMode == MODE_ROUND_RECT) { mRect.offset(dx, dy); - } else if (mMode == MODE_CONVEX_PATH) { + } else if (mMode == MODE_PATH) { mPath.offset(dx, dy); } } |