Search in sources :

Example 26 with Filter

use of android.filterfw.core.Filter in project android_frameworks_base by ResurrectionRemix.

the class FilterFunctionEnvironment method createFunction.

/**
     * Create a new FilterFunction from a specific filter class. The function is initialized with
     * the given key-value list of parameters. Note, that this function uses the default shared
     * FilterFactory to create the filter instance.
     *
     * @param filterClass   The class of the filter to wrap. This must be a Filter subclass.
     * @param parameters    An argument list of alternating key-value filter parameters.
     * @return             A new FilterFunction instance.
     */
public FilterFunction createFunction(Class filterClass, Object... parameters) {
    String filterName = "FilterFunction(" + filterClass.getSimpleName() + ")";
    Filter filter = FilterFactory.sharedFactory().createFilterByClass(filterClass, filterName);
    filter.initWithAssignmentList(parameters);
    return new FilterFunction(getContext(), filter);
}
Also used : FilterFunction(android.filterfw.core.FilterFunction) Filter(android.filterfw.core.Filter)

Example 27 with Filter

use of android.filterfw.core.Filter in project android_frameworks_base by DirtyUnicorns.

the class RoundRobinScheduler method scheduleNextNode.

@Override
public Filter scheduleNextNode() {
    Set<Filter> all_filters = getGraph().getFilters();
    if (mLastPos >= all_filters.size())
        mLastPos = -1;
    int pos = 0;
    Filter first = null;
    int firstNdx = -1;
    for (Filter filter : all_filters) {
        if (filter.canProcess()) {
            if (pos <= mLastPos) {
                if (first == null) {
                    // store the first available filter
                    first = filter;
                    firstNdx = pos;
                }
            } else {
                // return the next available filter since last
                mLastPos = pos;
                return filter;
            }
        }
        pos++;
    }
    // going around from the beginning
    if (first != null) {
        mLastPos = firstNdx;
        return first;
    }
    // position.
    return null;
}
Also used : Filter(android.filterfw.core.Filter)

Example 28 with Filter

use of android.filterfw.core.Filter in project android_frameworks_base by DirtyUnicorns.

the class FilterGraphEffect method apply.

@Override
public void apply(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();
}
Also used : Filter(android.filterfw.core.Filter)

Example 29 with Filter

use of android.filterfw.core.Filter in project android_frameworks_base by crdroidandroid.

the class FilterFactory method createFilterByClass.

public Filter createFilterByClass(Class filterClass, String filterName) {
    // Make sure this is a Filter subclass
    try {
        filterClass.asSubclass(Filter.class);
    } catch (ClassCastException e) {
        throw new IllegalArgumentException("Attempting to allocate class '" + filterClass + "' which is not a subclass of Filter!");
    }
    // Look for the correct constructor
    Constructor filterConstructor = null;
    try {
        filterConstructor = filterClass.getConstructor(String.class);
    } catch (NoSuchMethodException e) {
        throw new IllegalArgumentException("The filter class '" + filterClass + "' does not have a constructor of the form <init>(String name)!");
    }
    // Construct the filter
    Filter filter = null;
    try {
        filter = (Filter) filterConstructor.newInstance(filterName);
    } catch (Throwable t) {
    // Condition checked below
    }
    if (filter == null) {
        throw new IllegalArgumentException("Could not construct the filter '" + filterName + "'!");
    }
    return filter;
}
Also used : Filter(android.filterfw.core.Filter) Constructor(java.lang.reflect.Constructor)

Example 30 with Filter

use of android.filterfw.core.Filter in project android_frameworks_base by crdroidandroid.

the class BackDropperEffect method setParameter.

@Override
public void setParameter(String parameterKey, Object value) {
    if (parameterKey.equals("source")) {
        Filter background = mGraph.getFilter("background");
        background.setInputValue("sourceUrl", value);
    } else if (parameterKey.equals("context")) {
        Filter background = mGraph.getFilter("background");
        background.setInputValue("context", value);
    }
}
Also used : Filter(android.filterfw.core.Filter) BackDropperFilter(android.filterpacks.videoproc.BackDropperFilter)

Aggregations

Filter (android.filterfw.core.Filter)30 FilterFunction (android.filterfw.core.FilterFunction)6 BackDropperFilter (android.filterpacks.videoproc.BackDropperFilter)6 Constructor (java.lang.reflect.Constructor)6