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

Commit 084ba368 authored by Vinit Nayak's avatar Vinit Nayak
Browse files

Lazy initialize split divider MotionSpec

* This may be a culprit for non-split related perf issues,
so we're trying to see if moving this to divider interaction helps.
* There's a chance this could then regress on split divider CUJs, but
then at least that's localized.

Bug: 425461336
Flag: com.android.wm.shell.enable_flexible_two_app_split
Test: Perf tests will tell! Works fine otherwise
Change-Id: If208f24ee281bb1e59e7b267968990358e88de9e
parent 7d29380a
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -122,8 +122,11 @@ public class DividerSnapAlgorithm {
    private final SnapTarget mDismissEndTarget;
    private final SnapTarget mMiddleTarget;

    /** A spec used for "magnetic snap" user-controlled movement. */
    private final MotionSpec mMotionSpec;
    /** A spec used for "magnetic snap" user-controlled movement. Lazy-initialized, {@code null} if
     * the flex split flag is not enabled
     */
    @Nullable
    private MotionSpec mMotionSpec;

    public DividerSnapAlgorithm(Resources res, int displayWidth, int displayHeight, int dividerSize,
            boolean isLeftRightSplit, Rect insets, Rect pinnedTaskbarInsets, int dockSide) {
@@ -177,8 +180,6 @@ public class DividerSnapAlgorithm {
        mDismissEndTarget = mTargets.get(mTargets.size() - 1);
        mMiddleTarget = mTargets.get(mTargets.size() / 2);
        mMiddleTarget.isMiddleTarget = true;
        mMotionSpec = Flags.enableFlexibleTwoAppSplit()
                ? MagneticDividerUtils.generateMotionSpec(mTargets, res) : null;
    }

    /**
@@ -556,7 +557,11 @@ public class DividerSnapAlgorithm {
        return snap(currentPosition, /* hardDismiss */ true).snapPosition;
    }

    public MotionSpec getMotionSpec() {
    @Nullable
    public MotionSpec getMotionSpec(Resources resources) {
        if (Flags.enableFlexibleTwoAppSplit() && mMotionSpec == null) {
            mMotionSpec = MagneticDividerUtils.generateMotionSpec(mTargets, resources);
        }
        return mMotionSpec;
    }

+1 −1
Original line number Diff line number Diff line
@@ -520,7 +520,7 @@ public class DividerView extends FrameLayout implements View.OnTouchListener {
                direction);
        mViewMotionValue = new ViewMotionValue(mStartPos,
                mDistanceGestureContext,
                mSplitLayout.mDividerSnapAlgorithm.getMotionSpec(),
                mSplitLayout.mDividerSnapAlgorithm.getMotionSpec(getResources()),
                "dividerView::pos" /* label */);
        mLastHoveredOverSnapPosition = mSplitLayout.calculateCurrentSnapPosition();
        // Set a "starting region" in which we don't want to show the tooltip yet.