Methods Summary |
---|
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)
// Get input frame
Frame input = pullInput("image");
FrameFormat inputFormat = input.getFormat();
// Create output frame
Frame output = context.getFrameManager().newFrame(inputFormat);
// Create program if not created already
updateProgramWithTarget(inputFormat.getTarget(), context);
// Process
mProgram.process(input, output);
// Push output
pushOutput("image", output);
// Release pushed frame
output.release();
|
public void | setupPorts()
if (mParameterName != null) {
try {
Field programField = SimpleImageFilter.class.getDeclaredField("mProgram");
addProgramPort(mParameterName, mParameterName, programField, float.class, false);
} catch (NoSuchFieldException e) {
throw new RuntimeException("Internal Error: mProgram field not found!");
}
}
addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
addOutputBasedOnInput("image", "image");
|
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;
}
|