summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java21
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterSharpen.java4
-rw-r--r--src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java1
3 files changed, 16 insertions, 10 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java
index 2ebd61f..729aef8 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java
@@ -35,12 +35,12 @@ public abstract class ImageFilterRS extends ImageFilter {
private static volatile int sHeight = 0;
private static volatile Resources sResources = null;
- private boolean mResourcesLoaded = false;
+ private volatile boolean mResourcesLoaded = false;
private static final Bitmap.Config BITMAP_CONFIG = Bitmap.Config.ARGB_8888;
// This must be used inside block synchronized on ImageFilterRS class object
- public void prepare(Bitmap bitmap, float scaleFactor, int quality) {
+ protected void prepare(Bitmap bitmap, float scaleFactor, int quality) {
if (mOutPixelsAllocation == null || mInPixelsAllocation == null ||
bitmap.getWidth() != sWidth || bitmap.getHeight() != sHeight) {
destroyPixelAllocations();
@@ -65,14 +65,14 @@ public abstract class ImageFilterRS extends ImageFilter {
}
// This must be used inside block synchronized on ImageFilterRS class object
- abstract public void createFilter(android.content.res.Resources res,
+ protected abstract void createFilter(android.content.res.Resources res,
float scaleFactor, int quality);
// This must be used inside block synchronized on ImageFilterRS class object
- abstract public void runFilter();
+ protected abstract void runFilter();
// This must be used inside block synchronized on ImageFilterRS class object
- public void update(Bitmap bitmap) {
+ protected void update(Bitmap bitmap) {
mOutPixelsAllocation.copyTo(bitmap);
}
@@ -84,7 +84,7 @@ public abstract class ImageFilterRS extends ImageFilter {
try {
synchronized(ImageFilterRS.class) {
if (sRS == null) {
- Log.w(LOGTAG, "Cannot apply before calling setRenderScriptContext");
+ Log.w(LOGTAG, "Cannot apply before calling createRenderScriptContext");
return bitmap;
}
prepare(bitmap, scaleFactor, quality);
@@ -199,13 +199,18 @@ public abstract class ImageFilterRS extends ImageFilter {
mResourcesLoaded = resourcesLoaded;
}
+ // TODO:
+ // Ideally, every filter would destroy _every_ renderscript allocation,
+ // script, and anything else that depends on a certain RS context here.
abstract protected void resetAllocations();
public void freeResources() {
if (!isResourcesLoaded()) {
return;
}
- resetAllocations();
- setResourcesLoaded(false);
+ synchronized(ImageFilterRS.class) {
+ resetAllocations();
+ setResourcesLoaded(false);
+ }
}
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterSharpen.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterSharpen.java
index 9f4c7e5..5f0a5f8 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterSharpen.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterSharpen.java
@@ -52,7 +52,7 @@ public class ImageFilterSharpen extends ImageFilterRS {
}
@Override
- public void createFilter(android.content.res.Resources res, float scaleFactor,
+ protected void createFilter(android.content.res.Resources res, float scaleFactor,
int quality) {
int w = mInPixelsAllocation.getType().getX();
int h = mInPixelsAllocation.getType().getY();
@@ -83,7 +83,7 @@ public class ImageFilterSharpen extends ImageFilterRS {
}
@Override
- public void runFilter() {
+ protected void runFilter() {
if (mParameters == null) {
return;
}
diff --git a/src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java b/src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java
index 246e3f5..4b6b1d3 100644
--- a/src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java
+++ b/src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java
@@ -43,6 +43,7 @@ public class FiltersManager extends BaseFiltersManager {
public static void reset() {
sInstance = null;
+ sPreviewInstance = null;
}
}