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

Commit b42dcc8f authored by wilsonshih's avatar wilsonshih Committed by Wei Sheng Shih
Browse files

Reduce memory usage for drawing app theme snapshot.

Since the content of the app theme snapshot is mostly a monochrome
image, drawing it in a smaller size should be a reasonable solution
to prevent memory waste.

Flag: com.android.window.flags.reduce_task_snapshot_memory_usage
Bug: 238206323
Test: verify the memory usage of app theme snapshot become much
smaller, and there is no obvious difference on recents animation.

Change-Id: Ibc74938adbf323e4bf703135db17aaf8f7433f72
parent 3e713107
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@ abstract class AbsAppSnapshotController<TYPE extends WindowContainer,
     */
    @VisibleForTesting
    static final int SNAPSHOT_MODE_NONE = 2;
    static final float THEME_SNAPSHOT_MIN_Length = 128.0f;

    protected final WindowManagerService mService;
    protected final float mHighResSnapshotScale;
@@ -436,14 +437,21 @@ abstract class AbsAppSnapshotController<TYPE extends WindowContainer,
        final Rect taskBounds = source.getBounds();
        final InsetsState insetsState = mainWindow.getInsetsStateWithVisibilityOverride();
        final Rect systemBarInsets = getSystemBarInsets(mainWindow.getFrame(), insetsState);
        final int taskWidth = taskBounds.width();
        final int taskHeight = taskBounds.height();
        float scale = mHighResSnapshotScale;
        if (Flags.reduceTaskSnapshotMemoryUsage()) {
            final int minLength = Math.min(taskWidth, taskHeight);
            if (THEME_SNAPSHOT_MIN_Length < minLength) {
                scale = Math.min(THEME_SNAPSHOT_MIN_Length / minLength, scale);
            }
        }
        final SnapshotDrawerUtils.SystemBarBackgroundPainter
                decorPainter = new SnapshotDrawerUtils.SystemBarBackgroundPainter(attrs.flags,
                attrs.privateFlags, attrs.insetsFlags.appearance, taskDescription,
                mHighResSnapshotScale, mainWindow.getRequestedVisibleTypes());
        final int taskWidth = taskBounds.width();
        final int taskHeight = taskBounds.height();
        final int width = (int) (taskWidth * mHighResSnapshotScale);
        final int height = (int) (taskHeight * mHighResSnapshotScale);
                scale, mainWindow.getRequestedVisibleTypes());
        final int width = (int) (taskWidth * scale);
        final int height = (int) (taskHeight * scale);
        final RenderNode node = RenderNode.create("SnapshotController", null);
        node.setLeftTopRightBottom(0, 0, width, height);
        node.setClipToBounds(false);