Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2410b90e authored by Leon Scroggins III's avatar Leon Scroggins III Committed by Leon Scroggins
Browse files

Deprecate Canvas.EdgeType

Bug: 129694386
Test: No change in behavior, no new tests

EdgeType is only used as a parameter to quickReject, but it is always
ignored. Deprecate it and the existing quickReject methods. Add new
versions of quickReject without EdgeType parameters. Switch clients to
the new versions.

Change-Id: Id932f10915a8c4959fe0e85f507ce7fd2da8a576
parent 6e62dbb2
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -14220,9 +14220,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);
@@ -14247,9 +14250,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 {
+1 −1
Original line number Diff line number Diff line
@@ -21773,7 +21773,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;
+1 −1
Original line number Diff line number Diff line
@@ -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;
        }

+60 −0
Original line number Diff line number Diff line
@@ -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,12 +1198,29 @@ 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
@@ -1217,11 +1235,29 @@ 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
@@ -1241,12 +1277,36 @@ 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
+8 −14
Original line number Diff line number Diff line
@@ -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();