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

Commit ef4c0c9f authored by Chris Craik's avatar Chris Craik Committed by Android (Google) Code Review
Browse files

Merge "Move most TransformationInfo properties to RenderNode"

parents 537be409 49e6c739
Loading
Loading
Loading
Loading
+40 −40
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.view;

import android.annotation.NonNull;
import android.graphics.Matrix;
import android.graphics.Outline;

@@ -196,18 +197,20 @@ public class RenderNode {
    }

    /**
     * Starts recording the display list. All operations performed on the
     * returned canvas are recorded and stored in this display list.
     * Starts recording a display list for the render node. All
     * operations performed on the returned canvas are recorded and
     * stored in this display list.
     *
     * Calling this method will mark the display list invalid until
     * {@link #end()} is called. Only valid display lists can be replayed.
     * Calling this method will mark the render node invalid until
     * {@link #end(HardwareRenderer, HardwareCanvas)} is called.
     * Only valid render nodes can be replayed.
     *
     * @param width The width of the display list's viewport
     * @param height The height of the display list's viewport
     * @param width The width of the recording viewport
     * @param height The height of the recording viewport
     *
     * @return A canvas to record drawing operations.
     *
     * @see #end()
     * @see #end(HardwareRenderer, HardwareCanvas)
     * @see #isValid()
     */
    public HardwareCanvas start(int width, int height) {
@@ -284,7 +287,23 @@ public class RenderNode {
    }

    ///////////////////////////////////////////////////////////////////////////
    // DisplayList Property Setters
    // Matrix manipulation
    ///////////////////////////////////////////////////////////////////////////

    public boolean hasIdentityMatrix() {
        return nHasIdentityMatrix(mNativeDisplayList);
    }

    public void getMatrix(@NonNull Matrix outMatrix) {
        nGetTransformMatrix(mNativeDisplayList, outMatrix.native_instance);
    }

    public void getInverseMatrix(@NonNull Matrix outMatrix) {
        nGetInverseTransformMatrix(mNativeDisplayList, outMatrix.native_instance);
    }

    ///////////////////////////////////////////////////////////////////////////
    // RenderProperty Setters
    ///////////////////////////////////////////////////////////////////////////

    /**
@@ -301,7 +320,7 @@ public class RenderNode {
    }

    /**
     * Set whether the display list should clip itself to its bounds. This property is controlled by
     * Set whether the Render node should clip itself to its bounds. This property is controlled by
     * the view's parent.
     *
     * @param clipToBounds true if the display list should clip to its bounds
@@ -312,9 +331,7 @@ public class RenderNode {

    /**
     * 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.
     * closest ancestor display list containing a projection receiver.
     *
     * @param shouldProject true if the display list should be projected onto a
     *            containing volume.
@@ -373,9 +390,6 @@ public class RenderNode {
     * 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);
@@ -612,28 +626,6 @@ public class RenderNode {
        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
     *
@@ -676,6 +668,10 @@ public class RenderNode {
        return nGetPivotY(mNativeDisplayList);
    }

    public boolean isPivotExplicitlySet() {
        return nIsPivotExplicitlySet(mNativeDisplayList);
    }

    /**
     * Sets the camera distance for the display list. Refer to
     * {@link View#setCameraDistance(float)} for more information on how to
@@ -842,6 +838,12 @@ public class RenderNode {
    private static native void nDestroyDisplayList(long displayList);
    private static native void nSetDisplayListName(long displayList, String name);

    // Matrix

    private static native void nGetTransformMatrix(long displayList, long nativeMatrix);
    private static native void nGetInverseTransformMatrix(long displayList, long nativeMatrix);
    private static native boolean nHasIdentityMatrix(long displayList);

    // Properties

    private static native void nOffsetTopAndBottom(long displayList, float offset);
@@ -877,9 +879,6 @@ public class RenderNode {
    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);

@@ -898,6 +897,7 @@ public class RenderNode {
    private static native float nGetRotation(long displayList);
    private static native float nGetRotationX(long displayList);
    private static native float nGetRotationY(long displayList);
    private static native boolean nIsPivotExplicitlySet(long displayList);
    private static native float nGetPivotX(long displayList);
    private static native float nGetPivotY(long displayList);
    private static native void nOutput(long displayList);
+137 −489

File changed.

Preview size limit exceeded, changes collapsed.

+5 −5
Original line number Diff line number Diff line
@@ -4449,7 +4449,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
     *
     * @hide
     */
    public void invalidateChildFast(View child, final Rect dirty) {
    public void damageChild(View child, final Rect dirty) {
        ViewParent parent = this;

        final AttachInfo attachInfo = mAttachInfo;
@@ -4472,7 +4472,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
                        parentVG.invalidate();
                        parent = null;
                    } else {
                        parent = parentVG.invalidateChildInParentFast(left, top, dirty);
                        parent = parentVG.damageChildInParent(left, top, dirty);
                        left = parentVG.mLeft;
                        top = parentVG.mTop;
                    }
@@ -4494,9 +4494,9 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
     *
     * @hide
     */
    protected ViewParent invalidateChildInParentFast(int left, int top, final Rect dirty) {
        if ((mPrivateFlags & PFLAG_DRAWN) == PFLAG_DRAWN ||
                (mPrivateFlags & PFLAG_DRAWING_CACHE_VALID) == PFLAG_DRAWING_CACHE_VALID) {
    protected ViewParent damageChildInParent(int left, int top, final Rect dirty) {
        if ((mPrivateFlags & PFLAG_DRAWN) != 0
                || (mPrivateFlags & PFLAG_DRAWING_CACHE_VALID) != 0) {
            dirty.offset(left - mScrollX, top - mScrollY);
            if ((mGroupFlags & FLAG_CLIP_CHILDREN) == 0) {
                dirty.union(0, 0, mRight - mLeft, mBottom - mTop);
+7 −3
Original line number Diff line number Diff line
@@ -290,7 +290,11 @@ public class ViewOverlay {
            }
        }

        public void invalidateChildFast(View child, final Rect dirty) {
        /**
         * @hide
         */
        @Override
        public void damageChild(View child, final Rect dirty) {
            if (mHostView != null) {
                // Note: This is not a "fast" invalidation. Would be nice to instead invalidate
                // using DisplayList properties and a dirty rect instead of causing a real
@@ -309,9 +313,9 @@ public class ViewOverlay {
         * @hide
         */
        @Override
        protected ViewParent invalidateChildInParentFast(int left, int top, Rect dirty) {
        protected ViewParent damageChildInParent(int left, int top, Rect dirty) {
            if (mHostView instanceof ViewGroup) {
                return ((ViewGroup) mHostView).invalidateChildInParentFast(left, top, dirty);
                return ((ViewGroup) mHostView).damageChildInParent(left, top, dirty);
            }
            return null;
        }
+23 −34
Original line number Diff line number Diff line
@@ -928,48 +928,38 @@ public class ViewPropertyAnimator {
        final RenderNode renderNode = mView.mRenderNode;
        switch (propertyConstant) {
            case TRANSLATION_X:
                info.mTranslationX = value;
                if (renderNode != null) renderNode.setTranslationX(value);
                renderNode.setTranslationX(value);
                break;
            case TRANSLATION_Y:
                info.mTranslationY = value;
                if (renderNode != null) renderNode.setTranslationY(value);
                renderNode.setTranslationY(value);
                break;
            case TRANSLATION_Z:
                info.mTranslationZ = value;
                if (renderNode != null) renderNode.setTranslationZ(value);
                renderNode.setTranslationZ(value);
                break;
            case ROTATION:
                info.mRotation = value;
                if (renderNode != null) renderNode.setRotation(value);
                renderNode.setRotation(value);
                break;
            case ROTATION_X:
                info.mRotationX = value;
                if (renderNode != null) renderNode.setRotationX(value);
                renderNode.setRotationX(value);
                break;
            case ROTATION_Y:
                info.mRotationY = value;
                if (renderNode != null) renderNode.setRotationY(value);
                renderNode.setRotationY(value);
                break;
            case SCALE_X:
                info.mScaleX = value;
                if (renderNode != null) renderNode.setScaleX(value);
                renderNode.setScaleX(value);
                break;
            case SCALE_Y:
                info.mScaleY = value;
                if (renderNode != null) renderNode.setScaleY(value);
                renderNode.setScaleY(value);
                break;
            case X:
                info.mTranslationX = value - mView.mLeft;
                if (renderNode != null) renderNode.setTranslationX(value - mView.mLeft);
                renderNode.setTranslationX(value - mView.mLeft);
                break;
            case Y:
                info.mTranslationY = value - mView.mTop;
                if (renderNode != null) renderNode.setTranslationY(value - mView.mTop);
                renderNode.setTranslationY(value - mView.mTop);
                break;
            case ALPHA:
                info.mAlpha = value;
                if (renderNode != null) renderNode.setAlpha(value);
                renderNode.setAlpha(value);
                break;
        }
    }
@@ -981,30 +971,30 @@ public class ViewPropertyAnimator {
     * @return float The value of the named property
     */
    private float getValue(int propertyConstant) {
        final View.TransformationInfo info = mView.mTransformationInfo;
        final RenderNode node = mView.mRenderNode;
        switch (propertyConstant) {
            case TRANSLATION_X:
                return info.mTranslationX;
                return node.getTranslationX();
            case TRANSLATION_Y:
                return info.mTranslationY;
                return node.getTranslationY();
            case TRANSLATION_Z:
                return info.mTranslationZ;
                return node.getTranslationZ();
            case ROTATION:
                return info.mRotation;
                return node.getRotation();
            case ROTATION_X:
                return info.mRotationX;
                return node.getRotationX();
            case ROTATION_Y:
                return info.mRotationY;
                return node.getRotationY();
            case SCALE_X:
                return info.mScaleX;
                return node.getScaleX();
            case SCALE_Y:
                return info.mScaleY;
                return node.getScaleY();
            case X:
                return mView.mLeft + info.mTranslationX;
                return mView.mLeft + node.getTranslationX();
            case Y:
                return mView.mTop + info.mTranslationY;
                return mView.mTop + node.getTranslationY();
            case ALPHA:
                return info.mAlpha;
                return mView.mTransformationInfo.mAlpha;
        }
        return 0;
    }
@@ -1123,7 +1113,6 @@ public class ViewPropertyAnimator {
                }
            }
            if ((propertyMask & TRANSFORM_MASK) != 0) {
                mView.mTransformationInfo.mMatrixDirty = true;
                if (!useRenderNodeProperties) {
                    mView.mPrivateFlags |= View.PFLAG_DRAWN; // force another invalidation
                }
Loading