Merge "Add compat workaround"

This commit is contained in:
TreeHugger Robot
2018-11-15 02:35:41 +00:00
committed by Android (Google) Code Review
3 changed files with 58 additions and 2 deletions

View File

@@ -0,0 +1,48 @@
/*
* 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);
}

View File

@@ -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) {

View File

@@ -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
}