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

Commit a6213633 authored by wilsonshih's avatar wilsonshih
Browse files

Recycle bitmap when persist snapshot finish

... so the referenced hardware buffer can also be cleanup more
quickly.

Bug: 341189625
Test: launch app, then kill app process, repeat several times and
verify the dmabuf used for system server won't increase.

Change-Id: Iebc383dd7addd72fb071cf1c10cab8018250f4cf
parent ad5cda01
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -348,6 +348,9 @@ class SnapshotPersistQueue {
                        + bitmap.isMutable() + ") to (config=ARGB_8888, isMutable=false) failed.");
                return false;
            }
            final int width = bitmap.getWidth();
            final int height = bitmap.getHeight();
            bitmap.recycle();

            final File file = mPersistInfoProvider.getHighResolutionBitmapFile(mId, mUserId);
            try {
@@ -365,8 +368,8 @@ class SnapshotPersistQueue {
            }

            final Bitmap lowResBitmap = Bitmap.createScaledBitmap(swBitmap,
                    (int) (bitmap.getWidth() * mPersistInfoProvider.lowResScaleFactor()),
                    (int) (bitmap.getHeight() * mPersistInfoProvider.lowResScaleFactor()),
                    (int) (width * mPersistInfoProvider.lowResScaleFactor()),
                    (int) (height * mPersistInfoProvider.lowResScaleFactor()),
                    true /* filter */);
            swBitmap.recycle();