-
- 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.
-
-
Field Summary
Fields Modifier and Type Field Description private Sizesizeprivate floatparameter1private floatparameter2
-
Constructor Summary
Constructors Constructor Description MultiFilter(Array<Filter> filters)Creates a new group with the given filters. MultiFilter(Collection<Filter> filters)Creates a new group with the given filters.
-
Method Summary
Modifier and Type Method Description voidsetSize(int width, int height)Called anytime the output size changes. floatgetParameter1()Returns the parameter.The returned value should always be between 0 and 1. voidsetParameter1(float parameter1)Sets the parameter.The value should always be between 0 and 1. floatgetParameter2()Returns the second parameter.The returned value should always be between 0 and 1. voidsetParameter2(float parameter2)Sets the second parameter.The value should always be between 0 and 1. voidaddFilter(@NonNull() Filter filter)Adds a new filter. voidonCreate(int programHandle)The filter program was just created. StringgetVertexShader()Returns a String containing the vertex shader. StringgetFragmentShader()Returns a String containing the fragment shader. voidonDestroy()The filter program is about to be destroyed. voiddraw(long timestampUs, @NonNull() Array<float> transformMatrix)Called to render the actual texture. Filtercopy()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- widthheight- 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
-
getVertexShader
@NonNull() String getVertexShader()
Returns a String containing the vertex shader.Together with getFragmentShader, this will be used tocreate the OpenGL program.
-
getFragmentShader
@NonNull() String getFragmentShader()
Returns a String containing the fragment shader.Together with getVertexShader, this will be used tocreate the OpenGL program.
-
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 microsecondstransformMatrix- matrix
-
-
-
-