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
commit6a2491c0afff0243b2174743937ea4be463a22b0 (patch)
treec606911e7993cd6cb4abc152609bf2ed3a620fed
parentd3d9e1d480631f9d2edaab326013855b39faa0ca (diff)
downloadandroid_packages_apps_Gallery2-6a2491c0afff0243b2174743937ea4be463a22b0.tar.gz
android_packages_apps_Gallery2-6a2491c0afff0243b2174743937ea4be463a22b0.tar.bz2
android_packages_apps_Gallery2-6a2491c0afff0243b2174743937ea4be463a22b0.zip
Add stop check in ImageFilterFX
speed up switching / interrupting of rendering. Change-Id: I3ef4b1d16047b00a062c86d72cdfff2bfe9817a2
-rw-r--r--jni/filters/fx.c8
-rw-r--r--src/com/android/gallery3d/filtershow/filters/IconUtilities.java5
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterFx.java19
3 files changed, 24 insertions, 8 deletions
diff --git a/jni/filters/fx.c b/jni/filters/fx.c
index 24fa5e0d7..c3c9cbdc6 100644
--- a/jni/filters/fx.c
+++ b/jni/filters/fx.c
@@ -29,7 +29,9 @@ __inline__ int interp(unsigned char *src, int p , int *off ,float dr,float dg,
return (int)frbg ;
}
-void JNIFUNCF(ImageFilterFx, nativeApplyFilter, jobject bitmap, jint width, jint height, jobject lutbitmap,jint lutwidth, jint lutheight )
+void JNIFUNCF(ImageFilterFx, nativeApplyFilter, jobject bitmap, jint width, jint height,
+ jobject lutbitmap, jint lutwidth, jint lutheight,
+ jint start, jint end)
{
char* destination = 0;
char* lut = 0;
@@ -58,9 +60,7 @@ void JNIFUNCF(ImageFilterFx, nativeApplyFilter, jobject bitmap, jint width, jint
float scale_B = (lutdim_b-1.f)/256.f;
int i;
- int len = width * height * STEP;
-
- for (i = 0; i < len; i+=STEP)
+ for (i = start; i < end; i+= STEP)
{
int r = rgb[RED];
int g = rgb[GREEN];
diff --git a/src/com/android/gallery3d/filtershow/filters/IconUtilities.java b/src/com/android/gallery3d/filtershow/filters/IconUtilities.java
index 38211f3c9..e2a01472d 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 51c66127b..19bea593b 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;
}