project.android.imageprocessing.filter
Class MultiInputFilter

java.lang.Object
  extended by project.android.imageprocessing.GLRenderer
      extended by project.android.imageprocessing.input.GLTextureOutputRenderer
          extended by project.android.imageprocessing.filter.BasicFilter
              extended by project.android.imageprocessing.filter.MultiInputFilter
All Implemented Interfaces:
GLTextureInputRenderer
Direct Known Subclasses:
AddBlendFilter, AlphaBlendFilter, ChromaKeyBlendFilter, ColourBlendFilter, ColourBurnBlendFilter, ColourDodgeBlendFilter, CompositeFilter, DarkenBlendFilter, DifferenceBlendFilter, DissolveBlendFilter, DivideBlendFilter, ExclusionBlendFilter, HardLightBlendFilter, HueBlendFilter, LightenBlendFilter, LinearBurnBlendFilter, LookupFilter, LuminosityBlendFilter, MaskFilter, MultiInputPixelFilter, MultiplyBlendFilter, NormalBlendFilter, OverlayBlendFilter, SaturationBlendFilter, ScreenBlendFilter, SoftLightBlendFilter, SourceOverBlendFilter, SubtractBlendFilter, ToneCurveFilter

public abstract class MultiInputFilter
extends BasicFilter

A multiple filter input extension of the BasicFilter. This class allows for multiple textures as inputs to the filter. This class can be used as the base for a filter which requires multiple filter inputs. By itself, this class is not useful because it's fragment shader only uses one texture. To take advantage of the multiple texture inputs, the getFragmentShader() method should be override to return a more useful fragment shader. This class supports a maximum of 10 input textures. However, only one set of texture coordinates is used so any rotation done in this filter will be applied to all input images. The position of the input textures should be registered before the filter attempts to draw. For example, if this class was extended with a fragment shader that required a grey scale filter as the first input texture and a blur filter as the second input, it would be set up as follows: GreyScaleFilter grey = new GreyScaleFilter(); FastBlurFilter blur = new FastBlurFilter(); SomeMultiInputFilter multiInput = new SomeMultiInputFilter(); grey.addTarget(multiInput); blur.addTarget(multiInput); multiInput.registerFilterLocation(grey, 0); multiInput.registerFilterLocation(blur, 1);

Author:
Chris Batt

Field Summary
 
Fields inherited from class project.android.imageprocessing.GLRenderer
ATTRIBUTE_POSITION, ATTRIBUTE_TEXCOORD, UNIFORM_TEXTURE0, VARYING_TEXCOORD
 
Constructor Summary
MultiInputFilter(int numOfInputs)
          Creates a MultiInputFilter with any number of initial filters or filter graphs that produce a set number of textures which can be used by this filter.
 
Method Summary
 void clearRegisteredFilterLocations()
          Removes all currently registered filters from filter location list.
 void newTextureReady(int texture, GLTextureOutputRenderer source)
          Signals that a new texture is available and the image should be reprocessed.
 void registerFilterLocation(GLTextureOutputRenderer filter)
          Registers the given filter in the next available texture location.
 void registerFilterLocation(GLTextureOutputRenderer filter, int location)
          Registers the given filter in the given texture location.
 
Methods inherited from class project.android.imageprocessing.input.GLTextureOutputRenderer
addTarget, destroy, getLockObject, getTargets, removeTarget
 
Methods inherited from class project.android.imageprocessing.GLRenderer
getBackgroundAlpha, getBackgroundBlue, getBackgroundGreen, getBackgroundRed, getHeight, getWidth, onDrawFrame, reInitialize, rotateClockwise90Degrees, rotateCounterClockwise90Degrees, setBackgroundAlpha, setBackgroundBlue, setBackgroundColour, setBackgroundGreen, setBackgroundRed, setRenderSize
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiInputFilter

public MultiInputFilter(int numOfInputs)
Creates a MultiInputFilter with any number of initial filters or filter graphs that produce a set number of textures which can be used by this filter.

Parameters:
numOfInputs - The number of inputs of this filter. For example, if the fragment shader of this filter requires three input textures, then this would be set to three.
Method Detail

clearRegisteredFilterLocations

public void clearRegisteredFilterLocations()
Removes all currently registered filters from filter location list.


newTextureReady

public void newTextureReady(int texture,
                            GLTextureOutputRenderer source)
Description copied from interface: GLTextureInputRenderer
Signals that a new texture is available and the image should be reprocessed.

Specified by:
newTextureReady in interface GLTextureInputRenderer
Overrides:
newTextureReady in class BasicFilter
Parameters:
texture - The texture id to be used as input.
source - The GLTextureOutputRenderer which produced the texture.

registerFilterLocation

public void registerFilterLocation(GLTextureOutputRenderer filter)
Registers the given filter in the next available texture location.

Parameters:
filter - An output filter which passes its output to this filter.

registerFilterLocation

public void registerFilterLocation(GLTextureOutputRenderer filter,
                                   int location)
Registers the given filter in the given texture location.

Parameters:
filter - An output filter which passes its output to this filter.
location - The texture location that this filter should pass its output to. This location must be in [0,numOfInputs).