summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2020-01-28 18:13:01 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-01-28 18:13:01 +0000
commite428a2cc043d5a7ea0f86776cfe7a47247908592 (patch)
treea44c52d45594138355343f3dfdecafbfb6bcb0bd
parentb32b15d146486a92da211f10706a86f9a951dc06 (diff)
parent2410b90e066b75b14798b2c60c77e00865654496 (diff)
Merge "Deprecate Canvas.EdgeType"
-rw-r--r--api/current.txt15
-rw-r--r--core/java/android/view/View.java2
-rw-r--r--core/java/android/widget/ScrollBarDrawable.java2
-rw-r--r--graphics/java/android/graphics/Canvas.java60
-rw-r--r--tests/HwAccelerationTest/src/com/android/test/hwui/AlphaLayersActivity.java22
5 files changed, 79 insertions, 22 deletions
diff --git a/api/current.txt b/api/current.txt
index c556bd0a4760..2ff81365fcfd 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -14249,9 +14249,12 @@ package android.graphics {
method public int getWidth();
method public boolean isHardwareAccelerated();
method public boolean isOpaque();
- method public boolean quickReject(@NonNull android.graphics.RectF, @NonNull android.graphics.Canvas.EdgeType);
- method public boolean quickReject(@NonNull android.graphics.Path, @NonNull android.graphics.Canvas.EdgeType);
- method public boolean quickReject(float, float, float, float, @NonNull android.graphics.Canvas.EdgeType);
+ method @Deprecated public boolean quickReject(@NonNull android.graphics.RectF, @NonNull android.graphics.Canvas.EdgeType);
+ method public boolean quickReject(@NonNull android.graphics.RectF);
+ method @Deprecated public boolean quickReject(@NonNull android.graphics.Path, @NonNull android.graphics.Canvas.EdgeType);
+ method public boolean quickReject(@NonNull android.graphics.Path);
+ method @Deprecated public boolean quickReject(float, float, float, float, @NonNull android.graphics.Canvas.EdgeType);
+ method public boolean quickReject(float, float, float, float);
method public void restore();
method public void restoreToCount(int);
method public void rotate(float);
@@ -14276,9 +14279,9 @@ package android.graphics {
field public static final int ALL_SAVE_FLAG = 31; // 0x1f
}
- public enum Canvas.EdgeType {
- enum_constant public static final android.graphics.Canvas.EdgeType AA;
- enum_constant public static final android.graphics.Canvas.EdgeType BW;
+ @Deprecated public enum Canvas.EdgeType {
+ enum_constant @Deprecated public static final android.graphics.Canvas.EdgeType AA;
+ enum_constant @Deprecated public static final android.graphics.Canvas.EdgeType BW;
}
public enum Canvas.VertexMode {
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index c5f4faf2f462..86836b347133 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -21856,7 +21856,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
if (!concatMatrix &&
(parentFlags & (ViewGroup.FLAG_SUPPORT_STATIC_TRANSFORMATIONS |
ViewGroup.FLAG_CLIP_CHILDREN)) == ViewGroup.FLAG_CLIP_CHILDREN &&
- canvas.quickReject(mLeft, mTop, mRight, mBottom, Canvas.EdgeType.BW) &&
+ canvas.quickReject(mLeft, mTop, mRight, mBottom) &&
(mPrivateFlags & PFLAG_DRAW_ANIMATION) == 0) {
mPrivateFlags2 |= PFLAG2_VIEW_QUICK_REJECTED;
return more;
diff --git a/core/java/android/widget/ScrollBarDrawable.java b/core/java/android/widget/ScrollBarDrawable.java
index 80e17b5e8217..c2d4596e17dc 100644
--- a/core/java/android/widget/ScrollBarDrawable.java
+++ b/core/java/android/widget/ScrollBarDrawable.java
@@ -138,7 +138,7 @@ public class ScrollBarDrawable extends Drawable implements Drawable.Callback {
}
final Rect r = getBounds();
- if (canvas.quickReject(r.left, r.top, r.right, r.bottom, Canvas.EdgeType.AA)) {
+ if (canvas.quickReject(r.left, r.top, r.right, r.bottom)) {
return;
}
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/tests/HwAccelerationTest/src/com/android/test/hwui/AlphaLayersActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/AlphaLayersActivity.java
index 1a68a93eed19..37661828da22 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/AlphaLayersActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/AlphaLayersActivity.java
@@ -50,7 +50,7 @@ public class AlphaLayersActivity extends Activity {
setContentView(container);
}
-
+
@SuppressWarnings({"UnusedDeclaration"})
static int dipToPx(Context c, int dip) {
return (int) (c.getResources().getDisplayMetrics().density * dip + 0.5f);
@@ -86,30 +86,24 @@ public class AlphaLayersActivity extends Activity {
canvas.save();
canvas.clipRect(20.0f, 0.0f, 40.0f, 20.0f);
Log.d(LOG_TAG, "clipRect = " + canvas.getClipBounds());
- Log.d(LOG_TAG, "rejected = " + canvas.quickReject(100.0f, 100.0f, 110.0f, 110.0f,
- Canvas.EdgeType.BW));
- Log.d(LOG_TAG, "rejected = " + canvas.quickReject(25.0f, 5.0f, 30.0f, 10.0f,
- Canvas.EdgeType.BW));
+ Log.d(LOG_TAG, "rejected = " + canvas.quickReject(100.0f, 100.0f, 110.0f, 110.0f));
+ Log.d(LOG_TAG, "rejected = " + canvas.quickReject(25.0f, 5.0f, 30.0f, 10.0f));
canvas.restore();
-
+
canvas.save();
canvas.scale(2.0f, 2.0f);
canvas.clipRect(20.0f, 0.0f, 40.0f, 20.0f);
Log.d(LOG_TAG, "clipRect = " + canvas.getClipBounds());
- Log.d(LOG_TAG, "rejected = " + canvas.quickReject(50.0f, 50.0f, 60.0f, 60.0f,
- Canvas.EdgeType.BW));
- Log.d(LOG_TAG, "rejected = " + canvas.quickReject(25.0f, 5.0f, 30.0f, 10.0f,
- Canvas.EdgeType.BW));
+ Log.d(LOG_TAG, "rejected = " + canvas.quickReject(50.0f, 50.0f, 60.0f, 60.0f));
+ Log.d(LOG_TAG, "rejected = " + canvas.quickReject(25.0f, 5.0f, 30.0f, 10.0f));
canvas.restore();
canvas.save();
canvas.translate(20.0f, 20.0f);
canvas.clipRect(20.0f, 0.0f, 40.0f, 20.0f);
Log.d(LOG_TAG, "clipRect = " + canvas.getClipBounds());
- Log.d(LOG_TAG, "rejected = " + canvas.quickReject(80.0f, 80.0f, 90.0f, 90.0f,
- Canvas.EdgeType.BW));
- Log.d(LOG_TAG, "rejected = " + canvas.quickReject(25.0f, 5.0f, 30.0f, 10.0f,
- Canvas.EdgeType.BW));
+ Log.d(LOG_TAG, "rejected = " + canvas.quickReject(80.0f, 80.0f, 90.0f, 90.0f));
+ Log.d(LOG_TAG, "rejected = " + canvas.quickReject(25.0f, 5.0f, 30.0f, 10.0f));
canvas.restore();
canvas.save();