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

Commit 4858b218 authored by Ashish Kumar Gupta's avatar Ashish Kumar Gupta Committed by Android (Google) Code Review
Browse files

Revert "Track Bitmap native allocations"

This reverts commit b27f9146.

Reason for revert: Files by Google app and print preview experience is broken due to this CL. Please check b/368409430

Change-Id: I91b87073ecd597a1f180095cbaf759f37434a741
parent b27f9146
Loading
Loading
Loading
Loading
+11 −18
Original line number Diff line number Diff line
@@ -127,22 +127,6 @@ public final class Bitmap implements Parcelable {
     */
    private static final WeakHashMap<Bitmap, Void> sAllBitmaps = new WeakHashMap<>();

    /**
     * @hide
     */
    private static NativeAllocationRegistry getRegistry(boolean malloc, long size) {
        final long free = nativeGetNativeFinalizer();
        if (com.android.libcore.Flags.nativeMetrics()) {
            Class cls = Bitmap.class;
            return malloc ? NativeAllocationRegistry.createMalloced(cls, free, size)
                          : NativeAllocationRegistry.createNonmalloced(cls, free, size);
        } else {
            ClassLoader loader = Bitmap.class.getClassLoader();
            return malloc ? NativeAllocationRegistry.createMalloced(loader, free, size)
                          : NativeAllocationRegistry.createNonmalloced(loader, free, size);
        }
    }

    /**
     * Private constructor that must receive an already allocated native bitmap
     * int (pointer).
@@ -167,6 +151,7 @@ public final class Bitmap implements Parcelable {
        mWidth = width;
        mHeight = height;
        mRequestPremultiplied = requestPremultiplied;

        mNinePatchChunk = ninePatchChunk;
        mNinePatchInsets = ninePatchInsets;
        if (density >= 0) {
@@ -174,9 +159,17 @@ public final class Bitmap implements Parcelable {
        }

        mNativePtr = nativeBitmap;
        final int allocationByteCount = getAllocationByteCount();
        getRegistry(fromMalloc, allocationByteCount).registerNativeAllocation(this, mNativePtr);

        final int allocationByteCount = getAllocationByteCount();
        NativeAllocationRegistry registry;
        if (fromMalloc) {
            registry = NativeAllocationRegistry.createMalloced(
                    Bitmap.class.getClassLoader(), nativeGetNativeFinalizer(), allocationByteCount);
        } else {
            registry = NativeAllocationRegistry.createNonmalloced(
                    Bitmap.class.getClassLoader(), nativeGetNativeFinalizer(), allocationByteCount);
        }
        registry.registerNativeAllocation(this, nativeBitmap);
        synchronized (Bitmap.class) {
          sAllBitmaps.put(this, null);
        }