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

Commit dab91059 authored by Kevin Jeon's avatar Kevin Jeon Committed by Android (Google) Code Review
Browse files

Merge "Save sizes when dumping bitmaps" into main

parents c7ca021a 2dcf64fa
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -1575,6 +1575,7 @@ public final class Bitmap implements Parcelable {
        private int format;
        private long[] natives;
        private byte[][] buffers;
        private int[] sizes;
        private int max;

        public DumpData(@NonNull CompressFormat format, int max) {
@@ -1582,12 +1583,14 @@ public final class Bitmap implements Parcelable {
            this.format = format.nativeInt;
            this.natives = new long[max];
            this.buffers = new byte[max][];
            this.sizes = new int[max];
            this.count = 0;
        }

        public void add(long nativePtr, byte[] buffer) {
        public void add(long nativePtr, byte[] buffer, int size) {
            natives[count] = nativePtr;
            buffers[count] = buffer;
            sizes[count] = size;
            count = (count >= max) ? max : count + 1;
        }

@@ -1639,7 +1642,8 @@ public final class Bitmap implements Parcelable {
        for (Bitmap bitmap : allBitmaps) {
            ByteArrayOutputStream bas = new ByteArrayOutputStream();
            if (bitmap.compress(fmt, 90, bas)) {
                dumpData.add(bitmap.getNativeInstance(), bas.toByteArray());
                dumpData.add(bitmap.getNativeInstance(), bas.toByteArray(),
                        bitmap.getAllocationByteCount());
            }
        }
        Log.i(TAG, dumpData.size() + "/" + allBitmaps.size() + " bitmaps dumped");