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

Commit 0f53e10c authored by Leon Scroggins III's avatar Leon Scroggins III
Browse files

Switch Java calls to enableZ and disableZ; remove isRecordingFor

Bug: 155422223
Test: make

insertInOrderBarrier and insertReorderBarrier are @hide and deprecated.
Remove them and update all callers to enableZ and disableZ, which are
already public.

Update native code to refer to enableZ instead of insertReorderBarrier.

In addition, remove @hide Canvas#isRecordingFor. This method was
originally used to prevent a single RenderNode from being in two display
lists. This is now supported, so there's no reason to avoid it. The one
caller used it to determine whether to reorder drawing its child Views
(which, as the comment says, makes sense to determine based on whether
the Canvas isHardwareAccelerated) and whether to call
insertReorderBarrier/insertInOrderBarrier (now enableZ/disableZ). In the
latter case, there is no need for a conditional, since enableZ/disableZ
only work on a hardware Canvas.

Change-Id: Ib216a19d6aeff40b2e23532bacd62d1795c2ab27
parent c8d49eff
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -54,11 +54,11 @@ public class CanvasPerfTest {
            canvas = node.start(200, 200);
            int save = canvas.save();
            canvas.clipRect(1, 1, 199, 199);
            canvas.insertReorderBarrier();
            canvas.enableZ();
            for (int i = 0; i < 5; i++) {
                canvas.drawRenderNode(child);
            }
            canvas.insertInorderBarrier();
            canvas.disableZ();
            canvas.restoreToCount(save);
            node.end(canvas);
        }
+2 −2
Original line number Diff line number Diff line
@@ -54,9 +54,9 @@ public class GhostView extends View {
            mView.mRecreateDisplayList = true;
            RenderNode renderNode = mView.updateDisplayListIfDirty();
            if (renderNode.hasDisplayList()) {
                dlCanvas.insertReorderBarrier(); // enable shadow for this rendernode
                dlCanvas.enableZ(); // enable shadow for this rendernode
                dlCanvas.drawRenderNode(renderNode);
                dlCanvas.insertInorderBarrier(); // re-disable reordering/shadows
                dlCanvas.disableZ(); // re-disable reordering/shadows
            }
        }
    }
+3 −5
Original line number Diff line number Diff line
@@ -4105,13 +4105,11 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager

    @Override
    protected void dispatchDraw(Canvas canvas) {
        boolean usingRenderNodeProperties = canvas.isRecordingFor(mRenderNode);
        final int childrenCount = mChildrenCount;
        final View[] children = mChildren;
        int flags = mGroupFlags;

        if ((flags & FLAG_RUN_ANIMATION) != 0 && canAnimate()) {
            final boolean buildCache = !isHardwareAccelerated();
            for (int i = 0; i < childrenCount; i++) {
                final View child = children[i];
                if ((child.mViewFlags & VISIBILITY_MASK) == VISIBLE) {
@@ -4152,12 +4150,12 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
        boolean more = false;
        final long drawingTime = getDrawingTime();

        if (usingRenderNodeProperties) canvas.insertReorderBarrier();
        canvas.enableZ();
        final int transientCount = mTransientIndices == null ? 0 : mTransientIndices.size();
        int transientIndex = transientCount != 0 ? 0 : -1;
        // Only use the preordered list if not HW accelerated, since the HW pipeline will do the
        // draw reordering internally
        final ArrayList<View> preorderedList = usingRenderNodeProperties
        final ArrayList<View> preorderedList = isHardwareAccelerated()
                ? null : buildOrderedChildList();
        final boolean customOrder = preorderedList == null
                && isChildrenDrawingOrderEnabled();
@@ -4204,7 +4202,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
                more |= drawChild(canvas, child, drawingTime);
            }
        }
        if (usingRenderNodeProperties) canvas.insertInorderBarrier();
        canvas.disableZ();

        if (isShowingLayoutBounds()) {
            onDebugDraw(canvas);
+2 −2
Original line number Diff line number Diff line
@@ -249,11 +249,11 @@ public class ViewOverlay {
             * This means that we need to insert reorder barriers manually though, so that children
             * of the OverlayViewGroup can cast shadows and Z reorder with each other.
             */
            canvas.insertReorderBarrier();
            canvas.enableZ();

            super.dispatchDraw(canvas);

            canvas.insertInorderBarrier();
            canvas.disableZ();
            final int numDrawables = (mDrawables == null) ? 0 : mDrawables.size();
            for (int i = 0; i < numDrawables; ++i) {
                mDrawables.get(i).draw(canvas);
+0 −19
Original line number Diff line number Diff line
@@ -62,9 +62,6 @@ public class Canvas extends BaseCanvas {
        return mNativeCanvasWrapper;
    }

    /** @hide */
    public boolean isRecordingFor(Object o) { return false; }

    // may be null
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 117521088)
    private Bitmap mBitmap;
@@ -204,22 +201,6 @@ public class Canvas extends BaseCanvas {
        mBitmap = bitmap;
    }

    /**
     * @deprecated use {@link #enableZ()} instead
     * @hide */
    @Deprecated
    public void insertReorderBarrier() {
        enableZ();
    }

    /**
     * @deprecated use {@link #disableZ()} instead
     * @hide */
    @Deprecated
    public void insertInorderBarrier() {
        disableZ();
    }

    /**
     * <p>Enables Z support which defaults to disabled. This allows for RenderNodes drawn with
     * {@link #drawRenderNode(RenderNode)} to be re-arranged based off of their
Loading