diff options
Diffstat (limited to 'src/com')
5 files changed, 9 insertions, 51 deletions
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java index cd80e9257..7e8a3f582 100644 --- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java +++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java @@ -152,7 +152,6 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - ImageFilter.setActivityForMemoryToasts(this); setResources(); Resources res = getResources(); @@ -521,9 +520,6 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, if (mLoadBitmapTask != null) { mLoadBitmapTask.cancel(false); } - MasterImage.reset(); - FilteringPipeline.reset(); - ImageFilter.reset(); super.onDestroy(); } diff --git a/src/com/android/gallery3d/filtershow/cache/FilteringPipeline.java b/src/com/android/gallery3d/filtershow/cache/FilteringPipeline.java index 0af406316..7d5b52921 100644 --- a/src/com/android/gallery3d/filtershow/cache/FilteringPipeline.java +++ b/src/com/android/gallery3d/filtershow/cache/FilteringPipeline.java @@ -31,7 +31,7 @@ import com.android.gallery3d.filtershow.presets.ImagePreset; public class FilteringPipeline implements Handler.Callback { - private static FilteringPipeline sPipeline; + private final static FilteringPipeline gPipeline = new FilteringPipeline(); private static final String LOGTAG = "FilteringPipeline"; private ImagePreset mPreviousGeometryPreset = null; private ImagePreset mPreviousFiltersPreset = null; @@ -117,10 +117,7 @@ public class FilteringPipeline implements Handler.Callback { } public static FilteringPipeline getPipeline() { - if (sPipeline == null) { - sPipeline = new FilteringPipeline(); - } - return sPipeline; + return gPipeline; } public synchronized void setOriginal(Bitmap bitmap) { @@ -340,8 +337,4 @@ public class FilteringPipeline implements Handler.Callback { public float getPreviewScaleFactor() { return mPreviewScaleFactor; } - - public static void reset() { - sPipeline = null; - } } diff --git a/src/com/android/gallery3d/filtershow/cache/ImageLoader.java b/src/com/android/gallery3d/filtershow/cache/ImageLoader.java index a5b1bc5a4..25bb6b60a 100644 --- a/src/com/android/gallery3d/filtershow/cache/ImageLoader.java +++ b/src/com/android/gallery3d/filtershow/cache/ImageLoader.java @@ -62,8 +62,6 @@ import java.io.OutputStream; import java.util.Vector; import java.util.concurrent.locks.ReentrantLock; - -// TODO: this class has waaaay to much bitmap copying. Cleanup. public class ImageLoader { private static final String LOGTAG = "ImageLoader"; @@ -391,13 +389,15 @@ public class ImageLoader { } bmp = loadRegionBitmap(mUri, options, bounds); if (bmp != null) { + // TODO: this workaround for RS might not be needed ultimately + Bitmap bmp2 = bmp.copy(Bitmap.Config.ARGB_8888, true); float scaleFactor = imagePreset.getScaleFactor(); imagePreset.setScaleFactor(1.0f); - bmp = imagePreset.apply(bmp); + bmp2 = imagePreset.apply(bmp2); imagePreset.setScaleFactor(scaleFactor); - mZoomCache.setImage(imagePreset, bounds, bmp); + mZoomCache.setImage(imagePreset, bounds, bmp2); mLoadingLock.unlock(); - return bmp; + return bmp2; } } mLoadingLock.unlock(); diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java index 866fc5e42..614c6a01d 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java @@ -18,10 +18,8 @@ package com.android.gallery3d.filtershow.filters; import android.graphics.Bitmap; import android.graphics.Matrix; -import android.widget.Toast; import com.android.gallery3d.R; -import com.android.gallery3d.filtershow.FilterShowActivity; import com.android.gallery3d.filtershow.editors.BasicEditor; import com.android.gallery3d.filtershow.imageshow.GeometryMetadata; import com.android.gallery3d.filtershow.presets.ImagePreset; @@ -33,30 +31,6 @@ public abstract class ImageFilter implements Cloneable { protected String mName = "Original"; private final String LOGTAG = "ImageFilter"; - // TODO: Temporary, for dogfood note memory issues with toasts for better - // feedback. Remove this when filters actually work in low memory - // situations. - private static FilterShowActivity sActivity = null; - - public static void setActivityForMemoryToasts(FilterShowActivity activity) { - sActivity = activity; - } - - public static void reset() { - sActivity = null; - } - - public void displayLowMemoryToast() { - if (sActivity != null) { - sActivity.runOnUiThread(new Runnable() { - public void run() { - Toast.makeText(sActivity, "Memory too low for filter " + getName() + - ", please file a bug report", Toast.LENGTH_SHORT).show(); - } - }); - } - } - public void setName(String name) { mName = name; } @@ -71,8 +45,8 @@ public abstract class ImageFilter implements Cloneable { } /** - * Called on small bitmaps to create button icons for each filter. Override - * this to provide filter-specific button icons. + * Called on small bitmaps to create button icons for each filter. + * Override this to provide filter-specific button icons. */ public Bitmap iconApply(Bitmap bitmap, float scaleFactor, int quality) { return apply(bitmap, scaleFactor, quality); diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java index a3467edde..74712be47 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java @@ -89,11 +89,6 @@ public abstract class ImageFilterRS extends ImageFilter { Log.e(LOGTAG, "Illegal argument? " + e); } catch (android.renderscript.RSRuntimeException e) { Log.e(LOGTAG, "RS runtime exception ? " + e); - } catch (java.lang.OutOfMemoryError e) { - // Many of the renderscript filters allocated large (>16Mb resources) in order to apply. - System.gc(); - displayLowMemoryToast(); - Log.e(LOGTAG, "not enough memory for filter " + getName(), e); } return bitmap; } |