summaryrefslogtreecommitdiff
path: root/graphics/java
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/java')
-rw-r--r--graphics/java/android/graphics/Bitmap.java3
-rw-r--r--graphics/java/android/graphics/Canvas.java60
-rw-r--r--graphics/java/android/graphics/Outline.java38
-rw-r--r--graphics/java/android/graphics/Path.java6
-rw-r--r--graphics/java/android/graphics/RenderNode.java6
-rw-r--r--graphics/java/android/graphics/drawable/AdaptiveIconDrawable.java2
-rw-r--r--graphics/java/android/graphics/drawable/GradientDrawable.java2
-rw-r--r--graphics/java/android/graphics/drawable/shapes/RoundRectShape.java2
8 files changed, 98 insertions, 21 deletions
diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java
index ac094ba5d5d2..9c2e95fab455 100644
--- a/graphics/java/android/graphics/Bitmap.java
+++ b/graphics/java/android/graphics/Bitmap.java
@@ -2132,7 +2132,7 @@ public final class Bitmap implements Parcelable {
public void writeToParcel(Parcel p, int flags) {
checkRecycled("Can't parcel a recycled bitmap");
noteHardwareBitmapSlowCall();
- if (!nativeWriteToParcel(mNativePtr, isMutable(), mDensity, p)) {
+ if (!nativeWriteToParcel(mNativePtr, mDensity, p)) {
throw new RuntimeException("native writeToParcel failed");
}
}
@@ -2285,7 +2285,6 @@ public final class Bitmap implements Parcelable {
private static native Bitmap nativeCreateFromParcel(Parcel p);
// returns true on success
private static native boolean nativeWriteToParcel(long nativeBitmap,
- boolean isMutable,
int density,
Parcel p);
// returns a new bitmap built from the native bitmap's alpha, and the paint
diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java
index 9a0ca3e4ad9b..d949444d44d6 100644
--- a/graphics/java/android/graphics/Canvas.java
+++ b/graphics/java/android/graphics/Canvas.java
@@ -1162,6 +1162,7 @@ public class Canvas extends BaseCanvas {
* @see #quickReject(float, float, float, float, EdgeType)
* @see #quickReject(Path, EdgeType)
* @see #quickReject(RectF, EdgeType)
+ * @deprecated quickReject no longer uses this.
*/
public enum EdgeType {
@@ -1197,13 +1198,30 @@ public class Canvas extends BaseCanvas {
* non-antialiased ({@link Canvas.EdgeType#BW}).
* @return true if the rect (transformed by the canvas' matrix)
* does not intersect with the canvas' clip
+ * @deprecated The EdgeType is ignored. Use {@link #quickReject(RectF)} instead.
*/
+ @Deprecated
public boolean quickReject(@NonNull RectF rect, @NonNull EdgeType type) {
return nQuickReject(mNativeCanvasWrapper,
rect.left, rect.top, rect.right, rect.bottom);
}
/**
+ * Return true if the specified rectangle, after being transformed by the
+ * current matrix, would lie completely outside of the current clip. Call
+ * this to check if an area you intend to draw into is clipped out (and
+ * therefore you can skip making the draw calls).
+ *
+ * @param rect the rect to compare with the current clip
+ * @return true if the rect (transformed by the canvas' matrix)
+ * does not intersect with the canvas' clip
+ */
+ public boolean quickReject(@NonNull RectF rect) {
+ return nQuickReject(mNativeCanvasWrapper,
+ rect.left, rect.top, rect.right, rect.bottom);
+ }
+
+ /**
* Return true if the specified path, after being transformed by the
* current matrix, would lie completely outside of the current clip. Call
* this to check if an area you intend to draw into is clipped out (and
@@ -1217,12 +1235,30 @@ public class Canvas extends BaseCanvas {
* non-antialiased ({@link Canvas.EdgeType#BW}).
* @return true if the path (transformed by the canvas' matrix)
* does not intersect with the canvas' clip
+ * @deprecated The EdgeType is ignored. Use {@link #quickReject(Path)} instead.
*/
+ @Deprecated
public boolean quickReject(@NonNull Path path, @NonNull EdgeType type) {
return nQuickReject(mNativeCanvasWrapper, path.readOnlyNI());
}
/**
+ * Return true if the specified path, after being transformed by the
+ * current matrix, would lie completely outside of the current clip. Call
+ * this to check if an area you intend to draw into is clipped out (and
+ * therefore you can skip making the draw calls). Note: for speed it may
+ * return false even if the path itself might not intersect the clip
+ * (i.e. the bounds of the path intersects, but the path does not).
+ *
+ * @param path The path to compare with the current clip
+ * @return true if the path (transformed by the canvas' matrix)
+ * does not intersect with the canvas' clip
+ */
+ public boolean quickReject(@NonNull Path path) {
+ return nQuickReject(mNativeCanvasWrapper, path.readOnlyNI());
+ }
+
+ /**
* Return true if the specified rectangle, after being transformed by the
* current matrix, would lie completely outside of the current clip. Call
* this to check if an area you intend to draw into is clipped out (and
@@ -1241,13 +1277,37 @@ public class Canvas extends BaseCanvas {
* non-antialiased ({@link Canvas.EdgeType#BW}).
* @return true if the rect (transformed by the canvas' matrix)
* does not intersect with the canvas' clip
+ * @deprecated The EdgeType is ignored. Use {@link #quickReject(float, float, float, float)}
+ * instead.
*/
+ @Deprecated
public boolean quickReject(float left, float top, float right, float bottom,
@NonNull EdgeType type) {
return nQuickReject(mNativeCanvasWrapper, left, top, right, bottom);
}
/**
+ * Return true if the specified rectangle, after being transformed by the
+ * current matrix, would lie completely outside of the current clip. Call
+ * this to check if an area you intend to draw into is clipped out (and
+ * therefore you can skip making the draw calls).
+ *
+ * @param left The left side of the rectangle to compare with the
+ * current clip
+ * @param top The top of the rectangle to compare with the current
+ * clip
+ * @param right The right side of the rectangle to compare with the
+ * current clip
+ * @param bottom The bottom of the rectangle to compare with the
+ * current clip
+ * @return true if the rect (transformed by the canvas' matrix)
+ * does not intersect with the canvas' clip
+ */
+ public boolean quickReject(float left, float top, float right, float bottom) {
+ return nQuickReject(mNativeCanvasWrapper, left, top, right, bottom);
+ }
+
+ /**
* Return the bounds of the current clip (in local coordinates) in the
* bounds parameter, and return true if it is non-empty. This can be useful
* in a way similar to quickReject, in that it tells you that drawing
diff --git a/graphics/java/android/graphics/Outline.java b/graphics/java/android/graphics/Outline.java
index 91a60c327bf0..c12159cfd7a4 100644
--- a/graphics/java/android/graphics/Outline.java
+++ b/graphics/java/android/graphics/Outline.java
@@ -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,21 @@ 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 The path is no longer required to be convex. 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 +302,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 +314,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);
}
}
diff --git a/graphics/java/android/graphics/Path.java b/graphics/java/android/graphics/Path.java
index 1362fd864d29..84fe39290681 100644
--- a/graphics/java/android/graphics/Path.java
+++ b/graphics/java/android/graphics/Path.java
@@ -209,7 +209,13 @@ public class Path {
* points, and cache the result.
*
* @return True if the path is convex.
+ *
+ * @deprecated This method is not reliable. The way convexity is computed may change from
+ * release to release, and convexity could change based on a matrix as well. This method was
+ * useful when non-convex Paths were unable to be used in certain contexts, but that is no
+ * longer the case.
*/
+ @Deprecated
public boolean isConvex() {
return nIsConvex(mNativePath);
}
diff --git a/graphics/java/android/graphics/RenderNode.java b/graphics/java/android/graphics/RenderNode.java
index 17e3b4465130..3835b2d493c5 100644
--- a/graphics/java/android/graphics/RenderNode.java
+++ b/graphics/java/android/graphics/RenderNode.java
@@ -687,8 +687,8 @@ public final class RenderNode {
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,
+ case Outline.MODE_PATH:
+ return nSetOutlinePath(mNativeRenderNode, outline.mPath.mNativePath,
outline.mAlpha);
}
@@ -1620,7 +1620,7 @@ public final class RenderNode {
int right, int bottom, float radius, float alpha);
@CriticalNative
- private static native boolean nSetOutlineConvexPath(long renderNode, long nativePath,
+ private static native boolean nSetOutlinePath(long renderNode, long nativePath,
float alpha);
@CriticalNative
diff --git a/graphics/java/android/graphics/drawable/AdaptiveIconDrawable.java b/graphics/java/android/graphics/drawable/AdaptiveIconDrawable.java
index 928e607abbbe..746378e10bc7 100644
--- a/graphics/java/android/graphics/drawable/AdaptiveIconDrawable.java
+++ b/graphics/java/android/graphics/drawable/AdaptiveIconDrawable.java
@@ -387,7 +387,7 @@ public class AdaptiveIconDrawable extends Drawable implements Drawable.Callback
@Override
public void getOutline(@NonNull Outline outline) {
- outline.setConvexPath(mMask);
+ outline.setPath(mMask);
}
/** @hide */
diff --git a/graphics/java/android/graphics/drawable/GradientDrawable.java b/graphics/java/android/graphics/drawable/GradientDrawable.java
index 3881955d2632..f053f392b97e 100644
--- a/graphics/java/android/graphics/drawable/GradientDrawable.java
+++ b/graphics/java/android/graphics/drawable/GradientDrawable.java
@@ -1915,7 +1915,7 @@ public class GradientDrawable extends Drawable {
case RECTANGLE:
if (st.mRadiusArray != null) {
buildPathIfDirty();
- outline.setConvexPath(mPath);
+ outline.setPath(mPath);
return;
}
diff --git a/graphics/java/android/graphics/drawable/shapes/RoundRectShape.java b/graphics/java/android/graphics/drawable/shapes/RoundRectShape.java
index 475e0bb70f2b..28ba60577fb1 100644
--- a/graphics/java/android/graphics/drawable/shapes/RoundRectShape.java
+++ b/graphics/java/android/graphics/drawable/shapes/RoundRectShape.java
@@ -94,7 +94,7 @@ public class RoundRectShape extends RectShape {
for (int i = 1; i < 8; i++) {
if (mOuterRadii[i] != radius) {
// can't call simple constructors, use path
- outline.setConvexPath(mPath);
+ outline.setPath(mPath);
return;
}
}