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

Commit a1cff504 authored by Chet Haase's avatar Chet Haase
Browse files

Handle view properties at the native level

Basic functionality of handling View properties (transforms,
left/right/top/bottom, and alpha) at the native DisplayList level.
This logic is disabled for now (via compile-time flags in View.java and
DisplayListRenderer.h) as we continue work on it (there is no advantage
to the new approach until we optimize invalidation and rendering paths
to use the new code path).

Change-Id: I370c8d21fbd291be415f55515ab8dced6f6d51a3
parent bdc5afee
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -8034,6 +8034,9 @@ package android.graphics {
    ctor public Camera();
    method public void applyToCanvas(android.graphics.Canvas);
    method public float dotWithNormal(float, float, float);
    method public float getLocationX();
    method public float getLocationY();
    method public float getLocationZ();
    method public void getMatrix(android.graphics.Matrix);
    method public void restore();
    method public void rotate(float, float, float);
@@ -23195,6 +23198,7 @@ package android.view {
    method public final int getBottom();
    method protected float getBottomFadingEdgeStrength();
    method protected int getBottomPaddingOffset();
    method public float getCameraDistance();
    method public java.lang.CharSequence getContentDescription();
    method public final android.content.Context getContext();
    method protected android.view.ContextMenu.ContextMenuInfo getContextMenuInfo();
+200 −0
Original line number Diff line number Diff line
@@ -70,4 +70,204 @@ public abstract class DisplayList {
     * @return The size of this display list in bytes
     */
    public abstract int getSize();

    ///////////////////////////////////////////////////////////////////////////
    // DisplayList Property Setters
    ///////////////////////////////////////////////////////////////////////////

    /**
     * Set the caching property on the DisplayList, which indicates whether the DisplayList
     * holds a layer. Layer DisplayLists should avoid creating an alpha layer, since alpha is
     * handled in the drawLayer operation directly (and more efficiently).
     *
     * @param caching true if the DisplayList represents a hardware layer, false otherwise.
     */
    public abstract void setCaching(boolean caching);

    /**
     * Set whether the DisplayList should clip itself to its bounds. This property is controlled by
     * the view's parent.
     *
     * @param clipChildren true if the DisplayList should clip to its bounds
     */
    public abstract void setClipChildren(boolean clipChildren);

    /**
     * Set the application scale on the DisplayList. This scale is incurred by applications that
     * are auto-scaled for compatibility reasons. By default, the value is 1 (unscaled).
     *
     * @param scale The scaling factor
     */
    public abstract void setApplicationScale(float scale);

    /**
     * Sets the alpha value for the DisplayList
     *
     * @param alpha The translucency of the DisplayList
     * @see View#setAlpha(float)
     */
    public abstract void setAlpha(float alpha);

    /**
     * Sets the translationX value for the DisplayList
     *
     * @param translationX The translationX value of the DisplayList
     * @see View#setTranslationX(float)
     */
    public abstract void setTranslationX(float translationX);

    /**
     * Sets the translationY value for the DisplayList
     *
     * @param translationY The translationY value of the DisplayList
     * @see View#setTranslationY(float)
     */
    public abstract void setTranslationY(float translationY);

    /**
     * Sets the rotation value for the DisplayList
     *
     * @param rotation The rotation value of the DisplayList
     * @see View#setRotation(float)
     */
    public abstract void setRotation(float rotation);

    /**
     * Sets the rotationX value for the DisplayList
     *
     * @param rotationX The rotationX value of the DisplayList
     * @see View#setRotationX(float)
     */
    public abstract void setRotationX(float rotationX);

    /**
     * Sets the rotationY value for the DisplayList
     *
     * @param rotationY The rotationY value of the DisplayList
     * @see View#setRotationY(float)
     */
    public abstract void setRotationY(float rotationY);

    /**
     * Sets the scaleX value for the DisplayList
     *
     * @param scaleX The scaleX value of the DisplayList
     * @see View#setScaleX(float)
     */
    public abstract void setScaleX(float scaleX);

    /**
     * Sets the scaleY value for the DisplayList
     *
     * @param scaleY The scaleY value of the DisplayList
     * @see View#setScaleY(float)
     */
    public abstract void setScaleY(float scaleY);

    /**
     * Sets all of the transform-related values of the View onto the DisplayList
     *
     * @param alpha The alpha value of the DisplayList
     * @param translationX The translationX value of the DisplayList
     * @param translationY The translationY value of the DisplayList
     * @param rotation The rotation value of the DisplayList
     * @param rotationX The rotationX value of the DisplayList
     * @param rotationY The rotationY value of the DisplayList
     * @param scaleX The scaleX value of the DisplayList
     * @param scaleY The scaleY value of the DisplayList
     */
    public abstract void setTransformationInfo(float alpha, float translationX, float translationY,
            float rotation, float rotationX, float rotationY, float scaleX, float scaleY);

    /**
     * Sets the pivotX value for the DisplayList
     *
     * @param pivotX The pivotX value of the DisplayList
     * @see View#setPivotX(float)
     */
    public abstract void setPivotX(float pivotX);

    /**
     * Sets the pivotY value for the DisplayList
     *
     * @param pivotY The pivotY value of the DisplayList
     * @see View#setPivotY(float)
     */
    public abstract void setPivotY(float pivotY);

    /**
     * Sets the camera distance for the DisplayList
     *
     * @param distance The distance in z of the camera of the DisplayList
     * @see View#setCameraDistance(float)
     */
    public abstract void setCameraDistance(float distance);

    /**
     * Sets the left value for the DisplayList
     *
     * @param left The left value of the DisplayList
     * @see View#setLeft(int)
     */
    public abstract void setLeft(int left);

    /**
     * Sets the top value for the DisplayList
     *
     * @param top The top value of the DisplayList
     * @see View#setTop(int)
     */
    public abstract void setTop(int top);

    /**
     * Sets the right value for the DisplayList
     *
     * @param right The right value of the DisplayList
     * @see View#setRight(int)
     */
    public abstract void setRight(int right);

    /**
     * Sets the bottom value for the DisplayList
     *
     * @param bottom The bottom value of the DisplayList
     * @see View#setBottom(int)
     */
    public abstract void setBottom(int bottom);

    /**
     * Sets the left and top values for the DisplayList
     *
     * @param left The left value of the DisplayList
     * @param top The top value of the DisplayList
     * @see View#setLeft(int)
     * @see View#setTop(int)
     */
    public abstract void setLeftTop(int left, int top);

    /**
     * Sets the left and top values for the DisplayList
     *
     * @param left The left value of the DisplayList
     * @param top The top value of the DisplayList
     * @see View#setLeft(int)
     * @see View#setTop(int)
     */
    public abstract void setLeftTopRightBottom(int left, int top, int right, int bottom);

    /**
     * Offsets the left and right values for the DisplayList
     *
     * @param offset The amount that the left and right values of the DisplayList are offset
     * @see View#offsetLeftAndRight(int)
     */
    public abstract void offsetLeftRight(int offset);

    /**
     * Offsets the top and bottom values for the DisplayList
     *
     * @param offset The amount that the top and bottom values of the DisplayList are offset
     * @see View#offsetTopAndBottom(int)
     */
    public abstract void offsetTopBottom(int offset);
}
+245 −0
Original line number Diff line number Diff line
@@ -96,6 +96,251 @@ class GLES20DisplayList extends DisplayList {
        return GLES20Canvas.getDisplayListSize(mFinalizer.mNativeDisplayList);
    }

    ///////////////////////////////////////////////////////////////////////////
    // Native View Properties
    ///////////////////////////////////////////////////////////////////////////

    @Override
    public void setCaching(boolean caching) {
        try {
            nSetCaching(getNativeDisplayList(), caching);
        } catch (IllegalStateException e) {
            // invalid DisplayList okay: we'll set current values the next time we render to it
        }
    }

    @Override
    public void setClipChildren(boolean clipChildren) {
        try {
            nSetClipChildren(getNativeDisplayList(), clipChildren);
        } catch (IllegalStateException e) {
            // invalid DisplayList okay: we'll set current values the next time we render to it
        }
    }

    @Override
    public void setApplicationScale(float scale) {
        try {
            nSetApplicationScale(getNativeDisplayList(), scale);
        } catch (IllegalStateException e) {
            // invalid DisplayList okay: we'll set current values the next time we render to it
        }
    }

    @Override
    public void setAlpha(float alpha) {
        try {
            nSetAlpha(getNativeDisplayList(), alpha);
        } catch (IllegalStateException e) {
            // invalid DisplayList okay: we'll set current values the next time we render to it
        }
    }

    @Override
    public void setTranslationX(float translationX) {
        try {
            nSetTranslationX(getNativeDisplayList(), translationX);
        } catch (IllegalStateException e) {
            // invalid DisplayList okay: we'll set current values the next time we render to it
        }
    }

    @Override
    public void setTranslationY(float translationY) {
        try {
            nSetTranslationY(getNativeDisplayList(), translationY);
        } catch (IllegalStateException e) {
            // invalid DisplayList okay: we'll set current values the next time we render to it
        }
    }

    @Override
    public void setRotation(float rotation) {
        try {
            nSetRotation(getNativeDisplayList(), rotation);
        } catch (IllegalStateException e) {
            // invalid DisplayList okay: we'll set current values the next time we render to it
        }
    }

    @Override
    public void setRotationX(float rotationX) {
        try {
            nSetRotationX(getNativeDisplayList(), rotationX);
        } catch (IllegalStateException e) {
            // invalid DisplayList okay: we'll set current values the next time we render to it
        }
    }

    @Override
    public void setRotationY(float rotationY) {
        try {
            nSetRotationY(getNativeDisplayList(), rotationY);
        } catch (IllegalStateException e) {
            // invalid DisplayList okay: we'll set current values the next time we render to it
        }
    }

    @Override
    public void setScaleX(float scaleX) {
        try {
            nSetScaleX(getNativeDisplayList(), scaleX);
        } catch (IllegalStateException e) {
            // invalid DisplayList okay: we'll set current values the next time we render to it
        }
    }

    @Override
    public void setScaleY(float scaleY) {
        try {
            nSetScaleY(getNativeDisplayList(), scaleY);
        } catch (IllegalStateException e) {
            // invalid DisplayList okay: we'll set current values the next time we render to it
        }
    }

    @Override
    public void setTransformationInfo(float alpha, float translationX, float translationY,
            float rotation, float rotationX, float rotationY, float scaleX, float scaleY) {
        try {
            nSetTransformationInfo(getNativeDisplayList(), alpha, translationX, translationY,
                    rotation, rotationX, rotationY, scaleX, scaleY);
        } catch (IllegalStateException e) {
            // invalid DisplayList okay: we'll set current values the next time we render to it
        }
    }

    @Override
    public void setPivotX(float pivotX) {
        try {
            nSetPivotX(getNativeDisplayList(), pivotX);
        } catch (IllegalStateException e) {
            // invalid DisplayList okay: we'll set current values the next time we render to it
        }
    }

    @Override
    public void setPivotY(float pivotY) {
        try {
            nSetPivotY(getNativeDisplayList(), pivotY);
        } catch (IllegalStateException e) {
            // invalid DisplayList okay: we'll set current values the next time we render to it
        }
    }

    @Override
    public void setCameraDistance(float distance) {
        try {
            nSetCameraDistance(getNativeDisplayList(), distance);
        } catch (IllegalStateException e) {
            // invalid DisplayList okay: we'll set current values the next time we render to it
        }
    }

    @Override
    public void setLeft(int left) {
        try {
            nSetLeft(getNativeDisplayList(), left);
        } catch (IllegalStateException e) {
            // invalid DisplayList okay: we'll set current values the next time we render to it
        }
    }

    @Override
    public void setTop(int top) {
        try {
            nSetTop(getNativeDisplayList(), top);
        } catch (IllegalStateException e) {
            // invalid DisplayList okay: we'll set current values the next time we render to it
        }
    }

    @Override
    public void setRight(int right) {
        try {
            nSetRight(getNativeDisplayList(), right);
        } catch (IllegalStateException e) {
            // invalid DisplayList okay: we'll set current values the next time we render to it
        }
    }

    @Override
    public void setBottom(int bottom) {
        try {
            nSetBottom(getNativeDisplayList(), bottom);
        } catch (IllegalStateException e) {
            // invalid DisplayList okay: we'll set current values the next time we render to it
        }
    }

    @Override
    public void setLeftTop(int left, int top) {
        try {
            nSetLeftTop(getNativeDisplayList(), left, top);
        } catch (IllegalStateException e) {
            // invalid DisplayList okay: we'll set current values the next time we render to it
        }
    }

    @Override
    public void setLeftTopRightBottom(int left, int top, int right, int bottom) {
        try {
            nSetLeftTopRightBottom(getNativeDisplayList(), left, top, right, bottom);
        } catch (IllegalStateException e) {
            // invalid DisplayList okay: we'll set current values the next time we render to it
        }
    }

    @Override
    public void offsetLeftRight(int offset) {
        try {
            nOffsetLeftRight(getNativeDisplayList(), offset);
        } catch (IllegalStateException e) {
            // invalid DisplayList okay: we'll set current values the next time we render to it
        }
    }

    @Override
    public void offsetTopBottom(int offset) {
        try {
            nOffsetTopBottom(getNativeDisplayList(), offset);
        } catch (IllegalStateException e) {
            // invalid DisplayList okay: we'll set current values the next time we render to it
        }
    }

    private static native void nOffsetTopBottom(int displayList, int offset);
    private static native void nOffsetLeftRight(int displayList, int offset);
    private static native void nSetLeftTopRightBottom(int displayList, int left, int top,
            int right, int bottom);
    private static native void nSetLeftTop(int displayList, int left, int top);
    private static native void nSetBottom(int displayList, int bottom);
    private static native void nSetRight(int displayList, int right);
    private static native void nSetTop(int displayList, int top);
    private static native void nSetLeft(int displayList, int left);
    private static native void nSetCameraDistance(int displayList, float distance);
    private static native void nSetPivotY(int displayList, float pivotY);
    private static native void nSetPivotX(int displayList, float pivotX);
    private static native void nSetCaching(int displayList, boolean caching);
    private static native void nSetClipChildren(int displayList, boolean clipChildren);
    private static native void nSetApplicationScale(int displayList, float scale);
    private static native void nSetAlpha(int displayList, float alpha);
    private static native void nSetTranslationX(int displayList, float translationX);
    private static native void nSetTranslationY(int displayList, float translationY);
    private static native void nSetRotation(int displayList, float rotation);
    private static native void nSetRotationX(int displayList, float rotationX);
    private static native void nSetRotationY(int displayList, float rotationY);
    private static native void nSetScaleX(int displayList, float scaleX);
    private static native void nSetScaleY(int displayList, float scaleY);
    private static native void nSetTransformationInfo(int displayList, float alpha,
            float translationX, float translationY, float rotation, float rotationX,
            float rotationY, float scaleX, float scaleY);


    ///////////////////////////////////////////////////////////////////////////
    // Finalization
    ///////////////////////////////////////////////////////////////////////////

    private static class DisplayListFinalizer {
        final int mNativeDisplayList;

+19 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ abstract class HardwareLayer {
    
    int mWidth;
    int mHeight;
    DisplayList mDisplayList;

    boolean mOpaque;

@@ -78,6 +79,24 @@ abstract class HardwareLayer {
        return mHeight;
    }

    /**
     * Returns the DisplayList for the layer.
     *
     * @return The DisplayList of the hardware layer
     */
    DisplayList getDisplayList() {
        return mDisplayList;
    }

    /**
     * Sets the DisplayList for the layer.
     *
     * @param displayList The new DisplayList for this layer
     */
    void setDisplayList(DisplayList displayList) {
        mDisplayList = displayList;
    }

    /**
     * Returns whether or not this layer is opaque.
     * 
+265 −62

File changed.

Preview size limit exceeded, changes collapsed.

Loading