Package 

Class BaseFilter

  • All Implemented Interfaces:
    com.otaliastudios.cameraview.filter.Filter

    
    public abstract class BaseFilter
     implements Filter
                        

    A base implementation of Filter that just leaves the fragment shader to subclasses. See NoFilter for a non-abstract implementation. This class offers a default vertex shader implementation which in most cases is not required to be changed. Most effects can be rendered by simply changing the fragment shader, thus by overriding getFragmentShader. All BaseFilters should have a no-arguments public constructor. This class will try to automatically implement copy thanks to this. If your filter implements public parameters, please implement OneParameterFilter and TwoParameterFilter to handle them and have them passed automatically to copies. NOTE - This class expects variable to have a certain name: - vertexPositionName - vertexTransformMatrixName - vertexModelViewProjectionMatrixName - vertexTextureCoordinateName - fragmentTextureCoordinateName You can either change these variables, for example in your constructor, or change your vertex and fragment shader code to use them. NOTE - the android.graphics.SurfaceTexture restrictions apply: We only support the GL_TEXTURE_EXTERNAL_OES texture target and it must be specified in the fragment shader as a samplerExternalOES texture. You also have to explicitly require the extension: see createDefaultFragmentShader.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      Size size
    • Method Summary

      Modifier and Type Method Description
      void setSize(int width, int height) Called anytime the output size changes.
      void onCreate(int programHandle) The filter program was just created.
      void onDestroy() The filter program is about to be destroyed.
      String getVertexShader() Returns a String containing the vertex shader.
      void draw(long timestampUs, @NonNull() Array<float> transformMatrix) Called to render the actual texture.
      final BaseFilter 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.Filter

        copy, getFragmentShader
      • Methods inherited from class java.lang.Object

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

      • setSize

         void setSize(int width, int height)

        Called anytime the output size changes.

        Parameters:
        width - width
        height - height
      • 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() final BaseFilter copy()

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