From f52ceba89962829aa12f5caba131580e8da85880 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/ui/AlbumLabelMaker.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/com/android/gallery3d/ui/AlbumLabelMaker.java') diff --git a/src/com/android/gallery3d/ui/AlbumLabelMaker.java b/src/com/android/gallery3d/ui/AlbumLabelMaker.java index 6eeeec045..da1cac0bd 100644 --- a/src/com/android/gallery3d/ui/AlbumLabelMaker.java +++ b/src/com/android/gallery3d/ui/AlbumLabelMaker.java @@ -27,8 +27,8 @@ import android.text.TextPaint; import android.text.TextUtils; import com.android.gallery3d.R; -import com.android.gallery3d.data.BitmapPool; import com.android.gallery3d.data.DataSourceType; +import com.android.photos.data.GalleryBitmapPool; import com.android.gallery3d.util.ThreadPool; import com.android.gallery3d.util.ThreadPool.JobContext; @@ -41,7 +41,8 @@ public class AlbumLabelMaker { private final Context mContext; private int mLabelWidth; - private BitmapPool mBitmapPool; + private int mBitmapWidth; + private int mBitmapHeight; private final LazyLoadedBitmap mLocalSetIcon; private final LazyLoadedBitmap mPicasaIcon; @@ -109,8 +110,8 @@ public class AlbumLabelMaker { if (mLabelWidth == width) return; mLabelWidth = width; int borders = 2 * BORDER_SIZE; - mBitmapPool = new BitmapPool( - width + borders, mSpec.labelBackgroundHeight + borders, 16); + mBitmapWidth = width + borders; + mBitmapHeight = mSpec.labelBackgroundHeight + borders; } public ThreadPool.Job requestLabel( @@ -152,7 +153,7 @@ public class AlbumLabelMaker { synchronized (this) { labelWidth = mLabelWidth; - bitmap = mBitmapPool.getBitmap(); + bitmap = GalleryBitmapPool.getInstance().get(mBitmapWidth, mBitmapHeight); } if (bitmap == null) { @@ -200,10 +201,6 @@ public class AlbumLabelMaker { } public void recycleLabel(Bitmap label) { - mBitmapPool.recycle(label); - } - - public void clearRecycledLabels() { - if (mBitmapPool != null) mBitmapPool.clear(); + GalleryBitmapPool.getInstance().put(label); } } -- cgit v1.2.3