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

Commit 546e7ad2 authored by Tiger Huang's avatar Tiger Huang
Browse files

Only update insetsHint while necessary

To improve the performance, this CL makes it only calculates and updates
insetsHint when:
- the insets source is visible at the server side.
- the insets source frame is changed.

Fix: 183739779
Test: atest --iterations 10 ImePerfTest#testHideIme
Change-Id: Ie4e6fe7af21a036dabbca71c9170f40e04997a13
parent 6b2d6fbe
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ class InsetsSourceProvider {
    private TriConsumer<DisplayFrames, WindowState, Rect> mImeFrameProvider;
    private final Rect mImeOverrideFrame = new Rect();
    private boolean mIsLeashReadyForDispatching;
    private final Rect mLastSourceFrame = new Rect();

    private final Consumer<Transaction> mSetLeashPositionConsumer = t -> {
        if (mControl != null) {
@@ -268,12 +269,15 @@ class InsetsSourceProvider {
                    mSetLeashPositionConsumer.accept(mWin.getPendingTransaction());
                }
            }
            if (mServerVisible && !mLastSourceFrame.equals(mSource.getFrame())) {
                final Insets insetsHint = mSource.calculateInsets(
                        mWin.getBounds(), true /* ignoreVisibility */);
                if (!insetsHint.equals(mControl.getInsetsHint())) {
                    changed = true;
                    mControl.setInsetsHint(insetsHint);
                }
                mLastSourceFrame.set(mSource.getFrame());
            }
            if (changed) {
                mStateController.notifyControlChanged(mControlTarget);
            }