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

Commit 3c57702e authored by chaviw's avatar chaviw
Browse files

Send transaction when possible for WSA

In WSA, we are sometimes using the global transaction. This will make
things difficult when trying to handle synced transactions for blast
sync. We need to make sure all changes on WSA that can happen during a
sync are put on the sync transaction so they can all be applied by the
client at the same time.

Also cleaned up some unused functions in SurfaceControl.

Test: Split and PIP
Change-Id: Ic1abc3c009c38d00593f80a4e03f895c026364e2
parent cd413cf8
Loading
Loading
Loading
Loading
+2 −110
Original line number Diff line number Diff line
@@ -1523,24 +1523,6 @@ public final class SurfaceControl implements Parcelable {
        }
    }

    /**
     * @hide
     */
    public void deferTransactionUntil(SurfaceControl barrier, long frame) {
        synchronized(SurfaceControl.class) {
            sGlobalTransaction.deferTransactionUntil(this, barrier, frame);
        }
    }

    /**
     * @hide
     */
    public void reparentChildren(SurfaceControl newParent) {
        synchronized(SurfaceControl.class) {
            sGlobalTransaction.reparentChildren(this, newParent);
        }
    }

    /**
     * @hide
     */
@@ -1550,60 +1532,6 @@ public final class SurfaceControl implements Parcelable {
        }
    }

    /**
     * @hide
     */
    @UnsupportedAppUsage
    public void setLayer(int zorder) {
        checkNotReleased();
        synchronized(SurfaceControl.class) {
            sGlobalTransaction.setLayer(this, zorder);
        }
    }

    /**
     * @hide
     */
    @UnsupportedAppUsage
    public void setPosition(float x, float y) {
        checkNotReleased();
        synchronized(SurfaceControl.class) {
            sGlobalTransaction.setPosition(this, x, y);
        }
    }

    /**
     * @hide
     */
    public void setBufferSize(int w, int h) {
        checkNotReleased();
        synchronized(SurfaceControl.class) {
            sGlobalTransaction.setBufferSize(this, w, h);
        }
    }

    /**
     * @hide
     */
    @UnsupportedAppUsage
    public void hide() {
        checkNotReleased();
        synchronized(SurfaceControl.class) {
            sGlobalTransaction.hide(this);
        }
    }

    /**
     * @hide
     */
    @UnsupportedAppUsage
    public void show() {
        checkNotReleased();
        synchronized(SurfaceControl.class) {
            sGlobalTransaction.show(this);
        }
    }

    /**
     * @hide
     */
@@ -1644,36 +1572,6 @@ public final class SurfaceControl implements Parcelable {
        return nativeGetAnimationFrameStats(outStats);
    }

    /**
     * @hide
     */
    public void setAlpha(float alpha) {
        checkNotReleased();
        synchronized(SurfaceControl.class) {
            sGlobalTransaction.setAlpha(this, alpha);
        }
    }

    /**
     * @hide
     */
    public void setBackgroundBlurRadius(int blur) {
        checkNotReleased();
        synchronized (SurfaceControl.class) {
            sGlobalTransaction.setBackgroundBlurRadius(this, blur);
        }
    }

    /**
     * @hide
     */
    public void setMatrix(float dsdx, float dtdx, float dtdy, float dsdy) {
        checkNotReleased();
        synchronized(SurfaceControl.class) {
            sGlobalTransaction.setMatrix(this, dsdx, dtdx, dtdy, dsdy);
        }
    }

    /**
     * Sets the Surface to be color space agnostic. If a surface is color space agnostic,
     * the color can be interpreted in any color space.
@@ -1688,18 +1586,12 @@ public final class SurfaceControl implements Parcelable {
    }

    /**
     * Bounds the surface and its children to the bounds specified. Size of the surface will be
     * ignored and only the crop and buffer size will be used to determine the bounds of the
     * surface. If no crop is specified and the surface has no buffer, the surface bounds is only
     * constrained by the size of its parent bounds.
     *
     * @param crop Bounds of the crop to apply.
     * @hide
     */
    public void setWindowCrop(Rect crop) {
    public void setBackgroundBlurRadius(int blur) {
        checkNotReleased();
        synchronized (SurfaceControl.class) {
            sGlobalTransaction.setWindowCrop(this, crop);
            sGlobalTransaction.setBackgroundBlurRadius(this, blur);
        }
    }

+4 −2
Original line number Diff line number Diff line
@@ -3405,6 +3405,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
    boolean destroyLeakedSurfaces() {
        // Used to indicate that a surface was leaked.
        mTmpWindow = null;
        final Transaction t = mWmService.mTransactionFactory.get();
        forAllWindows(w -> {
            final WindowStateAnimator wsa = w.mWinAnimator;
            if (wsa.mSurfaceController == null) {
@@ -3416,7 +3417,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
                        + " token=" + w.mToken
                        + " pid=" + w.mSession.mPid
                        + " uid=" + w.mSession.mUid);
                wsa.destroySurface();
                wsa.destroySurface(t);
                mWmService.mForceRemoves.add(w);
                mTmpWindow = w;
            } else if (w.mActivityRecord != null && !w.mActivityRecord.isClientVisible()) {
@@ -3424,10 +3425,11 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
                        + w + " surface=" + wsa.mSurfaceController
                        + " token=" + w.mActivityRecord);
                ProtoLog.i(WM_SHOW_TRANSACTIONS, "SURFACE LEAK DESTROY: %s", w);
                wsa.destroySurface();
                wsa.destroySurface(t);
                mTmpWindow = w;
            }
        }, false /* traverseTopToBottom */);
        t.apply();

        return mTmpWindow != null;
    }
+4 −2
Original line number Diff line number Diff line
@@ -778,7 +778,9 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
                if (surfaceController != null) {
                    ProtoLog.i(WM_SHOW_SURFACE_ALLOC,
                            "SURFACE RECOVER DESTROY: %s", winAnimator.mWin);
                    winAnimator.destroySurface();
                    SurfaceControl.Transaction t = mWmService.mTransactionFactory.get();
                    winAnimator.destroySurface(t);
                    t.apply();
                    if (winAnimator.mWin.mActivityRecord != null) {
                        winAnimator.mWin.mActivityRecord.removeStartingWindow();
                    }
@@ -926,7 +928,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
                    displayContent.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER;
                }
                win.destroySurfaceUnchecked();
                win.mWinAnimator.destroyPreservedSurfaceLocked();
                win.mWinAnimator.destroyPreservedSurfaceLocked(win.getSyncTransaction());
            } while (i > 0);
            mWmService.mDestroySurface.clear();
        }
+1 −1
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ class TaskScreenshotAnimatable implements SurfaceAnimator.Animatable {
            surface.attachAndQueueBufferWithColorSpace(buffer, screenshotBuffer.getColorSpace());
            surface.release();
            final float scale = 1.0f * mTask.getBounds().width() / mWidth;
            mSurfaceControl.setMatrix(scale, 0, 0, scale);
            getPendingTransaction().setMatrix(mSurfaceControl, scale, 0, 0, scale);
        }
        getPendingTransaction().show(mSurfaceControl);
    }
+1 −1
Original line number Diff line number Diff line
@@ -5349,7 +5349,7 @@ public class WindowManagerService extends IWindowManager.Stub
    void destroyPreservedSurfaceLocked() {
        for (int i = mDestroyPreservedSurface.size() - 1; i >= 0 ; i--) {
            final WindowState w = mDestroyPreservedSurface.get(i);
            w.mWinAnimator.destroyPreservedSurfaceLocked();
            w.mWinAnimator.destroyPreservedSurfaceLocked(w.getSyncTransaction());
        }
        mDestroyPreservedSurface.clear();
    }
Loading