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

Commit 63513baa authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Remove usages of global transaction

The performSurfacePlacement will prepare the operation in the
pending transaction and then let WindowAnimator apply it with
vsync. Since there are only few usages of global transaction,
the transaction applied from performSurfacePlacement is almost
only from DisplayContent#prepareSurface, so it is more efficient
to centralize with WindowAnimator.

This can reduce an IPC to surfaceflinger in every surface
placement, which should eliminate one of major cost.

Bug: 159103089
Test: CtsWindowManagerDeviceActivity

Change-Id: I67e4e58aced78a2f36163178a64ca55d3c77e6f3
parent 65959325
Loading
Loading
Loading
Loading
+4 −9
Original line number Diff line number Diff line
@@ -115,7 +115,6 @@ import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.Surface.ROTATION_270;
import static android.view.Surface.ROTATION_90;
import static android.view.SurfaceControl.getGlobalTransaction;
import static android.view.WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD;
import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
@@ -5693,14 +5692,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        // can be synchronized with showing the next surface in the transition.
        if (!usingShellTransitions && !isVisible() && !delayed
                && !displayContent.mAppTransition.isTransitionSet()) {
            SurfaceControl.openTransaction();
            try {
            forAllWindows(win -> {
                    win.mWinAnimator.hide(getGlobalTransaction(), "immediately hidden");
                win.mWinAnimator.hide(getPendingTransaction(), "immediately hidden");
            }, true);
            } finally {
                SurfaceControl.closeTransaction();
            }
            scheduleAnimation();
        }
    }

+6 −10
Original line number Diff line number Diff line
@@ -1633,7 +1633,12 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
        }
    }

    private void removeRootTaskInSurfaceTransaction(Task rootTask) {
    /**
     * Removes the root task associated with the given {@param rootTask}. If the {@param rootTask}
     * is the pinned task, then its child tasks are not explicitly removed when the root task is
     * destroyed, but instead moved back onto the TaskDisplayArea.
     */
    void removeRootTask(Task rootTask) {
        if (rootTask.getWindowingMode() == WINDOWING_MODE_PINNED) {
            removePinnedRootTaskInSurfaceTransaction(rootTask);
        } else {
@@ -1643,15 +1648,6 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
        }
    }

    /**
     * Removes the root task associated with the given {@param task}. If the {@param task} is the
     * pinned task, then its child tasks are not explicitly removed when the root task is
     * destroyed, but instead moved back onto the TaskDisplayArea.
     */
    void removeRootTask(Task task) {
        mWindowManager.inSurfaceTransaction(() -> removeRootTaskInSurfaceTransaction(task));
    }

    /**
     * Removes the task with the specified task id.
     *
+1 −12
Original line number Diff line number Diff line
@@ -71,7 +71,6 @@ import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_APP_TRANSITIO
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_RECENTS;
import static com.android.server.wm.WallpaperAnimationAdapter.shouldStartWallpaperAnimation;
import static com.android.server.wm.WindowContainer.AnimationFlags.PARENTS;
import static com.android.server.wm.WindowManagerDebugConfig.SHOW_LIGHT_TRANSACTIONS;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;

@@ -82,7 +81,6 @@ import android.os.Trace;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.Pair;
import android.util.Slog;
import android.view.Display;
import android.view.RemoteAnimationAdapter;
import android.view.RemoteAnimationDefinition;
@@ -1179,16 +1177,7 @@ public class AppTransitionController {
            }
            app.updateReportedVisibilityLocked();
            app.waitingToShow = false;
            if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
                    ">>> OPEN TRANSACTION handleAppTransitionReady()");
            mService.openSurfaceTransaction();
            try {
            app.showAllWindowsLocked();
            } finally {
                mService.closeSurfaceTransaction("handleAppTransitionReady");
                if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
                        "<<< CLOSE TRANSACTION handleAppTransitionReady()");
            }

            if (mDisplayContent.mAppTransition.isNextAppTransitionThumbnailUp()) {
                app.attachThumbnailAnimation();
+0 −5
Original line number Diff line number Diff line
@@ -5586,12 +5586,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
    void prepareSurfaces() {
        Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "prepareSurfaces");
        try {
            final Transaction transaction = getPendingTransaction();
            super.prepareSurfaces();

            // TODO: Once we totally eliminate global transaction we will pass transaction in here
            //       rather than merging to global.
            SurfaceControl.mergeToGlobalTransaction(transaction);
        } finally {
            Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
        }
+6 −1
Original line number Diff line number Diff line
@@ -307,7 +307,7 @@ class RecentsAnimation implements RecentsAnimationCallbacks, OnRootTaskOrderChan
                mService.stopAppSwitches();
            }

            mWindowManager.inSurfaceTransaction(() -> {
            inSurfaceTransaction(() -> {
                Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER,
                        "RecentsAnimation#onAnimationFinished_inSurfaceTransaction");
                mService.deferWindowLayout();
@@ -419,6 +419,11 @@ class RecentsAnimation implements RecentsAnimationCallbacks, OnRootTaskOrderChan
        }
    }

    // No-op wrapper to keep legacy code.
    private static void inSurfaceTransaction(Runnable exec) {
        exec.run();
    }

    /** Gives the owner of recents animation higher priority. */
    private void setProcessAnimating(boolean animating) {
        if (mCaller == null) return;
Loading