diff options
author | Christian Wichner <cwichner@google.com> | 2013-05-24 16:09:07 +0200 |
---|---|---|
committer | Christian Wichner <cwichner@google.com> | 2013-05-24 16:09:07 +0200 |
commit | 07a438da6d0c4dcd383c4d5e8a10e63066481dc9 (patch) | |
tree | c2b2863d2c1d9ffd689d18b15e0f8ce6939f17b6 /src | |
parent | 0125c1797512189a99c9ca002f21b9812aca16b6 (diff) | |
download | android_packages_apps_Gallery2-07a438da6d0c4dcd383c4d5e8a10e63066481dc9.tar.gz android_packages_apps_Gallery2-07a438da6d0c4dcd383c4d5e8a10e63066481dc9.tar.bz2 android_packages_apps_Gallery2-07a438da6d0c4dcd383c4d5e8a10e63066481dc9.zip |
functionality added to transport filter parameter values to following filters. e.g. FixedFrames use the style from Retrolux or Film to tinting the frame.
Change-Id: I87f2497bdaccf8de5d153cbebf9641b979ea15a3
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/gallery3d/filtershow/filters/ImageFilter.java | 9 | ||||
-rw-r--r-- | src/com/android/gallery3d/filtershow/presets/FilterEnvironment.java | 24 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java index b80fc7f15..6481e108e 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java @@ -69,10 +69,12 @@ public abstract class ImageFilter implements Cloneable { public boolean supportsAllocationInput() { return false; } public void apply(Allocation in, Allocation out) { + setGeneralParameters(); } public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) { // do nothing here, subclasses will implement filtering here + setGeneralParameters(); return bitmap; } @@ -102,4 +104,11 @@ public abstract class ImageFilter implements Cloneable { public FilterEnvironment getEnvironment() { return mEnvironment; } + + public void setGeneralParameters() { + // should implement in subclass which like to transport + // some information to other filters. (like the style setting from RetroLux + // and Film to FixedFrame) + mEnvironment.clearGeneralParameters(); + } } diff --git a/src/com/android/gallery3d/filtershow/presets/FilterEnvironment.java b/src/com/android/gallery3d/filtershow/presets/FilterEnvironment.java index 47f8dfccb..8d59c9f54 100644 --- a/src/com/android/gallery3d/filtershow/presets/FilterEnvironment.java +++ b/src/com/android/gallery3d/filtershow/presets/FilterEnvironment.java @@ -50,6 +50,9 @@ public class FilterEnvironment { private HashMap<Long, WeakReference<Bitmap>> bitmapCach = new HashMap<Long, WeakReference<Bitmap>>(); + private HashMap<Integer, Integer> + generalParameters = new HashMap<Integer, Integer>(); + public void cache(Bitmap bitmap) { if (bitmap == null) { return; @@ -116,6 +119,7 @@ public class FilterEnvironment { if (filter.supportsAllocationInput()) { filter.apply(in, out); } + filter.setGeneralParameters(); filter.setEnvironment(null); } @@ -124,6 +128,7 @@ public class FilterEnvironment { filter.useRepresentation(representation); filter.setEnvironment(this); Bitmap ret = filter.apply(bitmap, mScaleFactor, mQuality); + filter.setGeneralParameters(); filter.setEnvironment(null); return ret; } @@ -136,4 +141,23 @@ public class FilterEnvironment { mPipeline = cachingPipeline; } + public synchronized void clearGeneralParameters() { + generalParameters = null; + } + + public synchronized Integer getGeneralParameter(int id) { + if (generalParameters == null || !generalParameters.containsKey(id)) { + return null; + } + return generalParameters.get(id); + } + + public synchronized void setGeneralParameter(int id, int value) { + if (generalParameters == null) { + generalParameters = new HashMap<Integer, Integer>(); + } + + generalParameters.put(id, value); + } + } |