summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorJohn Hoford <hoford@google.com>2013-04-18 18:43:29 -0700
committerJohn Hoford <hoford@google.com>2013-04-19 15:26:53 -0700
commitbe3e14d561ed1033fa44526ab83b170cfae45b4f (patch)
tree7b3b52f37c8f6f06c41652f12034c0f498b59853 /src/com
parente7cb33d130d2e86f4ef664b9203167afbfee42ff (diff)
downloadandroid_packages_apps_Snap-be3e14d561ed1033fa44526ab83b170cfae45b4f.tar.gz
android_packages_apps_Snap-be3e14d561ed1033fa44526ab83b170cfae45b4f.tar.bz2
android_packages_apps_Snap-be3e14d561ed1033fa44526ab83b170cfae45b4f.zip
tiny planet fix
bug:8323524 Change-Id: I39283face7079574dbe25e797323a84141930f9a
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java9
-rw-r--r--src/com/android/gallery3d/filtershow/presets/FilterEnvironment.java34
2 files changed, 43 insertions, 0 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java
index 7b69ce9e0..ac5e04601 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java
@@ -31,6 +31,7 @@ public class FilterTinyPlanetRepresentation extends FilterBasicRepresentation {
setTextId(R.string.tinyplanet);
setButtonId(R.id.tinyplanetButton);
setEditorId(EditorTinyPlanet.ID);
+ setMinimum(1);
}
@Override
@@ -42,6 +43,14 @@ public class FilterTinyPlanetRepresentation extends FilterBasicRepresentation {
return representation;
}
+ @Override
+ public void useParametersFrom(FilterRepresentation a) {
+ FilterTinyPlanetRepresentation representation = (FilterTinyPlanetRepresentation) a;
+ super.useParametersFrom(a);
+ mAngle = representation.mAngle;
+ setZoom(representation.getZoom());
+ }
+
public void setAngle(float angle) {
mAngle = angle;
}
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;