-
- 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.
-
-
Method Summary
Modifier and Type Method Description voidsetSize(int width, int height)Called anytime the output size changes. voidonCreate(int programHandle)The filter program was just created. voidonDestroy()The filter program is about to be destroyed. StringgetVertexShader()Returns a String containing the vertex shader. voiddraw(long timestampUs, @NonNull() Array<float> transformMatrix)Called to render the actual texture. final BaseFiltercopy()Clones this filter creating a new instance of it.If it has any important parameters, these should be passedto the new instance. -
-
Method Detail
-
setSize
void setSize(int width, int height)
Called anytime the output size changes.
- Parameters:
width- widthheight- 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.
-
getVertexShader
@NonNull() String getVertexShader()
Returns a String containing the vertex shader.Together with getFragmentShader, this will be used tocreate the OpenGL program.
-
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 microsecondstransformMatrix- 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.
-
-
-
-