De-couple RenderNode from View package
First step of moving RenderNode to the graphics package Test: builds Change-Id: Ife7f5ec6698e32393d1b85ed2bad909ef0210be4
This commit is contained in:
@@ -1022,6 +1022,7 @@ android.graphics.-$$Lambda$ColorSpace$Rgb$b9VGKuNnse0bbguR9jbOM_wK2Ac
|
||||
android.graphics.-$$Lambda$ColorSpace$Rgb$bWzafC8vMHNuVmRuTUPEFUMlfuY
|
||||
android.graphics.-$$Lambda$ColorSpace$S2rlqJvkXGTpUF6mZhvkElds8JE
|
||||
android.graphics.BaseCanvas
|
||||
android.graphics.BaseRecordingCanvas
|
||||
android.graphics.Bitmap
|
||||
android.graphics.Bitmap$1
|
||||
android.graphics.Bitmap$2
|
||||
@@ -3303,7 +3304,6 @@ android.view.OrientationEventListener
|
||||
android.view.OrientationEventListener$SensorEventListenerImpl
|
||||
android.view.PointerIcon
|
||||
android.view.PointerIcon$1
|
||||
android.view.RecordingCanvas
|
||||
android.view.RenderNode
|
||||
android.view.RenderNode$NoImagePreloadHolder
|
||||
android.view.RenderNodeAnimator
|
||||
|
||||
@@ -19,6 +19,7 @@ package android.view;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.UnsupportedAppUsage;
|
||||
import android.graphics.BaseRecordingCanvas;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.CanvasProperty;
|
||||
import android.graphics.Paint;
|
||||
@@ -35,7 +36,7 @@ import dalvik.annotation.optimization.FastNative;
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public final class DisplayListCanvas extends RecordingCanvas {
|
||||
public final class DisplayListCanvas extends BaseRecordingCanvas {
|
||||
// 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;
|
||||
|
||||
29
core/java/android/view/NativeVectorDrawableAnimator.java
Normal file
29
core/java/android/view/NativeVectorDrawableAnimator.java
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Exists just to allow for android.graphics & android.view package separation
|
||||
*
|
||||
* TODO: Get off of this coupling more cleanly somehow
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public interface NativeVectorDrawableAnimator {
|
||||
/** @hide */
|
||||
long getAnimatorNativePtr();
|
||||
}
|
||||
@@ -24,7 +24,6 @@ import android.graphics.Matrix;
|
||||
import android.graphics.Outline;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.AnimatedVectorDrawable;
|
||||
|
||||
import dalvik.annotation.optimization.CriticalNative;
|
||||
import dalvik.annotation.optimization.FastNative;
|
||||
@@ -148,12 +147,12 @@ public class RenderNode {
|
||||
* @hide
|
||||
*/
|
||||
final long mNativeRenderNode;
|
||||
private final View mOwningView;
|
||||
private final AnimationHost mAnimationHost;
|
||||
|
||||
private RenderNode(String name, View owningView) {
|
||||
private RenderNode(String name, AnimationHost animationHost) {
|
||||
mNativeRenderNode = nCreate(name);
|
||||
NoImagePreloadHolder.sRegistry.registerNativeAllocation(this, mNativeRenderNode);
|
||||
mOwningView = owningView;
|
||||
mAnimationHost = animationHost;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -162,7 +161,7 @@ public class RenderNode {
|
||||
private RenderNode(long nativePtr) {
|
||||
mNativeRenderNode = nativePtr;
|
||||
NoImagePreloadHolder.sRegistry.registerNativeAllocation(this, mNativeRenderNode);
|
||||
mOwningView = null;
|
||||
mAnimationHost = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,8 +173,8 @@ public class RenderNode {
|
||||
* @return A new RenderNode.
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public static RenderNode create(String name, @Nullable View owningView) {
|
||||
return new RenderNode(name, owningView);
|
||||
public static RenderNode create(String name, @Nullable AnimationHost animationHost) {
|
||||
return new RenderNode(name, animationHost);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,11 +187,38 @@ public class RenderNode {
|
||||
return new RenderNode(nativePtr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Listens for RenderNode position updates for synchronous window movement.
|
||||
*
|
||||
* This is not suitable for generic position listening, it is only designed & intended
|
||||
* for use by things which require external position events like SurfaceView, PopupWindow, etc..
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
interface PositionUpdateListener {
|
||||
|
||||
/**
|
||||
* Called by native by a Rendering Worker thread to update window position
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
void positionChanged(long frameNumber, int left, int top, int right, int bottom);
|
||||
|
||||
/**
|
||||
* Called by native on RenderThread to notify that the view is no longer in the
|
||||
* draw tree. UI thread is blocked at this point.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
void positionLost(long frameNumber);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable callbacks for position changes.
|
||||
*/
|
||||
public void requestPositionUpdates(SurfaceView view) {
|
||||
nRequestPositionUpdates(mNativeRenderNode, view);
|
||||
public void requestPositionUpdates(PositionUpdateListener listener) {
|
||||
nRequestPositionUpdates(mNativeRenderNode, listener);
|
||||
}
|
||||
|
||||
|
||||
@@ -873,26 +899,42 @@ public class RenderNode {
|
||||
// Animations
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* TODO: Figure out if this can be eliminated/refactored away
|
||||
*
|
||||
* For now this interface exists to de-couple RenderNode from anything View-specific in a
|
||||
* bit of a kludge.
|
||||
*
|
||||
* @hide */
|
||||
interface AnimationHost {
|
||||
void registerAnimatingRenderNode(RenderNode animator);
|
||||
void registerVectorDrawableAnimator(NativeVectorDrawableAnimator animator);
|
||||
boolean isAttached();
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public void addAnimator(RenderNodeAnimator animator) {
|
||||
if (mOwningView == null || mOwningView.mAttachInfo == null) {
|
||||
if (!isAttached()) {
|
||||
throw new IllegalStateException("Cannot start this animator on a detached view!");
|
||||
}
|
||||
nAddAnimator(mNativeRenderNode, animator.getNativeAnimator());
|
||||
mOwningView.mAttachInfo.mViewRootImpl.registerAnimatingRenderNode(this);
|
||||
mAnimationHost.registerAnimatingRenderNode(this);
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public boolean isAttached() {
|
||||
return mOwningView != null && mOwningView.mAttachInfo != null;
|
||||
return mAnimationHost != null && mAnimationHost.isAttached();
|
||||
}
|
||||
|
||||
public void registerVectorDrawableAnimator(
|
||||
AnimatedVectorDrawable.VectorDrawableAnimatorRT animatorSet) {
|
||||
if (mOwningView == null || mOwningView.mAttachInfo == null) {
|
||||
/** @hide */
|
||||
public void registerVectorDrawableAnimator(NativeVectorDrawableAnimator animatorSet) {
|
||||
if (!isAttached()) {
|
||||
throw new IllegalStateException("Cannot start this animator on a detached view!");
|
||||
}
|
||||
mOwningView.mAttachInfo.mViewRootImpl.registerVectorDrawableAnimator(animatorSet);
|
||||
mAnimationHost.registerVectorDrawableAnimator(animatorSet);
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public void endAllAnimators() {
|
||||
nEndAllAnimators(mNativeRenderNode);
|
||||
}
|
||||
@@ -906,7 +948,8 @@ public class RenderNode {
|
||||
private static native long nGetNativeFinalizer();
|
||||
private static native void nOutput(long renderNode);
|
||||
private static native int nGetDebugSize(long renderNode);
|
||||
private static native void nRequestPositionUpdates(long renderNode, SurfaceView callback);
|
||||
private static native void nRequestPositionUpdates(long renderNode,
|
||||
PositionUpdateListener callback);
|
||||
|
||||
// Animations
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
|
||||
|
||||
public SurfaceView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
mRenderNode.requestPositionUpdates(this);
|
||||
mRenderNode.requestPositionUpdates(mPositionListener);
|
||||
|
||||
setWillNotDraw(true);
|
||||
}
|
||||
@@ -826,81 +826,80 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
|
||||
|
||||
private Rect mRTLastReportedPosition = new Rect();
|
||||
|
||||
/**
|
||||
* Called by native by a Rendering Worker thread to update the window position
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public final void updateSurfacePosition_renderWorker(long frameNumber,
|
||||
int left, int top, int right, int bottom) {
|
||||
if (mSurfaceControl == null) {
|
||||
return;
|
||||
}
|
||||
private RenderNode.PositionUpdateListener mPositionListener =
|
||||
new RenderNode.PositionUpdateListener() {
|
||||
|
||||
// TODO: This is teensy bit racey in that a brand new SurfaceView moving on
|
||||
// its 2nd frame if RenderThread is running slowly could potentially see
|
||||
// this as false, enter the branch, get pre-empted, then this comes along
|
||||
// and reports a new position, then the UI thread resumes and reports
|
||||
// its position. This could therefore be de-sync'd in that interval, but
|
||||
// the synchronization would violate the rule that RT must never block
|
||||
// on the UI thread which would open up potential deadlocks. The risk of
|
||||
// a single-frame desync is therefore preferable for now.
|
||||
mRtHandlingPositionUpdates = true;
|
||||
if (mRTLastReportedPosition.left == left
|
||||
&& mRTLastReportedPosition.top == top
|
||||
&& mRTLastReportedPosition.right == right
|
||||
&& mRTLastReportedPosition.bottom == bottom) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, String.format("%d updateSurfacePosition RenderWorker, frameNr = %d, " +
|
||||
"postion = [%d, %d, %d, %d]", System.identityHashCode(this),
|
||||
frameNumber, left, top, right, bottom));
|
||||
@Override
|
||||
public void positionChanged(long frameNumber, int left, int top, int right, int bottom) {
|
||||
if (mSurfaceControl == null) {
|
||||
return;
|
||||
}
|
||||
mRTLastReportedPosition.set(left, top, right, bottom);
|
||||
setParentSpaceRectangle(mRTLastReportedPosition, frameNumber);
|
||||
// Now overwrite mRTLastReportedPosition with our values
|
||||
} catch (Exception ex) {
|
||||
Log.e(TAG, "Exception from repositionChild", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by native on RenderThread to notify that the view is no longer in the
|
||||
* draw tree. UI thread is blocked at this point.
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public final void surfacePositionLost_uiRtSync(long frameNumber) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, String.format("%d windowPositionLost, frameNr = %d",
|
||||
System.identityHashCode(this), frameNumber));
|
||||
// TODO: This is teensy bit racey in that a brand new SurfaceView moving on
|
||||
// its 2nd frame if RenderThread is running slowly could potentially see
|
||||
// this as false, enter the branch, get pre-empted, then this comes along
|
||||
// and reports a new position, then the UI thread resumes and reports
|
||||
// its position. This could therefore be de-sync'd in that interval, but
|
||||
// the synchronization would violate the rule that RT must never block
|
||||
// on the UI thread which would open up potential deadlocks. The risk of
|
||||
// a single-frame desync is therefore preferable for now.
|
||||
mRtHandlingPositionUpdates = true;
|
||||
if (mRTLastReportedPosition.left == left
|
||||
&& mRTLastReportedPosition.top == top
|
||||
&& mRTLastReportedPosition.right == right
|
||||
&& mRTLastReportedPosition.bottom == bottom) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, String.format(
|
||||
"%d updateSurfacePosition RenderWorker, frameNr = %d, "
|
||||
+ "postion = [%d, %d, %d, %d]",
|
||||
System.identityHashCode(this), frameNumber,
|
||||
left, top, right, bottom));
|
||||
}
|
||||
mRTLastReportedPosition.set(left, top, right, bottom);
|
||||
setParentSpaceRectangle(mRTLastReportedPosition, frameNumber);
|
||||
// Now overwrite mRTLastReportedPosition with our values
|
||||
} catch (Exception ex) {
|
||||
Log.e(TAG, "Exception from repositionChild", ex);
|
||||
}
|
||||
}
|
||||
mRTLastReportedPosition.setEmpty();
|
||||
|
||||
if (mSurfaceControl == null) {
|
||||
return;
|
||||
}
|
||||
if (mRtHandlingPositionUpdates) {
|
||||
mRtHandlingPositionUpdates = false;
|
||||
// This callback will happen while the UI thread is blocked, so we can
|
||||
// safely access other member variables at this time.
|
||||
// So do what the UI thread would have done if RT wasn't handling position
|
||||
// updates.
|
||||
if (!mScreenRect.isEmpty() && !mScreenRect.equals(mRTLastReportedPosition)) {
|
||||
try {
|
||||
if (DEBUG) Log.d(TAG, String.format("%d updateSurfacePosition, " +
|
||||
"postion = [%d, %d, %d, %d]", System.identityHashCode(this),
|
||||
mScreenRect.left, mScreenRect.top,
|
||||
mScreenRect.right, mScreenRect.bottom));
|
||||
setParentSpaceRectangle(mScreenRect, frameNumber);
|
||||
} catch (Exception ex) {
|
||||
Log.e(TAG, "Exception configuring surface", ex);
|
||||
@Override
|
||||
public void positionLost(long frameNumber) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, String.format("%d windowPositionLost, frameNr = %d",
|
||||
System.identityHashCode(this), frameNumber));
|
||||
}
|
||||
mRTLastReportedPosition.setEmpty();
|
||||
|
||||
if (mSurfaceControl == null) {
|
||||
return;
|
||||
}
|
||||
if (mRtHandlingPositionUpdates) {
|
||||
mRtHandlingPositionUpdates = false;
|
||||
// This callback will happen while the UI thread is blocked, so we can
|
||||
// safely access other member variables at this time.
|
||||
// So do what the UI thread would have done if RT wasn't handling position
|
||||
// updates.
|
||||
if (!mScreenRect.isEmpty() && !mScreenRect.equals(mRTLastReportedPosition)) {
|
||||
try {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, String.format("%d updateSurfacePosition, "
|
||||
+ "postion = [%d, %d, %d, %d]",
|
||||
System.identityHashCode(this),
|
||||
mScreenRect.left, mScreenRect.top,
|
||||
mScreenRect.right, mScreenRect.bottom));
|
||||
}
|
||||
setParentSpaceRectangle(mScreenRect, frameNumber);
|
||||
} catch (Exception ex) {
|
||||
Log.e(TAG, "Exception configuring surface", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private SurfaceHolder.Callback[] getSurfaceCallbacks() {
|
||||
SurfaceHolder.Callback callbacks[];
|
||||
|
||||
@@ -25,7 +25,6 @@ import android.content.res.TypedArray;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.AnimatedVectorDrawable;
|
||||
import android.os.IBinder;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.os.RemoteException;
|
||||
@@ -914,8 +913,7 @@ public final class ThreadedRenderer {
|
||||
nRegisterAnimatingRenderNode(mRootNode.mNativeRenderNode, animator.mNativeRenderNode);
|
||||
}
|
||||
|
||||
void registerVectorDrawableAnimator(
|
||||
AnimatedVectorDrawable.VectorDrawableAnimatorRT animator) {
|
||||
void registerVectorDrawableAnimator(NativeVectorDrawableAnimator animator) {
|
||||
nRegisterVectorDrawableAnimator(mRootNode.mNativeRenderNode,
|
||||
animator.getAnimatorNativePtr());
|
||||
}
|
||||
|
||||
@@ -4864,7 +4864,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
setOverScrollMode(OVER_SCROLL_IF_CONTENT_SCROLLS);
|
||||
mUserPaddingStart = UNDEFINED_PADDING;
|
||||
mUserPaddingEnd = UNDEFINED_PADDING;
|
||||
mRenderNode = RenderNode.create(getClass().getName(), this);
|
||||
mRenderNode = RenderNode.create(getClass().getName(), new ViewAnimationHostBridge(this));
|
||||
|
||||
if (!sCompatibilityDone && context != null) {
|
||||
final int targetSdkVersion = context.getApplicationInfo().targetSdkVersion;
|
||||
@@ -5732,7 +5732,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
@UnsupportedAppUsage
|
||||
View() {
|
||||
mResources = null;
|
||||
mRenderNode = RenderNode.create(getClass().getName(), this);
|
||||
mRenderNode = RenderNode.create(getClass().getName(), new ViewAnimationHostBridge(this));
|
||||
}
|
||||
|
||||
final boolean debugDraw() {
|
||||
@@ -20600,7 +20600,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
*/
|
||||
private RenderNode getDrawableRenderNode(Drawable drawable, RenderNode renderNode) {
|
||||
if (renderNode == null) {
|
||||
renderNode = RenderNode.create(drawable.getClass().getName(), this);
|
||||
renderNode = RenderNode.create(drawable.getClass().getName(),
|
||||
new ViewAnimationHostBridge(this));
|
||||
renderNode.setUsageHint(RenderNode.USAGE_BACKGROUND);
|
||||
}
|
||||
|
||||
|
||||
48
core/java/android/view/ViewAnimationHostBridge.java
Normal file
48
core/java/android/view/ViewAnimationHostBridge.java
Normal 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;
|
||||
|
||||
/**
|
||||
* Maps a View to a RenderNode's AnimationHost
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public class ViewAnimationHostBridge implements RenderNode.AnimationHost {
|
||||
private final View mView;
|
||||
|
||||
/**
|
||||
* @param view the View to bridge to an AnimationHost
|
||||
*/
|
||||
public ViewAnimationHostBridge(View view) {
|
||||
mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerAnimatingRenderNode(RenderNode animator) {
|
||||
mView.mAttachInfo.mViewRootImpl.registerAnimatingRenderNode(animator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerVectorDrawableAnimator(NativeVectorDrawableAnimator animator) {
|
||||
mView.mAttachInfo.mViewRootImpl.registerVectorDrawableAnimator(animator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAttached() {
|
||||
return mView.mAttachInfo != null;
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,6 @@ import android.graphics.PointF;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Region;
|
||||
import android.graphics.drawable.AnimatedVectorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.hardware.display.DisplayManager;
|
||||
import android.hardware.display.DisplayManager.DisplayListener;
|
||||
@@ -991,6 +990,9 @@ public final class ViewRootImpl implements ViewParent,
|
||||
ThreadedRenderer.invokeFunctor(functor, waitForCompletion);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param animator animator to register with the hardware renderer
|
||||
*/
|
||||
public void registerAnimatingRenderNode(RenderNode animator) {
|
||||
if (mAttachInfo.mThreadedRenderer != null) {
|
||||
mAttachInfo.mThreadedRenderer.registerAnimatingRenderNode(animator);
|
||||
@@ -1002,8 +1004,10 @@ public final class ViewRootImpl implements ViewParent,
|
||||
}
|
||||
}
|
||||
|
||||
public void registerVectorDrawableAnimator(
|
||||
AnimatedVectorDrawable.VectorDrawableAnimatorRT animator) {
|
||||
/**
|
||||
* @param animator animator to register with the hardware renderer
|
||||
*/
|
||||
public void registerVectorDrawableAnimator(NativeVectorDrawableAnimator animator) {
|
||||
if (mAttachInfo.mThreadedRenderer != null) {
|
||||
mAttachInfo.mThreadedRenderer.registerVectorDrawableAnimator(animator);
|
||||
}
|
||||
|
||||
@@ -674,7 +674,7 @@ int register_android_graphics_Canvas(JNIEnv* env) {
|
||||
int ret = 0;
|
||||
ret |= RegisterMethodsOrDie(env, "android/graphics/Canvas", gMethods, NELEM(gMethods));
|
||||
ret |= RegisterMethodsOrDie(env, "android/graphics/BaseCanvas", gDrawMethods, NELEM(gDrawMethods));
|
||||
ret |= RegisterMethodsOrDie(env, "android/view/RecordingCanvas", gDrawMethods, NELEM(gDrawMethods));
|
||||
ret |= RegisterMethodsOrDie(env, "android/graphics/BaseRecordingCanvas", gDrawMethods, NELEM(gDrawMethods));
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
@@ -473,8 +473,8 @@ static void android_view_RenderNode_endAllAnimators(JNIEnv* env, jobject clazz,
|
||||
// SurfaceView position callback
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
jmethodID gSurfaceViewPositionUpdateMethod;
|
||||
jmethodID gSurfaceViewPositionLostMethod;
|
||||
jmethodID gPositionListener_PositionChangedMethod;
|
||||
jmethodID gPositionListener_PositionLostMethod;
|
||||
|
||||
static void android_view_RenderNode_requestPositionUpdates(JNIEnv* env, jobject,
|
||||
jlong renderNodePtr, jobject surfaceview) {
|
||||
@@ -531,7 +531,7 @@ static void android_view_RenderNode_requestPositionUpdates(JNIEnv* env, jobject,
|
||||
return;
|
||||
}
|
||||
|
||||
env->CallVoidMethod(localref, gSurfaceViewPositionLostMethod,
|
||||
env->CallVoidMethod(localref, gPositionListener_PositionLostMethod,
|
||||
info ? info->canvasContext.getFrameNumber() : 0);
|
||||
env->DeleteLocalRef(localref);
|
||||
}
|
||||
@@ -555,7 +555,7 @@ static void android_view_RenderNode_requestPositionUpdates(JNIEnv* env, jobject,
|
||||
env->DeleteWeakGlobalRef(mWeakRef);
|
||||
mWeakRef = nullptr;
|
||||
} else {
|
||||
env->CallVoidMethod(localref, gSurfaceViewPositionUpdateMethod,
|
||||
env->CallVoidMethod(localref, gPositionListener_PositionChangedMethod,
|
||||
frameNumber, left, top, right, bottom);
|
||||
env->DeleteLocalRef(localref);
|
||||
}
|
||||
@@ -588,7 +588,7 @@ static const JNINativeMethod gMethods[] = {
|
||||
{ "nGetDebugSize", "(J)I", (void*) android_view_RenderNode_getDebugSize },
|
||||
{ "nAddAnimator", "(JJ)V", (void*) android_view_RenderNode_addAnimator },
|
||||
{ "nEndAllAnimators", "(J)V", (void*) android_view_RenderNode_endAllAnimators },
|
||||
{ "nRequestPositionUpdates", "(JLandroid/view/SurfaceView;)V", (void*) android_view_RenderNode_requestPositionUpdates },
|
||||
{ "nRequestPositionUpdates", "(JLandroid/view/RenderNode$PositionUpdateListener;)V", (void*) android_view_RenderNode_requestPositionUpdates },
|
||||
{ "nSetDisplayList", "(JJ)V", (void*) android_view_RenderNode_setDisplayList },
|
||||
|
||||
|
||||
@@ -677,11 +677,11 @@ static const JNINativeMethod gMethods[] = {
|
||||
};
|
||||
|
||||
int register_android_view_RenderNode(JNIEnv* env) {
|
||||
jclass clazz = FindClassOrDie(env, "android/view/SurfaceView");
|
||||
gSurfaceViewPositionUpdateMethod = GetMethodIDOrDie(env, clazz,
|
||||
"updateSurfacePosition_renderWorker", "(JIIII)V");
|
||||
gSurfaceViewPositionLostMethod = GetMethodIDOrDie(env, clazz,
|
||||
"surfacePositionLost_uiRtSync", "(J)V");
|
||||
jclass clazz = FindClassOrDie(env, "android/view/RenderNode$PositionUpdateListener");
|
||||
gPositionListener_PositionChangedMethod = GetMethodIDOrDie(env, clazz,
|
||||
"positionChanged", "(JIIII)V");
|
||||
gPositionListener_PositionLostMethod = GetMethodIDOrDie(env, clazz,
|
||||
"positionLost", "(J)V");
|
||||
return RegisterMethodsOrDie(env, kClassPathName, gMethods, NELEM(gMethods));
|
||||
}
|
||||
|
||||
|
||||
@@ -28,11 +28,10 @@ import android.text.PrecomputedText;
|
||||
import android.text.SpannableString;
|
||||
import android.text.SpannedString;
|
||||
import android.text.TextUtils;
|
||||
import android.view.RecordingCanvas;
|
||||
|
||||
/**
|
||||
* This class is a base class for Canvas's drawing operations. Any modifications here
|
||||
* should be accompanied by a similar modification to {@link RecordingCanvas}.
|
||||
* should be accompanied by a similar modification to {@link BaseRecordingCanvas}.
|
||||
*
|
||||
* The purpose of this class is to minimize the cost of deciding between regular JNI
|
||||
* and @FastNative JNI to just the virtual call that Canvas already has.
|
||||
|
||||
@@ -14,25 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.view;
|
||||
package android.graphics;
|
||||
|
||||
import android.annotation.ColorInt;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.Size;
|
||||
import android.graphics.BaseCanvas;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.NinePatch;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.Picture;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.TemporaryBuffer;
|
||||
import android.text.GraphicsOperations;
|
||||
import android.text.MeasuredParagraph;
|
||||
import android.text.PrecomputedText;
|
||||
@@ -49,9 +36,9 @@ import dalvik.annotation.optimization.FastNative;
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public class RecordingCanvas extends Canvas {
|
||||
public class BaseRecordingCanvas extends Canvas {
|
||||
|
||||
public RecordingCanvas(long nativeCanvas) {
|
||||
public BaseRecordingCanvas(long nativeCanvas) {
|
||||
super(nativeCanvas);
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ import android.util.Property;
|
||||
import android.util.TimeUtils;
|
||||
import android.view.Choreographer;
|
||||
import android.view.DisplayListCanvas;
|
||||
import android.view.NativeVectorDrawableAnimator;
|
||||
import android.view.RenderNode;
|
||||
import android.view.RenderNodeAnimatorSetHelper;
|
||||
import android.view.View;
|
||||
@@ -1231,7 +1232,8 @@ public class AnimatedVectorDrawable extends Drawable implements Animatable2 {
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public static class VectorDrawableAnimatorRT implements VectorDrawableAnimator {
|
||||
public static class VectorDrawableAnimatorRT implements VectorDrawableAnimator,
|
||||
NativeVectorDrawableAnimator {
|
||||
private static final int START_ANIMATION = 1;
|
||||
private static final int REVERSE_ANIMATION = 2;
|
||||
private static final int RESET_ANIMATION = 3;
|
||||
@@ -1704,6 +1706,7 @@ public class AnimatedVectorDrawable extends Drawable implements Animatable2 {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAnimatorNativePtr() {
|
||||
return mSetPtr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user