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

Commit 491ed067 authored by Leon Scroggins III's avatar Leon Scroggins III Committed by Leon Scroggins
Browse files

Make Canvas#drawPatch public

Bug: 155422223
Bug: 155661807
Test: NinePatchTest#testDraw
Test: NinePatchDrawableTest#testDraw

As part of the move to a mainline module, code outside the module cannot
access @hidden APIs on Canvas. Although no code outside the module calls
these methods, there is a Canvas subclass that overrides it - NopCanvas,
which overrides it to do nothing. This is useful, and cannot be achieved
another way. (If NopCanvas did not override drawPatch, it would crash
when attempting to draw a NinePatchDrawable.)

In addition, this method is already public on RecordingCanvas. (This is
likely an accident; it contains no documentation for the method.)

Lastly, it is somewhat arbitrary that the way to draw a NinePatch
directly was to call NinePatch#draw. This is the reverse of how Canvas
drawing generally works. The newly public method matches the typical
pattern (Canvas#draw<Something>(Something, Paint)) and is already called
by NinePatch#draw.

Change-Id: I16d7dc7391e3ad5777fdd7023472545c6104af69
parent c357f974
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -14300,6 +14300,8 @@ package android.graphics {
    method public void drawOval(@NonNull android.graphics.RectF, @NonNull android.graphics.Paint);
    method public void drawOval(float, float, float, float, @NonNull android.graphics.Paint);
    method public void drawPaint(@NonNull android.graphics.Paint);
    method public void drawPatch(@NonNull android.graphics.NinePatch, @NonNull android.graphics.Rect, @Nullable android.graphics.Paint);
    method public void drawPatch(@NonNull android.graphics.NinePatch, @NonNull android.graphics.RectF, @Nullable android.graphics.Paint);
    method public void drawPath(@NonNull android.graphics.Path, @NonNull android.graphics.Paint);
    method public void drawPicture(@NonNull android.graphics.Picture);
    method public void drawPicture(@NonNull android.graphics.Picture, @NonNull android.graphics.RectF);
@@ -15354,8 +15356,6 @@ package android.graphics {
  }
  public final class RecordingCanvas extends android.graphics.Canvas {
    method public final void drawPatch(@NonNull android.graphics.NinePatch, @NonNull android.graphics.Rect, @Nullable android.graphics.Paint);
    method public final void drawPatch(@NonNull android.graphics.NinePatch, @NonNull android.graphics.RectF, @Nullable android.graphics.Paint);
  }
  public final class Rect implements android.os.Parcelable {
+2 −4
Original line number Diff line number Diff line
@@ -1873,24 +1873,22 @@ public class Canvas extends BaseCanvas {
    }

    /**
     * Draws the specified bitmap as an N-patch (most often, a 9-patches.)
     * Draws the specified bitmap as an N-patch (most often, a 9-patch.)
     *
     * @param patch The ninepatch object to render
     * @param dst The destination rectangle.
     * @param paint The paint to draw the bitmap with. may be null
     * @hide
     */
    public void drawPatch(@NonNull NinePatch patch, @NonNull Rect dst, @Nullable Paint paint) {
        super.drawPatch(patch, dst, paint);
    }

    /**
     * Draws the specified bitmap as an N-patch (most often, a 9-patches.)
     * Draws the specified bitmap as an N-patch (most often, a 9-patch.)
     *
     * @param patch The ninepatch object to render
     * @param dst The destination rectangle.
     * @param paint The paint to draw the bitmap with. may be null
     * @hide
     */
    public void drawPatch(@NonNull NinePatch patch, @NonNull RectF dst, @Nullable Paint paint) {
        super.drawPatch(patch, dst, paint);