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

Commit 0a8e926c authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "The bigger update to Canvas"

parents a9469e64 caa08ff5
Loading
Loading
Loading
Loading
+10 −13
Original line number Diff line number Diff line
@@ -16,28 +16,27 @@

package android.text;

import android.graphics.BaseCanvas;
import android.graphics.Canvas;
import android.graphics.Paint;

/**
 * Please implement this interface if your CharSequence can do quick
 * draw/measure/widths calculations from an internal array.
 * {@hide}
 * Please implement this interface if your CharSequence can do quick draw/measure/widths
 * calculations from an internal array.
 *
 * @hide
 */
public interface GraphicsOperations
extends CharSequence
{
public interface GraphicsOperations extends CharSequence {
    /**
     * Just like {@link Canvas#drawText}.
     */
    void drawText(Canvas c, int start, int end,
    void drawText(BaseCanvas c, int start, int end,
            float x, float y, Paint p);

    /**
     * Just like {@link Canvas#drawTextRun}.
     * {@hide}
     */
    void drawTextRun(Canvas c, int start, int end, int contextStart, int contextEnd,
    void drawTextRun(BaseCanvas c, int start, int end, int contextStart, int contextEnd,
            float x, float y, boolean isRtl, Paint p);

    /**
@@ -52,14 +51,12 @@ extends CharSequence

    /**
     * Just like {@link Paint#getTextRunAdvances}.
     * @hide
     */
    float getTextRunAdvances(int start, int end, int contextStart, int contextEnd,
            boolean isRtl, float[] advances, int advancesIndex, Paint paint);

    /**
     * Just like {@link Paint#getTextRunCursor}.
     * @hide
     */
    int getTextRunCursor(int contextStart, int contextEnd, int dir, int offset,
            int cursorOpt, Paint p);
+5 −3
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
package android.text;

import android.annotation.Nullable;
import android.graphics.Canvas;
import android.graphics.BaseCanvas;
import android.graphics.Paint;
import android.util.Log;

@@ -1357,7 +1357,8 @@ public class SpannableStringBuilder implements CharSequence, GetChars, Spannable
     * Don't call this yourself -- exists for Canvas to use internally.
     * {@hide}
     */
    public void drawText(Canvas c, int start, int end, float x, float y, Paint p) {
    @Override
    public void drawText(BaseCanvas c, int start, int end, float x, float y, Paint p) {
        checkRange("drawText", start, end);

        if (end <= mGapStart) {
@@ -1378,7 +1379,8 @@ public class SpannableStringBuilder implements CharSequence, GetChars, Spannable
     * Don't call this yourself -- exists for Canvas to use internally.
     * {@hide}
     */
    public void drawTextRun(Canvas c, int start, int end, int contextStart, int contextEnd,
    @Override
    public void drawTextRun(BaseCanvas c, int start, int end, int contextStart, int contextEnd,
            float x, float y, boolean isRtl, Paint p) {
        checkRange("drawTextRun", start, end);

+2 −3
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package android.view;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.CanvasProperty;
import android.graphics.Paint;
import android.util.Pools.SynchronizedPool;
@@ -34,7 +33,7 @@ import dalvik.annotation.optimization.FastNative;
 *
 * @hide
 */
public class DisplayListCanvas extends Canvas {
public final class DisplayListCanvas extends RecordingCanvas {
    // The recording canvas pool should be large enough to handle a deeply nested
    // view hierarchy because display lists are generated recursively.
    private static final int POOL_LIMIT = 25;
@@ -42,7 +41,7 @@ public class DisplayListCanvas extends Canvas {
    private static final int MAX_BITMAP_SIZE = 100 * 1024 * 1024; // 100 MB

    private static final SynchronizedPool<DisplayListCanvas> sPool =
            new SynchronizedPool<DisplayListCanvas>(POOL_LIMIT);
            new SynchronizedPool<>(POOL_LIMIT);

    RenderNode mNode;
    private int mWidth;
+641 −0

File added.

Preview size limit exceeded, changes collapsed.

+5 −2
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.graphics.BaseCanvas;
import android.graphics.Canvas;
import android.graphics.Insets;
import android.graphics.Paint;
@@ -10222,12 +10223,14 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            System.arraycopy(mChars, start + mStart, buf, off, end - start);
        }

        public void drawText(Canvas c, int start, int end,
        @Override
        public void drawText(BaseCanvas c, int start, int end,
                             float x, float y, Paint p) {
            c.drawText(mChars, start + mStart, end - start, x, y, p);
        }

        public void drawTextRun(Canvas c, int start, int end,
        @Override
        public void drawTextRun(BaseCanvas c, int start, int end,
                int contextStart, int contextEnd, float x, float y, boolean isRtl, Paint p) {
            int count = end - start;
            int contextCount = contextEnd - contextStart;
Loading