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

Commit 480ced8a authored by Alec Mouri's avatar Alec Mouri Committed by Automerger Merge Worker
Browse files

Merge "Revert "Drive SurfaceView visibility on renderthread"" into udc-dev am: 836eac8a

parents 80a70272 836eac8a
Loading
Loading
Loading
Loading
+21 −11
Original line number Original line Diff line number Diff line
@@ -851,15 +851,11 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
            }
            }
            mParentSurfaceSequenceId = viewRoot.getSurfaceSequenceId();
            mParentSurfaceSequenceId = viewRoot.getSurfaceSequenceId();


            // Only control visibility if we're not hardware-accelerated. Otherwise we'll
            // let renderthread drive since offscreen SurfaceControls should not be visible.
            if (!isHardwareAccelerated()) {
            if (mViewVisibility) {
            if (mViewVisibility) {
                surfaceUpdateTransaction.show(mSurfaceControl);
                surfaceUpdateTransaction.show(mSurfaceControl);
            } else {
            } else {
                surfaceUpdateTransaction.hide(mSurfaceControl);
                surfaceUpdateTransaction.hide(mSurfaceControl);
            }
            }
            }


            updateBackgroundVisibility(surfaceUpdateTransaction);
            updateBackgroundVisibility(surfaceUpdateTransaction);
            updateBackgroundColor(surfaceUpdateTransaction);
            updateBackgroundColor(surfaceUpdateTransaction);
@@ -1421,10 +1417,12 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
    }
    }


    private final Rect mRTLastReportedPosition = new Rect();
    private final Rect mRTLastReportedPosition = new Rect();
    private final Point mRTLastReportedSurfaceSize = new Point();


    private class SurfaceViewPositionUpdateListener implements RenderNode.PositionUpdateListener {
    private class SurfaceViewPositionUpdateListener implements RenderNode.PositionUpdateListener {
        private final int mRtSurfaceWidth;
        private final int mRtSurfaceWidth;
        private final int mRtSurfaceHeight;
        private final int mRtSurfaceHeight;
        private boolean mRtFirst = true;
        private final SurfaceControl.Transaction mPositionChangedTransaction =
        private final SurfaceControl.Transaction mPositionChangedTransaction =
                new SurfaceControl.Transaction();
                new SurfaceControl.Transaction();


@@ -1435,6 +1433,15 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall


        @Override
        @Override
        public void positionChanged(long frameNumber, int left, int top, int right, int bottom) {
        public void positionChanged(long frameNumber, int left, int top, int right, int bottom) {
            if (!mRtFirst && (mRTLastReportedPosition.left == left
                    && mRTLastReportedPosition.top == top
                    && mRTLastReportedPosition.right == right
                    && mRTLastReportedPosition.bottom == bottom
                    && mRTLastReportedSurfaceSize.x == mRtSurfaceWidth
                    && mRTLastReportedSurfaceSize.y == mRtSurfaceHeight)) {
                return;
            }
            mRtFirst = false;
            try {
            try {
                if (DEBUG_POSITION) {
                if (DEBUG_POSITION) {
                    Log.d(TAG, String.format(
                    Log.d(TAG, String.format(
@@ -1445,8 +1452,8 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
                }
                }
                synchronized (mSurfaceControlLock) {
                synchronized (mSurfaceControlLock) {
                    if (mSurfaceControl == null) return;
                    if (mSurfaceControl == null) return;

                    mRTLastReportedPosition.set(left, top, right, bottom);
                    mRTLastReportedPosition.set(left, top, right, bottom);
                    mRTLastReportedSurfaceSize.set(mRtSurfaceWidth, mRtSurfaceHeight);
                    onSetSurfacePositionAndScale(mPositionChangedTransaction, mSurfaceControl,
                    onSetSurfacePositionAndScale(mPositionChangedTransaction, mSurfaceControl,
                            mRTLastReportedPosition.left /*positionLeft*/,
                            mRTLastReportedPosition.left /*positionLeft*/,
                            mRTLastReportedPosition.top /*positionTop*/,
                            mRTLastReportedPosition.top /*positionTop*/,
@@ -1454,9 +1461,11 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
                                    / (float) mRtSurfaceWidth /*postScaleX*/,
                                    / (float) mRtSurfaceWidth /*postScaleX*/,
                            mRTLastReportedPosition.height()
                            mRTLastReportedPosition.height()
                                    / (float) mRtSurfaceHeight /*postScaleY*/);
                                    / (float) mRtSurfaceHeight /*postScaleY*/);

                    if (mViewVisibility) {
                        // b/131239825
                        mPositionChangedTransaction.show(mSurfaceControl);
                        mPositionChangedTransaction.show(mSurfaceControl);
                    }
                    }
                }
                applyOrMergeTransaction(mPositionChangedTransaction, frameNumber);
                applyOrMergeTransaction(mPositionChangedTransaction, frameNumber);
            } catch (Exception ex) {
            } catch (Exception ex) {
                Log.e(TAG, "Exception from repositionChild", ex);
                Log.e(TAG, "Exception from repositionChild", ex);
@@ -1481,6 +1490,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
                        System.identityHashCode(this), frameNumber));
                        System.identityHashCode(this), frameNumber));
            }
            }
            mRTLastReportedPosition.setEmpty();
            mRTLastReportedPosition.setEmpty();
            mRTLastReportedSurfaceSize.set(-1, -1);


            // positionLost can be called while UI thread is un-paused.
            // positionLost can be called while UI thread is un-paused.
            synchronized (mSurfaceControlLock) {
            synchronized (mSurfaceControlLock) {