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

Commit 7b44e04e authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Remove explicit creation of SurfaceSession from View

This is similar to [1] and [2]
[1]: Iab7e708d064dd42d39d3ab8cf3e08d657b926c68
[2]: I4750ab7dc6e8544e2060ec89207f09f1241966ad

It reduces unnecessary IPC to SF when clients create windows.

Bug: 163976519
Flag: EXEMPT reduce unnecessary invocation
Test: atest CtsWindowManagerDeviceWindow
Change-Id: Ic75134b97fdb424402a3591cabf50ea3135ac720
parent d8aa9a2a
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -191,7 +191,6 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
    boolean mDrawFinished = false;

    final Rect mScreenRect = new Rect();
    private final SurfaceSession mSurfaceSession = new SurfaceSession();
    private final boolean mLimitedHdrEnabled = Flags.limitedHdr();

    SurfaceControl mSurfaceControl;
@@ -1517,7 +1516,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
    private void createBlastSurfaceControls(ViewRootImpl viewRoot, String name,
            Transaction surfaceUpdateTransaction) {
        if (mSurfaceControl == null) {
            mSurfaceControl = new SurfaceControl.Builder(mSurfaceSession)
            mSurfaceControl = new SurfaceControl.Builder()
                    .setName(name)
                    .setLocalOwnerView(this)
                    .setParent(viewRoot.updateAndGetBoundsLayer(surfaceUpdateTransaction))
@@ -1527,7 +1526,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
        }

        if (mBlastSurfaceControl == null) {
            mBlastSurfaceControl = new SurfaceControl.Builder(mSurfaceSession)
            mBlastSurfaceControl = new SurfaceControl.Builder()
                    .setName(name + "(BLAST)")
                    .setLocalOwnerView(this)
                    .setParent(mSurfaceControl)
@@ -1545,7 +1544,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
        }

        if (mBackgroundControl == null) {
            mBackgroundControl = new SurfaceControl.Builder(mSurfaceSession)
            mBackgroundControl = new SurfaceControl.Builder()
                    .setName("Background for " + name)
                    .setLocalOwnerView(this)
                    .setOpaque(true)
+1 −3
Original line number Diff line number Diff line
@@ -29217,8 +29217,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                    + " shadowX=" + shadowTouchPoint.x + " shadowY=" + shadowTouchPoint.y);
        }
        final SurfaceSession session = new SurfaceSession();
        final SurfaceControl surfaceControl = new SurfaceControl.Builder(session)
        final SurfaceControl surfaceControl = new SurfaceControl.Builder()
                .setName("drag surface")
                .setParent(root.getSurfaceControl())
                .setBufferSize(shadowSize.x, shadowSize.y)
@@ -29284,7 +29283,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            if (token == null) {
                surface.destroy();
            }
            session.kill();
            surfaceControl.release();
        }
    }
+1 −2
Original line number Diff line number Diff line
@@ -838,7 +838,6 @@ public final class ViewRootImpl implements ViewParent,
     * surfaces can ensure they do not draw into the surface inset region set by the parent window.
     */
    private SurfaceControl mBoundsLayer;
    private final SurfaceSession mSurfaceSession = new SurfaceSession();
    private final Transaction mTransaction = new Transaction();
    private final Transaction mFrameRateTransaction = new Transaction();
@@ -2704,7 +2703,7 @@ public final class ViewRootImpl implements ViewParent,
     */
    public SurfaceControl updateAndGetBoundsLayer(Transaction t) {
        if (mBoundsLayer == null) {
            mBoundsLayer = new SurfaceControl.Builder(mSurfaceSession)
            mBoundsLayer = new SurfaceControl.Builder()
                    .setContainerLayer()
                    .setName("Bounds for - " + getTitle().toString())
                    .setParent(getSurfaceControl())
+2 −3
Original line number Diff line number Diff line
@@ -86,7 +86,6 @@ public class WindowlessWindowManager implements IWindowSession {
    final HashMap<IBinder, ResizeCompleteCallback> mResizeCompletionForWindow =
        new HashMap<IBinder, ResizeCompleteCallback>();

    private final SurfaceSession mSurfaceSession = new SurfaceSession();
    protected final SurfaceControl mRootSurface;
    private final Configuration mConfiguration;
    private final IWindowSession mRealWm;
@@ -184,13 +183,13 @@ public class WindowlessWindowManager implements IWindowSession {
            InputChannel outInputChannel, InsetsState outInsetsState,
            InsetsSourceControl.Array outActiveControls, Rect outAttachedFrame,
            float[] outSizeCompatScale) {
        final SurfaceControl leash = new SurfaceControl.Builder(mSurfaceSession)
        final SurfaceControl leash = new SurfaceControl.Builder()
                .setName(attrs.getTitle().toString() + "Leash")
                .setCallsite("WindowlessWindowManager.addToDisplay")
                .setParent(getParentSurface(window, attrs))
                .build();

        final SurfaceControl sc = new SurfaceControl.Builder(mSurfaceSession)
        final SurfaceControl sc = new SurfaceControl.Builder()
                .setFormat(attrs.format)
                .setBLASTLayer()
                .setName(attrs.getTitle().toString())