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

Commit 7b7e0121 authored by Wei Sheng Shih's avatar Wei Sheng Shih Committed by Android (Google) Code Review
Browse files

Merge "Reduce memory usage for drawing app theme snapshot." into main

parents c093df16 b42dcc8f
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);