}
/**
+ * Transfers any frame from an input port to its destination. This is useful to force a
+ * transfer from a FieldPort or ProgramPort to its connected target (field or program variable).
+ */
+ protected void transferInputPortFrame(String name, FilterContext context) {
+ getInputPort(name).transfer(context);
+ }
+
+ /**
* Adds an input port to the filter. You should call this from within setupPorts, if your
* filter has input ports. No type-checking is performed on the input. If you would like to
* check against a type mask, use
}
@Override
- public void process(FilterContext env) {
+ public void process(FilterContext context) {
// Get input frame
Frame input = pullInput("image");
// Create output frame
// TODO: Use Frame Provider
- Frame output = env.getFrameManager().newFrame(input.getFormat());
+ Frame output = context.getFrameManager().newFrame(input.getFormat());
Log.e("Fisheye", "width: " + input.getFormat().getWidth() +
", height: " + input.getFormat().getHeight());
Log.e("Fisheye", "( " + center[0] + ", " + center[1] + " )");
// Make sure we have a program
- updateProgramWithTarget(input.getFormat().getTarget());
+ updateProgramWithTarget(input.getFormat().getTarget(), context);
// set uniforms in shader
mProgram.setHostValue("center", center);
Frame output = context.getFrameManager().newFrame(inputs[0].getFormat());
// Make sure we have a program
- updateProgramWithTarget(inputs[0].getFormat().getTarget());
+ updateProgramWithTarget(inputs[0].getFormat().getTarget(), context);
// Process
mProgram.process(inputs, output);
output.release();
}
- protected void updateProgramWithTarget(int target) {
+ protected void updateProgramWithTarget(int target, FilterContext context) {
if (target != mCurrentTarget) {
switch (target) {
case FrameFormat.TARGET_NATIVE:
throw new RuntimeException("Could not create a program for image filter "
+ this + "!");
}
+ transferInputPortFrame(mParameterName, context);
mCurrentTarget = target;
}
}
Frame output = context.getFrameManager().newFrame(inputFormat);
// Create program if not created already
- updateProgramWithTarget(inputFormat.getTarget());
+ updateProgramWithTarget(inputFormat.getTarget(), context);
// Process
mProgram.process(input, output);
output.release();
}
- protected void updateProgramWithTarget(int target) {
+ protected void updateProgramWithTarget(int target, FilterContext context) {
if (target != mCurrentTarget) {
switch (target) {
case FrameFormat.TARGET_NATIVE:
if (mProgram == null) {
throw new RuntimeException("Could not create a program for image filter " + this + "!");
}
+ transferInputPortFrame(mParameterName, context);
mCurrentTarget = target;
}
}
}
@Override
- public void process(FilterContext env) {
+ public void process(FilterContext context) {
// Get input frame
Frame input = pullInput("image");
// Create output frame
MutableFrameFormat outputFormat = input.getFormat().mutableCopy();
outputFormat.setBytesPerSample(mOutChannels);
- Frame output = env.getFrameManager().newFrame(outputFormat);
+ Frame output = context.getFrameManager().newFrame(outputFormat);
// Make sure we have a program
- updateProgramWithTarget(input.getFormat().getTarget());
+ updateProgramWithTarget(input.getFormat().getTarget(), context);
// Process
mProgram.process(input, output);