From 11cfeeddedd61d3c4aa40945fef0bc2d87c7559d Mon Sep 17 00:00:00 2001 From: Bobby Georgescu Date: Tue, 19 Feb 2013 15:49:14 -0800 Subject: Replace various BitmapPools with a smarter unified pool Make all of gallery use a single shared pool, and pave the way for making the pool more adaptive based on the current workload. Change-Id: Ia32561ad50b1b9716ebe2fd32a7bf02737685dac --- src/com/android/gallery3d/ingest/IngestService.java | 1 - src/com/android/gallery3d/ingest/data/MtpBitmapFetch.java | 15 +++------------ 2 files changed, 3 insertions(+), 13 deletions(-) (limited to 'src/com/android/gallery3d/ingest') diff --git a/src/com/android/gallery3d/ingest/IngestService.java b/src/com/android/gallery3d/ingest/IngestService.java index 5e0ca0b68..fa421e771 100644 --- a/src/com/android/gallery3d/ingest/IngestService.java +++ b/src/com/android/gallery3d/ingest/IngestService.java @@ -187,7 +187,6 @@ public class IngestService extends Service implements ImportTask.Listener, public void deviceRemoved(MtpDevice device) { if (device == mDevice) { setDevice(null); - MtpBitmapFetch.onDeviceDisconnected(device); } } diff --git a/src/com/android/gallery3d/ingest/data/MtpBitmapFetch.java b/src/com/android/gallery3d/ingest/data/MtpBitmapFetch.java index 46a2051be..5e1fb34fd 100644 --- a/src/com/android/gallery3d/ingest/data/MtpBitmapFetch.java +++ b/src/com/android/gallery3d/ingest/data/MtpBitmapFetch.java @@ -25,19 +25,14 @@ import android.util.DisplayMetrics; import android.view.WindowManager; import com.android.camera.Exif; -import com.android.gallery3d.common.Utils; -import com.android.gallery3d.data.BitmapPool; - -import java.util.ArrayList; +import com.android.photos.data.GalleryBitmapPool; public class MtpBitmapFetch { - private static final int BITMAP_POOL_SIZE = 32; - private static BitmapPool sThumbnailPool = new BitmapPool(BITMAP_POOL_SIZE); private static int sMaxSize = 0; public static void recycleThumbnail(Bitmap b) { if (b != null) { - sThumbnailPool.recycle(b); + GalleryBitmapPool.getInstance().put(b); } } @@ -48,7 +43,7 @@ public class MtpBitmapFetch { o.inJustDecodeBounds = true; BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length, o); if (o.outWidth == 0 || o.outHeight == 0) return null; - o.inBitmap = sThumbnailPool.getBitmap(o.outWidth, o.outHeight); + o.inBitmap = GalleryBitmapPool.getInstance().get(o.outWidth, o.outHeight); o.inMutable = true; o.inJustDecodeBounds = false; o.inSampleSize = 1; @@ -86,10 +81,6 @@ public class MtpBitmapFetch { return new BitmapWithMetadata(created, Exif.getOrientation(imageBytes)); } - public static void onDeviceDisconnected(MtpDevice device) { - sThumbnailPool.clear(); - } - public static void configureForContext(Context context) { DisplayMetrics metrics = new DisplayMetrics(); WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); -- cgit v1.2.3