Package 

Class MultiFilter

  • All Implemented Interfaces:
    com.otaliastudios.cameraview.filter.Filter , com.otaliastudios.cameraview.filter.OneParameterFilter , com.otaliastudios.cameraview.filter.TwoParameterFilter

    
    public class MultiFilter
     implements Filter, OneParameterFilter, TwoParameterFilter
                        

    A MultiFilter is a special Filter that can group one or more filters together. When this happens, filters are applied in sequence: - the first filter reads from input frames - the second filters reads the output of the first And so on, until the last filter which will read from the previous and write to the real output. New filters can be added at any time through addFilter, but currently they can not be removed because we can not easily ensure that they would be correctly released. The MultiFilter does also implement OneParameterFilter and TwoParameterFilter, dispatching all the parameter calls to child filters, assuming they support it. There are some important technical caveats when using MultiFilter: - each child filter requires the allocation of a GL framebuffer. Using a large number of filters will likely cause memory issues (e.g. https://stackoverflow.com/q/6354208/4288782). - some of the children need to write into GL_TEXTURE_2D instead of GL_TEXTURE_EXTERNAL_OES! To achieve this, we replace samplerExternalOES with sampler2D in your fragment shader code. This might cause issues for some shaders.

    • Method Summary

      Modifier and Type Method Description
      void setSize(int width, int height) Called anytime the output size changes.
      float getParameter1() Returns the parameter.The returned value should always be between 0 and 1.
      void setParameter1(float parameter1) Sets the parameter.The value should always be between 0 and 1.
      float getParameter2() Returns the second parameter.The returned value should always be between 0 and 1.
      void setParameter2(float parameter2) Sets the second parameter.The value should always be between 0 and 1.
      void addFilter(@NonNull() Filter filter) Adds a new filter.
      void onCreate(int programHandle) The filter program was just created.
      String getVertexShader() Returns a String containing the vertex shader.
      String getFragmentShader() Returns a String containing the fragment shader.
      void onDestroy() The filter program is about to be destroyed.
      void draw(long timestampUs, @NonNull() Array<float> transformMatrix) Called to render the actual texture.
      Filter copy() Clones this filter creating a new instance of it.If it has any important parameters, these should be passedto the new instance.
      • Methods inherited from class com.otaliastudios.cameraview.filter.OneParameterFilter

        setParameter1
      • Methods inherited from class com.otaliastudios.cameraview.filter.TwoParameterFilter

        setParameter2
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MultiFilter

        MultiFilter(Array<Filter> filters)
        Creates a new group with the given filters.
        Parameters:
        filters - children
      • MultiFilter

        MultiFilter(Collection<Filter> filters)
        Creates a new group with the given filters.
        Parameters:
        filters - children
    • Method Detail

      • setSize

         void setSize(int width, int height)

        Called anytime the output size changes.

        Parameters:
        width - width
        height - height
      • getParameter1

         float getParameter1()

        Returns the parameter.The returned value should always be between 0 and 1.

      • setParameter1

         void setParameter1(float parameter1)

        Sets the parameter.The value should always be between 0 and 1.

      • getParameter2

         float getParameter2()

        Returns the second parameter.The returned value should always be between 0 and 1.

      • setParameter2

         void setParameter2(float parameter2)

        Sets the second parameter.The value should always be between 0 and 1.

      • addFilter

         void addFilter(@NonNull() Filter filter)

        Adds a new filter. It will be used in the next frame.If the filter is a MultiFilter, we'll use its children instead.

        Parameters:
        filter - a new filter
      • onCreate

         void onCreate(int programHandle)

        The filter program was just created. We pass in a handle to the OpenGLprogram that was created, so you can fetch pointers.

        Parameters:
        programHandle - handle
      • onDestroy

         void onDestroy()

        The filter program is about to be destroyed.

      • draw

         void draw(long timestampUs, @NonNull() Array<float> transformMatrix)

        Called to render the actual texture. The given transformation matrixshould be applied.

        Parameters:
        timestampUs - timestamp in microseconds
        transformMatrix - matrix
      • copy

        @NonNull() Filter copy()

        Clones this filter creating a new instance of it.If it has any important parameters, these should be passedto the new instance.