Fix stickiness issues with UI
The renderGeometryIcon() function shouldn't
be synchronized -- it's independent of the rest
of the pipeline and is only used to apply a given geometry.
Change-Id: I91a5d2ec3f28f15c489066ed2c5a5009e29fa7b3
diff --git a/src/com/android/gallery3d/filtershow/cache/CachingPipeline.java b/src/com/android/gallery3d/filtershow/cache/CachingPipeline.java
index 752e1c2..8c312a9 100644
--- a/src/com/android/gallery3d/filtershow/cache/CachingPipeline.java
+++ b/src/com/android/gallery3d/filtershow/cache/CachingPipeline.java
@@ -23,6 +23,7 @@
import android.support.v8.renderscript.RenderScript;
import android.util.Log;
import com.android.gallery3d.filtershow.filters.FiltersManager;
+import com.android.gallery3d.filtershow.filters.ImageFilterGeometry;
import com.android.gallery3d.filtershow.filters.ImageFilterRS;
import com.android.gallery3d.filtershow.imageshow.GeometryMetadata;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
@@ -57,6 +58,8 @@
private volatile float mHighResPreviewScaleFactor = 1.0f;
private volatile String mName = "";
+ private ImageFilterGeometry mGeometry = null;
+
public CachingPipeline(FiltersManager filtersManager, String name) {
mFiltersManager = filtersManager;
mName = name;
@@ -302,16 +305,15 @@
}
}
- public synchronized Bitmap renderGeometryIcon(Bitmap bitmap, ImagePreset preset) {
- synchronized (CachingPipeline.class) {
- if (getRenderScriptContext() == null) {
- return bitmap;
- }
- setupEnvironment(preset, false);
- mEnvironment.setQuality(ImagePreset.QUALITY_PREVIEW);
- bitmap = preset.applyGeometry(bitmap, mEnvironment);
- return bitmap;
+ public Bitmap renderGeometryIcon(Bitmap bitmap, ImagePreset preset) {
+ // Called by RenderRequest on the main thread
+ // TODO: change this -- we should reuse a pool of bitmaps instead...
+ if (mGeometry == null) {
+ mGeometry = new ImageFilterGeometry();
}
+ mGeometry.useRepresentation(preset.getGeometry());
+ return mGeometry.apply(bitmap, mPreviewScaleFactor,
+ ImagePreset.QUALITY_PREVIEW);
}
public synchronized void compute(TripleBufferBitmap buffer, ImagePreset preset, int type) {