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

Commit d0232c6a authored by Robert Carr's avatar Robert Carr Committed by android-build-merger
Browse files

Merge "SurfaceView: Expose hook for subclass to position child surfaces." into pi-dev

am: 89b18289

Change-Id: I2ad5181dab33597fc9a917bf8cdd0d83e6f0466a
parents 77f8c35f 89b18289
Loading
Loading
Loading
Loading
+26 −11
Original line number Diff line number Diff line
@@ -179,6 +179,8 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb

    private int mPendingReportDraws;

    private SurfaceControl.Transaction mRtTransaction = new SurfaceControl.Transaction();

    public SurfaceView(Context context) {
        this(context, null);
    }
@@ -774,21 +776,34 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
        });
    }

    /**
     * A place to over-ride for applying child-surface transactions.
     * These can be synchronized with the viewroot surface using deferTransaction.
     *
     * Called from RenderWorker while UI thread is paused.
     * @hide
     */
    protected void applyChildSurfaceTransaction_renderWorker(SurfaceControl.Transaction t,
            Surface viewRootSurface, long nextViewRootFrameNumber) {
    }

    private void setParentSpaceRectangle(Rect position, long frameNumber) {
        ViewRootImpl viewRoot = getViewRootImpl();

        SurfaceControl.openTransaction();
        try {
        if (frameNumber > 0) {
                mSurfaceControl.deferTransactionUntil(viewRoot.mSurface, frameNumber);
            mRtTransaction.deferTransactionUntilSurface(mSurfaceControl, viewRoot.mSurface,
                    frameNumber);
        }
            mSurfaceControl.setPosition(position.left, position.top);
            mSurfaceControl.setMatrix(position.width() / (float) mSurfaceWidth,
        mRtTransaction.setPosition(mSurfaceControl,position.left, position.top);
        mRtTransaction.setMatrix(mSurfaceControl,
                position.width() / (float) mSurfaceWidth,
                0.0f, 0.0f,
                position.height() / (float) mSurfaceHeight);
        } finally {
            SurfaceControl.closeTransaction();
        }

        applyChildSurfaceTransaction_renderWorker(mRtTransaction, viewRoot.mSurface,
                frameNumber);

        mRtTransaction.apply();
    }

    private Rect mRTLastReportedPosition = new Rect();