summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicolasroard <nicolasroard@google.com>2013-07-02 13:21:31 -0700
committernicolasroard <nicolasroard@google.com>2013-07-02 13:22:38 -0700
commitdbc7b1ebe939d68cbc7f01878e038ca3e9c35f89 (patch)
treef832719bc9d7f369757de8828ae3e105e6f5c787
parente6af6d79fdaebcf566f9281ed6a29778d284dc42 (diff)
downloadandroid_packages_apps_Snap-dbc7b1ebe939d68cbc7f01878e038ca3e9c35f89.zip
android_packages_apps_Snap-dbc7b1ebe939d68cbc7f01878e038ca3e9c35f89.tar.gz
android_packages_apps_Snap-dbc7b1ebe939d68cbc7f01878e038ca3e9c35f89.tar.bz2
Add stop check in ImageFilterFX
speed up switching / interrupting of rendering. Change-Id: I3ef4b1d16047b00a062c86d72cdfff2bfe9817a2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/IconUtilities.java5
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterFx.java19
2 files changed, 20 insertions, 4 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/IconUtilities.java b/src/com/android/gallery3d/filtershow/filters/IconUtilities.java
index 38211f3..e2a0147 100644
--- a/src/com/android/gallery3d/filtershow/filters/IconUtilities.java
+++ b/src/com/android/gallery3d/filtershow/filters/IconUtilities.java
@@ -64,8 +64,9 @@ public class IconUtilities {
int h = bitmap.getHeight();
int fxw = fxBitmap.getWidth();
int fxh = fxBitmap.getHeight();
-
- nativeApplyFilter(bitmap, w, h, fxBitmap, fxw, fxh);
+ int start = 0;
+ int end = w * h * 4;
+ nativeApplyFilter(bitmap, w, h, fxBitmap, fxw, fxh, start, end);
return bitmap;
}
};
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterFx.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterFx.java
index 51c6612..19bea59 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterFx.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterFx.java
@@ -51,7 +51,9 @@ public class ImageFilterFx extends ImageFilter {
return mParameters;
}
- native protected void nativeApplyFilter(Bitmap bitmap, int w, int h,Bitmap fxBitmap, int fxw, int fxh);
+ native protected void nativeApplyFilter(Bitmap bitmap, int w, int h,
+ Bitmap fxBitmap, int fxw, int fxh,
+ int start, int end);
@Override
public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
@@ -85,7 +87,20 @@ public class ImageFilterFx extends ImageFilter {
int fxw = mFxBitmap.getWidth();
int fxh = mFxBitmap.getHeight();
- nativeApplyFilter(bitmap, w, h, mFxBitmap, fxw, fxh);
+ int stride = w * 4;
+ int max = stride * h;
+ int increment = stride * 256; // 256 lines
+ for (int i = 0; i < max; i += increment) {
+ int start = i;
+ int end = i + increment;
+ if (end > max) {
+ end = max;
+ }
+ if (!getEnvironment().needsStop()) {
+ nativeApplyFilter(bitmap, w, h, mFxBitmap, fxw, fxh, start, end);
+ }
+ }
+
return bitmap;
}