From 1440e7564079e4e6e54216e0ed80c809a3cec421 Mon Sep 17 00:00:00 2001 From: nicolasroard Date: Mon, 11 Mar 2013 19:16:03 -0700 Subject: Various bugfixes/improvements for Fx Filters: - fix bug in history with Fx filters - don't load Fx bitmaps at startup - free bitmaps when unneeded - fix history preview bitmaps Change-Id: I5631a5bcec12c121871b3575066c201486896a14 --- .../filtershow/filters/FilterFxRepresentation.java | 26 ++++++++++------------ .../filtershow/filters/FilterRepresentation.java | 6 ++++- .../gallery3d/filtershow/presets/ImagePreset.java | 2 ++ 3 files changed, 19 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java index d4128dc79..6e2e7ea16 100644 --- a/src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java +++ b/src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java @@ -17,10 +17,11 @@ package com.android.gallery3d.filtershow.filters; import android.graphics.Bitmap; +import com.android.gallery3d.app.Log; import com.android.gallery3d.filtershow.editors.ImageOnlyEditor; public class FilterFxRepresentation extends FilterRepresentation { - private Bitmap mFxBitmap = null; + private static final String LOGTAG = "FilterFxRepresentation"; // TODO: When implementing serialization, we should find a unique way of // specifying bitmaps / names (the resource IDs being random) private int mBitmapResource = 0; @@ -41,26 +42,24 @@ public class FilterFxRepresentation extends FilterRepresentation { } public String toString() { - return "FilterFx: " + getName(); + return "FilterFx: " + hashCode() + " : " + getName() + " bitmap rsc: " + mBitmapResource; } @Override - public FilterRepresentation clone() throws CloneNotSupportedException { + public synchronized FilterRepresentation clone() throws CloneNotSupportedException { FilterFxRepresentation representation = (FilterFxRepresentation) super.clone(); representation.setName(getName()); representation.setBitmapResource(getBitmapResource()); representation.setNameResource(getNameResource()); - representation.setFxBitmap(getFxBitmap()); return representation; } - public void useParametersFrom(FilterRepresentation a) { + public synchronized void useParametersFrom(FilterRepresentation a) { if (a instanceof FilterFxRepresentation) { FilterFxRepresentation representation = (FilterFxRepresentation) a; setName(representation.getName()); setBitmapResource(representation.getBitmapResource()); setNameResource(representation.getNameResource()); - setFxBitmap(representation.getFxBitmap()); } } @@ -79,16 +78,15 @@ public class FilterFxRepresentation extends FilterRepresentation { return false; } - public boolean allowsMultipleInstances() { - return true; - } - - public Bitmap getFxBitmap() { - return mFxBitmap; + public boolean same(FilterRepresentation representation) { + if (!super.same(representation)) { + return false; + } + return equals(representation); } - public void setFxBitmap(Bitmap fxBitmap) { - mFxBitmap = fxBitmap; + public boolean allowsMultipleInstances() { + return true; } public int getNameResource() { diff --git a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java index e0dc905e3..b92460d99 100644 --- a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java +++ b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java @@ -21,6 +21,7 @@ import com.android.gallery3d.filtershow.editors.BasicEditor; public class FilterRepresentation implements Cloneable { private static final String LOGTAG = "FilterRepresentation"; + private static final boolean DEBUG = false; private String mName; private int mPriority = TYPE_NORMAL; private Class mFilterClass; @@ -62,7 +63,10 @@ public class FilterRepresentation implements Cloneable { representation.setShowEditingControls(showEditingControls()); representation.setShowParameterValue(showParameterValue()); representation.setShowUtilityPanel(showUtilityPanel()); - Log.v(LOGTAG, "cloning from <" + this + "> to <" + representation + ">"); + representation.mTempRepresentation = null; + if (DEBUG) { + Log.v(LOGTAG, "cloning from <" + this + "> to <" + representation + ">"); + } return representation; } diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java index 87d9c8183..e27afe580 100644 --- a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java +++ b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java @@ -54,6 +54,7 @@ public class ImagePreset { public final GeometryMetadata mGeoData = new GeometryMetadata(); private boolean mPartialRendering = false; private Rect mPartialRenderingBounds; + private Bitmap mPreviewImage; private FilterEnvironment mEnvironment = new FilterEnvironment(); @@ -90,6 +91,7 @@ public class ImagePreset { mHistoryName = source.name(); mIsFxPreset = source.isFx(); mImageLoader = source.getImageLoader(); + mPreviewImage = source.getPreviewImage(); mGeoData.set(source.mGeoData); } -- cgit v1.2.3