speed up switching / interrupting of rendering.
Change-Id: I3ef4b1d16047b00a062c86d72cdfff2bfe9817a2
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;
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];
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;
}
};
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) {
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;
}