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

Commit f93ac2b4 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Avoid changing resize dim layer if not needed

UPDATE_DOCKED_STACK_DIVIDER gets called fairly frequently.
When we switched to having a stack per task,
TaskStack.resetAdjustedForIme was called a lot more frequently,
leading to a lot of empty surface transaction binder calls, which
took very long to execute.

We fix this by avoid calling setResizeDimLayer as well as avoid
even creating a transaction when the dim layer hasn't changed.

Test: go/wm-smoke
Test: Resize docked stack, check IME adjust animations
Change-Id: I75e64c6e3ac77012388c68c6750a426bd3ed6e21
Fixes: 67747409
Bug: 67780926
parent a34524e7
Loading
Loading
Loading
Loading
+23 −5
Original line number Diff line number Diff line
@@ -137,6 +137,8 @@ public class DockedStackDividerController implements DimLayerUser {
    float mLastDividerProgress;
    private final DividerSnapAlgorithm[] mSnapAlgorithmForRotation = new DividerSnapAlgorithm[4];
    private boolean mImeHideRequested;
    private final Rect mLastDimLayerRect = new Rect();
    private float mLastDimLayerAlpha;

    DockedStackDividerController(WindowManagerService service, DisplayContent displayContent) {
        mService = service;
@@ -525,7 +527,6 @@ public class DockedStackDividerController implements DimLayerUser {
     * display in that windowing mode.
     */
    void setResizeDimLayer(boolean visible, int targetWindowingMode, float alpha) {
        mService.openSurfaceTransaction();
        // TODO: Maybe only allow split-screen windowing modes?
        final TaskStack stack = targetWindowingMode != WINDOWING_MODE_UNDEFINED
                ? mDisplayContent.getStack(targetWindowingMode)
@@ -535,17 +536,34 @@ public class DockedStackDividerController implements DimLayerUser {
        if (visibleAndValid) {
            stack.getDimBounds(mTmpRect);
            if (mTmpRect.height() > 0 && mTmpRect.width() > 0) {
                if (!mLastDimLayerRect.equals(mTmpRect) || mLastDimLayerAlpha != alpha) {
                    try {
                        // TODO: This should use the regular animation transaction - here and below
                        mService.openSurfaceTransaction();
                        mDimLayer.setBounds(mTmpRect);
                        mDimLayer.show(getResizeDimLayer(), alpha, 0 /* duration */);
                    } finally {
                        mService.closeSurfaceTransaction();
                    }
                }
                mLastDimLayerRect.set(mTmpRect);
                mLastDimLayerAlpha = alpha;
            } else {
                visibleAndValid = false;
            }
        }
        if (!visibleAndValid) {
            if (mLastDimLayerAlpha != 0f) {
                try {
                    mService.openSurfaceTransaction();
                    mDimLayer.hide();
        }
                } finally {
                    mService.closeSurfaceTransaction();
                }
            }
            mLastDimLayerAlpha = 0f;
        }
    }

    /**
     * @return The layer used for dimming the apps when dismissing docked/fullscreen stack. Just
+4 −1
Original line number Diff line number Diff line
@@ -1008,10 +1008,13 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye
    void resetAdjustedForIme(boolean adjustBoundsNow) {
        if (adjustBoundsNow) {
            mImeWin = null;
            mAdjustedForIme = false;
            mImeGoingAway = false;
            mAdjustImeAmount = 0f;
            mAdjustDividerAmount = 0f;
            if (!mAdjustedForIme) {
                return;
            }
            mAdjustedForIme = false;
            updateAdjustedBounds();
            mService.setResizeDimLayer(false, getWindowingMode(), 1.0f);
        } else {