summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/data/BitmapPool.java
diff options
context:
space:
mode:
authorOwen Lin <owenlin@google.com>2012-06-28 17:12:20 +0800
committerOwen Lin <owenlin@google.com>2012-07-03 18:05:47 +0800
commit7aac26484af3d40df81e1d08c673bd925856a7fa (patch)
tree4f444fc13ca1ee651f2e5e75787b5f1c16cef9eb /src/com/android/gallery3d/data/BitmapPool.java
parentce8b4485801843c14abc3654e57aad96d1364e49 (diff)
downloadandroid_packages_apps_Snap-7aac26484af3d40df81e1d08c673bd925856a7fa.tar.gz
android_packages_apps_Snap-7aac26484af3d40df81e1d08c673bd925856a7fa.tar.bz2
android_packages_apps_Snap-7aac26484af3d40df81e1d08c673bd925856a7fa.zip
Don't reuse bitmap before HoneyComb.
Change-Id: I0df9bf0a8f43e28ed25b436d4c584dc3ceb43c1d
Diffstat (limited to 'src/com/android/gallery3d/data/BitmapPool.java')
-rw-r--r--src/com/android/gallery3d/data/BitmapPool.java69
1 files changed, 2 insertions, 67 deletions
diff --git a/src/com/android/gallery3d/data/BitmapPool.java b/src/com/android/gallery3d/data/BitmapPool.java
index 0fbd84ef5..1151dded7 100644
--- a/src/com/android/gallery3d/data/BitmapPool.java
+++ b/src/com/android/gallery3d/data/BitmapPool.java
@@ -17,14 +17,9 @@
package com.android.gallery3d.data;
import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.BitmapFactory.Options;
import com.android.gallery3d.common.Utils;
-import com.android.gallery3d.ui.Log;
-import com.android.gallery3d.util.ThreadPool.JobContext;
-import java.io.FileDescriptor;
import java.util.ArrayList;
public class BitmapPool {
@@ -94,67 +89,7 @@ public class BitmapPool {
mPool.clear();
}
- private Bitmap findCachedBitmap(JobContext jc,
- byte[] data, int offset, int length, Options options) {
- if (mOneSize) return getBitmap();
- DecodeUtils.decodeBounds(jc, data, offset, length, options);
- return getBitmap(options.outWidth, options.outHeight);
- }
-
- private Bitmap findCachedBitmap(JobContext jc,
- FileDescriptor fileDescriptor, Options options) {
- if (mOneSize) return getBitmap();
- DecodeUtils.decodeBounds(jc, fileDescriptor, options);
- return getBitmap(options.outWidth, options.outHeight);
- }
-
- public Bitmap decode(JobContext jc,
- byte[] data, int offset, int length, BitmapFactory.Options options) {
- if (options == null) options = new BitmapFactory.Options();
- if (options.inSampleSize < 1) options.inSampleSize = 1;
- options.inPreferredConfig = Bitmap.Config.ARGB_8888;
- options.inBitmap = (options.inSampleSize == 1)
- ? findCachedBitmap(jc, data, offset, length, options) : null;
- try {
- Bitmap bitmap = DecodeUtils.decode(jc, data, offset, length, options);
- if (options.inBitmap != null && options.inBitmap != bitmap) {
- recycle(options.inBitmap);
- options.inBitmap = null;
- }
- return bitmap;
- } catch (IllegalArgumentException e) {
- if (options.inBitmap == null) throw e;
-
- Log.w(TAG, "decode fail with a given bitmap, try decode to a new bitmap");
- recycle(options.inBitmap);
- options.inBitmap = null;
- return DecodeUtils.decode(jc, data, offset, length, options);
- }
- }
-
- // This is the same as the method above except the source data comes
- // from a file descriptor instead of a byte array.
- public Bitmap decode(JobContext jc,
- FileDescriptor fileDescriptor, Options options) {
- if (options == null) options = new BitmapFactory.Options();
- if (options.inSampleSize < 1) options.inSampleSize = 1;
- options.inPreferredConfig = Bitmap.Config.ARGB_8888;
- options.inBitmap = (options.inSampleSize == 1)
- ? findCachedBitmap(jc, fileDescriptor, options) : null;
- try {
- Bitmap bitmap = DecodeUtils.decode(jc, fileDescriptor, options);
- if (options.inBitmap != null&& options.inBitmap != bitmap) {
- recycle(options.inBitmap);
- options.inBitmap = null;
- }
- return bitmap;
- } catch (IllegalArgumentException e) {
- if (options.inBitmap == null) throw e;
-
- Log.w(TAG, "decode fail with a given bitmap, try decode to a new bitmap");
- recycle(options.inBitmap);
- options.inBitmap = null;
- return DecodeUtils.decode(jc, fileDescriptor, options);
- }
+ public boolean isOneSize() {
+ return mOneSize;
}
}