diff options
| author | 2025-02-14 02:59:05 +0000 | |
|---|---|---|
| committer | 2025-03-10 23:28:17 -0700 | |
| commit | b42dcc8f4b314223ce2017a74fb8336dd18b8ee7 (patch) | |
| tree | c4c30c51b2e40f71c39af7234569ca0cbb339555 | |
| parent | 3e713107ff026d94a07622ac86196132839593f2 (diff) | |
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
| -rw-r--r-- | services/core/java/com/android/server/wm/AbsAppSnapshotController.java | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/wm/AbsAppSnapshotController.java b/services/core/java/com/android/server/wm/AbsAppSnapshotController.java index a731bf7c64b3..70fc6bace868 100644 --- a/services/core/java/com/android/server/wm/AbsAppSnapshotController.java +++ b/services/core/java/com/android/server/wm/AbsAppSnapshotController.java @@ -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); |