use of android.filterfw.core.Filter in project android_frameworks_base by ParanoidAndroid.
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);
}
use of android.filterfw.core.Filter in project android_frameworks_base by ParanoidAndroid.
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;
}
use of android.filterfw.core.Filter in project platform_frameworks_base by android.
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();
}
use of android.filterfw.core.Filter in project platform_frameworks_base by android.
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;
}
use of android.filterfw.core.Filter in project android_frameworks_base by AOSPA.
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);
}
}
Aggregations