diff options
| author | 2019-03-26 12:11:27 -0400 | |
|---|---|---|
| committer | 2019-03-26 16:50:32 -0400 | |
| commit | ca8aef63766b3193464b8f9b4cde45324a83789a (patch) | |
| tree | 0e4b9e8cddf0673773e6c7f845892c412ee596e0 /graphics/java/android | |
| parent | 3111cff3c790a340ab479cf086b2a537fb2e8df1 (diff) | |
Remove bitmap::getBitmapAllocationByteCount
Test: I7eb02bc2389aadc10ee0b65993bb7e2dab27a129
Also remove gBitmap_getAllocationByteCountMethodID. These called into
Java, which then called back into native. Instead, call the native method
directly. The only extra wrinkle is that the Java method returns 0
if (mRecycled). But we would never reach that return value, since if
it was recycled, we would have crashed in native Bitmap::assertValid.
Instead, throw an IllegalArgumentException when attempting to reuse
it.
This avoids the overhead of two JNI calls, which tend to be slow.
Change-Id: I29e8d2428036252cfad532b1351e3a3d33817b43
Diffstat (limited to 'graphics/java/android')
| -rw-r--r-- | graphics/java/android/graphics/BitmapFactory.java | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/graphics/java/android/graphics/BitmapFactory.java b/graphics/java/android/graphics/BitmapFactory.java index 49c3a3ba68b8..d8a864015202 100644 --- a/graphics/java/android/graphics/BitmapFactory.java +++ b/graphics/java/android/graphics/BitmapFactory.java @@ -436,9 +436,15 @@ public class BitmapFactory { static void validate(Options opts) { if (opts == null) return; - if (opts.inBitmap != null && opts.inBitmap.getConfig() == Bitmap.Config.HARDWARE) { - throw new IllegalArgumentException( - "Bitmaps with Config.HARDWARE are always immutable"); + if (opts.inBitmap != null) { + if (opts.inBitmap.getConfig() == Bitmap.Config.HARDWARE) { + throw new IllegalArgumentException( + "Bitmaps with Config.HARDWARE are always immutable"); + } + if (opts.inBitmap.isRecycled()) { + throw new IllegalArgumentException( + "Cannot reuse a recycled Bitmap"); + } } if (opts.inMutable && opts.inPreferredConfig == Bitmap.Config.HARDWARE) { |