summaryrefslogtreecommitdiffstats
path: root/src/com/android/photos
diff options
context:
space:
mode:
authorGeorge Mount <mount@google.com>2013-05-28 16:27:44 -0700
committerGeorge Mount <mount@google.com>2013-05-28 16:43:03 -0700
commite7b3f10280065ecc19b4b6a1cf9952a48ab618c0 (patch)
tree88b5d07becc6a7eed3b71ba9c2d3d091257a4cba /src/com/android/photos
parente0dbb510456f0682804a3a2c3b0d3f921ab15b64 (diff)
downloadandroid_packages_apps_Gallery2-e7b3f10280065ecc19b4b6a1cf9952a48ab618c0.tar.gz
android_packages_apps_Gallery2-e7b3f10280065ecc19b4b6a1cf9952a48ab618c0.tar.bz2
android_packages_apps_Gallery2-e7b3f10280065ecc19b4b6a1cf9952a48ab618c0.zip
Recover from bitmap decode failure.
Skia errors out when decoding a bitmap into another bitmap sometimes. When this situation is detected, the decode is is retried without reusing a bitmap. Change-Id: I935dec988ed7e115ceda9233a65d3b6083a17468
Diffstat (limited to 'src/com/android/photos')
-rw-r--r--src/com/android/photos/data/BitmapDecoder.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/com/android/photos/data/BitmapDecoder.java b/src/com/android/photos/data/BitmapDecoder.java
index 3e5a0f778..c5101cdfb 100644
--- a/src/com/android/photos/data/BitmapDecoder.java
+++ b/src/com/android/photos/data/BitmapDecoder.java
@@ -97,13 +97,13 @@ public class BitmapDecoder {
private static <T> Bitmap delegateDecode(Decoder<T> decoder, T input) {
BitmapFactory.Options options = getOptions();
+ GalleryBitmapPool pool = GalleryBitmapPool.getInstance();
try {
options.inJustDecodeBounds = true;
if (!decoder.decodeBounds(input, options)) {
return null;
}
options.inJustDecodeBounds = false;
- GalleryBitmapPool pool = GalleryBitmapPool.getInstance();
Bitmap reuseBitmap = pool.get(options.outWidth, options.outHeight);
options.inBitmap = reuseBitmap;
Bitmap decodedBitmap = decoder.decode(input, options);
@@ -111,6 +111,13 @@ public class BitmapDecoder {
pool.put(reuseBitmap);
}
return decodedBitmap;
+ } catch (IllegalArgumentException e) {
+ if (options.inBitmap == null) {
+ throw e;
+ }
+ pool.put(options.inBitmap);
+ options.inBitmap = null;
+ return decoder.decode(input, options);
} finally {
options.inBitmap = null;
options.inJustDecodeBounds = false;