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

Commit 7913d259 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Skip initializing unused system bar painter

SystemBarBackgroundPainter invokes getSystemUiContext, that may trigger
initializing a window context and load resources. The operation could
cost ~5ms due to attachWindowContextToDisplayContent.

Since flag drawSnapshotAspectRatioMatch is introduced, there is no
longer a case that the snapshot starting window need to draw bars
background. So its initialization can be skipped as well.

Bug: 297502610
Flag: EXEMPT reduce unnecessary invocation
Test: Task snapshot starting window is normal from hot launch app.

Change-Id: Id6fa10da245845d5ed5f78558ab2f4193d2c7133
parent 2f4e0476
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -151,10 +151,12 @@ public class SnapshotDrawerUtils {
        @VisibleForTesting
        public void setFrames(Rect frame, Rect systemBarInsets) {
            mFrame.set(frame);
            mSystemBarInsets.set(systemBarInsets);
            mSizeMismatch = (mFrame.width() != mSnapshotW || mFrame.height() != mSnapshotH);
            if (!Flags.drawSnapshotAspectRatioMatch() && systemBarInsets != null) {
                mSystemBarInsets.set(systemBarInsets);
                mSystemBarBackgroundPainter.setInsets(systemBarInsets);
            }
        }

        private void drawSnapshot(boolean releaseAfterDraw) {
            Log.v(TAG, "Drawing snapshot surface sizeMismatch=" + mSizeMismatch);
@@ -394,9 +396,12 @@ public class SnapshotDrawerUtils {
        final ActivityManager.RunningTaskInfo runningTaskInfo = info.taskInfo;
        final ActivityManager.TaskDescription taskDescription =
                getOrCreateTaskDescription(runningTaskInfo);
        Rect systemBarInsets = null;
        if (!Flags.drawSnapshotAspectRatioMatch()) {
            drawSurface.initiateSystemBarPainter(lp.flags, lp.privateFlags,
                    attrs.insetsFlags.appearance, taskDescription, info.requestedVisibleTypes);
        final Rect systemBarInsets = getSystemBarInsets(windowBounds, topWindowInsetsState);
            systemBarInsets = getSystemBarInsets(windowBounds, topWindowInsetsState);
        }
        drawSurface.setFrames(windowBounds, systemBarInsets);
        drawSurface.drawSnapshot(releaseAfterDraw);
    }