FileDocCategorySizeDatePackage
FilterGraphEffect.javaAPI DocAndroid 5.1 API3904Thu Mar 12 22:22:30 GMT 2015android.media.effect

FilterGraphEffect

public class FilterGraphEffect extends android.media.effect.FilterEffect
Effect subclass for effects based on a single Filter. Subclasses need only invoke the constructor with the correct arguments to obtain an Effect implementation.
hide

Fields Summary
private static final String
TAG
protected String
mInputName
protected String
mOutputName
protected android.filterfw.core.GraphRunner
mRunner
protected android.filterfw.core.FilterGraph
mGraph
protected Class
mSchedulerClass
Constructors Summary
public FilterGraphEffect(android.media.effect.EffectContext context, String name, String graphString, String inputName, String outputName, Class scheduler)
Constructs a new FilterGraphEffect.

param
name The name of this effect (used to create it in the EffectFactory).
param
graphString The graph string to create the graph.
param
inputName The name of the input GLTextureSource filter.
param
outputName The name of the output GLTextureSource filter.


                                                      
      
                               
                               
                               
                               
                                
        super(context, name);

        mInputName = inputName;
        mOutputName = outputName;
        mSchedulerClass = scheduler;
        createGraph(graphString);

    
Methods Summary
public voidapply(int inputTexId, int width, int height, int outputTexId)

        beginGLEffect();
        Filter src = mGraph.getFilter(mInputName);
        if (src != null) {
            src.setInputValue("texId", inputTexId);
            src.setInputValue("width", width);
            src.setInputValue("height", height);
        } else {
            throw new RuntimeException("Internal error applying effect");
        }
        Filter dest  = mGraph.getFilter(mOutputName);
        if (dest != null) {
            dest.setInputValue("texId", outputTexId);
        } else {
            throw new RuntimeException("Internal error applying effect");
        }
        try {
            mRunner.run();
        } catch (RuntimeException e) {
            throw new RuntimeException("Internal error applying effect: ", e);
        }
        endGLEffect();
    
private voidcreateGraph(java.lang.String graphString)

        GraphReader reader = new TextGraphReader();
        try {
            mGraph = reader.readGraphString(graphString);
        } catch (GraphIOException e) {
            throw new RuntimeException("Could not setup effect", e);
        }

        if (mGraph == null) {
            throw new RuntimeException("Could not setup effect");
        }
        mRunner = new SyncRunner(getFilterContext(), mGraph, mSchedulerClass);
    
public voidrelease()

         mGraph.tearDown(getFilterContext());
         mGraph = null;
    
public voidsetParameter(java.lang.String parameterKey, java.lang.Object value)