Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper way to change matrix from TransformFilter #28

Open
puelocesar opened this issue Aug 26, 2015 · 0 comments
Open

Proper way to change matrix from TransformFilter #28

puelocesar opened this issue Aug 26, 2015 · 0 comments

Comments

@puelocesar
Copy link

So, I'm testing a very basic setup:

             Image1 \
                     \
                       - >  blend -> view
                     /
Image2 -> transform /

Problem is, I want to modify the transform matrix based on user input. As I couldn't find any way to modify TransformFilter matrix after it's created, I'm destroying it and recreating it with the new matrix.

It's working fine on emulator, but when running on device, it always crash after a few edits. Sometimes it crashes due OutOfMemory error, and sometimes it crashes with:

08-26 15:56:13.173    4312-4327/? E/AndroidRuntime﹕ FATAL EXCEPTION: GLThread 270
    java.lang.ArrayIndexOutOfBoundsException: length=1; index=-2
            at project.android.imageprocessing.filter.MultiInputFilter.newTextureReady(MultiInputFilter.java:87)
            at project.android.imageprocessing.input.GLTextureOutputRenderer.drawFrame(GLTextureOutputRenderer.java:88)
            at project.android.imageprocessing.input.ImageResourceInput.drawFrame(ImageResourceInput.java:67)
            at project.android.imageprocessing.GLRenderer.onDrawFrame(GLRenderer.java:232)
            at project.android.imageprocessing.FastImageProcessingPipeline.onDrawFrame(FastImageProcessingPipeline.java:91)
            at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1463)
            at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1217)

And here are the methods I'm calling to remove the transform, and then reinstall it:

private void clean() {
        pipeline.pauseRendering();

        input2.removeTarget(transform);
        blend.clearRegisteredFilterLocations();

        pipeline.addFilterToDestroy(transform);

        transform.removeTarget(blend);
        transform.destroy();
    }

    private void reinstallFilters() {

        Matrix.translateM(matrix, 0, matrix, 0, translatex, translatey, 0);

        transform = new TransformFilter(matrix, false, false);

//        debugMatrix();

        input2.addTarget(transform);
        transform.addTarget(blend);

        blend.registerFilterLocation(input);
        blend.registerFilterLocation(transform);

        pipeline.startRendering();
        preview.requestRender();
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant