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

Commit 0b10c335 authored by Robert Carr's avatar Robert Carr
Browse files

Ensure we change SurfaceView size from UI thread.

We need to change the SurfaceView size from the UI thread
so that we can appropriately deliver the SurfaceChanged
callback. We also need to not preserve geometry
in this case, as if we don't update the surface
and layout size together we could get scaling. This still has
some potential for holes, as transactions are not synced with
the parent renderer, but we have other methods to avoid
these in the case of resizing. This fixes the remaining
issues with content sizing and surface view "out of sync".

Bug: 27780983
Bug: 27687126
Bug: 27676101

Change-Id: Idd7864f00e5cf7a4eb32dd66c0b389292a788069
parent 15d4b5aa
Loading
Loading
Loading
Loading
+0 −3
Original line number Original line Diff line number Diff line
@@ -116,14 +116,11 @@ interface IWindowSession {
     *  @param top The new top position
     *  @param top The new top position
     *  @param right The new right position
     *  @param right The new right position
     *  @param bottom The new bottom position
     *  @param bottom The new bottom position
     *  @param requestedWidth The new requested width
     *  @param requestedHeight The new requested height
     *  @param deferTransactionUntilFrame Frame number from our parent (attached) to
     *  @param deferTransactionUntilFrame Frame number from our parent (attached) to
     *  defer this action until.
     *  defer this action until.
     *  @param outFrame Rect in which is placed the new position/size on screen.
     *  @param outFrame Rect in which is placed the new position/size on screen.
     */
     */
    void repositionChild(IWindow childWindow, int left, int top, int right, int bottom,
    void repositionChild(IWindow childWindow, int left, int top, int right, int bottom,
            int requestedWidth, int requestedHeight,
            long deferTransactionUntilFrame, out Rect outFrame);
            long deferTransactionUntilFrame, out Rect outFrame);


    /*
    /*
+1 −15
Original line number Original line Diff line number Diff line
@@ -490,7 +490,7 @@ public class SurfaceView extends View {
                              | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                              | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                              | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
                              | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
                              ;
                              ;
                if (!creating && !force && !mUpdateWindowNeeded) {
                if (!creating && !force && !mUpdateWindowNeeded && !sizeChanged) {
                    mLayout.privateFlags |=
                    mLayout.privateFlags |=
                            WindowManager.LayoutParams.PRIVATE_FLAG_PRESERVE_GEOMETRY;
                            WindowManager.LayoutParams.PRIVATE_FLAG_PRESERVE_GEOMETRY;
                } else {
                } else {
@@ -584,18 +584,6 @@ public class SurfaceView extends View {


                    mSurface.transferFrom(mNewSurface);
                    mSurface.transferFrom(mNewSurface);
                    if (visible && mSurface.isValid()) {
                    if (visible && mSurface.isValid()) {
                        // We set SCALING_MODE_NO_SCALE_CROP to allow the WindowManager
                        // to update our Surface crop without requiring a new buffer from
                        // us. In the default mode of SCALING_MODE_FREEZE, surface geometry
                        // state (which includes crop) is only applied when a buffer
                        // with appropriate geometry is available. During drag resize
                        // it is quite frequent that a matching buffer will not be available
                        // (because we are constantly being resized and have fallen behind).
                        // However in such situations the WindowManager still needs to be able
                        // to update our crop to ensure we stay within the bounds of the containing
                        // window.
                        mSurface.setScalingMode(Surface.SCALING_MODE_NO_SCALE_CROP);

                        if (!mSurfaceCreated && (surfaceChanged || visibleChanged)) {
                        if (!mSurfaceCreated && (surfaceChanged || visibleChanged)) {
                            mSurfaceCreated = true;
                            mSurfaceCreated = true;
                            mIsCreating = true;
                            mIsCreating = true;
@@ -666,7 +654,6 @@ public class SurfaceView extends View {
                            mLocation[0], mLocation[1]));
                            mLocation[0], mLocation[1]));
                    mSession.repositionChild(mWindow, mWindowSpaceLeft, mWindowSpaceTop,
                    mSession.repositionChild(mWindow, mWindowSpaceLeft, mWindowSpaceTop,
                            mLocation[0], mLocation[1],
                            mLocation[0], mLocation[1],
                            mWindowSpaceWidth, mWindowSpaceHeight,
                            -1, mWinFrame);
                            -1, mWinFrame);
                } catch (RemoteException ex) {
                } catch (RemoteException ex) {
                    Log.e(TAG, "Exception from relayout", ex);
                    Log.e(TAG, "Exception from relayout", ex);
@@ -703,7 +690,6 @@ public class SurfaceView extends View {
            }
            }
            // Just using mRTLastReportedPosition as a dummy rect here
            // Just using mRTLastReportedPosition as a dummy rect here
            session.repositionChild(window, left, top, right, bottom,
            session.repositionChild(window, left, top, right, bottom,
                    mWindowSpaceWidth, mWindowSpaceHeight,
                    frameNumber,
                    frameNumber,
                    mRTLastReportedPosition);
                    mRTLastReportedPosition);
            // Now overwrite mRTLastReportedPosition with our values
            // Now overwrite mRTLastReportedPosition with our values
+0 −2
Original line number Original line Diff line number Diff line
@@ -195,10 +195,8 @@ final class Session extends IWindowSession.Stub


    @Override
    @Override
    public void repositionChild(IWindow window, int left, int top, int right, int bottom,
    public void repositionChild(IWindow window, int left, int top, int right, int bottom,
            int requestedWidth, int requestedHeight,
            long deferTransactionUntilFrame, Rect outFrame) {
            long deferTransactionUntilFrame, Rect outFrame) {
        mService.repositionChild(this, window, left, top, right, bottom,
        mService.repositionChild(this, window, left, top, right, bottom,
                requestedWidth, requestedHeight,
                deferTransactionUntilFrame, outFrame);
                deferTransactionUntilFrame, outFrame);
    }
    }


+0 −2
Original line number Original line Diff line number Diff line
@@ -2531,7 +2531,6 @@ public class WindowManagerService extends IWindowManager.Stub


    void repositionChild(Session session, IWindow client,
    void repositionChild(Session session, IWindow client,
            int left, int top, int right, int bottom,
            int left, int top, int right, int bottom,
            int requestedWidth, int requestedHeight,
            long deferTransactionUntilFrame, Rect outFrame) {
            long deferTransactionUntilFrame, Rect outFrame) {
        Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "repositionChild");
        Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "repositionChild");
        long origId = Binder.clearCallingIdentity();
        long origId = Binder.clearCallingIdentity();
@@ -2547,7 +2546,6 @@ public class WindowManagerService extends IWindowManager.Stub
                            "repositionChild called but window is not"
                            "repositionChild called but window is not"
                            + "attached to a parent win=" + win);
                            + "attached to a parent win=" + win);
                }
                }
                win.setRequestedSize(requestedWidth, requestedHeight);


                win.mAttrs.x = left;
                win.mAttrs.x = left;
                win.mAttrs.y = top;
                win.mAttrs.y = top;
+0 −1
Original line number Original line Diff line number Diff line
@@ -97,7 +97,6 @@ public final class BridgeWindowSession implements IWindowSession {


    @Override
    @Override
    public void repositionChild(IWindow window, int left, int top, int right, int bottom,
    public void repositionChild(IWindow window, int left, int top, int right, int bottom,
            int requestedWidth, int requestedHeight,
            long deferTransactionUntilFrame, Rect outFrame) {
            long deferTransactionUntilFrame, Rect outFrame) {
        // pass for now.
        // pass for now.
        return;
        return;