Loading graphics/java/android/graphics/Bitmap.java +18 −11 Original line number Diff line number Diff line Loading @@ -127,6 +127,22 @@ 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). Loading @@ -151,7 +167,6 @@ public final class Bitmap implements Parcelable { mWidth = width; mHeight = height; mRequestPremultiplied = requestPremultiplied; mNinePatchChunk = ninePatchChunk; mNinePatchInsets = ninePatchInsets; if (density >= 0) { Loading @@ -159,17 +174,9 @@ public final class Bitmap implements Parcelable { } mNativePtr = nativeBitmap; 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); getRegistry(fromMalloc, allocationByteCount).registerNativeAllocation(this, mNativePtr); synchronized (Bitmap.class) { sAllBitmaps.put(this, null); } Loading Loading
graphics/java/android/graphics/Bitmap.java +18 −11 Original line number Diff line number Diff line Loading @@ -127,6 +127,22 @@ 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). Loading @@ -151,7 +167,6 @@ public final class Bitmap implements Parcelable { mWidth = width; mHeight = height; mRequestPremultiplied = requestPremultiplied; mNinePatchChunk = ninePatchChunk; mNinePatchInsets = ninePatchInsets; if (density >= 0) { Loading @@ -159,17 +174,9 @@ public final class Bitmap implements Parcelable { } mNativePtr = nativeBitmap; 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); getRegistry(fromMalloc, allocationByteCount).registerNativeAllocation(this, mNativePtr); synchronized (Bitmap.class) { sAllBitmaps.put(this, null); } Loading