diff options
author | John Reck <jreck@google.com> | 2014-03-14 16:24:57 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2014-03-17 10:30:32 -0700 |
commit | f666ad7046c0b1b255835f75aeb7d1391067df93 (patch) | |
tree | fbb47933fdf2a0d9d2d4b85c34f0c39a419ba74b | |
parent | 6b2b14028ddec40b70c346f5a1e4d266720fadcd (diff) | |
download | frameworks_base-f666ad7046c0b1b255835f75aeb7d1391067df93.zip frameworks_base-f666ad7046c0b1b255835f75aeb7d1391067df93.tar.gz frameworks_base-f666ad7046c0b1b255835f75aeb7d1391067df93.tar.bz2 |
Rename DisplayList->RenderNode
Change-Id: Idcca6f26ba6282594789962f5edb3ed53a290fef
-rw-r--r-- | core/java/android/view/DisplayList.java | 914 | ||||
-rw-r--r-- | core/java/android/view/GLES20Canvas.java | 2 | ||||
-rw-r--r-- | core/java/android/view/GLRenderer.java | 18 | ||||
-rw-r--r-- | core/java/android/view/HardwareCanvas.java | 32 | ||||
-rw-r--r-- | core/java/android/view/HardwareLayer.java | 6 | ||||
-rw-r--r-- | core/java/android/view/RenderNode.java | 931 | ||||
-rw-r--r-- | core/java/android/view/ThreadedRenderer.java | 2 | ||||
-rw-r--r-- | core/java/android/view/View.java | 24 | ||||
-rw-r--r-- | core/java/android/view/ViewPropertyAnimator.java | 2 | ||||
-rw-r--r-- | core/java/android/view/ViewRootImpl.java | 10 | ||||
-rw-r--r-- | core/java/android/widget/Editor.java | 10 | ||||
-rw-r--r-- | core/jni/Android.mk | 2 | ||||
-rw-r--r-- | core/jni/AndroidRuntime.cpp | 4 | ||||
-rw-r--r-- | core/jni/android_view_RenderNode.cpp (renamed from core/jni/android_view_DisplayList.cpp) | 216 | ||||
-rw-r--r-- | tests/HwAccelerationTest/src/com/android/test/hwui/ProjectionActivity.java | 4 | ||||
-rw-r--r-- | tests/RenderThreadTest/src/com/example/renderthread/MainActivity.java | 4 |
16 files changed, 1103 insertions, 1078 deletions
diff --git a/core/java/android/view/DisplayList.java b/core/java/android/view/DisplayList.java index be6f401..ed52803 100644 --- a/core/java/android/view/DisplayList.java +++ b/core/java/android/view/DisplayList.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 The Android Open Source Project + * Copyright (C) 2014 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. @@ -16,916 +16,10 @@ package android.view; -import android.graphics.Matrix; -import android.graphics.Path; - -/** - * <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 HardwareCanvas}. 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 HardwareCanvas}. 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"> - * HardwareRenderer renderer = myView.getHardwareRenderer(); - * if (renderer != null) { - * DisplayList displayList = renderer.createDisplayList(); - * HardwareCanvas 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()) { - * HardwareCanvas hardwareCanvas = (HardwareCanvas) canvas; - * hardwareCanvas.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"); - * HardwareCanvas 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()) { - * HardwareCanvas hardwareCanvas = (HardwareCanvas) canvas; - * hardwareCanvas.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 +/** TODO: Remove once frameworks/webview is updated + * @hide */ public class DisplayList { - /** - * Flag used when calling - * {@link HardwareCanvas#drawDisplayList(DisplayList, android.graphics.Rect, int)} - * When this flag is set, draw operations lying outside of the bounds of the - * display list will be culled early. It is recommeneded to always set this - * flag. - * - * @hide - */ - public static final int FLAG_CLIP_CHILDREN = 0x1; - - // NOTE: The STATUS_* values *must* match the enum in DrawGlInfo.h - - /** - * Indicates that the display list is done drawing. - * - * @see HardwareCanvas#drawDisplayList(DisplayList, android.graphics.Rect, int) - * - * @hide - */ + /** @hide */ public static final int STATUS_DONE = 0x0; - - /** - * Indicates that the display list needs another drawing pass. - * - * @see HardwareCanvas#drawDisplayList(DisplayList, android.graphics.Rect, int) - * - * @hide - */ - public static final int STATUS_DRAW = 0x1; - - /** - * Indicates that the display list needs to re-execute its GL functors. - * - * @see HardwareCanvas#drawDisplayList(DisplayList, android.graphics.Rect, int) - * @see HardwareCanvas#callDrawGLFunction(long) - * - * @hide - */ - public static final int STATUS_INVOKE = 0x2; - - /** - * Indicates that the display list performed GL drawing operations. - * - * @see HardwareCanvas#drawDisplayList(DisplayList, android.graphics.Rect, int) - * - * @hide - */ - public static final int STATUS_DREW = 0x4; - - private boolean mValid; - private final long mNativeDisplayList; - private HardwareRenderer mRenderer; - - private DisplayList(String name) { - mNativeDisplayList = nCreate(); - nSetDisplayListName(mNativeDisplayList, name); - } - - /** - * Creates a new display list that can be used to record batches of - * drawing operations. - * - * @param name The name of the display list, used for debugging purpose. May be null. - * - * @return A new display list. - * - * @hide - */ - public static DisplayList create(String name) { - return new DisplayList(name); - } - - /** - * Starts recording the display list. All operations performed on the - * returned canvas are recorded and stored in this display list. - * - * Calling this method will mark the display list invalid until - * {@link #end()} is called. Only valid display lists can be replayed. - * - * @param width The width of the display list's viewport - * @param height The height of the display list's viewport - * - * @return A canvas to record drawing operations. - * - * @see #end() - * @see #isValid() - */ - public HardwareCanvas start(int width, int height) { - HardwareCanvas canvas = GLES20RecordingCanvas.obtain(); - canvas.setViewport(width, height); - // The dirty rect should always be null for a display list - canvas.onPreDraw(null); - return canvas; - } - - /** - * 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() - */ - public void end(HardwareRenderer renderer, HardwareCanvas endCanvas) { - if (!(endCanvas instanceof GLES20RecordingCanvas)) { - throw new IllegalArgumentException("Passed an invalid canvas to end!"); - } - - GLES20RecordingCanvas canvas = (GLES20RecordingCanvas) endCanvas; - canvas.onPostDraw(); - long displayListData = canvas.finishRecording(); - if (renderer != mRenderer) { - // If we are changing renderers first destroy with the old - // renderer, then set with the new one - destroyDisplayListData(); - } - mRenderer = renderer; - setDisplayListData(displayListData); - canvas.recycle(); - mValid = true; - } - - /** - * 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. - * - * @hide - */ - public void destroyDisplayListData() { - if (!mValid) return; - - setDisplayListData(0); - mRenderer = null; - mValid = false; - } - - private void setDisplayListData(long newData) { - if (mRenderer != null) { - mRenderer.setDisplayListData(mNativeDisplayList, newData); - } else { - throw new IllegalStateException("Trying to set data without a renderer! data=" + newData); - } - } - - /** - * Returns whether the display list 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. - */ - public boolean isValid() { return mValid; } - - long getNativeDisplayList() { - if (!mValid) { - throw new IllegalStateException("The display list is not valid."); - } - return mNativeDisplayList; - } - - /////////////////////////////////////////////////////////////////////////// - // DisplayList Property Setters - /////////////////////////////////////////////////////////////////////////// - - /** - * Set the caching property on the display list, which indicates whether the display list - * holds a layer. Layer display lists should avoid creating an alpha layer, since alpha is - * handled in the drawLayer operation directly (and more efficiently). - * - * @param caching true if the display list represents a hardware layer, false otherwise. - * - * @hide - */ - public void setCaching(boolean caching) { - nSetCaching(mNativeDisplayList, caching); - } - - /** - * Set whether the display list 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 - */ - public void setClipToBounds(boolean clipToBounds) { - nSetClipToBounds(mNativeDisplayList, clipToBounds); - } - - /** - * Set whether the display list should collect and Z order all 3d composited descendents, and - * draw them in order with the default Z=0 content. - * - * @param isolatedZVolume true if the display list should collect and Z order descendents. - */ - public void setIsolatedZVolume(boolean isolatedZVolume) { - nSetIsolatedZVolume(mNativeDisplayList, isolatedZVolume); - } - - /** - * Sets whether the display list should be drawn immediately after the - * closest ancestor display list where isolateZVolume is true. If the - * display list itself satisfies this constraint, changing this attribute - * has no effect on drawing order. - * - * @param shouldProject true if the display list should be projected onto a - * containing volume. - */ - public void setProjectBackwards(boolean shouldProject) { - nSetProjectBackwards(mNativeDisplayList, 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 void setProjectionReceiver(boolean shouldRecieve) { - nSetProjectionReceiver(mNativeDisplayList, shouldRecieve); - } - - /** - * Sets the outline, defining the shape that casts a shadow, and the path to - * be clipped if setClipToOutline is set. - * - * Deep copies the native path to simplify reference ownership. - * - * @param outline Convex, CW Path to store in the DisplayList. May be null. - */ - public void setOutline(Path outline) { - long nativePath = (outline == null) ? 0 : outline.mNativePath; - nSetOutline(mNativeDisplayList, nativePath); - } - - /** - * Enables or disables clipping to the outline. - * - * @param clipToOutline true if clipping to the outline. - */ - public void setClipToOutline(boolean clipToOutline) { - nSetClipToOutline(mNativeDisplayList, clipToOutline); - } - - /** - * Set whether the DisplayList should cast a shadow. - * - * The shape of the shadow casting area is defined by the outline of the display list, if set - * and non-empty, otherwise it will be the bounds rect. - */ - public void setCastsShadow(boolean castsShadow) { - nSetCastsShadow(mNativeDisplayList, castsShadow); - } - - /** - * Sets whether the DisplayList should be drawn with perspective applied from the global camera. - * - * If set to true, camera distance will be ignored. Defaults to false. - */ - public void setUsesGlobalCamera(boolean usesGlobalCamera) { - nSetUsesGlobalCamera(mNativeDisplayList, usesGlobalCamera); - } - - /** - * 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 - * - * @see #getMatrix(android.graphics.Matrix) - * @see #getMatrix() - */ - public void setStaticMatrix(Matrix matrix) { - nSetStaticMatrix(mNativeDisplayList, 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. - * - * @hide - */ - public void setAnimationMatrix(Matrix matrix) { - nSetAnimationMatrix(mNativeDisplayList, - (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 void setAlpha(float alpha) { - nSetAlpha(mNativeDisplayList, 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(mNativeDisplayList); - } - - /** - * 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() - */ - public void setHasOverlappingRendering(boolean hasOverlappingRendering) { - nSetHasOverlappingRendering(mNativeDisplayList, hasOverlappingRendering); - } - - /** - * 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() { - //noinspection SimplifiableIfStatement - return nHasOverlappingRendering(mNativeDisplayList); - } - - /** - * 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 void setTranslationX(float translationX) { - nSetTranslationX(mNativeDisplayList, translationX); - } - - /** - * Returns the translation value for this display list on the X axis, in pixels. - * - * @see #setTranslationX(float) - */ - public float getTranslationX() { - return nGetTranslationX(mNativeDisplayList); - } - - /** - * 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 void setTranslationY(float translationY) { - nSetTranslationY(mNativeDisplayList, translationY); - } - - /** - * Returns the translation value for this display list on the Y axis, in pixels. - * - * @see #setTranslationY(float) - */ - public float getTranslationY() { - return nGetTranslationY(mNativeDisplayList); - } - - /** - * Sets the translation value for the display list on the Z axis. - * - * @see View#setTranslationZ(float) - * @see #getTranslationZ() - */ - public void setTranslationZ(float translationZ) { - nSetTranslationZ(mNativeDisplayList, translationZ); - } - - /** - * Returns the translation value for this display list on the Z axis. - * - * @see #setTranslationZ(float) - */ - public float getTranslationZ() { - return nGetTranslationZ(mNativeDisplayList); - } - - /** - * 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 void setRotation(float rotation) { - nSetRotation(mNativeDisplayList, rotation); - } - - /** - * Returns the rotation value for this display list around the Z axis, in degrees. - * - * @see #setRotation(float) - */ - public float getRotation() { - return nGetRotation(mNativeDisplayList); - } - - /** - * 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 void setRotationX(float rotationX) { - nSetRotationX(mNativeDisplayList, rotationX); - } - - /** - * Returns the rotation value for this display list around the X axis, in degrees. - * - * @see #setRotationX(float) - */ - public float getRotationX() { - return nGetRotationX(mNativeDisplayList); - } - - /** - * 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 void setRotationY(float rotationY) { - nSetRotationY(mNativeDisplayList, rotationY); - } - - /** - * Returns the rotation value for this display list around the Y axis, in degrees. - * - * @see #setRotationY(float) - */ - public float getRotationY() { - return nGetRotationY(mNativeDisplayList); - } - - /** - * 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 void setScaleX(float scaleX) { - nSetScaleX(mNativeDisplayList, scaleX); - } - - /** - * Returns the scale value for this display list on the X axis. - * - * @see #setScaleX(float) - */ - public float getScaleX() { - return nGetScaleX(mNativeDisplayList); - } - - /** - * 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 void setScaleY(float scaleY) { - nSetScaleY(mNativeDisplayList, scaleY); - } - - /** - * Returns the scale value for this display list on the Y axis. - * - * @see #setScaleY(float) - */ - public float getScaleY() { - return nGetScaleY(mNativeDisplayList); - } - - /** - * Sets all of the transform-related values of the display list - * - * @param alpha The alpha value of the display list - * @param translationX The translationX value of the display list - * @param translationY The translationY value of the display list - * @param rotation The rotation value of the display list - * @param rotationX The rotationX value of the display list - * @param rotationY The rotationY value of the display list - * @param scaleX The scaleX value of the display list - * @param scaleY The scaleY value of the display list - * - * @hide - */ - public void setTransformationInfo(float alpha, - float translationX, float translationY, float translationZ, - float rotation, float rotationX, float rotationY, float scaleX, float scaleY) { - nSetTransformationInfo(mNativeDisplayList, alpha, - translationX, translationY, translationZ, - rotation, rotationX, rotationY, scaleX, scaleY); - } - - /** - * 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 void setPivotX(float pivotX) { - nSetPivotX(mNativeDisplayList, pivotX); - } - - /** - * Returns the pivot value for this display list on the X axis, in pixels. - * - * @see #setPivotX(float) - */ - public float getPivotX() { - return nGetPivotX(mNativeDisplayList); - } - - /** - * 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 void setPivotY(float pivotY) { - nSetPivotY(mNativeDisplayList, pivotY); - } - - /** - * Returns the pivot value for this display list on the Y axis, in pixels. - * - * @see #setPivotY(float) - */ - public float getPivotY() { - return nGetPivotY(mNativeDisplayList); - } - - /** - * 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 void setCameraDistance(float distance) { - nSetCameraDistance(mNativeDisplayList, distance); - } - - /** - * Returns the distance in Z of the camera of the display list. - * - * @see #setCameraDistance(float) - */ - public float getCameraDistance() { - return nGetCameraDistance(mNativeDisplayList); - } - - /** - * Sets the left position for the display list. - * - * @param left The left position, in pixels, of the display list - * - * @see View#setLeft(int) - * @see #getLeft() - */ - public void setLeft(int left) { - nSetLeft(mNativeDisplayList, left); - } - - /** - * Returns the left position for the display list in pixels. - * - * @see #setLeft(int) - */ - public float getLeft() { - return nGetLeft(mNativeDisplayList); - } - - /** - * Sets the top position for the display list. - * - * @param top The top position, in pixels, of the display list - * - * @see View#setTop(int) - * @see #getTop() - */ - public void setTop(int top) { - nSetTop(mNativeDisplayList, top); - } - - /** - * Returns the top position for the display list in pixels. - * - * @see #setTop(int) - */ - public float getTop() { - return nGetTop(mNativeDisplayList); - } - - /** - * Sets the right position for the display list. - * - * @param right The right position, in pixels, of the display list - * - * @see View#setRight(int) - * @see #getRight() - */ - public void setRight(int right) { - nSetRight(mNativeDisplayList, right); - } - - /** - * Returns the right position for the display list in pixels. - * - * @see #setRight(int) - */ - public float getRight() { - return nGetRight(mNativeDisplayList); - } - - /** - * Sets the bottom position for the display list. - * - * @param bottom The bottom position, in pixels, of the display list - * - * @see View#setBottom(int) - * @see #getBottom() - */ - public void setBottom(int bottom) { - nSetBottom(mNativeDisplayList, bottom); - } - - /** - * Returns the bottom position for the display list in pixels. - * - * @see #setBottom(int) - */ - public float getBottom() { - return nGetBottom(mNativeDisplayList); - } - - /** - * 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) - */ - public void setLeftTopRightBottom(int left, int top, int right, int bottom) { - nSetLeftTopRightBottom(mNativeDisplayList, 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) - */ - public void offsetLeftAndRight(float offset) { - nOffsetLeftAndRight(mNativeDisplayList, 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 void offsetTopAndBottom(float offset) { - nOffsetTopAndBottom(mNativeDisplayList, 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. - * - * @hide - */ - public void output() { - nOutput(mNativeDisplayList); - } - - /////////////////////////////////////////////////////////////////////////// - // Native methods - /////////////////////////////////////////////////////////////////////////// - - private static native long nCreate(); - private static native void nDestroyDisplayList(long displayList); - private static native void nSetDisplayListName(long displayList, String name); - - // Properties - - private static native void nOffsetTopAndBottom(long displayList, float offset); - private static native void nOffsetLeftAndRight(long displayList, float offset); - private static native void nSetLeftTopRightBottom(long displayList, int left, int top, - int right, int bottom); - private static native void nSetBottom(long displayList, int bottom); - private static native void nSetRight(long displayList, int right); - private static native void nSetTop(long displayList, int top); - private static native void nSetLeft(long displayList, int left); - private static native void nSetCameraDistance(long displayList, float distance); - private static native void nSetPivotY(long displayList, float pivotY); - private static native void nSetPivotX(long displayList, float pivotX); - private static native void nSetCaching(long displayList, boolean caching); - private static native void nSetClipToBounds(long displayList, boolean clipToBounds); - private static native void nSetProjectBackwards(long displayList, boolean shouldProject); - private static native void nSetProjectionReceiver(long displayList, boolean shouldRecieve); - private static native void nSetIsolatedZVolume(long displayList, boolean isolateZVolume); - private static native void nSetOutline(long displayList, long nativePath); - private static native void nSetClipToOutline(long displayList, boolean clipToOutline); - private static native void nSetCastsShadow(long displayList, boolean castsShadow); - private static native void nSetUsesGlobalCamera(long displayList, boolean usesGlobalCamera); - private static native void nSetAlpha(long displayList, float alpha); - private static native void nSetHasOverlappingRendering(long displayList, - boolean hasOverlappingRendering); - private static native void nSetTranslationX(long displayList, float translationX); - private static native void nSetTranslationY(long displayList, float translationY); - private static native void nSetTranslationZ(long displayList, float translationZ); - private static native void nSetRotation(long displayList, float rotation); - private static native void nSetRotationX(long displayList, float rotationX); - private static native void nSetRotationY(long displayList, float rotationY); - private static native void nSetScaleX(long displayList, float scaleX); - private static native void nSetScaleY(long displayList, float scaleY); - private static native void nSetTransformationInfo(long displayList, float alpha, - float translationX, float translationY, float translationZ, - float rotation, float rotationX, float rotationY, float scaleX, float scaleY); - private static native void nSetStaticMatrix(long displayList, long nativeMatrix); - private static native void nSetAnimationMatrix(long displayList, long animationMatrix); - - private static native boolean nHasOverlappingRendering(long displayList); - private static native float nGetAlpha(long displayList); - private static native float nGetLeft(long displayList); - private static native float nGetTop(long displayList); - private static native float nGetRight(long displayList); - private static native float nGetBottom(long displayList); - private static native float nGetCameraDistance(long displayList); - private static native float nGetScaleX(long displayList); - private static native float nGetScaleY(long displayList); - private static native float nGetTranslationX(long displayList); - private static native float nGetTranslationY(long displayList); - private static native float nGetTranslationZ(long displayList); - private static native float nGetRotation(long displayList); - private static native float nGetRotationX(long displayList); - private static native float nGetRotationY(long displayList); - private static native float nGetPivotX(long displayList); - private static native float nGetPivotY(long displayList); - private static native void nOutput(long displayList); - - /////////////////////////////////////////////////////////////////////////// - // Finalization - /////////////////////////////////////////////////////////////////////////// - - @Override - protected void finalize() throws Throwable { - try { - destroyDisplayListData(); - nDestroyDisplayList(mNativeDisplayList); - } finally { - super.finalize(); - } - } } diff --git a/core/java/android/view/GLES20Canvas.java b/core/java/android/view/GLES20Canvas.java index 6c6fc9b..c274fc4 100644 --- a/core/java/android/view/GLES20Canvas.java +++ b/core/java/android/view/GLES20Canvas.java @@ -359,7 +359,7 @@ class GLES20Canvas extends HardwareCanvas { protected static native long nFinishRecording(long renderer); @Override - public int drawDisplayList(DisplayList displayList, Rect dirty, int flags) { + public int drawDisplayList(RenderNode displayList, Rect dirty, int flags) { return nDrawDisplayList(mRenderer, displayList.getNativeDisplayList(), dirty, flags); } diff --git a/core/java/android/view/GLRenderer.java b/core/java/android/view/GLRenderer.java index 81f778d..4d42c5d 100644 --- a/core/java/android/view/GLRenderer.java +++ b/core/java/android/view/GLRenderer.java @@ -1125,7 +1125,7 @@ public class GLRenderer extends HardwareRenderer { dirty = beginFrame(canvas, dirty, surfaceState); - DisplayList displayList = buildDisplayList(view, canvas); + RenderNode displayList = buildDisplayList(view, canvas); flushLayerChanges(); @@ -1137,7 +1137,7 @@ public class GLRenderer extends HardwareRenderer { } int saveCount = 0; - int status = DisplayList.STATUS_DONE; + int status = RenderNode.STATUS_DONE; long start = getSystemTime(); try { @@ -1201,7 +1201,7 @@ public class GLRenderer extends HardwareRenderer { } private static native void nSetDisplayListData(long displayList, long newData); - private DisplayList buildDisplayList(View view, HardwareCanvas canvas) { + private RenderNode buildDisplayList(View view, HardwareCanvas canvas) { if (mDrawDelta <= 0) { return view.mDisplayList; } @@ -1214,7 +1214,7 @@ public class GLRenderer extends HardwareRenderer { canvas.clearLayerUpdates(); Trace.traceBegin(Trace.TRACE_TAG_VIEW, "getDisplayList"); - DisplayList displayList = view.getDisplayList(); + RenderNode displayList = view.getDisplayList(); Trace.traceEnd(Trace.TRACE_TAG_VIEW); endBuildDisplayListProfiling(buildDisplayListStartTime); @@ -1279,7 +1279,7 @@ public class GLRenderer extends HardwareRenderer { } private int drawDisplayList(View.AttachInfo attachInfo, HardwareCanvas canvas, - DisplayList displayList, int status) { + RenderNode displayList, int status) { long drawDisplayListStartTime = 0; if (mProfileEnabled) { @@ -1289,7 +1289,7 @@ public class GLRenderer extends HardwareRenderer { Trace.traceBegin(Trace.TRACE_TAG_VIEW, "drawDisplayList"); try { status |= canvas.drawDisplayList(displayList, mRedrawClip, - DisplayList.FLAG_CLIP_CHILDREN); + RenderNode.FLAG_CLIP_CHILDREN); } finally { Trace.traceEnd(Trace.TRACE_TAG_VIEW); } @@ -1305,7 +1305,7 @@ public class GLRenderer extends HardwareRenderer { } private void swapBuffers(int status) { - if ((status & DisplayList.STATUS_DREW) == DisplayList.STATUS_DREW) { + if ((status & RenderNode.STATUS_DREW) == RenderNode.STATUS_DREW) { long eglSwapBuffersStartTime = 0; if (mProfileEnabled) { eglSwapBuffersStartTime = System.nanoTime(); @@ -1339,7 +1339,7 @@ public class GLRenderer extends HardwareRenderer { private void handleFunctorStatus(View.AttachInfo attachInfo, int status) { // If the draw flag is set, functors will be invoked while executing // the tree of display lists - if ((status & DisplayList.STATUS_DRAW) != 0) { + if ((status & RenderNode.STATUS_DRAW) != 0) { if (mRedrawClip.isEmpty()) { attachInfo.mViewRootImpl.invalidate(); } else { @@ -1348,7 +1348,7 @@ public class GLRenderer extends HardwareRenderer { } } - if ((status & DisplayList.STATUS_INVOKE) != 0 || + if ((status & RenderNode.STATUS_INVOKE) != 0 || attachInfo.mHandler.hasCallbacks(mFunctorsRunnable)) { attachInfo.mHandler.removeCallbacks(mFunctorsRunnable); mFunctorsRunnable.attachInfo = attachInfo; diff --git a/core/java/android/view/HardwareCanvas.java b/core/java/android/view/HardwareCanvas.java index a3c7b63..f695b20 100644 --- a/core/java/android/view/HardwareCanvas.java +++ b/core/java/android/view/HardwareCanvas.java @@ -42,7 +42,7 @@ public abstract class HardwareCanvas extends Canvas { * Invoked before any drawing operation is performed in this canvas. * * @param dirty The dirty rectangle to update, can be null. - * @return {@link DisplayList#STATUS_DREW} if anything was drawn (such as a call to clear + * @return {@link RenderNode#STATUS_DREW} if anything was drawn (such as a call to clear * the canvas). * * @hide @@ -58,12 +58,12 @@ public abstract class HardwareCanvas extends Canvas { /** * Draws the specified display list onto this canvas. The display list can only - * be drawn if {@link android.view.DisplayList#isValid()} returns true. + * be drawn if {@link android.view.RenderNode#isValid()} returns true. * * @param displayList The display list to replay. */ - public void drawDisplayList(DisplayList displayList) { - drawDisplayList(displayList, null, DisplayList.FLAG_CLIP_CHILDREN); + public void drawDisplayList(RenderNode displayList) { + drawDisplayList(displayList, null, RenderNode.FLAG_CLIP_CHILDREN); } /** @@ -71,17 +71,17 @@ public abstract class HardwareCanvas extends Canvas { * * @param displayList The display list to replay. * @param dirty The dirty region to redraw in the next pass, matters only - * if this method returns {@link DisplayList#STATUS_DRAW}, can be null. - * @param flags Optional flags about drawing, see {@link DisplayList} for + * if this method returns {@link RenderNode#STATUS_DRAW}, can be null. + * @param flags Optional flags about drawing, see {@link RenderNode} for * the possible flags. * - * @return One of {@link DisplayList#STATUS_DONE}, {@link DisplayList#STATUS_DRAW}, or - * {@link DisplayList#STATUS_INVOKE}, or'd with {@link DisplayList#STATUS_DREW} + * @return One of {@link RenderNode#STATUS_DONE}, {@link RenderNode#STATUS_DRAW}, or + * {@link RenderNode#STATUS_INVOKE}, or'd with {@link RenderNode#STATUS_DREW} * if anything was drawn. * * @hide */ - public abstract int drawDisplayList(DisplayList displayList, Rect dirty, int flags); + public abstract int drawDisplayList(RenderNode displayList, Rect dirty, int flags); /** * Draws the specified layer onto this canvas. @@ -102,28 +102,28 @@ public abstract class HardwareCanvas extends Canvas { * * @param drawGLFunction A native function pointer * - * @return One of {@link DisplayList#STATUS_DONE}, {@link DisplayList#STATUS_DRAW} or - * {@link DisplayList#STATUS_INVOKE} + * @return One of {@link RenderNode#STATUS_DONE}, {@link RenderNode#STATUS_DRAW} or + * {@link RenderNode#STATUS_INVOKE} * * @hide */ public int callDrawGLFunction(long drawGLFunction) { // Noop - this is done in the display list recorder subclass - return DisplayList.STATUS_DONE; + return RenderNode.STATUS_DONE; } /** * Invoke all the functors who requested to be invoked during the previous frame. * - * @param dirty The region to redraw when the functors return {@link DisplayList#STATUS_DRAW} + * @param dirty The region to redraw when the functors return {@link RenderNode#STATUS_DRAW} * - * @return One of {@link DisplayList#STATUS_DONE}, {@link DisplayList#STATUS_DRAW} or - * {@link DisplayList#STATUS_INVOKE} + * @return One of {@link RenderNode#STATUS_DONE}, {@link RenderNode#STATUS_DRAW} or + * {@link RenderNode#STATUS_INVOKE} * * @hide */ public int invokeFunctors(Rect dirty) { - return DisplayList.STATUS_DONE; + return RenderNode.STATUS_DONE; } /** diff --git a/core/java/android/view/HardwareLayer.java b/core/java/android/view/HardwareLayer.java index 46e2690..4d78733 100644 --- a/core/java/android/view/HardwareLayer.java +++ b/core/java/android/view/HardwareLayer.java @@ -37,7 +37,7 @@ final class HardwareLayer { private HardwareRenderer mRenderer; private Finalizer mFinalizer; - private DisplayList mDisplayList; + private RenderNode mDisplayList; private final int mLayerType; private HardwareLayer(HardwareRenderer renderer, long deferredUpdater, int type) { @@ -122,11 +122,11 @@ final class HardwareLayer { } } - public DisplayList startRecording() { + public RenderNode startRecording() { assertType(LAYER_TYPE_DISPLAY_LIST); if (mDisplayList == null) { - mDisplayList = DisplayList.create("HardwareLayer"); + mDisplayList = RenderNode.create("HardwareLayer"); } return mDisplayList; } diff --git a/core/java/android/view/RenderNode.java b/core/java/android/view/RenderNode.java new file mode 100644 index 0000000..430bf5e --- /dev/null +++ b/core/java/android/view/RenderNode.java @@ -0,0 +1,931 @@ +/* + * 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.graphics.Matrix; +import android.graphics.Path; + +/** + * <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 HardwareCanvas}. 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 HardwareCanvas}. 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"> + * HardwareRenderer renderer = myView.getHardwareRenderer(); + * if (renderer != null) { + * DisplayList displayList = renderer.createDisplayList(); + * HardwareCanvas 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()) { + * HardwareCanvas hardwareCanvas = (HardwareCanvas) canvas; + * hardwareCanvas.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"); + * HardwareCanvas 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()) { + * HardwareCanvas hardwareCanvas = (HardwareCanvas) canvas; + * hardwareCanvas.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 { + /** + * Flag used when calling + * {@link HardwareCanvas#drawDisplayList(RenderNode, android.graphics.Rect, int)} + * When this flag is set, draw operations lying outside of the bounds of the + * display list will be culled early. It is recommeneded to always set this + * flag. + * + * @hide + */ + public static final int FLAG_CLIP_CHILDREN = 0x1; + + // NOTE: The STATUS_* values *must* match the enum in DrawGlInfo.h + + /** + * Indicates that the display list is done drawing. + * + * @see HardwareCanvas#drawDisplayList(RenderNode, android.graphics.Rect, int) + * + * @hide + */ + public static final int STATUS_DONE = 0x0; + + /** + * Indicates that the display list needs another drawing pass. + * + * @see HardwareCanvas#drawDisplayList(RenderNode, android.graphics.Rect, int) + * + * @hide + */ + public static final int STATUS_DRAW = 0x1; + + /** + * Indicates that the display list needs to re-execute its GL functors. + * + * @see HardwareCanvas#drawDisplayList(RenderNode, android.graphics.Rect, int) + * @see HardwareCanvas#callDrawGLFunction(long) + * + * @hide + */ + public static final int STATUS_INVOKE = 0x2; + + /** + * Indicates that the display list performed GL drawing operations. + * + * @see HardwareCanvas#drawDisplayList(RenderNode, android.graphics.Rect, int) + * + * @hide + */ + public static final int STATUS_DREW = 0x4; + + private boolean mValid; + private final long mNativeDisplayList; + private HardwareRenderer mRenderer; + + private RenderNode(String name) { + mNativeDisplayList = nCreate(); + nSetDisplayListName(mNativeDisplayList, name); + } + + /** + * Creates a new display list that can be used to record batches of + * drawing operations. + * + * @param name The name of the display list, used for debugging purpose. May be null. + * + * @return A new display list. + * + * @hide + */ + public static RenderNode create(String name) { + return new RenderNode(name); + } + + /** + * Starts recording the display list. All operations performed on the + * returned canvas are recorded and stored in this display list. + * + * Calling this method will mark the display list invalid until + * {@link #end()} is called. Only valid display lists can be replayed. + * + * @param width The width of the display list's viewport + * @param height The height of the display list's viewport + * + * @return A canvas to record drawing operations. + * + * @see #end() + * @see #isValid() + */ + public HardwareCanvas start(int width, int height) { + HardwareCanvas canvas = GLES20RecordingCanvas.obtain(); + canvas.setViewport(width, height); + // The dirty rect should always be null for a display list + canvas.onPreDraw(null); + return canvas; + } + + /** + * 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() + */ + public void end(HardwareRenderer renderer, HardwareCanvas endCanvas) { + if (!(endCanvas instanceof GLES20RecordingCanvas)) { + throw new IllegalArgumentException("Passed an invalid canvas to end!"); + } + + GLES20RecordingCanvas canvas = (GLES20RecordingCanvas) endCanvas; + canvas.onPostDraw(); + long displayListData = canvas.finishRecording(); + if (renderer != mRenderer) { + // If we are changing renderers first destroy with the old + // renderer, then set with the new one + destroyDisplayListData(); + } + mRenderer = renderer; + setDisplayListData(displayListData); + canvas.recycle(); + mValid = true; + } + + /** + * 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. + * + * @hide + */ + public void destroyDisplayListData() { + if (!mValid) return; + + setDisplayListData(0); + mRenderer = null; + mValid = false; + } + + private void setDisplayListData(long newData) { + if (mRenderer != null) { + mRenderer.setDisplayListData(mNativeDisplayList, newData); + } else { + throw new IllegalStateException("Trying to set data without a renderer! data=" + newData); + } + } + + /** + * Returns whether the display list 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. + */ + public boolean isValid() { return mValid; } + + long getNativeDisplayList() { + if (!mValid) { + throw new IllegalStateException("The display list is not valid."); + } + return mNativeDisplayList; + } + + /////////////////////////////////////////////////////////////////////////// + // DisplayList Property Setters + /////////////////////////////////////////////////////////////////////////// + + /** + * Set the caching property on the display list, which indicates whether the display list + * holds a layer. Layer display lists should avoid creating an alpha layer, since alpha is + * handled in the drawLayer operation directly (and more efficiently). + * + * @param caching true if the display list represents a hardware layer, false otherwise. + * + * @hide + */ + public void setCaching(boolean caching) { + nSetCaching(mNativeDisplayList, caching); + } + + /** + * Set whether the display list 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 + */ + public void setClipToBounds(boolean clipToBounds) { + nSetClipToBounds(mNativeDisplayList, clipToBounds); + } + + /** + * Set whether the display list should collect and Z order all 3d composited descendents, and + * draw them in order with the default Z=0 content. + * + * @param isolatedZVolume true if the display list should collect and Z order descendents. + */ + public void setIsolatedZVolume(boolean isolatedZVolume) { + nSetIsolatedZVolume(mNativeDisplayList, isolatedZVolume); + } + + /** + * Sets whether the display list should be drawn immediately after the + * closest ancestor display list where isolateZVolume is true. If the + * display list itself satisfies this constraint, changing this attribute + * has no effect on drawing order. + * + * @param shouldProject true if the display list should be projected onto a + * containing volume. + */ + public void setProjectBackwards(boolean shouldProject) { + nSetProjectBackwards(mNativeDisplayList, 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 void setProjectionReceiver(boolean shouldRecieve) { + nSetProjectionReceiver(mNativeDisplayList, shouldRecieve); + } + + /** + * Sets the outline, defining the shape that casts a shadow, and the path to + * be clipped if setClipToOutline is set. + * + * Deep copies the native path to simplify reference ownership. + * + * @param outline Convex, CW Path to store in the DisplayList. May be null. + */ + public void setOutline(Path outline) { + long nativePath = (outline == null) ? 0 : outline.mNativePath; + nSetOutline(mNativeDisplayList, nativePath); + } + + /** + * Enables or disables clipping to the outline. + * + * @param clipToOutline true if clipping to the outline. + */ + public void setClipToOutline(boolean clipToOutline) { + nSetClipToOutline(mNativeDisplayList, clipToOutline); + } + + /** + * Set whether the DisplayList should cast a shadow. + * + * The shape of the shadow casting area is defined by the outline of the display list, if set + * and non-empty, otherwise it will be the bounds rect. + */ + public void setCastsShadow(boolean castsShadow) { + nSetCastsShadow(mNativeDisplayList, castsShadow); + } + + /** + * Sets whether the DisplayList should be drawn with perspective applied from the global camera. + * + * If set to true, camera distance will be ignored. Defaults to false. + */ + public void setUsesGlobalCamera(boolean usesGlobalCamera) { + nSetUsesGlobalCamera(mNativeDisplayList, usesGlobalCamera); + } + + /** + * 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 + * + * @see #getMatrix(android.graphics.Matrix) + * @see #getMatrix() + */ + public void setStaticMatrix(Matrix matrix) { + nSetStaticMatrix(mNativeDisplayList, 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. + * + * @hide + */ + public void setAnimationMatrix(Matrix matrix) { + nSetAnimationMatrix(mNativeDisplayList, + (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 void setAlpha(float alpha) { + nSetAlpha(mNativeDisplayList, 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(mNativeDisplayList); + } + + /** + * 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() + */ + public void setHasOverlappingRendering(boolean hasOverlappingRendering) { + nSetHasOverlappingRendering(mNativeDisplayList, hasOverlappingRendering); + } + + /** + * 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() { + //noinspection SimplifiableIfStatement + return nHasOverlappingRendering(mNativeDisplayList); + } + + /** + * 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 void setTranslationX(float translationX) { + nSetTranslationX(mNativeDisplayList, translationX); + } + + /** + * Returns the translation value for this display list on the X axis, in pixels. + * + * @see #setTranslationX(float) + */ + public float getTranslationX() { + return nGetTranslationX(mNativeDisplayList); + } + + /** + * 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 void setTranslationY(float translationY) { + nSetTranslationY(mNativeDisplayList, translationY); + } + + /** + * Returns the translation value for this display list on the Y axis, in pixels. + * + * @see #setTranslationY(float) + */ + public float getTranslationY() { + return nGetTranslationY(mNativeDisplayList); + } + + /** + * Sets the translation value for the display list on the Z axis. + * + * @see View#setTranslationZ(float) + * @see #getTranslationZ() + */ + public void setTranslationZ(float translationZ) { + nSetTranslationZ(mNativeDisplayList, translationZ); + } + + /** + * Returns the translation value for this display list on the Z axis. + * + * @see #setTranslationZ(float) + */ + public float getTranslationZ() { + return nGetTranslationZ(mNativeDisplayList); + } + + /** + * 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 void setRotation(float rotation) { + nSetRotation(mNativeDisplayList, rotation); + } + + /** + * Returns the rotation value for this display list around the Z axis, in degrees. + * + * @see #setRotation(float) + */ + public float getRotation() { + return nGetRotation(mNativeDisplayList); + } + + /** + * 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 void setRotationX(float rotationX) { + nSetRotationX(mNativeDisplayList, rotationX); + } + + /** + * Returns the rotation value for this display list around the X axis, in degrees. + * + * @see #setRotationX(float) + */ + public float getRotationX() { + return nGetRotationX(mNativeDisplayList); + } + + /** + * 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 void setRotationY(float rotationY) { + nSetRotationY(mNativeDisplayList, rotationY); + } + + /** + * Returns the rotation value for this display list around the Y axis, in degrees. + * + * @see #setRotationY(float) + */ + public float getRotationY() { + return nGetRotationY(mNativeDisplayList); + } + + /** + * 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 void setScaleX(float scaleX) { + nSetScaleX(mNativeDisplayList, scaleX); + } + + /** + * Returns the scale value for this display list on the X axis. + * + * @see #setScaleX(float) + */ + public float getScaleX() { + return nGetScaleX(mNativeDisplayList); + } + + /** + * 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 void setScaleY(float scaleY) { + nSetScaleY(mNativeDisplayList, scaleY); + } + + /** + * Returns the scale value for this display list on the Y axis. + * + * @see #setScaleY(float) + */ + public float getScaleY() { + return nGetScaleY(mNativeDisplayList); + } + + /** + * Sets all of the transform-related values of the display list + * + * @param alpha The alpha value of the display list + * @param translationX The translationX value of the display list + * @param translationY The translationY value of the display list + * @param rotation The rotation value of the display list + * @param rotationX The rotationX value of the display list + * @param rotationY The rotationY value of the display list + * @param scaleX The scaleX value of the display list + * @param scaleY The scaleY value of the display list + * + * @hide + */ + public void setTransformationInfo(float alpha, + float translationX, float translationY, float translationZ, + float rotation, float rotationX, float rotationY, float scaleX, float scaleY) { + nSetTransformationInfo(mNativeDisplayList, alpha, + translationX, translationY, translationZ, + rotation, rotationX, rotationY, scaleX, scaleY); + } + + /** + * 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 void setPivotX(float pivotX) { + nSetPivotX(mNativeDisplayList, pivotX); + } + + /** + * Returns the pivot value for this display list on the X axis, in pixels. + * + * @see #setPivotX(float) + */ + public float getPivotX() { + return nGetPivotX(mNativeDisplayList); + } + + /** + * 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 void setPivotY(float pivotY) { + nSetPivotY(mNativeDisplayList, pivotY); + } + + /** + * Returns the pivot value for this display list on the Y axis, in pixels. + * + * @see #setPivotY(float) + */ + public float getPivotY() { + return nGetPivotY(mNativeDisplayList); + } + + /** + * 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 void setCameraDistance(float distance) { + nSetCameraDistance(mNativeDisplayList, distance); + } + + /** + * Returns the distance in Z of the camera of the display list. + * + * @see #setCameraDistance(float) + */ + public float getCameraDistance() { + return nGetCameraDistance(mNativeDisplayList); + } + + /** + * Sets the left position for the display list. + * + * @param left The left position, in pixels, of the display list + * + * @see View#setLeft(int) + * @see #getLeft() + */ + public void setLeft(int left) { + nSetLeft(mNativeDisplayList, left); + } + + /** + * Returns the left position for the display list in pixels. + * + * @see #setLeft(int) + */ + public float getLeft() { + return nGetLeft(mNativeDisplayList); + } + + /** + * Sets the top position for the display list. + * + * @param top The top position, in pixels, of the display list + * + * @see View#setTop(int) + * @see #getTop() + */ + public void setTop(int top) { + nSetTop(mNativeDisplayList, top); + } + + /** + * Returns the top position for the display list in pixels. + * + * @see #setTop(int) + */ + public float getTop() { + return nGetTop(mNativeDisplayList); + } + + /** + * Sets the right position for the display list. + * + * @param right The right position, in pixels, of the display list + * + * @see View#setRight(int) + * @see #getRight() + */ + public void setRight(int right) { + nSetRight(mNativeDisplayList, right); + } + + /** + * Returns the right position for the display list in pixels. + * + * @see #setRight(int) + */ + public float getRight() { + return nGetRight(mNativeDisplayList); + } + + /** + * Sets the bottom position for the display list. + * + * @param bottom The bottom position, in pixels, of the display list + * + * @see View#setBottom(int) + * @see #getBottom() + */ + public void setBottom(int bottom) { + nSetBottom(mNativeDisplayList, bottom); + } + + /** + * Returns the bottom position for the display list in pixels. + * + * @see #setBottom(int) + */ + public float getBottom() { + return nGetBottom(mNativeDisplayList); + } + + /** + * 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) + */ + public void setLeftTopRightBottom(int left, int top, int right, int bottom) { + nSetLeftTopRightBottom(mNativeDisplayList, 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) + */ + public void offsetLeftAndRight(float offset) { + nOffsetLeftAndRight(mNativeDisplayList, 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 void offsetTopAndBottom(float offset) { + nOffsetTopAndBottom(mNativeDisplayList, 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. + * + * @hide + */ + public void output() { + nOutput(mNativeDisplayList); + } + + /////////////////////////////////////////////////////////////////////////// + // Native methods + /////////////////////////////////////////////////////////////////////////// + + private static native long nCreate(); + private static native void nDestroyDisplayList(long displayList); + private static native void nSetDisplayListName(long displayList, String name); + + // Properties + + private static native void nOffsetTopAndBottom(long displayList, float offset); + private static native void nOffsetLeftAndRight(long displayList, float offset); + private static native void nSetLeftTopRightBottom(long displayList, int left, int top, + int right, int bottom); + private static native void nSetBottom(long displayList, int bottom); + private static native void nSetRight(long displayList, int right); + private static native void nSetTop(long displayList, int top); + private static native void nSetLeft(long displayList, int left); + private static native void nSetCameraDistance(long displayList, float distance); + private static native void nSetPivotY(long displayList, float pivotY); + private static native void nSetPivotX(long displayList, float pivotX); + private static native void nSetCaching(long displayList, boolean caching); + private static native void nSetClipToBounds(long displayList, boolean clipToBounds); + private static native void nSetProjectBackwards(long displayList, boolean shouldProject); + private static native void nSetProjectionReceiver(long displayList, boolean shouldRecieve); + private static native void nSetIsolatedZVolume(long displayList, boolean isolateZVolume); + private static native void nSetOutline(long displayList, long nativePath); + private static native void nSetClipToOutline(long displayList, boolean clipToOutline); + private static native void nSetCastsShadow(long displayList, boolean castsShadow); + private static native void nSetUsesGlobalCamera(long displayList, boolean usesGlobalCamera); + private static native void nSetAlpha(long displayList, float alpha); + private static native void nSetHasOverlappingRendering(long displayList, + boolean hasOverlappingRendering); + private static native void nSetTranslationX(long displayList, float translationX); + private static native void nSetTranslationY(long displayList, float translationY); + private static native void nSetTranslationZ(long displayList, float translationZ); + private static native void nSetRotation(long displayList, float rotation); + private static native void nSetRotationX(long displayList, float rotationX); + private static native void nSetRotationY(long displayList, float rotationY); + private static native void nSetScaleX(long displayList, float scaleX); + private static native void nSetScaleY(long displayList, float scaleY); + private static native void nSetTransformationInfo(long displayList, float alpha, + float translationX, float translationY, float translationZ, + float rotation, float rotationX, float rotationY, float scaleX, float scaleY); + private static native void nSetStaticMatrix(long displayList, long nativeMatrix); + private static native void nSetAnimationMatrix(long displayList, long animationMatrix); + + private static native boolean nHasOverlappingRendering(long displayList); + private static native float nGetAlpha(long displayList); + private static native float nGetLeft(long displayList); + private static native float nGetTop(long displayList); + private static native float nGetRight(long displayList); + private static native float nGetBottom(long displayList); + private static native float nGetCameraDistance(long displayList); + private static native float nGetScaleX(long displayList); + private static native float nGetScaleY(long displayList); + private static native float nGetTranslationX(long displayList); + private static native float nGetTranslationY(long displayList); + private static native float nGetTranslationZ(long displayList); + private static native float nGetRotation(long displayList); + private static native float nGetRotationX(long displayList); + private static native float nGetRotationY(long displayList); + private static native float nGetPivotX(long displayList); + private static native float nGetPivotY(long displayList); + private static native void nOutput(long displayList); + + /////////////////////////////////////////////////////////////////////////// + // Finalization + /////////////////////////////////////////////////////////////////////////// + + @Override + protected void finalize() throws Throwable { + try { + destroyDisplayListData(); + nDestroyDisplayList(mNativeDisplayList); + } finally { + super.finalize(); + } + } +} diff --git a/core/java/android/view/ThreadedRenderer.java b/core/java/android/view/ThreadedRenderer.java index a1fb123..2a488a0 100644 --- a/core/java/android/view/ThreadedRenderer.java +++ b/core/java/android/view/ThreadedRenderer.java @@ -163,7 +163,7 @@ public class ThreadedRenderer extends HardwareRenderer { view.mPrivateFlags &= ~View.PFLAG_INVALIDATED; Trace.traceBegin(Trace.TRACE_TAG_VIEW, "getDisplayList"); - DisplayList displayList = view.getDisplayList(); + RenderNode displayList = view.getDisplayList(); Trace.traceEnd(Trace.TRACE_TAG_VIEW); view.mRecreateDisplayList = false; diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 7a58d06..eff78d3 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -3269,7 +3269,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * of the background drawable. It is cleared on temporary detach and reset * on cleanup. */ - private DisplayList mBackgroundDisplayList; + private RenderNode mBackgroundDisplayList; private int mBackgroundResource; private boolean mBackgroundSizeChanged; @@ -3559,7 +3559,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * of the View content. It is cleared on temporary detach and reset on * cleanup. */ - DisplayList mDisplayList; + RenderNode mDisplayList; /** * Set to true when the view is sending hover accessibility events because it @@ -13802,7 +13802,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } mHardwareLayer.setLayerPaint(mLayerPaint); - DisplayList displayList = mHardwareLayer.startRecording(); + RenderNode displayList = mHardwareLayer.startRecording(); if (getDisplayList(displayList, true) != displayList) { throw new IllegalStateException("getDisplayList() didn't return" + " the input displaylist for a hardware layer!"); @@ -13952,7 +13952,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * the view will avoid creating a layer inside the resulting display list. * @return A new or reused DisplayList object. */ - private DisplayList getDisplayList(DisplayList displayList, boolean isLayer) { + private RenderNode getDisplayList(RenderNode displayList, boolean isLayer) { final HardwareRenderer renderer = getHardwareRenderer(); if (renderer == null || !canHaveDisplayList()) { return null; @@ -13978,7 +13978,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, mRecreateDisplayList = true; } if (displayList == null) { - displayList = DisplayList.create(getClass().getName()); + displayList = RenderNode.create(getClass().getName()); // If we're creating a new display list, make sure our parent gets invalidated // since they will need to recreate their display list to account for this // new child display list. @@ -14065,7 +14065,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * * @hide */ - public DisplayList getDisplayList() { + public RenderNode getDisplayList() { mDisplayList = getDisplayList(mDisplayList, false); return mDisplayList; } @@ -14671,7 +14671,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * necessary when a display list is being re-created, because we need to make sure that * previously-set transform values */ - void setDisplayListProperties(DisplayList displayList) { + void setDisplayListProperties(RenderNode displayList) { if (displayList != null) { displayList.setLeftTopRightBottom(mLeft, mTop, mRight, mBottom); displayList.setHasOverlappingRendering(hasOverlappingRendering()); @@ -14816,7 +14816,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, mPrivateFlags &= ~PFLAG_INVALIDATED; } - DisplayList displayList = null; + RenderNode displayList = null; Bitmap cache = null; boolean hasDisplayList = false; if (caching) { @@ -15295,7 +15295,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, && mAttachInfo.mHardwareRenderer != null) { mBackgroundDisplayList = getDrawableDisplayList(background, mBackgroundDisplayList); - final DisplayList displayList = mBackgroundDisplayList; + final RenderNode displayList = mBackgroundDisplayList; if (displayList != null && displayList.isValid()) { setBackgroundDisplayListProperties(displayList); ((HardwareCanvas) canvas).drawDisplayList(displayList); @@ -15319,7 +15319,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * * @param displayList Valid display list for the background drawable */ - private void setBackgroundDisplayListProperties(DisplayList displayList) { + private void setBackgroundDisplayListProperties(RenderNode displayList) { displayList.setTranslationX(mScrollX); displayList.setTranslationY(mScrollY); } @@ -15332,9 +15332,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @param displayList Existing display list, or {@code null} * @return A valid display list for the specified drawable */ - private DisplayList getDrawableDisplayList(Drawable drawable, DisplayList displayList) { + private RenderNode getDrawableDisplayList(Drawable drawable, RenderNode displayList) { if (displayList == null) { - displayList = DisplayList.create(drawable.getClass().getName()); + displayList = RenderNode.create(drawable.getClass().getName()); } final Rect bounds = drawable.getBounds(); diff --git a/core/java/android/view/ViewPropertyAnimator.java b/core/java/android/view/ViewPropertyAnimator.java index 1892aa7..563ffb7 100644 --- a/core/java/android/view/ViewPropertyAnimator.java +++ b/core/java/android/view/ViewPropertyAnimator.java @@ -925,7 +925,7 @@ public class ViewPropertyAnimator { */ private void setValue(int propertyConstant, float value) { final View.TransformationInfo info = mView.mTransformationInfo; - final DisplayList displayList = mView.mDisplayList; + final RenderNode displayList = mView.mDisplayList; switch (propertyConstant) { case TRANSLATION_X: info.mTranslationX = value; diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 18517c5..185cb65 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -1465,7 +1465,7 @@ public final class ViewRootImpl implements ViewParent, mWidth, mHeight); } mResizeBuffer.prepare(mWidth, mHeight, false); - DisplayList layerDisplayList = mResizeBuffer.startRecording(); + RenderNode layerDisplayList = mResizeBuffer.startRecording(); HardwareCanvas layerCanvas = layerDisplayList.start(mWidth, mHeight); final int restoreCount = layerCanvas.save(); @@ -1484,10 +1484,10 @@ public final class ViewRootImpl implements ViewParent, mTranslator.translateCanvas(layerCanvas); } - DisplayList displayList = mView.mDisplayList; + RenderNode displayList = mView.mDisplayList; if (displayList != null && displayList.isValid()) { layerCanvas.drawDisplayList(displayList, null, - DisplayList.FLAG_CLIP_CHILDREN); + RenderNode.FLAG_CLIP_CHILDREN); } else { mView.draw(layerCanvas); } @@ -2178,7 +2178,7 @@ public final class ViewRootImpl implements ViewParent, * @hide */ void outputDisplayList(View view) { - DisplayList displayList = view.getDisplayList(); + RenderNode displayList = view.getDisplayList(); if (displayList != null) { displayList.output(); } @@ -5206,7 +5206,7 @@ public final class ViewRootImpl implements ViewParent, } private static void getGfxInfo(View view, int[] info) { - DisplayList displayList = view.mDisplayList; + RenderNode displayList = view.mDisplayList; info[0]++; if (displayList != null) { info[1] += 0; /* TODO: Memory used by display lists */ diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java index 53d9e28..333e631 100644 --- a/core/java/android/widget/Editor.java +++ b/core/java/android/widget/Editor.java @@ -74,7 +74,7 @@ import android.util.DisplayMetrics; import android.util.Log; import android.view.ActionMode; import android.view.ActionMode.Callback; -import android.view.DisplayList; +import android.view.RenderNode; import android.view.DragEvent; import android.view.Gravity; import android.view.HardwareCanvas; @@ -138,11 +138,11 @@ public class Editor { InputMethodState mInputMethodState; private static class TextDisplayList { - DisplayList displayList; + RenderNode displayList; boolean isDirty; public TextDisplayList(String name) { isDirty = true; - displayList = DisplayList.create(name); + displayList = RenderNode.create(name); } boolean needsRecord() { return isDirty || !displayList.isValid(); } } @@ -289,7 +289,7 @@ public class Editor { private void destroyDisplayListsData() { if (mTextDisplayLists != null) { for (int i = 0; i < mTextDisplayLists.length; i++) { - DisplayList displayList = mTextDisplayLists[i] != null + RenderNode displayList = mTextDisplayLists[i] != null ? mTextDisplayLists[i].displayList : null; if (displayList != null && displayList.isValid()) { displayList.destroyDisplayListData(); @@ -1371,7 +1371,7 @@ public class Editor { } final boolean blockDisplayListIsInvalid = mTextDisplayLists[blockIndex].needsRecord(); - DisplayList blockDisplayList = mTextDisplayLists[blockIndex].displayList; + RenderNode blockDisplayList = mTextDisplayLists[blockIndex].displayList; if (i >= indexFirstChangedBlock || blockDisplayListIsInvalid) { final int blockBeginLine = endOfPreviousBlock + 1; final int top = layout.getLineTop(blockBeginLine); diff --git a/core/jni/Android.mk b/core/jni/Android.mk index a09c314..51c5a86 100644 --- a/core/jni/Android.mk +++ b/core/jni/Android.mk @@ -42,7 +42,6 @@ LOCAL_SRC_FILES:= \ android_database_SQLiteDebug.cpp \ android_emoji_EmojiFactory.cpp \ android_view_DisplayEventReceiver.cpp \ - android_view_DisplayList.cpp \ android_view_Surface.cpp \ android_view_SurfaceControl.cpp \ android_view_SurfaceSession.cpp \ @@ -61,6 +60,7 @@ LOCAL_SRC_FILES:= \ android_view_ThreadedRenderer.cpp \ android_view_MotionEvent.cpp \ android_view_PointerIcon.cpp \ + android_view_RenderNode.cpp \ android_view_VelocityTracker.cpp \ android_text_AndroidCharacter.cpp \ android_text_AndroidBidi.cpp \ diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp index 94c3f44..05d7d29 100644 --- a/core/jni/AndroidRuntime.cpp +++ b/core/jni/AndroidRuntime.cpp @@ -119,7 +119,7 @@ extern int register_android_graphics_SurfaceTexture(JNIEnv* env); extern int register_android_graphics_Xfermode(JNIEnv* env); extern int register_android_graphics_pdf_PdfDocument(JNIEnv* env); extern int register_android_view_DisplayEventReceiver(JNIEnv* env); -extern int register_android_view_DisplayList(JNIEnv* env); +extern int register_android_view_RenderNode(JNIEnv* env); extern int register_android_view_GraphicBuffer(JNIEnv* env); extern int register_android_view_GLES20Canvas(JNIEnv* env); extern int register_android_view_GLRenderer(JNIEnv* env); @@ -1173,7 +1173,7 @@ static const RegJNIRec gRegJNI[] = { REG_JNI(register_android_nio_utils), REG_JNI(register_android_graphics_Graphics), REG_JNI(register_android_view_DisplayEventReceiver), - REG_JNI(register_android_view_DisplayList), + REG_JNI(register_android_view_RenderNode), REG_JNI(register_android_view_GraphicBuffer), REG_JNI(register_android_view_GLES20Canvas), REG_JNI(register_android_view_GLRenderer), diff --git a/core/jni/android_view_DisplayList.cpp b/core/jni/android_view_RenderNode.cpp index 4a6346e..2f69b8b 100644 --- a/core/jni/android_view_DisplayList.cpp +++ b/core/jni/android_view_RenderNode.cpp @@ -41,7 +41,7 @@ using namespace uirenderer; // DisplayList view properties // ---------------------------------------------------------------------------- -static void android_view_DisplayList_setDisplayListName(JNIEnv* env, +static void android_view_RenderNode_setDisplayListName(JNIEnv* env, jobject clazz, jlong displayListPtr, jstring name) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); if (name != NULL) { @@ -51,18 +51,18 @@ static void android_view_DisplayList_setDisplayListName(JNIEnv* env, } } -static void android_view_DisplayList_output(JNIEnv* env, +static void android_view_RenderNode_output(JNIEnv* env, jobject clazz, jlong displayListPtr) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); displayList->output(); } -static jlong android_view_DisplayList_create(JNIEnv* env, jobject clazz) { +static jlong android_view_RenderNode_create(JNIEnv* env, jobject clazz) { RenderNode* displayList = new RenderNode(); return reinterpret_cast<jlong>(displayList); } -static void android_view_DisplayList_destroyDisplayList(JNIEnv* env, +static void android_view_RenderNode_destroyDisplayList(JNIEnv* env, jobject clazz, jlong displayListPtr) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); RenderNode::destroyDisplayListDeferred(displayList); @@ -72,135 +72,135 @@ static void android_view_DisplayList_destroyDisplayList(JNIEnv* env, // DisplayList view properties // ---------------------------------------------------------------------------- -static void android_view_DisplayList_setCaching(JNIEnv* env, +static void android_view_RenderNode_setCaching(JNIEnv* env, jobject clazz, jlong displayListPtr, jboolean caching) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); displayList->properties().setCaching(caching); } -static void android_view_DisplayList_setStaticMatrix(JNIEnv* env, +static void android_view_RenderNode_setStaticMatrix(JNIEnv* env, jobject clazz, jlong displayListPtr, jlong matrixPtr) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixPtr); displayList->properties().setStaticMatrix(matrix); } -static void android_view_DisplayList_setAnimationMatrix(JNIEnv* env, +static void android_view_RenderNode_setAnimationMatrix(JNIEnv* env, jobject clazz, jlong displayListPtr, jlong matrixPtr) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixPtr); displayList->properties().setAnimationMatrix(matrix); } -static void android_view_DisplayList_setClipToBounds(JNIEnv* env, +static void android_view_RenderNode_setClipToBounds(JNIEnv* env, jobject clazz, jlong displayListPtr, jboolean clipToBounds) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); displayList->properties().setClipToBounds(clipToBounds); } -static void android_view_DisplayList_setIsolatedZVolume(JNIEnv* env, +static void android_view_RenderNode_setIsolatedZVolume(JNIEnv* env, jobject clazz, jlong displayListPtr, jboolean shouldIsolate) { // No-op, TODO: Remove Java usage of this method } -static void android_view_DisplayList_setProjectBackwards(JNIEnv* env, +static void android_view_RenderNode_setProjectBackwards(JNIEnv* env, jobject clazz, jlong displayListPtr, jboolean shouldProject) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); displayList->properties().setProjectBackwards(shouldProject); } -static void android_view_DisplayList_setProjectionReceiver(JNIEnv* env, +static void android_view_RenderNode_setProjectionReceiver(JNIEnv* env, jobject clazz, jlong displayListPtr, jboolean shouldRecieve) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); displayList->properties().setProjectionReceiver(shouldRecieve); } -static void android_view_DisplayList_setOutline(JNIEnv* env, +static void android_view_RenderNode_setOutline(JNIEnv* env, jobject clazz, jlong displayListPtr, jlong outlinePathPtr) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); SkPath* outline = reinterpret_cast<SkPath*>(outlinePathPtr); displayList->properties().setOutline(outline); } -static void android_view_DisplayList_setClipToOutline(JNIEnv* env, +static void android_view_RenderNode_setClipToOutline(JNIEnv* env, jobject clazz, jlong displayListPtr, jboolean clipToOutline) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); displayList->properties().setClipToOutline(clipToOutline); } -static void android_view_DisplayList_setCastsShadow(JNIEnv* env, +static void android_view_RenderNode_setCastsShadow(JNIEnv* env, jobject clazz, jlong displayListPtr, jboolean castsShadow) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); displayList->properties().setCastsShadow(castsShadow); } -static void android_view_DisplayList_setUsesGlobalCamera(JNIEnv* env, +static void android_view_RenderNode_setUsesGlobalCamera(JNIEnv* env, jobject clazz, jlong displayListPtr, jboolean usesGlobalCamera) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); displayList->properties().setUsesGlobalCamera(usesGlobalCamera); } -static void android_view_DisplayList_setAlpha(JNIEnv* env, +static void android_view_RenderNode_setAlpha(JNIEnv* env, jobject clazz, jlong displayListPtr, float alpha) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); displayList->properties().setAlpha(alpha); } -static void android_view_DisplayList_setHasOverlappingRendering(JNIEnv* env, +static void android_view_RenderNode_setHasOverlappingRendering(JNIEnv* env, jobject clazz, jlong displayListPtr, bool hasOverlappingRendering) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); displayList->properties().setHasOverlappingRendering(hasOverlappingRendering); } -static void android_view_DisplayList_setTranslationX(JNIEnv* env, +static void android_view_RenderNode_setTranslationX(JNIEnv* env, jobject clazz, jlong displayListPtr, float tx) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); displayList->properties().setTranslationX(tx); } -static void android_view_DisplayList_setTranslationY(JNIEnv* env, +static void android_view_RenderNode_setTranslationY(JNIEnv* env, jobject clazz, jlong displayListPtr, float ty) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); displayList->properties().setTranslationY(ty); } -static void android_view_DisplayList_setTranslationZ(JNIEnv* env, +static void android_view_RenderNode_setTranslationZ(JNIEnv* env, jobject clazz, jlong displayListPtr, float tz) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); displayList->properties().setTranslationZ(tz); } -static void android_view_DisplayList_setRotation(JNIEnv* env, +static void android_view_RenderNode_setRotation(JNIEnv* env, jobject clazz, jlong displayListPtr, float rotation) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); displayList->properties().setRotation(rotation); } -static void android_view_DisplayList_setRotationX(JNIEnv* env, +static void android_view_RenderNode_setRotationX(JNIEnv* env, jobject clazz, jlong displayListPtr, float rx) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); displayList->properties().setRotationX(rx); } -static void android_view_DisplayList_setRotationY(JNIEnv* env, +static void android_view_RenderNode_setRotationY(JNIEnv* env, jobject clazz, jlong displayListPtr, float ry) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); displayList->properties().setRotationY(ry); } -static void android_view_DisplayList_setScaleX(JNIEnv* env, +static void android_view_RenderNode_setScaleX(JNIEnv* env, jobject clazz, jlong displayListPtr, float sx) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); displayList->properties().setScaleX(sx); } -static void android_view_DisplayList_setScaleY(JNIEnv* env, +static void android_view_RenderNode_setScaleY(JNIEnv* env, jobject clazz, jlong displayListPtr, float sy) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); displayList->properties().setScaleY(sy); } -static void android_view_DisplayList_setTransformationInfo(JNIEnv* env, +static void android_view_RenderNode_setTransformationInfo(JNIEnv* env, jobject clazz, jlong displayListPtr, float alpha, float translationX, float translationY, float translationZ, float rotation, float rotationX, float rotationY, float scaleX, float scaleY) { @@ -216,158 +216,158 @@ static void android_view_DisplayList_setTransformationInfo(JNIEnv* env, displayList->properties().setScaleY(scaleY); } -static void android_view_DisplayList_setPivotX(JNIEnv* env, +static void android_view_RenderNode_setPivotX(JNIEnv* env, jobject clazz, jlong displayListPtr, float px) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); displayList->properties().setPivotX(px); } -static void android_view_DisplayList_setPivotY(JNIEnv* env, +static void android_view_RenderNode_setPivotY(JNIEnv* env, jobject clazz, jlong displayListPtr, float py) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); displayList->properties().setPivotY(py); } -static void android_view_DisplayList_setCameraDistance(JNIEnv* env, +static void android_view_RenderNode_setCameraDistance(JNIEnv* env, jobject clazz, jlong displayListPtr, float distance) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); displayList->properties().setCameraDistance(distance); } -static void android_view_DisplayList_setLeft(JNIEnv* env, +static void android_view_RenderNode_setLeft(JNIEnv* env, jobject clazz, jlong displayListPtr, int left) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); displayList->properties().setLeft(left); } -static void android_view_DisplayList_setTop(JNIEnv* env, +static void android_view_RenderNode_setTop(JNIEnv* env, jobject clazz, jlong displayListPtr, int top) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); displayList->properties().setTop(top); } -static void android_view_DisplayList_setRight(JNIEnv* env, +static void android_view_RenderNode_setRight(JNIEnv* env, jobject clazz, jlong displayListPtr, int right) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); displayList->properties().setRight(right); } -static void android_view_DisplayList_setBottom(JNIEnv* env, +static void android_view_RenderNode_setBottom(JNIEnv* env, jobject clazz, jlong displayListPtr, int bottom) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); displayList->properties().setBottom(bottom); } -static void android_view_DisplayList_setLeftTopRightBottom(JNIEnv* env, +static void android_view_RenderNode_setLeftTopRightBottom(JNIEnv* env, jobject clazz, jlong displayListPtr, int left, int top, int right, int bottom) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); displayList->properties().setLeftTopRightBottom(left, top, right, bottom); } -static void android_view_DisplayList_offsetLeftAndRight(JNIEnv* env, +static void android_view_RenderNode_offsetLeftAndRight(JNIEnv* env, jobject clazz, jlong displayListPtr, float offset) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); displayList->properties().offsetLeftRight(offset); } -static void android_view_DisplayList_offsetTopAndBottom(JNIEnv* env, +static void android_view_RenderNode_offsetTopAndBottom(JNIEnv* env, jobject clazz, jlong displayListPtr, float offset) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); displayList->properties().offsetTopBottom(offset); } -static jboolean android_view_DisplayList_hasOverlappingRendering(JNIEnv* env, +static jboolean android_view_RenderNode_hasOverlappingRendering(JNIEnv* env, jobject clazz, jlong displayListPtr) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); return displayList->properties().hasOverlappingRendering(); } -static jfloat android_view_DisplayList_getAlpha(JNIEnv* env, +static jfloat android_view_RenderNode_getAlpha(JNIEnv* env, jobject clazz, jlong displayListPtr) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); return displayList->properties().getAlpha(); } -static jfloat android_view_DisplayList_getLeft(JNIEnv* env, +static jfloat android_view_RenderNode_getLeft(JNIEnv* env, jobject clazz, jlong displayListPtr) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); return displayList->properties().getLeft(); } -static jfloat android_view_DisplayList_getTop(JNIEnv* env, +static jfloat android_view_RenderNode_getTop(JNIEnv* env, jobject clazz, jlong displayListPtr) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); return displayList->properties().getTop(); } -static jfloat android_view_DisplayList_getRight(JNIEnv* env, +static jfloat android_view_RenderNode_getRight(JNIEnv* env, jobject clazz, jlong displayListPtr) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); return displayList->properties().getRight(); } -static jfloat android_view_DisplayList_getBottom(JNIEnv* env, +static jfloat android_view_RenderNode_getBottom(JNIEnv* env, jobject clazz, jlong displayListPtr) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); return displayList->properties().getBottom(); } -static jfloat android_view_DisplayList_getCameraDistance(JNIEnv* env, +static jfloat android_view_RenderNode_getCameraDistance(JNIEnv* env, jobject clazz, jlong displayListPtr) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); return displayList->properties().getCameraDistance(); } -static jfloat android_view_DisplayList_getScaleX(JNIEnv* env, +static jfloat android_view_RenderNode_getScaleX(JNIEnv* env, jobject clazz, jlong displayListPtr) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); return displayList->properties().getScaleX(); } -static jfloat android_view_DisplayList_getScaleY(JNIEnv* env, +static jfloat android_view_RenderNode_getScaleY(JNIEnv* env, jobject clazz, jlong displayListPtr) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); return displayList->properties().getScaleY(); } -static jfloat android_view_DisplayList_getTranslationX(JNIEnv* env, +static jfloat android_view_RenderNode_getTranslationX(JNIEnv* env, jobject clazz, jlong displayListPtr) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); return displayList->properties().getTranslationX(); } -static jfloat android_view_DisplayList_getTranslationY(JNIEnv* env, +static jfloat android_view_RenderNode_getTranslationY(JNIEnv* env, jobject clazz, jlong displayListPtr) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); return displayList->properties().getTranslationY(); } -static jfloat android_view_DisplayList_getRotation(JNIEnv* env, +static jfloat android_view_RenderNode_getRotation(JNIEnv* env, jobject clazz, jlong displayListPtr) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); return displayList->properties().getRotation(); } -static jfloat android_view_DisplayList_getRotationX(JNIEnv* env, +static jfloat android_view_RenderNode_getRotationX(JNIEnv* env, jobject clazz, jlong displayListPtr) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); return displayList->properties().getRotationX(); } -static jfloat android_view_DisplayList_getRotationY(JNIEnv* env, +static jfloat android_view_RenderNode_getRotationY(JNIEnv* env, jobject clazz, jlong displayListPtr) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); return displayList->properties().getRotationY(); } -static jfloat android_view_DisplayList_getPivotX(JNIEnv* env, +static jfloat android_view_RenderNode_getPivotX(JNIEnv* env, jobject clazz, jlong displayListPtr) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); return displayList->properties().getPivotX(); } -static jfloat android_view_DisplayList_getPivotY(JNIEnv* env, +static jfloat android_view_RenderNode_getPivotY(JNIEnv* env, jobject clazz, jlong displayListPtr) { RenderNode* displayList = reinterpret_cast<RenderNode*>(displayListPtr); return displayList->properties().getPivotY(); @@ -379,67 +379,67 @@ static jfloat android_view_DisplayList_getPivotY(JNIEnv* env, // JNI Glue // ---------------------------------------------------------------------------- -const char* const kClassPathName = "android/view/DisplayList"; +const char* const kClassPathName = "android/view/RenderNode"; static JNINativeMethod gMethods[] = { #ifdef USE_OPENGL_RENDERER - { "nCreate", "()J", (void*) android_view_DisplayList_create }, - { "nDestroyDisplayList", "(J)V", (void*) android_view_DisplayList_destroyDisplayList }, + { "nCreate", "()J", (void*) android_view_RenderNode_create }, + { "nDestroyDisplayList", "(J)V", (void*) android_view_RenderNode_destroyDisplayList }, { "nSetDisplayListName", "(JLjava/lang/String;)V", - (void*) android_view_DisplayList_setDisplayListName }, - { "nOutput", "(J)V", (void*) android_view_DisplayList_output }, - - { "nSetCaching", "(JZ)V", (void*) android_view_DisplayList_setCaching }, - { "nSetStaticMatrix", "(JJ)V", (void*) android_view_DisplayList_setStaticMatrix }, - { "nSetAnimationMatrix", "(JJ)V", (void*) android_view_DisplayList_setAnimationMatrix }, - { "nSetClipToBounds", "(JZ)V", (void*) android_view_DisplayList_setClipToBounds }, - { "nSetIsolatedZVolume", "(JZ)V", (void*) android_view_DisplayList_setIsolatedZVolume }, - { "nSetProjectBackwards", "(JZ)V", (void*) android_view_DisplayList_setProjectBackwards }, - { "nSetProjectionReceiver","(JZ)V", (void*) android_view_DisplayList_setProjectionReceiver }, - { "nSetOutline", "(JJ)V", (void*) android_view_DisplayList_setOutline }, - { "nSetClipToOutline", "(JZ)V", (void*) android_view_DisplayList_setClipToOutline }, - { "nSetCastsShadow", "(JZ)V", (void*) android_view_DisplayList_setCastsShadow }, - { "nSetUsesGlobalCamera", "(JZ)V", (void*) android_view_DisplayList_setUsesGlobalCamera }, - { "nSetAlpha", "(JF)V", (void*) android_view_DisplayList_setAlpha }, + (void*) android_view_RenderNode_setDisplayListName }, + { "nOutput", "(J)V", (void*) android_view_RenderNode_output }, + + { "nSetCaching", "(JZ)V", (void*) android_view_RenderNode_setCaching }, + { "nSetStaticMatrix", "(JJ)V", (void*) android_view_RenderNode_setStaticMatrix }, + { "nSetAnimationMatrix", "(JJ)V", (void*) android_view_RenderNode_setAnimationMatrix }, + { "nSetClipToBounds", "(JZ)V", (void*) android_view_RenderNode_setClipToBounds }, + { "nSetIsolatedZVolume", "(JZ)V", (void*) android_view_RenderNode_setIsolatedZVolume }, + { "nSetProjectBackwards", "(JZ)V", (void*) android_view_RenderNode_setProjectBackwards }, + { "nSetProjectionReceiver","(JZ)V", (void*) android_view_RenderNode_setProjectionReceiver }, + { "nSetOutline", "(JJ)V", (void*) android_view_RenderNode_setOutline }, + { "nSetClipToOutline", "(JZ)V", (void*) android_view_RenderNode_setClipToOutline }, + { "nSetCastsShadow", "(JZ)V", (void*) android_view_RenderNode_setCastsShadow }, + { "nSetUsesGlobalCamera", "(JZ)V", (void*) android_view_RenderNode_setUsesGlobalCamera }, + { "nSetAlpha", "(JF)V", (void*) android_view_RenderNode_setAlpha }, { "nSetHasOverlappingRendering", "(JZ)V", - (void*) android_view_DisplayList_setHasOverlappingRendering }, - { "nSetTranslationX", "(JF)V", (void*) android_view_DisplayList_setTranslationX }, - { "nSetTranslationY", "(JF)V", (void*) android_view_DisplayList_setTranslationY }, - { "nSetTranslationZ", "(JF)V", (void*) android_view_DisplayList_setTranslationZ }, - { "nSetRotation", "(JF)V", (void*) android_view_DisplayList_setRotation }, - { "nSetRotationX", "(JF)V", (void*) android_view_DisplayList_setRotationX }, - { "nSetRotationY", "(JF)V", (void*) android_view_DisplayList_setRotationY }, - { "nSetScaleX", "(JF)V", (void*) android_view_DisplayList_setScaleX }, - { "nSetScaleY", "(JF)V", (void*) android_view_DisplayList_setScaleY }, + (void*) android_view_RenderNode_setHasOverlappingRendering }, + { "nSetTranslationX", "(JF)V", (void*) android_view_RenderNode_setTranslationX }, + { "nSetTranslationY", "(JF)V", (void*) android_view_RenderNode_setTranslationY }, + { "nSetTranslationZ", "(JF)V", (void*) android_view_RenderNode_setTranslationZ }, + { "nSetRotation", "(JF)V", (void*) android_view_RenderNode_setRotation }, + { "nSetRotationX", "(JF)V", (void*) android_view_RenderNode_setRotationX }, + { "nSetRotationY", "(JF)V", (void*) android_view_RenderNode_setRotationY }, + { "nSetScaleX", "(JF)V", (void*) android_view_RenderNode_setScaleX }, + { "nSetScaleY", "(JF)V", (void*) android_view_RenderNode_setScaleY }, { "nSetTransformationInfo","(JFFFFFFFFF)V", - (void*) android_view_DisplayList_setTransformationInfo }, - { "nSetPivotX", "(JF)V", (void*) android_view_DisplayList_setPivotX }, - { "nSetPivotY", "(JF)V", (void*) android_view_DisplayList_setPivotY }, - { "nSetCameraDistance", "(JF)V", (void*) android_view_DisplayList_setCameraDistance }, - { "nSetLeft", "(JI)V", (void*) android_view_DisplayList_setLeft }, - { "nSetTop", "(JI)V", (void*) android_view_DisplayList_setTop }, - { "nSetRight", "(JI)V", (void*) android_view_DisplayList_setRight }, - { "nSetBottom", "(JI)V", (void*) android_view_DisplayList_setBottom }, - { "nSetLeftTopRightBottom","(JIIII)V", (void*) android_view_DisplayList_setLeftTopRightBottom }, - { "nOffsetLeftAndRight", "(JF)V", (void*) android_view_DisplayList_offsetLeftAndRight }, - { "nOffsetTopAndBottom", "(JF)V", (void*) android_view_DisplayList_offsetTopAndBottom }, - - { "nHasOverlappingRendering", "(J)Z", (void*) android_view_DisplayList_hasOverlappingRendering }, - { "nGetAlpha", "(J)F", (void*) android_view_DisplayList_getAlpha }, - { "nGetLeft", "(J)F", (void*) android_view_DisplayList_getLeft }, - { "nGetTop", "(J)F", (void*) android_view_DisplayList_getTop }, - { "nGetRight", "(J)F", (void*) android_view_DisplayList_getRight }, - { "nGetBottom", "(J)F", (void*) android_view_DisplayList_getBottom }, - { "nGetCameraDistance", "(J)F", (void*) android_view_DisplayList_getCameraDistance }, - { "nGetScaleX", "(J)F", (void*) android_view_DisplayList_getScaleX }, - { "nGetScaleY", "(J)F", (void*) android_view_DisplayList_getScaleY }, - { "nGetTranslationX", "(J)F", (void*) android_view_DisplayList_getTranslationX }, - { "nGetTranslationY", "(J)F", (void*) android_view_DisplayList_getTranslationY }, - { "nGetRotation", "(J)F", (void*) android_view_DisplayList_getRotation }, - { "nGetRotationX", "(J)F", (void*) android_view_DisplayList_getRotationX }, - { "nGetRotationY", "(J)F", (void*) android_view_DisplayList_getRotationY }, - { "nGetPivotX", "(J)F", (void*) android_view_DisplayList_getPivotX }, - { "nGetPivotY", "(J)F", (void*) android_view_DisplayList_getPivotY }, + (void*) android_view_RenderNode_setTransformationInfo }, + { "nSetPivotX", "(JF)V", (void*) android_view_RenderNode_setPivotX }, + { "nSetPivotY", "(JF)V", (void*) android_view_RenderNode_setPivotY }, + { "nSetCameraDistance", "(JF)V", (void*) android_view_RenderNode_setCameraDistance }, + { "nSetLeft", "(JI)V", (void*) android_view_RenderNode_setLeft }, + { "nSetTop", "(JI)V", (void*) android_view_RenderNode_setTop }, + { "nSetRight", "(JI)V", (void*) android_view_RenderNode_setRight }, + { "nSetBottom", "(JI)V", (void*) android_view_RenderNode_setBottom }, + { "nSetLeftTopRightBottom","(JIIII)V", (void*) android_view_RenderNode_setLeftTopRightBottom }, + { "nOffsetLeftAndRight", "(JF)V", (void*) android_view_RenderNode_offsetLeftAndRight }, + { "nOffsetTopAndBottom", "(JF)V", (void*) android_view_RenderNode_offsetTopAndBottom }, + + { "nHasOverlappingRendering", "(J)Z", (void*) android_view_RenderNode_hasOverlappingRendering }, + { "nGetAlpha", "(J)F", (void*) android_view_RenderNode_getAlpha }, + { "nGetLeft", "(J)F", (void*) android_view_RenderNode_getLeft }, + { "nGetTop", "(J)F", (void*) android_view_RenderNode_getTop }, + { "nGetRight", "(J)F", (void*) android_view_RenderNode_getRight }, + { "nGetBottom", "(J)F", (void*) android_view_RenderNode_getBottom }, + { "nGetCameraDistance", "(J)F", (void*) android_view_RenderNode_getCameraDistance }, + { "nGetScaleX", "(J)F", (void*) android_view_RenderNode_getScaleX }, + { "nGetScaleY", "(J)F", (void*) android_view_RenderNode_getScaleY }, + { "nGetTranslationX", "(J)F", (void*) android_view_RenderNode_getTranslationX }, + { "nGetTranslationY", "(J)F", (void*) android_view_RenderNode_getTranslationY }, + { "nGetRotation", "(J)F", (void*) android_view_RenderNode_getRotation }, + { "nGetRotationX", "(J)F", (void*) android_view_RenderNode_getRotationX }, + { "nGetRotationY", "(J)F", (void*) android_view_RenderNode_getRotationY }, + { "nGetPivotX", "(J)F", (void*) android_view_RenderNode_getPivotX }, + { "nGetPivotY", "(J)F", (void*) android_view_RenderNode_getPivotY }, #endif }; @@ -456,7 +456,7 @@ static JNINativeMethod gMethods[] = { #define GET_METHOD_ID(var, clazz, methodName, methodDescriptor) #endif -int register_android_view_DisplayList(JNIEnv* env) { +int register_android_view_RenderNode(JNIEnv* env) { return AndroidRuntime::registerNativeMethods(env, kClassPathName, gMethods, NELEM(gMethods)); } diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ProjectionActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ProjectionActivity.java index 208c387..5ba3ad9 100644 --- a/tests/HwAccelerationTest/src/com/android/test/hwui/ProjectionActivity.java +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ProjectionActivity.java @@ -8,7 +8,7 @@ import android.os.Bundle; import android.app.Activity; import android.util.AttributeSet; -import android.view.DisplayList; +import android.view.RenderNode; import android.view.View; import android.widget.LinearLayout; @@ -46,7 +46,7 @@ public class ProjectionActivity extends Activity { } private void setProject(boolean value) { - DisplayList displayList = getDisplayList(); + RenderNode displayList = getDisplayList(); if (displayList != null) { displayList.setProjectBackwards(value); } diff --git a/tests/RenderThreadTest/src/com/example/renderthread/MainActivity.java b/tests/RenderThreadTest/src/com/example/renderthread/MainActivity.java index a39aba8..09531fd 100644 --- a/tests/RenderThreadTest/src/com/example/renderthread/MainActivity.java +++ b/tests/RenderThreadTest/src/com/example/renderthread/MainActivity.java @@ -7,7 +7,7 @@ import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.os.SystemClock; -import android.view.DisplayList; +import android.view.RenderNode; import android.view.HardwareRenderer; import android.view.ThreadedRenderer; import android.view.View; @@ -70,7 +70,7 @@ public class MainActivity extends Activity implements OnItemClickListener { private static final TimeInterpolator sDefaultInterpolator = new AccelerateDecelerateInterpolator(); - DisplayList mDisplayList; + RenderNode mDisplayList; float mFromValue; float mDelta; long mDuration = DURATION * 2; |