Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6a2491c0 authored by nicolasroard's avatar nicolasroard
Browse files

Add stop check in ImageFilterFX

speed up switching / interrupting of rendering.

Change-Id: I3ef4b1d16047b00a062c86d72cdfff2bfe9817a2
parent d3d9e1d4
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -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];
+3 −2
Original line number Diff line number Diff line
@@ -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;
            }
        };
+17 −2
Original line number Diff line number Diff line
@@ -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;
    }