use of android.filterfw.geometry.Quad in project platform_frameworks_base by android.
the class CropFilter method process.
@Override
public void process(FilterContext env) {
// Get input frame
Frame imageFrame = pullInput("image");
Frame boxFrame = pullInput("box");
createProgram(env, imageFrame.getFormat());
// Get the box
Quad box = (Quad) boxFrame.getObjectValue();
// Create output format
MutableFrameFormat outputFormat = imageFrame.getFormat().mutableCopy();
outputFormat.setDimensions(mOutputWidth == -1 ? outputFormat.getWidth() : mOutputWidth, mOutputHeight == -1 ? outputFormat.getHeight() : mOutputHeight);
// Create output frame
Frame output = env.getFrameManager().newFrame(outputFormat);
// Set the program parameters
if (mProgram instanceof ShaderProgram) {
ShaderProgram shaderProgram = (ShaderProgram) mProgram;
shaderProgram.setSourceRegion(box);
}
mProgram.process(imageFrame, output);
// Push output
pushOutput("image", output);
// Release pushed frame
output.release();
}
use of android.filterfw.geometry.Quad in project platform_frameworks_base by android.
the class RotateFilter method updateParameters.
private void updateParameters() {
float sinTheta;
float cosTheta;
if (mAngle % 90 == 0) {
if (mAngle % 180 == 0) {
sinTheta = 0f;
cosTheta = (mAngle % 360 == 0) ? 1f : -1f;
} else {
cosTheta = 0f;
sinTheta = ((mAngle + 90) % 360 == 0) ? -1f : 1f;
mOutputWidth = mHeight;
mOutputHeight = mWidth;
}
} else {
throw new RuntimeException("degree has to be multiply of 90.");
}
Point x0 = new Point(0.5f * (-cosTheta + sinTheta + 1f), 0.5f * (-sinTheta - cosTheta + 1f));
Point x1 = new Point(0.5f * (cosTheta + sinTheta + 1f), 0.5f * (sinTheta - cosTheta + 1f));
Point x2 = new Point(0.5f * (-cosTheta - sinTheta + 1f), 0.5f * (-sinTheta + cosTheta + 1f));
Point x3 = new Point(0.5f * (cosTheta - sinTheta + 1f), 0.5f * (sinTheta + cosTheta + 1f));
Quad quad = new Quad(x0, x1, x2, x3);
((ShaderProgram) mProgram).setTargetRegion(quad);
}
use of android.filterfw.geometry.Quad in project platform_frameworks_base by android.
the class DrawOverlayFilter method process.
@Override
public void process(FilterContext env) {
// Get input frame
Frame sourceFrame = pullInput("source");
Frame overlayFrame = pullInput("overlay");
Frame boxFrame = pullInput("box");
// Get the box
Quad box = (Quad) boxFrame.getObjectValue();
box = box.translated(1.0f, 1.0f).scaled(2.0f);
mProgram.setTargetRegion(box);
// Create output frame with copy of input
Frame output = env.getFrameManager().newFrame(sourceFrame.getFormat());
output.setDataFromFrame(sourceFrame);
// Draw onto output
mProgram.process(overlayFrame, output);
// Push output
pushOutput("image", output);
// Release pushed frame
output.release();
}
use of android.filterfw.geometry.Quad in project android_frameworks_base by AOSPA.
the class CropFilter method process.
@Override
public void process(FilterContext env) {
// Get input frame
Frame imageFrame = pullInput("image");
Frame boxFrame = pullInput("box");
createProgram(env, imageFrame.getFormat());
// Get the box
Quad box = (Quad) boxFrame.getObjectValue();
// Create output format
MutableFrameFormat outputFormat = imageFrame.getFormat().mutableCopy();
outputFormat.setDimensions(mOutputWidth == -1 ? outputFormat.getWidth() : mOutputWidth, mOutputHeight == -1 ? outputFormat.getHeight() : mOutputHeight);
// Create output frame
Frame output = env.getFrameManager().newFrame(outputFormat);
// Set the program parameters
if (mProgram instanceof ShaderProgram) {
ShaderProgram shaderProgram = (ShaderProgram) mProgram;
shaderProgram.setSourceRegion(box);
}
mProgram.process(imageFrame, output);
// Push output
pushOutput("image", output);
// Release pushed frame
output.release();
}
use of android.filterfw.geometry.Quad in project android_frameworks_base by AOSPA.
the class DrawOverlayFilter method process.
@Override
public void process(FilterContext env) {
// Get input frame
Frame sourceFrame = pullInput("source");
Frame overlayFrame = pullInput("overlay");
Frame boxFrame = pullInput("box");
// Get the box
Quad box = (Quad) boxFrame.getObjectValue();
box = box.translated(1.0f, 1.0f).scaled(2.0f);
mProgram.setTargetRegion(box);
// Create output frame with copy of input
Frame output = env.getFrameManager().newFrame(sourceFrame.getFormat());
output.setDataFromFrame(sourceFrame);
// Draw onto output
mProgram.process(overlayFrame, output);
// Push output
pushOutput("image", output);
// Release pushed frame
output.release();
}
Aggregations