summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicolasroard <nicolasroard@google.com>2013-02-12 10:47:34 -0800
committernicolasroard <nicolasroard@google.com>2013-02-12 10:47:34 -0800
commit3d3a66695f3d022a71e8b9c77326eb68cd15b31d (patch)
tree514cda60f4ea0206e3e085a8e104d27df120dd0a
parentc4816efb49d3e90e37835d9359a6fa8447df97df (diff)
downloadandroid_packages_apps_Snap-3d3a66695f3d022a71e8b9c77326eb68cd15b31d.zip
android_packages_apps_Snap-3d3a66695f3d022a71e8b9c77326eb68cd15b31d.tar.gz
android_packages_apps_Snap-3d3a66695f3d022a71e8b9c77326eb68cd15b31d.tar.bz2
Add reset bitmap for RS filters
Change-Id: I34e28ca72d13f9b5f8054d8a2c07cfffca4e85c6
-rw-r--r--src/com/android/gallery3d/filtershow/cache/FilteringPipeline.java33
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java4
-rw-r--r--src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java9
3 files changed, 46 insertions, 0 deletions
diff --git a/src/com/android/gallery3d/filtershow/cache/FilteringPipeline.java b/src/com/android/gallery3d/filtershow/cache/FilteringPipeline.java
index 472fad7..4f5cfc4 100644
--- a/src/com/android/gallery3d/filtershow/cache/FilteringPipeline.java
+++ b/src/com/android/gallery3d/filtershow/cache/FilteringPipeline.java
@@ -22,6 +22,7 @@ import android.os.Process;
import android.support.v8.renderscript.*;
import android.util.Log;
+import com.android.gallery3d.filtershow.filters.FiltersManager;
import com.android.gallery3d.filtershow.filters.ImageFilterRS;
import com.android.gallery3d.filtershow.imageshow.GeometryMetadata;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
@@ -136,6 +137,10 @@ public class FilteringPipeline implements Handler.Callback {
return false;
}
+ if (DEBUG) {
+ Log.v(LOGTAG, "geometry has changed");
+ }
+
RenderScript RS = ImageFilterRS.getRenderScriptContext();
if (mFiltersOnlyOriginalAllocation != null) {
mFiltersOnlyOriginalAllocation.destroy();
@@ -151,6 +156,7 @@ public class FilteringPipeline implements Handler.Callback {
mPreviousGeometry = new GeometryMetadata(geometry);
+ FiltersManager.getManager().resetBitmapsRS();
return true;
}
@@ -190,14 +196,38 @@ public class FilteringPipeline implements Handler.Callback {
}
}
+ private String getType(RenderingRequest request) {
+ if (request.getType() == RenderingRequest.ICON_RENDERING) {
+ return "ICON_RENDERING";
+ }
+ if (request.getType() == RenderingRequest.FILTERS_RENDERING) {
+ return "FILTERS_RENDERING";
+ }
+ if (request.getType() == RenderingRequest.FULL_RENDERING) {
+ return "FULL_RENDERING";
+ }
+ if (request.getType() == RenderingRequest.GEOMETRY_RENDERING) {
+ return "GEOMETRY_RENDERING";
+ }
+ return "UNKNOWN TYPE!";
+ }
+
private void render(RenderingRequest request) {
if (request.getBitmap() == null
|| request.getImagePreset() == null) {
return;
}
+ if (DEBUG) {
+ Log.v(LOGTAG, "render image of type " + getType(request));
+ }
+
Bitmap bitmap = request.getBitmap();
ImagePreset preset = request.getImagePreset();
setPresetParameters(preset);
+ if (request.getType() == RenderingRequest.FILTERS_RENDERING) {
+ FiltersManager.getManager().resetBitmapsRS();
+ }
+
if (request.getType() != RenderingRequest.ICON_RENDERING) {
updateOriginalAllocation(preset);
}
@@ -218,6 +248,9 @@ public class FilteringPipeline implements Handler.Callback {
Bitmap bmp = preset.apply(bitmap);
request.setBitmap(bmp);
}
+ if (request.getType() == RenderingRequest.FILTERS_RENDERING) {
+ FiltersManager.getManager().resetBitmapsRS();
+ }
}
private void compute(TripleBufferBitmap buffer, ImagePreset preset, int type) {
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java
index 79c783a..f5c1e7f 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java
@@ -33,6 +33,10 @@ public class ImageFilterRS extends ImageFilter {
private final Bitmap.Config mBitmapConfig = Bitmap.Config.ARGB_8888;
+ public void resetBitmap() {
+ mOldBitmap = null;
+ }
+
public void prepare(Bitmap bitmap, float scaleFactor, boolean highQuality) {
if (sOldBitmap == null
|| (bitmap.getWidth() != sOldBitmap.getWidth())
diff --git a/src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java b/src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java
index 446d96d..2a1a6da 100644
--- a/src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java
+++ b/src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java
@@ -112,4 +112,13 @@ public class FiltersManager {
new ImageFilterDownsample(imageLoader));
}
+ public void resetBitmapsRS() {
+ for (Class c : mFilters.keySet()) {
+ ImageFilter filter = mFilters.get(c);
+ if (filter instanceof ImageFilterRS) {
+ ImageFilterRS filterRS = (ImageFilterRS) filter;
+ filterRS.resetBitmap();
+ }
+ }
+ }
}