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

Commit 7f090dfa authored by John Reck's avatar John Reck Committed by Android (Google) Code Review
Browse files

Merge "Allow starting an RT animation via Canvas"

parents f72382ae 1c058e96
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.view;

import android.annotation.NonNull;
import android.util.Pools.SynchronizedPool;

/**
@@ -32,19 +33,25 @@ class GLES20RecordingCanvas extends GLES20Canvas {
    private static final SynchronizedPool<GLES20RecordingCanvas> sPool =
            new SynchronizedPool<GLES20RecordingCanvas>(POOL_LIMIT);

    RenderNode mNode;

    private GLES20RecordingCanvas() {
        super(true, true);
    }

    static GLES20RecordingCanvas obtain() {
    static GLES20RecordingCanvas obtain(@NonNull RenderNode node) {
        if (node == null) throw new IllegalArgumentException("node cannot be null");

        GLES20RecordingCanvas canvas = sPool.acquire();
        if (canvas == null) {
            canvas = new GLES20RecordingCanvas();
        }
        canvas.mNode = node;
        return canvas;
    }

    void recycle() {
        mNode = null;
        sPool.release(this);
    }

+1 −1
Original line number Diff line number Diff line
@@ -239,7 +239,7 @@ public class RenderNode {
     * @see #isValid()
     */
    public HardwareCanvas start(int width, int height) {
        HardwareCanvas canvas = GLES20RecordingCanvas.obtain();
        HardwareCanvas canvas = GLES20RecordingCanvas.obtain(this);
        canvas.setViewport(width, height);
        // The dirty rect should always be null for a display list
        canvas.onPreDraw(null);
+10 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.view;

import android.graphics.Canvas;
import android.graphics.CanvasProperty;
import android.graphics.Paint;
import android.util.SparseIntArray;
@@ -100,6 +101,15 @@ public final class RenderNodeAnimator {
        target.invalidateViewProperty(true, false);
    }

    public void start(Canvas canvas) {
        if (!(canvas instanceof GLES20RecordingCanvas)) {
            throw new IllegalArgumentException("Not a GLES20RecordingCanvas");
        }
        GLES20RecordingCanvas recordingCanvas = (GLES20RecordingCanvas) canvas;
        mTarget = recordingCanvas.mNode;
        mTarget.addAnimator(this);
    }

    public void cancel() {
        mTarget.removeAnimator(this);
    }