Methods Summary |
---|
private void | assertAllInputTargetsMatch()
int target = getInputFormat(mInputNames[0]).getTarget();
for (String inputName : mInputNames) {
if (target != getInputFormat(inputName).getTarget()) {
throw new RuntimeException("Type mismatch of input formats in filter " + this
+ ". All input frames must have the same target!");
}
}
|
protected abstract android.filterfw.core.Program | getNativeProgram(android.filterfw.core.FilterContext context)
|
public android.filterfw.core.FrameFormat | getOutputFormat(java.lang.String portName, android.filterfw.core.FrameFormat inputFormat)
return inputFormat;
|
protected abstract android.filterfw.core.Program | getShaderProgram(android.filterfw.core.FilterContext context)
|
public void | process(android.filterfw.core.FilterContext context)
// Pull input frames
int i = 0;
Frame[] inputs = new Frame[mInputNames.length];
for (String inputName : mInputNames) {
inputs[i++] = pullInput(inputName);
}
// Create output frame
Frame output = context.getFrameManager().newFrame(inputs[0].getFormat());
// Make sure we have a program
updateProgramWithTarget(inputs[0].getFormat().getTarget(), context);
// Process
mProgram.process(inputs, output);
// Push output
pushOutput(mOutputName, output);
// Release pushed frame
output.release();
|
public void | setupPorts()
if (mParameterName != null) {
try {
Field programField = ImageCombineFilter.class.getDeclaredField("mProgram");
addProgramPort(mParameterName, mParameterName, programField, float.class, false);
} catch (NoSuchFieldException e) {
throw new RuntimeException("Internal Error: mProgram field not found!");
}
}
for (String inputName : mInputNames) {
addMaskedInputPort(inputName, ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
}
addOutputBasedOnInput(mOutputName, mInputNames[0]);
|
protected void | updateProgramWithTarget(int target, android.filterfw.core.FilterContext context)
if (target != mCurrentTarget) {
switch (target) {
case FrameFormat.TARGET_NATIVE:
mProgram = getNativeProgram(context);
break;
case FrameFormat.TARGET_GPU:
mProgram = getShaderProgram(context);
break;
default:
mProgram = null;
break;
}
if (mProgram == null) {
throw new RuntimeException("Could not create a program for image filter "
+ this + "!");
}
initProgramInputs(mProgram, context);
mCurrentTarget = target;
}
|