Methods Summary |
---|
public void | fieldPortValueUpdated(java.lang.String name, android.filterfw.core.FilterContext context)
if (mProgram != null) {
updateParameters();
}
|
public android.filterfw.core.FrameFormat | getOutputFormat(java.lang.String portName, android.filterfw.core.FrameFormat inputFormat)
return inputFormat;
|
private void | initParameters()
if (mProgram != null) {
float scale[] = new float[2];
if (mWidth > mHeight) {
scale[0] = 1f;
scale[1] = ((float) mHeight) / mWidth;
} else {
scale[0] = ((float) mWidth) / mHeight;
scale[1] = 1f;
}
float max_dist = ((float) Math.sqrt(scale[0] * scale[0] + scale[1] * scale[1])) * 0.5f;
mProgram.setHostValue("scale", scale);
mProgram.setHostValue("inv_max_dist", 1f / max_dist);
mProgram.setHostValue("shade", mShade);
updateParameters();
}
|
public void | initProgram(android.filterfw.core.FilterContext context, int target)
switch (target) {
case FrameFormat.TARGET_GPU:
ShaderProgram shaderProgram = new ShaderProgram(context, mVignetteShader);
shaderProgram.setMaximumTileSize(mTileSize);
mProgram = shaderProgram;
break;
default:
throw new RuntimeException("Filter Sharpen does not support frames of " +
"target " + target + "!");
}
mTarget = target;
|
public void | process(android.filterfw.core.FilterContext context)
// Get input frame
Frame input = pullInput("image");
FrameFormat inputFormat = input.getFormat();
// Create program if not created already
if (mProgram == null || inputFormat.getTarget() != mTarget) {
initProgram(context, inputFormat.getTarget());
}
// Check if the frame size has changed
if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) {
mWidth = inputFormat.getWidth();
mHeight = inputFormat.getHeight();
initParameters();
}
// Create output frame
Frame output = context.getFrameManager().newFrame(inputFormat);
// Process
mProgram.process(input, output);
// Push output
pushOutput("image", output);
// Release pushed frame
output.release();
|
public void | setupPorts()
addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
addOutputBasedOnInput("image", "image");
|
private void | updateParameters()
// The 'range' is between 1.3 to 0.6. When scale is zero then range is 1.3
// which means no vignette at all because the luminousity difference is
// less than 1/256 and will cause nothing.
mProgram.setHostValue("range", 1.30f - (float) Math.sqrt(mScale) * 0.7f);
|