summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/filtershow/presets
diff options
context:
space:
mode:
authorJohn Hoford <hoford@google.com>2013-04-22 13:40:39 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-04-22 13:40:39 -0700
commitb6754c1cea1c1b7974b9eedc0b0357dd9fccb9d5 (patch)
treec4344f5033e004f57029d2721cfe9a866e69b937 /src/com/android/gallery3d/filtershow/presets
parent871d0fde36284a5861174514544ea225459a0cb3 (diff)
parent91d26f6c3b183862eeffc1856e2d758e800d13f4 (diff)
downloadandroid_packages_apps_Gallery2-b6754c1cea1c1b7974b9eedc0b0357dd9fccb9d5.tar.gz
android_packages_apps_Gallery2-b6754c1cea1c1b7974b9eedc0b0357dd9fccb9d5.tar.bz2
android_packages_apps_Gallery2-b6754c1cea1c1b7974b9eedc0b0357dd9fccb9d5.zip
am 91d26f6c: tiny planet fix
* commit '91d26f6c3b183862eeffc1856e2d758e800d13f4': tiny planet fix
Diffstat (limited to 'src/com/android/gallery3d/filtershow/presets')
-rw-r--r--src/com/android/gallery3d/filtershow/presets/FilterEnvironment.java34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/com/android/gallery3d/filtershow/presets/FilterEnvironment.java b/src/com/android/gallery3d/filtershow/presets/FilterEnvironment.java
index 7b0e0193f..3c53227fc 100644
--- a/src/com/android/gallery3d/filtershow/presets/FilterEnvironment.java
+++ b/src/com/android/gallery3d/filtershow/presets/FilterEnvironment.java
@@ -18,17 +18,51 @@ package com.android.gallery3d.filtershow.presets;
import android.graphics.Bitmap;
import android.support.v8.renderscript.Allocation;
+import android.util.Log;
+
import com.android.gallery3d.filtershow.cache.CachingPipeline;
import com.android.gallery3d.filtershow.filters.FilterRepresentation;
import com.android.gallery3d.filtershow.filters.FiltersManager;
import com.android.gallery3d.filtershow.filters.ImageFilter;
+import java.lang.ref.WeakReference;
+import java.util.HashMap;
+
public class FilterEnvironment {
+ private static final String LOGTAG = "FilterEnvironment";
private ImagePreset mImagePreset;
private float mScaleFactor;
private int mQuality;
private FiltersManager mFiltersManager;
private CachingPipeline mCachingPipeline;
+ private HashMap<Long, WeakReference<Bitmap>>
+ bitmapCach = new HashMap<Long, WeakReference<Bitmap>>();
+
+ public void cache(Bitmap bitmap) {
+ if (bitmap == null) {
+ return;
+ }
+ Long key = calcKey(bitmap.getWidth(), bitmap.getHeight());
+ bitmapCach.put(key, new WeakReference<Bitmap>(bitmap));
+ }
+
+ public Bitmap getBitmap(int w, int h) {
+ Long key = calcKey(w, h);
+ WeakReference<Bitmap> ref = bitmapCach.remove(key);
+ Bitmap bitmap = null;
+ if (ref != null) {
+ bitmap = ref.get();
+ }
+ if (bitmap == null) {
+ bitmap = Bitmap.createBitmap(
+ w, h, Bitmap.Config.ARGB_8888);
+ }
+ return bitmap;
+ }
+
+ private Long calcKey(long w, long h) {
+ return (w << 32) | (h << 32);
+ }
public void setImagePreset(ImagePreset imagePreset) {
mImagePreset = imagePreset;