public static void updateFilter(FullFrameRect rect, int newFilter) {
        Texture2dProgram.ProgramType programType;
        float[] kernel = null;
        float colorAdj = 0.0f;

        if (VERBOSE) Log.d(TAG, "Updating filter to " + newFilter);
        switch (newFilter) {
            case FILTER_NONE:
                programType = Texture2dProgram.ProgramType.TEXTURE_EXT;
                break;
            case FILTER_BLACK_WHITE:
                // (In a previous version the TEXTURE_EXT_BW variant was enabled by a flag called
                // ROSE_COLORED_GLASSES, because the shader set the red channel to the B&W color
                // and green/blue to zero.)
                programType = Texture2dProgram.ProgramType.TEXTURE_EXT_BW;
                break;
            case FILTER_NIGHT:
                programType = Texture2dProgram.ProgramType.TEXTURE_EXT_NIGHT;
                break;
            case FILTER_CHROMA_KEY:
                programType = Texture2dProgram.ProgramType.TEXTURE_EXT_CHROMA_KEY;
                break;
            case FILTER_SQUEEZE:
                programType = Texture2dProgram.ProgramType.TEXTURE_EXT_SQUEEZE;
                break;
            case FILTER_TWIRL:
                programType = Texture2dProgram.ProgramType.TEXTURE_EXT_TWIRL;
                break;
            case FILTER_TUNNEL:
                programType = Texture2dProgram.ProgramType.TEXTURE_EXT_TUNNEL;
                break;
            case FILTER_BULGE:
                programType = Texture2dProgram.ProgramType.TEXTURE_EXT_BULGE;
                break;
            case FILTER_DENT:
                programType = Texture2dProgram.ProgramType.TEXTURE_EXT_DENT;
                break;
            case FILTER_FISHEYE:
                programType = Texture2dProgram.ProgramType.TEXTURE_EXT_FISHEYE;
                break;
            case FILTER_STRETCH:
                programType = Texture2dProgram.ProgramType.TEXTURE_EXT_STRETCH;
                break;
            case FILTER_MIRROR:
                programType = Texture2dProgram.ProgramType.TEXTURE_EXT_MIRROR;
                break;
            case FILTER_BLUR:
                programType = Texture2dProgram.ProgramType.TEXTURE_EXT_FILT;
                kernel = new float[] {
                        1f/16f, 2f/16f, 1f/16f,
                        2f/16f, 4f/16f, 2f/16f,
                        1f/16f, 2f/16f, 1f/16f };
                break;
            case FILTER_SHARPEN:
                programType = Texture2dProgram.ProgramType.TEXTURE_EXT_FILT;
                kernel = new float[] {
                        0f, -1f, 0f,
                        -1f, 5f, -1f,
                        0f, -1f, 0f };
                break;
            case FILTER_EDGE_DETECT:
                programType = Texture2dProgram.ProgramType.TEXTURE_EXT_FILT;
                kernel = new float[] {
                        -1f, -1f, -1f,
                        -1f, 8f, -1f,
                        -1f, -1f, -1f };
                break;
            case FILTER_EMBOSS:
                programType = Texture2dProgram.ProgramType.TEXTURE_EXT_FILT;
                kernel = new float[] {
                        2f, 0f, 0f,
                        0f, -1f, 0f,
                        0f, 0f, -1f };
                colorAdj = 0.5f;
                break;
            default:
                throw new RuntimeException("Unknown filter mode " + newFilter);
        }

        // Do we need a whole new program?  (We want to avoid doing this if we don't have
        // too -- compiling a program could be expensive.)
        if (programType != rect.getProgram().getProgramType()) {
            rect.changeProgram(new Texture2dProgram(programType));
        }

        // Update the filter kernel (if any).
        if (kernel != null) {
            rect.getProgram().setKernel(kernel, colorAdj);
        }
    }
public static void updateFilter ( FullFrameRect rect , int newFilter ) { Texture2dProgram . ProgramType programType ; float [ ] kernel = null ; float colorAdj = 0.0f ; if ( VERBOSE ) Log . d ( TAG , "Updating filter to " + newFilter ) ; switch ( newFilter ) { case FILTER_NONE : programType = Texture2dProgram . ProgramType . TEXTURE_EXT ; break ; case FILTER_BLACK_WHITE : programType = Texture2dProgram . ProgramType . TEXTURE_EXT_BW ; break ; case FILTER_NIGHT : programType = Texture2dProgram . ProgramType . TEXTURE_EXT_NIGHT ; break ; case FILTER_CHROMA_KEY : programType = Texture2dProgram . ProgramType . TEXTURE_EXT_CHROMA_KEY ; break ; case FILTER_SQUEEZE : programType = Texture2dProgram . ProgramType . TEXTURE_EXT_SQUEEZE ; break ; case FILTER_TWIRL : programType = Texture2dProgram . ProgramType . TEXTURE_EXT_TWIRL ; break ; case FILTER_TUNNEL : programType = Texture2dProgram . ProgramType . TEXTURE_EXT_TUNNEL ; break ; case FILTER_BULGE : programType = Texture2dProgram . ProgramType . TEXTURE_EXT_BULGE ; break ; case FILTER_DENT : programType = Texture2dProgram . ProgramType . TEXTURE_EXT_DENT ; break ; case FILTER_FISHEYE : programType = Texture2dProgram . ProgramType . TEXTURE_EXT_FISHEYE ; break ; case FILTER_STRETCH : programType = Texture2dProgram . ProgramType . TEXTURE_EXT_STRETCH ; break ; case FILTER_MIRROR : programType = Texture2dProgram . ProgramType . TEXTURE_EXT_MIRROR ; break ; case FILTER_BLUR : programType = Texture2dProgram . ProgramType . TEXTURE_EXT_FILT ; kernel = new float [ ] { 1f / 16f , 2f / 16f , 1f / 16f , 2f / 16f , 4f / 16f , 2f / 16f , 1f / 16f , 2f / 16f , 1f / 16f } ; break ; case FILTER_SHARPEN : programType = Texture2dProgram . ProgramType . TEXTURE_EXT_FILT ; kernel = new float [ ] { 0f , - 1f , 0f , - 1f , 5f , - 1f , 0f , - 1f , 0f } ; break ; case FILTER_EDGE_DETECT : programType = Texture2dProgram . ProgramType . TEXTURE_EXT_FILT ; kernel = new float [ ] { - 1f , - 1f , - 1f , - 1f , 8f , - 1f , - 1f , - 1f , - 1f } ; break ; case FILTER_EMBOSS : programType = Texture2dProgram . ProgramType . TEXTURE_EXT_FILT ; kernel = new float [ ] { 2f , 0f , 0f , 0f , - 1f , 0f , 0f , 0f , - 1f } ; colorAdj = 0.5f ; break ; default : throw new RuntimeException ( "Unknown filter mode " + newFilter ) ; } if ( programType != rect . getProgram ( ) . getProgramType ( ) ) { rect . changeProgram ( new Texture2dProgram ( programType ) ) ; } if ( kernel != null ) { rect . getProgram ( ) . setKernel ( kernel , colorAdj ) ; } }
Updates the filter on the provided FullFrameRect
@return the int code of the new filter