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

Commit 5c6397e9 authored by John Reck's avatar John Reck
Browse files

Add compat workaround

Bug: 119066174
Test: repro from bug
Change-Id: Ifc50fc64422d571ee94ce8510825aed7f915adfd
parent 24f78ddd
Loading
Loading
Loading
Loading
+48 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.view;

import android.annotation.UnsupportedAppUsage;
import android.graphics.BaseRecordingCanvas;
import android.graphics.CanvasProperty;
import android.graphics.Paint;

/**
 * This class exists temporarily to workaround broken apps
 *
 * b/119066174
 *
 * @hide
 */
public abstract class DisplayListCanvas extends BaseRecordingCanvas {

    /** @hide */
    protected DisplayListCanvas(long nativeCanvas) {
        super(nativeCanvas);
    }

    /** @hide */
    @UnsupportedAppUsage
    public abstract void drawRoundRect(CanvasProperty<Float> left, CanvasProperty<Float> top,
            CanvasProperty<Float> right, CanvasProperty<Float> bottom, CanvasProperty<Float> rx,
            CanvasProperty<Float> ry, CanvasProperty<Paint> paint);

    /** @hide */
    @UnsupportedAppUsage
    public abstract void drawCircle(CanvasProperty<Float> cx, CanvasProperty<Float> cy,
            CanvasProperty<Float> radius, CanvasProperty<Paint> paint);
}
+6 −0
Original line number Diff line number Diff line
@@ -293,6 +293,12 @@ public class RenderNodeAnimator extends Animator {
        setTarget(canvas.mNode);
    }

    /** @hide */
    @UnsupportedAppUsage
    public void setTarget(DisplayListCanvas canvas) {
        setTarget((RecordingCanvas) canvas);
    }

    private void setTarget(RenderNode node) {
        checkMutable();
        if (mTarget != null) {
+4 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.graphics;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.util.Pools.SynchronizedPool;
import android.view.DisplayListCanvas;
import android.view.TextureLayer;

import dalvik.annotation.optimization.CriticalNative;
@@ -34,7 +35,7 @@ import dalvik.annotation.optimization.FastNative;
 * {@link RenderNode#endRecording()} is called. It must not be retained beyond that as it is
 * internally reused.
 */
public final class RecordingCanvas extends BaseRecordingCanvas {
public final class RecordingCanvas extends DisplayListCanvas {
    // 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;
@@ -89,7 +90,8 @@ public final class RecordingCanvas extends BaseRecordingCanvas {
    // Constructors
    ///////////////////////////////////////////////////////////////////////////

    private RecordingCanvas(@NonNull RenderNode node, int width, int height) {
    /** @hide */
    protected RecordingCanvas(@NonNull RenderNode node, int width, int height) {
        super(nCreateDisplayListCanvas(node.mNativeRenderNode, width, height));
        mDensity = 0; // disable bitmap density scaling
    }