diff options
| author | John Reck <jreck@google.com> | 2018-10-04 15:08:24 -0700 |
|---|---|---|
| committer | John Reck <jreck@google.com> | 2018-10-04 16:18:12 -0700 |
| commit | 32f140aa6764ebc71b549e57479a42fc3daefc8a (patch) | |
| tree | 83fcf0c85b8ee80d70afc48b86151621f98dc296 /core/java/android/view | |
| parent | b577f20c23093ff263adc30083928c1d70266fd3 (diff) | |
Rename & package shuffle
Rename DisplayListCanvas -> RecordingCanvas
Move RecordingCanvas to android.graphics
Move RenderNode to android.graphics
Bug: 112709971
Test: make & boot
Change-Id: Iddeb6a89f8923ea81a1f37bbee4e9b1db8ede238
Diffstat (limited to 'core/java/android/view')
| -rw-r--r-- | core/java/android/view/DisplayListCanvas.java | 272 | ||||
| -rw-r--r-- | core/java/android/view/GhostView.java | 6 | ||||
| -rw-r--r-- | core/java/android/view/RenderNode.java | 1119 | ||||
| -rw-r--r-- | core/java/android/view/RenderNodeAnimator.java | 8 | ||||
| -rw-r--r-- | core/java/android/view/RenderNodeAnimatorSetHelper.java | 6 | ||||
| -rw-r--r-- | core/java/android/view/Surface.java | 4 | ||||
| -rw-r--r-- | core/java/android/view/SurfaceView.java | 1 | ||||
| -rw-r--r-- | core/java/android/view/TextureLayer.java | 2 | ||||
| -rw-r--r-- | core/java/android/view/TextureView.java | 5 | ||||
| -rw-r--r-- | core/java/android/view/ThreadedRenderer.java | 8 | ||||
| -rw-r--r-- | core/java/android/view/View.java | 10 | ||||
| -rw-r--r-- | core/java/android/view/ViewAnimationHostBridge.java | 2 | ||||
| -rw-r--r-- | core/java/android/view/ViewDebug.java | 4 | ||||
| -rw-r--r-- | core/java/android/view/ViewPropertyAnimator.java | 1 | ||||
| -rw-r--r-- | core/java/android/view/ViewRootImpl.java | 6 | ||||
| -rw-r--r-- | core/java/android/view/WindowCallbacks.java | 3 |
16 files changed, 45 insertions, 1412 deletions
diff --git a/core/java/android/view/DisplayListCanvas.java b/core/java/android/view/DisplayListCanvas.java deleted file mode 100644 index 667fab5537c9..000000000000 --- a/core/java/android/view/DisplayListCanvas.java +++ /dev/null @@ -1,272 +0,0 @@ -/* - * Copyright (C) 2010 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.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; -import android.util.Pools.SynchronizedPool; - -import dalvik.annotation.optimization.CriticalNative; -import dalvik.annotation.optimization.FastNative; - -/** - * A Canvas implementation that records view system drawing operations for deferred rendering. - * This is intended for use with a DisplayList. This class keeps a list of all the Paint and - * Bitmap objects that it draws, preventing the backing memory of Bitmaps from being freed while - * the DisplayList is still holding a native reference to the memory. - * - * @hide - */ -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; - - public static final int MAX_BITMAP_SIZE = 100 * 1024 * 1024; // 100 MB - - private static final SynchronizedPool<DisplayListCanvas> sPool = - new SynchronizedPool<>(POOL_LIMIT); - - RenderNode mNode; - private int mWidth; - private int mHeight; - - static DisplayListCanvas obtain(@NonNull RenderNode node, int width, int height) { - if (node == null) throw new IllegalArgumentException("node cannot be null"); - DisplayListCanvas canvas = sPool.acquire(); - if (canvas == null) { - canvas = new DisplayListCanvas(node, width, height); - } else { - nResetDisplayListCanvas(canvas.mNativeCanvasWrapper, node.mNativeRenderNode, - width, height); - } - canvas.mNode = node; - canvas.mWidth = width; - canvas.mHeight = height; - return canvas; - } - - void recycle() { - mNode = null; - sPool.release(this); - } - - long finishRecording() { - return nFinishRecording(mNativeCanvasWrapper); - } - - @Override - public boolean isRecordingFor(Object o) { - return o == mNode; - } - - /////////////////////////////////////////////////////////////////////////// - // Constructors - /////////////////////////////////////////////////////////////////////////// - - private DisplayListCanvas(@NonNull RenderNode node, int width, int height) { - super(nCreateDisplayListCanvas(node.mNativeRenderNode, width, height)); - mDensity = 0; // disable bitmap density scaling - } - - /////////////////////////////////////////////////////////////////////////// - // Canvas management - /////////////////////////////////////////////////////////////////////////// - - - @Override - public void setDensity(int density) { - // drop silently, since DisplayListCanvas doesn't perform density scaling - } - - @Override - public boolean isHardwareAccelerated() { - return true; - } - - @Override - public void setBitmap(Bitmap bitmap) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean isOpaque() { - return false; - } - - @Override - public int getWidth() { - return mWidth; - } - - @Override - public int getHeight() { - return mHeight; - } - - @Override - public int getMaximumBitmapWidth() { - return nGetMaximumTextureWidth(); - } - - @Override - public int getMaximumBitmapHeight() { - return nGetMaximumTextureHeight(); - } - - /////////////////////////////////////////////////////////////////////////// - // Setup - /////////////////////////////////////////////////////////////////////////// - - @Override - public void insertReorderBarrier() { - nInsertReorderBarrier(mNativeCanvasWrapper, true); - } - - @Override - public void insertInorderBarrier() { - nInsertReorderBarrier(mNativeCanvasWrapper, false); - } - - /////////////////////////////////////////////////////////////////////////// - // Functor - /////////////////////////////////////////////////////////////////////////// - - /** - * Records the functor specified with the drawGLFunction function pointer. This is - * functionality used by webview for calling into their renderer from our display lists. - * - * @param drawGLFunction A native function pointer - */ - @UnsupportedAppUsage - public void callDrawGLFunction2(long drawGLFunction) { - nCallDrawGLFunction(mNativeCanvasWrapper, drawGLFunction, null); - } - - /** - * Records the functor specified with the drawGLFunction function pointer. This is - * functionality used by webview for calling into their renderer from our display lists. - * - * @param drawGLFunction A native function pointer - * @param releasedCallback Called when the display list is destroyed, and thus - * the functor is no longer referenced by this canvas's display list. - * - * NOTE: The callback does *not* necessarily mean that there are no longer - * any references to the functor, just that the reference from this specific - * canvas's display list has been released. - */ - @UnsupportedAppUsage - public void drawGLFunctor2(long drawGLFunctor, @Nullable Runnable releasedCallback) { - nCallDrawGLFunction(mNativeCanvasWrapper, drawGLFunctor, releasedCallback); - } - - /////////////////////////////////////////////////////////////////////////// - // Display list - /////////////////////////////////////////////////////////////////////////// - - /** - * Draws the specified display list onto this canvas. - * - * @param renderNode The RenderNode to draw. - */ - @UnsupportedAppUsage - public void drawRenderNode(RenderNode renderNode) { - nDrawRenderNode(mNativeCanvasWrapper, renderNode.mNativeRenderNode); - } - - /////////////////////////////////////////////////////////////////////////// - // Hardware layer - /////////////////////////////////////////////////////////////////////////// - - /** - * Draws the specified layer onto this canvas. - * - * @param layer The layer to composite on this canvas - */ - void drawTextureLayer(TextureLayer layer) { - nDrawTextureLayer(mNativeCanvasWrapper, layer.getLayerHandle()); - } - - /////////////////////////////////////////////////////////////////////////// - // Drawing - /////////////////////////////////////////////////////////////////////////// - - @UnsupportedAppUsage - public void drawCircle(CanvasProperty<Float> cx, CanvasProperty<Float> cy, - CanvasProperty<Float> radius, CanvasProperty<Paint> paint) { - nDrawCircle(mNativeCanvasWrapper, cx.getNativeContainer(), cy.getNativeContainer(), - radius.getNativeContainer(), paint.getNativeContainer()); - } - - public void drawRoundRect(CanvasProperty<Float> left, CanvasProperty<Float> top, - CanvasProperty<Float> right, CanvasProperty<Float> bottom, CanvasProperty<Float> rx, - CanvasProperty<Float> ry, CanvasProperty<Paint> paint) { - nDrawRoundRect(mNativeCanvasWrapper, left.getNativeContainer(), top.getNativeContainer(), - right.getNativeContainer(), bottom.getNativeContainer(), - rx.getNativeContainer(), ry.getNativeContainer(), - paint.getNativeContainer()); - } - - @Override - protected void throwIfCannotDraw(Bitmap bitmap) { - super.throwIfCannotDraw(bitmap); - int bitmapSize = bitmap.getByteCount(); - if (bitmapSize > MAX_BITMAP_SIZE) { - throw new RuntimeException( - "Canvas: trying to draw too large(" + bitmapSize + "bytes) bitmap."); - } - } - - - // ------------------ Fast JNI ------------------------ - - @FastNative - private static native void nCallDrawGLFunction(long renderer, - long drawGLFunction, Runnable releasedCallback); - - - // ------------------ Critical JNI ------------------------ - - @CriticalNative - private static native long nCreateDisplayListCanvas(long node, int width, int height); - @CriticalNative - private static native void nResetDisplayListCanvas(long canvas, long node, - int width, int height); - @CriticalNative - private static native int nGetMaximumTextureWidth(); - @CriticalNative - private static native int nGetMaximumTextureHeight(); - @CriticalNative - private static native void nInsertReorderBarrier(long renderer, boolean enableReorder); - @CriticalNative - private static native long nFinishRecording(long renderer); - @CriticalNative - private static native void nDrawRenderNode(long renderer, long renderNode); - @CriticalNative - private static native void nDrawTextureLayer(long renderer, long layer); - @CriticalNative - private static native void nDrawCircle(long renderer, long propCx, - long propCy, long propRadius, long propPaint); - @CriticalNative - private static native void nDrawRoundRect(long renderer, long propLeft, long propTop, - long propRight, long propBottom, long propRx, long propRy, long propPaint); -} diff --git a/core/java/android/view/GhostView.java b/core/java/android/view/GhostView.java index fa7b067deb20..98ed21735e62 100644 --- a/core/java/android/view/GhostView.java +++ b/core/java/android/view/GhostView.java @@ -18,6 +18,8 @@ package android.view; import android.annotation.UnsupportedAppUsage; import android.graphics.Canvas; import android.graphics.Matrix; +import android.graphics.RecordingCanvas; +import android.graphics.RenderNode; import android.widget.FrameLayout; import java.util.ArrayList; @@ -46,8 +48,8 @@ public class GhostView extends View { @Override protected void onDraw(Canvas canvas) { - if (canvas instanceof DisplayListCanvas) { - DisplayListCanvas dlCanvas = (DisplayListCanvas) canvas; + if (canvas instanceof RecordingCanvas) { + RecordingCanvas dlCanvas = (RecordingCanvas) canvas; mView.mRecreateDisplayList = true; RenderNode renderNode = mView.updateDisplayListIfDirty(); if (renderNode.isValid()) { diff --git a/core/java/android/view/RenderNode.java b/core/java/android/view/RenderNode.java deleted file mode 100644 index 8ae912762fdb..000000000000 --- a/core/java/android/view/RenderNode.java +++ /dev/null @@ -1,1119 +0,0 @@ -/* - * Copyright (C) 2010 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.IntDef; -import android.annotation.NonNull; -import android.annotation.Nullable; -import android.annotation.UnsupportedAppUsage; -import android.graphics.Matrix; -import android.graphics.Outline; -import android.graphics.Paint; -import android.graphics.Rect; - -import dalvik.annotation.optimization.CriticalNative; -import dalvik.annotation.optimization.FastNative; - -import libcore.util.NativeAllocationRegistry; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * <p>A display list records a series of graphics related operations and can replay - * them later. Display lists are usually built by recording operations on a - * {@link DisplayListCanvas}. Replaying the operations from a display list avoids - * executing application code on every frame, and is thus much more efficient.</p> - * - * <p>Display lists are used internally for all views by default, and are not - * typically used directly. One reason to consider using a display is a custom - * {@link View} implementation that needs to issue a large number of drawing commands. - * When the view invalidates, all the drawing commands must be reissued, even if - * large portions of the drawing command stream stay the same frame to frame, which - * can become a performance bottleneck. To solve this issue, a custom View might split - * its content into several display lists. A display list is updated only when its - * content, and only its content, needs to be updated.</p> - * - * <p>A text editor might for instance store each paragraph into its own display list. - * Thus when the user inserts or removes characters, only the display list of the - * affected paragraph needs to be recorded again.</p> - * - * <h3>Hardware acceleration</h3> - * <p>Display lists can only be replayed using a {@link DisplayListCanvas}. They are not - * supported in software. Always make sure that the {@link android.graphics.Canvas} - * you are using to render a display list is hardware accelerated using - * {@link android.graphics.Canvas#isHardwareAccelerated()}.</p> - * - * <h3>Creating a display list</h3> - * <pre class="prettyprint"> - * ThreadedRenderer renderer = myView.getThreadedRenderer(); - * if (renderer != null) { - * DisplayList displayList = renderer.createDisplayList(); - * DisplayListCanvas canvas = displayList.start(width, height); - * try { - * // Draw onto the canvas - * // For instance: canvas.drawBitmap(...); - * } finally { - * displayList.end(); - * } - * } - * </pre> - * - * <h3>Rendering a display list on a View</h3> - * <pre class="prettyprint"> - * protected void onDraw(Canvas canvas) { - * if (canvas.isHardwareAccelerated()) { - * DisplayListCanvas displayListCanvas = (DisplayListCanvas) canvas; - * displayListCanvas.drawDisplayList(mDisplayList); - * } - * } - * </pre> - * - * <h3>Releasing resources</h3> - * <p>This step is not mandatory but recommended if you want to release resources - * held by a display list as soon as possible.</p> - * <pre class="prettyprint"> - * // Mark this display list invalid, it cannot be used for drawing anymore, - * // and release resources held by this display list - * displayList.clear(); - * </pre> - * - * <h3>Properties</h3> - * <p>In addition, a display list offers several properties, such as - * {@link #setScaleX(float)} or {@link #setLeft(int)}, that can be used to affect all - * the drawing commands recorded within. For instance, these properties can be used - * to move around a large number of images without re-issuing all the individual - * <code>drawBitmap()</code> calls.</p> - * - * <pre class="prettyprint"> - * private void createDisplayList() { - * mDisplayList = DisplayList.create("MyDisplayList"); - * DisplayListCanvas canvas = mDisplayList.start(width, height); - * try { - * for (Bitmap b : mBitmaps) { - * canvas.drawBitmap(b, 0.0f, 0.0f, null); - * canvas.translate(0.0f, b.getHeight()); - * } - * } finally { - * displayList.end(); - * } - * } - * - * protected void onDraw(Canvas canvas) { - * if (canvas.isHardwareAccelerated()) { - * DisplayListCanvas displayListCanvas = (DisplayListCanvas) canvas; - * displayListCanvas.drawDisplayList(mDisplayList); - * } - * } - * - * private void moveContentBy(int x) { - * // This will move all the bitmaps recorded inside the display list - * // by x pixels to the right and redraw this view. All the commands - * // recorded in createDisplayList() won't be re-issued, only onDraw() - * // will be invoked and will execute very quickly - * mDisplayList.offsetLeftAndRight(x); - * invalidate(); - * } - * </pre> - * - * <h3>Threading</h3> - * <p>Display lists must be created on and manipulated from the UI thread only.</p> - * - * @hide - */ -public class RenderNode { - - // Use a Holder to allow static initialization in the boot image. - private static class NoImagePreloadHolder { - public static final NativeAllocationRegistry sRegistry = new NativeAllocationRegistry( - RenderNode.class.getClassLoader(), nGetNativeFinalizer(), 1024); - } - - /** Not for general use; use only if you are ThreadedRenderer or DisplayListCanvas. - * @hide - */ - final long mNativeRenderNode; - private final AnimationHost mAnimationHost; - - private RenderNode(String name, AnimationHost animationHost) { - mNativeRenderNode = nCreate(name); - NoImagePreloadHolder.sRegistry.registerNativeAllocation(this, mNativeRenderNode); - mAnimationHost = animationHost; - } - - /** - * @see RenderNode#adopt(long) - */ - private RenderNode(long nativePtr) { - mNativeRenderNode = nativePtr; - NoImagePreloadHolder.sRegistry.registerNativeAllocation(this, mNativeRenderNode); - mAnimationHost = null; - } - - /** - * Creates a new RenderNode that can be used to record batches of - * drawing operations, and store / apply render properties when drawn. - * - * @param name The name of the RenderNode, used for debugging purpose. May be null. - * - * @return A new RenderNode. - */ - @UnsupportedAppUsage - public static RenderNode create(String name, @Nullable AnimationHost animationHost) { - return new RenderNode(name, animationHost); - } - - /** - * Adopts an existing native render node. - * - * Note: This will *NOT* incRef() on the native object, however it will - * decRef() when it is destroyed. The caller should have already incRef'd it - */ - public static RenderNode adopt(long nativePtr) { - 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(PositionUpdateListener listener) { - nRequestPositionUpdates(mNativeRenderNode, listener); - } - - - /** - * Starts recording a display list for the render node. All - * operations performed on the returned canvas are recorded and - * stored in this display list. - * - * Calling this method will mark the render node invalid until - * {@link #end(DisplayListCanvas)} is called. - * Only valid render nodes can be replayed. - * - * @param width The width of the recording viewport - * @param height The height of the recording viewport - * - * @return A canvas to record drawing operations. - * - * @see #end(DisplayListCanvas) - * @see #isValid() - */ - @UnsupportedAppUsage - public DisplayListCanvas start(int width, int height) { - return DisplayListCanvas.obtain(this, width, height); - } - - /** - * Same as {@link #start(int, int)} but with the RenderNode's width & height - */ - public DisplayListCanvas start() { - return DisplayListCanvas.obtain(this, - nGetWidth(mNativeRenderNode), nGetHeight(mNativeRenderNode)); - } - - /** - * Ends the recording for this display list. A display list cannot be - * replayed if recording is not finished. Calling this method marks - * the display list valid and {@link #isValid()} will return true. - * - * @see #start(int, int) - * @see #isValid() - */ - @UnsupportedAppUsage - public void end(DisplayListCanvas canvas) { - long displayList = canvas.finishRecording(); - nSetDisplayList(mNativeRenderNode, displayList); - canvas.recycle(); - } - - /** - * Reset native resources. This is called when cleaning up the state of display lists - * during destruction of hardware resources, to ensure that we do not hold onto - * obsolete resources after related resources are gone. - */ - @UnsupportedAppUsage - public void discardDisplayList() { - nSetDisplayList(mNativeRenderNode, 0); - } - - /** - * Returns whether the RenderNode's display list content is currently usable. - * If this returns false, the display list should be re-recorded prior to replaying it. - * - * @return boolean true if the display list is able to be replayed, false otherwise. - */ - @UnsupportedAppUsage - public boolean isValid() { - return nIsValid(mNativeRenderNode); - } - - /////////////////////////////////////////////////////////////////////////// - // Matrix manipulation - /////////////////////////////////////////////////////////////////////////// - - public boolean hasIdentityMatrix() { - return nHasIdentityMatrix(mNativeRenderNode); - } - - public void getMatrix(@NonNull Matrix outMatrix) { - nGetTransformMatrix(mNativeRenderNode, outMatrix.native_instance); - } - - public void getInverseMatrix(@NonNull Matrix outMatrix) { - nGetInverseTransformMatrix(mNativeRenderNode, outMatrix.native_instance); - } - - /////////////////////////////////////////////////////////////////////////// - // RenderProperty Setters - /////////////////////////////////////////////////////////////////////////// - - public boolean setLayerType(int layerType) { - return nSetLayerType(mNativeRenderNode, layerType); - } - - public boolean setLayerPaint(@Nullable Paint paint) { - return nSetLayerPaint(mNativeRenderNode, paint != null ? paint.getNativeInstance() : 0); - } - - public boolean setClipBounds(@Nullable Rect rect) { - if (rect == null) { - return nSetClipBoundsEmpty(mNativeRenderNode); - } else { - return nSetClipBounds(mNativeRenderNode, rect.left, rect.top, rect.right, rect.bottom); - } - } - - /** - * Set whether the Render node should clip itself to its bounds. This property is controlled by - * the view's parent. - * - * @param clipToBounds true if the display list should clip to its bounds - */ - @UnsupportedAppUsage - public boolean setClipToBounds(boolean clipToBounds) { - return nSetClipToBounds(mNativeRenderNode, clipToBounds); - } - - /** - * Sets whether the display list should be drawn immediately after the - * closest ancestor display list containing a projection receiver. - * - * @param shouldProject true if the display list should be projected onto a - * containing volume. - */ - @UnsupportedAppUsage - public boolean setProjectBackwards(boolean shouldProject) { - return nSetProjectBackwards(mNativeRenderNode, shouldProject); - } - - /** - * Sets whether the display list is a projection receiver - that its parent - * DisplayList should draw any descendent DisplayLists with - * ProjectBackwards=true directly on top of it. Default value is false. - */ - public boolean setProjectionReceiver(boolean shouldRecieve) { - return nSetProjectionReceiver(mNativeRenderNode, shouldRecieve); - } - - /** - * Sets the outline, defining the shape that casts a shadow, and the path to - * be clipped if setClipToOutline is set. - * - * Deep copies the data into native to simplify reference ownership. - */ - public boolean setOutline(@Nullable Outline outline) { - if (outline == null) { - return nSetOutlineNone(mNativeRenderNode); - } - - switch(outline.mMode) { - case Outline.MODE_EMPTY: - return nSetOutlineEmpty(mNativeRenderNode); - case Outline.MODE_ROUND_RECT: - return nSetOutlineRoundRect(mNativeRenderNode, outline.mRect.left, outline.mRect.top, - outline.mRect.right, outline.mRect.bottom, outline.mRadius, outline.mAlpha); - case Outline.MODE_CONVEX_PATH: - return nSetOutlineConvexPath(mNativeRenderNode, outline.mPath.mNativePath, - outline.mAlpha); - } - - throw new IllegalArgumentException("Unrecognized outline?"); - } - - public boolean hasShadow() { - return nHasShadow(mNativeRenderNode); - } - - /** setSpotShadowColor */ - public boolean setSpotShadowColor(int color) { - return nSetSpotShadowColor(mNativeRenderNode, color); - } - - /** setAmbientShadowColor */ - public boolean setAmbientShadowColor(int color) { - return nSetAmbientShadowColor(mNativeRenderNode, color); - } - - /** getSpotShadowColor */ - public int getSpotShadowColor() { - return nGetSpotShadowColor(mNativeRenderNode); - } - - /** getAmbientShadowColor */ - public int getAmbientShadowColor() { - return nGetAmbientShadowColor(mNativeRenderNode); - } - - /** - * Enables or disables clipping to the outline. - * - * @param clipToOutline true if clipping to the outline. - */ - public boolean setClipToOutline(boolean clipToOutline) { - return nSetClipToOutline(mNativeRenderNode, clipToOutline); - } - - public boolean getClipToOutline() { - return nGetClipToOutline(mNativeRenderNode); - } - - /** - * Controls the RenderNode's circular reveal clip. - */ - public boolean setRevealClip(boolean shouldClip, - float x, float y, float radius) { - return nSetRevealClip(mNativeRenderNode, shouldClip, x, y, radius); - } - - /** - * Set the static matrix on the display list. The specified matrix is combined with other - * transforms (such as {@link #setScaleX(float)}, {@link #setRotation(float)}, etc.) - * - * @param matrix A transform matrix to apply to this display list - */ - public boolean setStaticMatrix(Matrix matrix) { - return nSetStaticMatrix(mNativeRenderNode, matrix.native_instance); - } - - /** - * Set the Animation matrix on the display list. This matrix exists if an Animation is - * currently playing on a View, and is set on the display list during at draw() time. When - * the Animation finishes, the matrix should be cleared by sending <code>null</code> - * for the matrix parameter. - * - * @param matrix The matrix, null indicates that the matrix should be cleared. - */ - public boolean setAnimationMatrix(Matrix matrix) { - return nSetAnimationMatrix(mNativeRenderNode, - (matrix != null) ? matrix.native_instance : 0); - } - - /** - * Sets the translucency level for the display list. - * - * @param alpha The translucency of the display list, must be a value between 0.0f and 1.0f - * - * @see View#setAlpha(float) - * @see #getAlpha() - */ - public boolean setAlpha(float alpha) { - return nSetAlpha(mNativeRenderNode, alpha); - } - - /** - * Returns the translucency level of this display list. - * - * @return A value between 0.0f and 1.0f - * - * @see #setAlpha(float) - */ - public float getAlpha() { - return nGetAlpha(mNativeRenderNode); - } - - /** - * Sets whether the display list renders content which overlaps. Non-overlapping rendering - * can use a fast path for alpha that avoids rendering to an offscreen buffer. By default - * display lists consider they do not have overlapping content. - * - * @param hasOverlappingRendering False if the content is guaranteed to be non-overlapping, - * true otherwise. - * - * @see android.view.View#hasOverlappingRendering() - * @see #hasOverlappingRendering() - */ - @UnsupportedAppUsage - public boolean setHasOverlappingRendering(boolean hasOverlappingRendering) { - return nSetHasOverlappingRendering(mNativeRenderNode, hasOverlappingRendering); - } - - /** @hide */ - @IntDef({USAGE_BACKGROUND}) - @Retention(RetentionPolicy.SOURCE) - public @interface UsageHint {} - - /** The default usage hint */ - public static final int USAGE_UNKNOWN = 0; - - /** Usage is background content */ - public static final int USAGE_BACKGROUND = 1; - - /** - * Provides a hint on what this RenderNode's display list content contains. This hint is used - * for automatic content transforms to improve accessibility or similar. - */ - public void setUsageHint(@UsageHint int usageHint) { - nSetUsageHint(mNativeRenderNode, usageHint); - } - - /** - * Indicates whether the content of this display list overlaps. - * - * @return True if this display list renders content which overlaps, false otherwise. - * - * @see #setHasOverlappingRendering(boolean) - */ - public boolean hasOverlappingRendering() { - return nHasOverlappingRendering(mNativeRenderNode); - } - - public boolean setElevation(float lift) { - return nSetElevation(mNativeRenderNode, lift); - } - - public float getElevation() { - return nGetElevation(mNativeRenderNode); - } - - /** - * Sets the translation value for the display list on the X axis. - * - * @param translationX The X axis translation value of the display list, in pixels - * - * @see View#setTranslationX(float) - * @see #getTranslationX() - */ - public boolean setTranslationX(float translationX) { - return nSetTranslationX(mNativeRenderNode, translationX); - } - - /** - * Returns the translation value for this display list on the X axis, in pixels. - * - * @see #setTranslationX(float) - */ - public float getTranslationX() { - return nGetTranslationX(mNativeRenderNode); - } - - /** - * Sets the translation value for the display list on the Y axis. - * - * @param translationY The Y axis translation value of the display list, in pixels - * - * @see View#setTranslationY(float) - * @see #getTranslationY() - */ - public boolean setTranslationY(float translationY) { - return nSetTranslationY(mNativeRenderNode, translationY); - } - - /** - * Returns the translation value for this display list on the Y axis, in pixels. - * - * @see #setTranslationY(float) - */ - public float getTranslationY() { - return nGetTranslationY(mNativeRenderNode); - } - - /** - * Sets the translation value for the display list on the Z axis. - * - * @see View#setTranslationZ(float) - * @see #getTranslationZ() - */ - public boolean setTranslationZ(float translationZ) { - return nSetTranslationZ(mNativeRenderNode, translationZ); - } - - /** - * Returns the translation value for this display list on the Z axis. - * - * @see #setTranslationZ(float) - */ - public float getTranslationZ() { - return nGetTranslationZ(mNativeRenderNode); - } - - /** - * Sets the rotation value for the display list around the Z axis. - * - * @param rotation The rotation value of the display list, in degrees - * - * @see View#setRotation(float) - * @see #getRotation() - */ - public boolean setRotation(float rotation) { - return nSetRotation(mNativeRenderNode, rotation); - } - - /** - * Returns the rotation value for this display list around the Z axis, in degrees. - * - * @see #setRotation(float) - */ - public float getRotation() { - return nGetRotation(mNativeRenderNode); - } - - /** - * Sets the rotation value for the display list around the X axis. - * - * @param rotationX The rotation value of the display list, in degrees - * - * @see View#setRotationX(float) - * @see #getRotationX() - */ - public boolean setRotationX(float rotationX) { - return nSetRotationX(mNativeRenderNode, rotationX); - } - - /** - * Returns the rotation value for this display list around the X axis, in degrees. - * - * @see #setRotationX(float) - */ - public float getRotationX() { - return nGetRotationX(mNativeRenderNode); - } - - /** - * Sets the rotation value for the display list around the Y axis. - * - * @param rotationY The rotation value of the display list, in degrees - * - * @see View#setRotationY(float) - * @see #getRotationY() - */ - public boolean setRotationY(float rotationY) { - return nSetRotationY(mNativeRenderNode, rotationY); - } - - /** - * Returns the rotation value for this display list around the Y axis, in degrees. - * - * @see #setRotationY(float) - */ - public float getRotationY() { - return nGetRotationY(mNativeRenderNode); - } - - /** - * Sets the scale value for the display list on the X axis. - * - * @param scaleX The scale value of the display list - * - * @see View#setScaleX(float) - * @see #getScaleX() - */ - public boolean setScaleX(float scaleX) { - return nSetScaleX(mNativeRenderNode, scaleX); - } - - /** - * Returns the scale value for this display list on the X axis. - * - * @see #setScaleX(float) - */ - public float getScaleX() { - return nGetScaleX(mNativeRenderNode); - } - - /** - * Sets the scale value for the display list on the Y axis. - * - * @param scaleY The scale value of the display list - * - * @see View#setScaleY(float) - * @see #getScaleY() - */ - public boolean setScaleY(float scaleY) { - return nSetScaleY(mNativeRenderNode, scaleY); - } - - /** - * Returns the scale value for this display list on the Y axis. - * - * @see #setScaleY(float) - */ - public float getScaleY() { - return nGetScaleY(mNativeRenderNode); - } - - /** - * Sets the pivot value for the display list on the X axis - * - * @param pivotX The pivot value of the display list on the X axis, in pixels - * - * @see View#setPivotX(float) - * @see #getPivotX() - */ - public boolean setPivotX(float pivotX) { - return nSetPivotX(mNativeRenderNode, pivotX); - } - - /** - * Returns the pivot value for this display list on the X axis, in pixels. - * - * @see #setPivotX(float) - */ - public float getPivotX() { - return nGetPivotX(mNativeRenderNode); - } - - /** - * Sets the pivot value for the display list on the Y axis - * - * @param pivotY The pivot value of the display list on the Y axis, in pixels - * - * @see View#setPivotY(float) - * @see #getPivotY() - */ - public boolean setPivotY(float pivotY) { - return nSetPivotY(mNativeRenderNode, pivotY); - } - - /** - * Returns the pivot value for this display list on the Y axis, in pixels. - * - * @see #setPivotY(float) - */ - public float getPivotY() { - return nGetPivotY(mNativeRenderNode); - } - - public boolean isPivotExplicitlySet() { - return nIsPivotExplicitlySet(mNativeRenderNode); - } - - /** lint */ - public boolean resetPivot() { - return nResetPivot(mNativeRenderNode); - } - - /** - * Sets the camera distance for the display list. Refer to - * {@link View#setCameraDistance(float)} for more information on how to - * use this property. - * - * @param distance The distance in Z of the camera of the display list - * - * @see View#setCameraDistance(float) - * @see #getCameraDistance() - */ - public boolean setCameraDistance(float distance) { - return nSetCameraDistance(mNativeRenderNode, distance); - } - - /** - * Returns the distance in Z of the camera of the display list. - * - * @see #setCameraDistance(float) - */ - public float getCameraDistance() { - return nGetCameraDistance(mNativeRenderNode); - } - - /** - * Sets the left position for the display list. - * - * @param left The left position, in pixels, of the display list - * - * @see View#setLeft(int) - */ - public boolean setLeft(int left) { - return nSetLeft(mNativeRenderNode, left); - } - - /** - * Sets the top position for the display list. - * - * @param top The top position, in pixels, of the display list - * - * @see View#setTop(int) - */ - public boolean setTop(int top) { - return nSetTop(mNativeRenderNode, top); - } - - /** - * Sets the right position for the display list. - * - * @param right The right position, in pixels, of the display list - * - * @see View#setRight(int) - */ - public boolean setRight(int right) { - return nSetRight(mNativeRenderNode, right); - } - - /** - * Sets the bottom position for the display list. - * - * @param bottom The bottom position, in pixels, of the display list - * - * @see View#setBottom(int) - */ - public boolean setBottom(int bottom) { - return nSetBottom(mNativeRenderNode, bottom); - } - - /** - * Sets the left and top positions for the display list - * - * @param left The left position of the display list, in pixels - * @param top The top position of the display list, in pixels - * @param right The right position of the display list, in pixels - * @param bottom The bottom position of the display list, in pixels - * - * @see View#setLeft(int) - * @see View#setTop(int) - * @see View#setRight(int) - * @see View#setBottom(int) - */ - @UnsupportedAppUsage - public boolean setLeftTopRightBottom(int left, int top, int right, int bottom) { - return nSetLeftTopRightBottom(mNativeRenderNode, left, top, right, bottom); - } - - /** - * Offsets the left and right positions for the display list - * - * @param offset The amount that the left and right positions of the display - * list are offset, in pixels - * - * @see View#offsetLeftAndRight(int) - */ - @UnsupportedAppUsage - public boolean offsetLeftAndRight(int offset) { - return nOffsetLeftAndRight(mNativeRenderNode, offset); - } - - /** - * Offsets the top and bottom values for the display list - * - * @param offset The amount that the top and bottom positions of the display - * list are offset, in pixels - * - * @see View#offsetTopAndBottom(int) - */ - public boolean offsetTopAndBottom(int offset) { - return nOffsetTopAndBottom(mNativeRenderNode, offset); - } - - /** - * Outputs the display list to the log. This method exists for use by - * tools to output display lists for selected nodes to the log. - */ - @UnsupportedAppUsage - public void output() { - nOutput(mNativeRenderNode); - } - - /** - * Gets the size of the DisplayList for debug purposes. - */ - public int getDebugSize() { - return nGetDebugSize(mNativeRenderNode); - } - - /** - * Sets whether or not to allow force dark to apply to this RenderNode. - * - * Setting this to false will disable the auto-dark feature on everything this RenderNode - * draws, including any descendants. - * - * Setting this to true will allow this RenderNode to be automatically made dark, however - * a value of 'true' will not override any 'false' value in its parent chain nor will - * it prevent any 'false' in any of its children. - * - * @param allow Whether or not to allow force dark. - * @return true If the value has changed, false otherwise. - */ - public boolean setAllowForceDark(boolean allow) { - return nSetAllowForceDark(mNativeRenderNode, allow); - } - - /** - * See {@link #setAllowForceDark(boolean)} - * - * @return true if force dark is allowed (default), false if it is disabled - */ - public boolean getAllowForceDark() { - return nGetAllowForceDark(mNativeRenderNode); - } - - /////////////////////////////////////////////////////////////////////////// - // 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 (!isAttached()) { - throw new IllegalStateException("Cannot start this animator on a detached view!"); - } - nAddAnimator(mNativeRenderNode, animator.getNativeAnimator()); - mAnimationHost.registerAnimatingRenderNode(this); - } - - /** @hide */ - public boolean isAttached() { - return mAnimationHost != null && mAnimationHost.isAttached(); - } - - /** @hide */ - public void registerVectorDrawableAnimator(NativeVectorDrawableAnimator animatorSet) { - if (!isAttached()) { - throw new IllegalStateException("Cannot start this animator on a detached view!"); - } - mAnimationHost.registerVectorDrawableAnimator(animatorSet); - } - - /** @hide */ - public void endAllAnimators() { - nEndAllAnimators(mNativeRenderNode); - } - - /////////////////////////////////////////////////////////////////////////// - // Regular JNI methods - /////////////////////////////////////////////////////////////////////////// - - private static native long nCreate(String name); - - 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, - PositionUpdateListener callback); - - // Animations - - private static native void nAddAnimator(long renderNode, long animatorPtr); - private static native void nEndAllAnimators(long renderNode); - - - /////////////////////////////////////////////////////////////////////////// - // @FastNative methods - /////////////////////////////////////////////////////////////////////////// - - @FastNative - private static native void nSetDisplayList(long renderNode, long newData); - - - /////////////////////////////////////////////////////////////////////////// - // @CriticalNative methods - /////////////////////////////////////////////////////////////////////////// - - @CriticalNative - private static native boolean nIsValid(long renderNode); - - // Matrix - - @CriticalNative - private static native void nGetTransformMatrix(long renderNode, long nativeMatrix); - @CriticalNative - private static native void nGetInverseTransformMatrix(long renderNode, long nativeMatrix); - @CriticalNative - private static native boolean nHasIdentityMatrix(long renderNode); - - // Properties - - @CriticalNative - private static native boolean nOffsetTopAndBottom(long renderNode, int offset); - @CriticalNative - private static native boolean nOffsetLeftAndRight(long renderNode, int offset); - @CriticalNative - private static native boolean nSetLeftTopRightBottom(long renderNode, int left, int top, - int right, int bottom); - @CriticalNative - private static native boolean nSetBottom(long renderNode, int bottom); - @CriticalNative - private static native boolean nSetRight(long renderNode, int right); - @CriticalNative - private static native boolean nSetTop(long renderNode, int top); - @CriticalNative - private static native boolean nSetLeft(long renderNode, int left); - @CriticalNative - private static native boolean nSetCameraDistance(long renderNode, float distance); - @CriticalNative - private static native boolean nSetPivotY(long renderNode, float pivotY); - @CriticalNative - private static native boolean nSetPivotX(long renderNode, float pivotX); - @CriticalNative - private static native boolean nResetPivot(long renderNode); - @CriticalNative - private static native boolean nSetLayerType(long renderNode, int layerType); - @CriticalNative - private static native boolean nSetLayerPaint(long renderNode, long paint); - @CriticalNative - private static native boolean nSetClipToBounds(long renderNode, boolean clipToBounds); - @CriticalNative - private static native boolean nSetClipBounds(long renderNode, int left, int top, - int right, int bottom); - @CriticalNative - private static native boolean nSetClipBoundsEmpty(long renderNode); - @CriticalNative - private static native boolean nSetProjectBackwards(long renderNode, boolean shouldProject); - @CriticalNative - private static native boolean nSetProjectionReceiver(long renderNode, boolean shouldRecieve); - @CriticalNative - private static native boolean nSetOutlineRoundRect(long renderNode, int left, int top, - int right, int bottom, float radius, float alpha); - @CriticalNative - private static native boolean nSetOutlineConvexPath(long renderNode, long nativePath, - float alpha); - @CriticalNative - private static native boolean nSetOutlineEmpty(long renderNode); - @CriticalNative - private static native boolean nSetOutlineNone(long renderNode); - @CriticalNative - private static native boolean nHasShadow(long renderNode); - @CriticalNative - private static native boolean nSetSpotShadowColor(long renderNode, int color); - @CriticalNative - private static native boolean nSetAmbientShadowColor(long renderNode, int color); - @CriticalNative - private static native int nGetSpotShadowColor(long renderNode); - @CriticalNative - private static native int nGetAmbientShadowColor(long renderNode); - @CriticalNative - private static native boolean nSetClipToOutline(long renderNode, boolean clipToOutline); - @CriticalNative - private static native boolean nSetRevealClip(long renderNode, - boolean shouldClip, float x, float y, float radius); - @CriticalNative - private static native boolean nSetAlpha(long renderNode, float alpha); - @CriticalNative - private static native boolean nSetHasOverlappingRendering(long renderNode, - boolean hasOverlappingRendering); - @CriticalNative - private static native void nSetUsageHint(long renderNode, int usageHint); - @CriticalNative - private static native boolean nSetElevation(long renderNode, float lift); - @CriticalNative - private static native boolean nSetTranslationX(long renderNode, float translationX); - @CriticalNative - private static native boolean nSetTranslationY(long renderNode, float translationY); - @CriticalNative - private static native boolean nSetTranslationZ(long renderNode, float translationZ); - @CriticalNative - private static native boolean nSetRotation(long renderNode, float rotation); - @CriticalNative - private static native boolean nSetRotationX(long renderNode, float rotationX); - @CriticalNative - private static native boolean nSetRotationY(long renderNode, float rotationY); - @CriticalNative - private static native boolean nSetScaleX(long renderNode, float scaleX); - @CriticalNative - private static native boolean nSetScaleY(long renderNode, float scaleY); - @CriticalNative - private static native boolean nSetStaticMatrix(long renderNode, long nativeMatrix); - @CriticalNative - private static native boolean nSetAnimationMatrix(long renderNode, long animationMatrix); - - @CriticalNative - private static native boolean nHasOverlappingRendering(long renderNode); - @CriticalNative - private static native boolean nGetClipToOutline(long renderNode); - @CriticalNative - private static native float nGetAlpha(long renderNode); - @CriticalNative - private static native float nGetCameraDistance(long renderNode); - @CriticalNative - private static native float nGetScaleX(long renderNode); - @CriticalNative - private static native float nGetScaleY(long renderNode); - @CriticalNative - private static native float nGetElevation(long renderNode); - @CriticalNative - private static native float nGetTranslationX(long renderNode); - @CriticalNative - private static native float nGetTranslationY(long renderNode); - @CriticalNative - private static native float nGetTranslationZ(long renderNode); - @CriticalNative - private static native float nGetRotation(long renderNode); - @CriticalNative - private static native float nGetRotationX(long renderNode); - @CriticalNative - private static native float nGetRotationY(long renderNode); - @CriticalNative - private static native boolean nIsPivotExplicitlySet(long renderNode); - @CriticalNative - private static native float nGetPivotX(long renderNode); - @CriticalNative - private static native float nGetPivotY(long renderNode); - @CriticalNative - private static native int nGetWidth(long renderNode); - @CriticalNative - private static native int nGetHeight(long renderNode); - @CriticalNative - private static native boolean nSetAllowForceDark(long renderNode, boolean allowForceDark); - @CriticalNative - private static native boolean nGetAllowForceDark(long renderNode); -} diff --git a/core/java/android/view/RenderNodeAnimator.java b/core/java/android/view/RenderNodeAnimator.java index e48bcfdb7203..9d31bd16b452 100644 --- a/core/java/android/view/RenderNodeAnimator.java +++ b/core/java/android/view/RenderNodeAnimator.java @@ -22,6 +22,8 @@ import android.animation.ValueAnimator; import android.annotation.UnsupportedAppUsage; import android.graphics.CanvasProperty; import android.graphics.Paint; +import android.graphics.RecordingCanvas; +import android.graphics.RenderNode; import android.util.SparseIntArray; import com.android.internal.util.VirtualRefBasePtr; @@ -286,8 +288,8 @@ public class RenderNodeAnimator extends Animator { setTarget(mViewTarget.mRenderNode); } - /** Sets the animation target to the owning view of the DisplayListCanvas */ - public void setTarget(DisplayListCanvas canvas) { + /** Sets the animation target to the owning view of the RecordingCanvas */ + public void setTarget(RecordingCanvas canvas) { setTarget(canvas.mNode); } @@ -405,7 +407,7 @@ public class RenderNodeAnimator extends Animator { return listeners; } - long getNativeAnimator() { + public long getNativeAnimator() { return mNativePtr.get(); } diff --git a/core/java/android/view/RenderNodeAnimatorSetHelper.java b/core/java/android/view/RenderNodeAnimatorSetHelper.java index e1ef05941394..d222e0739fa2 100644 --- a/core/java/android/view/RenderNodeAnimatorSetHelper.java +++ b/core/java/android/view/RenderNodeAnimatorSetHelper.java @@ -16,6 +16,8 @@ package android.view; import android.animation.TimeInterpolator; +import android.graphics.RecordingCanvas; +import android.graphics.RenderNode; import com.android.internal.view.animation.FallbackLUTInterpolator; import com.android.internal.view.animation.NativeInterpolatorFactory; @@ -29,10 +31,12 @@ import com.android.internal.view.animation.NativeInterpolatorFactoryHelper; */ public class RenderNodeAnimatorSetHelper { - public static RenderNode getTarget(DisplayListCanvas recordingCanvas) { + /** checkstyle @hide */ + public static RenderNode getTarget(RecordingCanvas recordingCanvas) { return recordingCanvas.mNode; } + /** checkstyle @hide */ public static long createNativeInterpolator(TimeInterpolator interpolator, long duration) { if (interpolator == null) { diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java index 6fb1bbabddc2..f17a45800aeb 100644 --- a/core/java/android/view/Surface.java +++ b/core/java/android/view/Surface.java @@ -22,7 +22,9 @@ import android.content.res.CompatibilityInfo.Translator; import android.graphics.Canvas; import android.graphics.GraphicBuffer; import android.graphics.Matrix; +import android.graphics.RecordingCanvas; import android.graphics.Rect; +import android.graphics.RenderNode; import android.graphics.SurfaceTexture; import android.os.Parcel; import android.os.Parcelable; @@ -889,7 +891,7 @@ public class Surface implements Parcelable { private final class HwuiContext { private final RenderNode mRenderNode; private long mHwuiRenderer; - private DisplayListCanvas mCanvas; + private RecordingCanvas mCanvas; private final boolean mIsWideColorGamut; HwuiContext(boolean isWideColorGamut) { diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java index e71182c33c12..67f9399e678a 100644 --- a/core/java/android/view/SurfaceView.java +++ b/core/java/android/view/SurfaceView.java @@ -30,6 +30,7 @@ import android.graphics.PixelFormat; import android.graphics.PorterDuff; import android.graphics.Rect; import android.graphics.Region; +import android.graphics.RenderNode; import android.os.Build; import android.os.Handler; import android.os.IBinder; diff --git a/core/java/android/view/TextureLayer.java b/core/java/android/view/TextureLayer.java index 35a886fa27a3..d89d634c6a25 100644 --- a/core/java/android/view/TextureLayer.java +++ b/core/java/android/view/TextureLayer.java @@ -31,7 +31,7 @@ import com.android.internal.util.VirtualRefBasePtr; * * @hide */ -final class TextureLayer { +public final class TextureLayer { private ThreadedRenderer mRenderer; private VirtualRefBasePtr mFinalizer; diff --git a/core/java/android/view/TextureView.java b/core/java/android/view/TextureView.java index 997e48fe61ac..0175ba201dd1 100644 --- a/core/java/android/view/TextureView.java +++ b/core/java/android/view/TextureView.java @@ -23,6 +23,7 @@ import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.Paint; +import android.graphics.RecordingCanvas; import android.graphics.Rect; import android.graphics.SurfaceTexture; import android.graphics.drawable.Drawable; @@ -343,7 +344,7 @@ public class TextureView extends View { properties (alpha, layer paint) affect all of the content of a TextureView. */ if (canvas.isHardwareAccelerated()) { - DisplayListCanvas displayListCanvas = (DisplayListCanvas) canvas; + RecordingCanvas recordingCanvas = (RecordingCanvas) canvas; TextureLayer layer = getTextureLayer(); if (layer != null) { @@ -351,7 +352,7 @@ public class TextureView extends View { applyTransformMatrix(); mLayer.setLayerPaint(mLayerPaint); // ensure layer paint is up to date - displayListCanvas.drawTextureLayer(layer); + recordingCanvas.drawTextureLayer(layer); } } } diff --git a/core/java/android/view/ThreadedRenderer.java b/core/java/android/view/ThreadedRenderer.java index 42690cef9da3..c1ab4d4b895e 100644 --- a/core/java/android/view/ThreadedRenderer.java +++ b/core/java/android/view/ThreadedRenderer.java @@ -24,7 +24,9 @@ import android.content.Context; import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.Point; +import android.graphics.RecordingCanvas; import android.graphics.Rect; +import android.graphics.RenderNode; import android.os.IBinder; import android.os.ParcelFileDescriptor; import android.os.RemoteException; @@ -693,7 +695,7 @@ public final class ThreadedRenderer { updateViewTreeDisplayList(view); if (mRootNodeNeedsUpdate || !mRootNode.isValid()) { - DisplayListCanvas canvas = mRootNode.start(mSurfaceWidth, mSurfaceHeight); + RecordingCanvas canvas = mRootNode.start(mSurfaceWidth, mSurfaceHeight); try { final int saveCount = canvas.save(); canvas.translate(mInsetLeft, mInsetTop); @@ -770,7 +772,7 @@ public final class ThreadedRenderer { * * @param canvas The Canvas used to render the view. */ - void onPreDraw(DisplayListCanvas canvas); + void onPreDraw(RecordingCanvas canvas); /** * Invoked after a view is drawn by a threaded renderer. @@ -778,7 +780,7 @@ public final class ThreadedRenderer { * * @param canvas The Canvas used to render the view. */ - void onPostDraw(DisplayListCanvas canvas); + void onPostDraw(RecordingCanvas canvas); } /** diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index cddd83c45c75..c7249dba79f8 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -57,9 +57,11 @@ import android.graphics.PixelFormat; import android.graphics.Point; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; +import android.graphics.RecordingCanvas; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.Region; +import android.graphics.RenderNode; import android.graphics.Shader; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; @@ -19213,7 +19215,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, int height = mBottom - mTop; int layerType = getLayerType(); - final DisplayListCanvas canvas = renderNode.start(width, height); + final RecordingCanvas canvas = renderNode.start(width, height); try { if (layerType == LAYER_TYPE_SOFTWARE) { @@ -20230,7 +20232,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, if (!drawingWithDrawingCache) { if (drawingWithRenderNode) { mPrivateFlags &= ~PFLAG_DIRTY_MASK; - ((DisplayListCanvas) canvas).drawRenderNode(renderNode); + ((RecordingCanvas) canvas).drawRenderNode(renderNode); } else { // Fast path for layouts with no backgrounds if ((mPrivateFlags & PFLAG_SKIP_DRAW) == PFLAG_SKIP_DRAW) { @@ -20561,7 +20563,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, final RenderNode renderNode = mBackgroundRenderNode; if (renderNode != null && renderNode.isValid()) { setBackgroundRenderNodeProperties(renderNode); - ((DisplayListCanvas) canvas).drawRenderNode(renderNode); + ((RecordingCanvas) canvas).drawRenderNode(renderNode); return; } } @@ -20613,7 +20615,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, final Rect bounds = drawable.getBounds(); final int width = bounds.width(); final int height = bounds.height(); - final DisplayListCanvas canvas = renderNode.start(width, height); + final RecordingCanvas canvas = renderNode.start(width, height); // Reverse left/top translation done by drawable canvas, which will // instead be applied by rendernode's LTRB bounds below. This way, the diff --git a/core/java/android/view/ViewAnimationHostBridge.java b/core/java/android/view/ViewAnimationHostBridge.java index 58f555dfa305..e0fae21bbdf6 100644 --- a/core/java/android/view/ViewAnimationHostBridge.java +++ b/core/java/android/view/ViewAnimationHostBridge.java @@ -16,6 +16,8 @@ package android.view; +import android.graphics.RenderNode; + /** * Maps a View to a RenderNode's AnimationHost * diff --git a/core/java/android/view/ViewDebug.java b/core/java/android/view/ViewDebug.java index 8dd03476a2b8..292e933c3f7e 100644 --- a/core/java/android/view/ViewDebug.java +++ b/core/java/android/view/ViewDebug.java @@ -23,7 +23,9 @@ import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Picture; +import android.graphics.RecordingCanvas; import android.graphics.Rect; +import android.graphics.RenderNode; import android.os.Debug; import android.os.Handler; import android.os.RemoteException; @@ -601,7 +603,7 @@ public class ViewDebug { } if (view.isHardwareAccelerated()) { - DisplayListCanvas canvas = node.start(dm.widthPixels, dm.heightPixels); + RecordingCanvas canvas = node.start(dm.widthPixels, dm.heightPixels); try { return profileViewOperation(view, () -> view.draw(canvas)); } finally { diff --git a/core/java/android/view/ViewPropertyAnimator.java b/core/java/android/view/ViewPropertyAnimator.java index e3e2069422fc..a0ab362f3985 100644 --- a/core/java/android/view/ViewPropertyAnimator.java +++ b/core/java/android/view/ViewPropertyAnimator.java @@ -19,6 +19,7 @@ package android.view; import android.animation.Animator; import android.animation.TimeInterpolator; import android.animation.ValueAnimator; +import android.graphics.RenderNode; import java.util.ArrayList; import java.util.HashMap; diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index bef8e8fedfdf..7da31ebe4a17 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -51,8 +51,10 @@ import android.graphics.PixelFormat; import android.graphics.Point; import android.graphics.PointF; import android.graphics.PorterDuff; +import android.graphics.RecordingCanvas; import android.graphics.Rect; import android.graphics.Region; +import android.graphics.RenderNode; import android.graphics.drawable.Drawable; import android.hardware.display.DisplayManager; import android.hardware.display.DisplayManager.DisplayListener; @@ -3120,7 +3122,7 @@ public final class ViewRootImpl implements ViewParent, int mHardwareYOffset; @Override - public void onPreDraw(DisplayListCanvas canvas) { + public void onPreDraw(RecordingCanvas canvas) { // If mCurScrollY is not 0 then this influences the hardwareYOffset. The end result is we // can apply offsets that are not handled by anything else, resulting in underdraw as // the View is shifted (thus shifting the window background) exposing unpainted @@ -3134,7 +3136,7 @@ public final class ViewRootImpl implements ViewParent, } @Override - public void onPostDraw(DisplayListCanvas canvas) { + public void onPostDraw(RecordingCanvas canvas) { drawAccessibilityFocusedDrawableIfNeeded(canvas); if (mUseMTRenderer) { for (int i = mWindowCallbacks.size() - 1; i >= 0; i--) { diff --git a/core/java/android/view/WindowCallbacks.java b/core/java/android/view/WindowCallbacks.java index b2dc1e91bdf7..a99730205136 100644 --- a/core/java/android/view/WindowCallbacks.java +++ b/core/java/android/view/WindowCallbacks.java @@ -16,6 +16,7 @@ package android.view; +import android.graphics.RecordingCanvas; import android.graphics.Rect; /** @@ -82,5 +83,5 @@ public interface WindowCallbacks { * * @param canvas The canvas to draw on. */ - void onPostDraw(DisplayListCanvas canvas); + void onPostDraw(RecordingCanvas canvas); } |
