use of android.filterfw.core.ShaderProgram in project android_frameworks_base by ResurrectionRemix.
the class RotateFilter method initProgram.
public void initProgram(FilterContext context, int target) {
switch(target) {
case FrameFormat.TARGET_GPU:
ShaderProgram shaderProgram = ShaderProgram.createIdentity(context);
shaderProgram.setMaximumTileSize(mTileSize);
shaderProgram.setClearsOutput(true);
mProgram = shaderProgram;
break;
default:
throw new RuntimeException("Filter Sharpen does not support frames of " + "target " + target + "!");
}
mTarget = target;
}
use of android.filterfw.core.ShaderProgram in project android_frameworks_base by ResurrectionRemix.
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.core.ShaderProgram in project android_frameworks_base by ResurrectionRemix.
the class SaturateFilter method initProgram.
public void initProgram(FilterContext context, int target) {
switch(target) {
case FrameFormat.TARGET_GPU:
ShaderProgram shaderProgram = new ShaderProgram(context, mBenSaturateShader);
shaderProgram.setMaximumTileSize(mTileSize);
mBenProgram = shaderProgram;
shaderProgram = new ShaderProgram(context, mHerfSaturateShader);
shaderProgram.setMaximumTileSize(mTileSize);
mHerfProgram = shaderProgram;
break;
default:
throw new RuntimeException("Filter Sharpen does not support frames of " + "target " + target + "!");
}
mTarget = target;
}
use of android.filterfw.core.ShaderProgram in project android_frameworks_base by ResurrectionRemix.
the class ImageSlicer method process.
@Override
public void process(FilterContext context) {
// Get input frame
if (mSliceIndex == 0) {
mOriginalFrame = pullInput("image");
calcOutputFormatForInput(mOriginalFrame);
}
FrameFormat inputFormat = mOriginalFrame.getFormat();
MutableFrameFormat outputFormat = inputFormat.mutableCopy();
outputFormat.setDimensions(mOutputWidth, mOutputHeight);
// Create output frame
Frame output = context.getFrameManager().newFrame(outputFormat);
// Create the program if not created already
if (mProgram == null) {
mProgram = ShaderProgram.createIdentity(context);
}
// Calculate the four corner of the source region
int xSliceIndex = mSliceIndex % mXSlices;
int ySliceIndex = mSliceIndex / mXSlices;
// TODO(rslin) : not sure shifting by 0.5 is needed.
float x0 = (xSliceIndex * mSliceWidth - mPadSize) / ((float) mInputWidth);
float y0 = (ySliceIndex * mSliceHeight - mPadSize) / ((float) mInputHeight);
((ShaderProgram) mProgram).setSourceRect(x0, y0, ((float) mOutputWidth) / mInputWidth, ((float) mOutputHeight) / mInputHeight);
// Process
mProgram.process(mOriginalFrame, output);
mSliceIndex++;
if (mSliceIndex == mXSlices * mYSlices) {
mSliceIndex = 0;
mOriginalFrame.release();
setWaitsOnInputPort("image", true);
} else {
// Retain the original frame so it can be used next time.
mOriginalFrame.retain();
setWaitsOnInputPort("image", false);
}
// Push output
pushOutput("image", output);
// Release pushed frame
output.release();
}
use of android.filterfw.core.ShaderProgram in project android_frameworks_base by ResurrectionRemix.
the class PosterizeFilter method initProgram.
public void initProgram(FilterContext context, int target) {
switch(target) {
case FrameFormat.TARGET_GPU:
ShaderProgram shaderProgram = new ShaderProgram(context, mPosterizeShader);
shaderProgram.setMaximumTileSize(mTileSize);
mProgram = shaderProgram;
break;
default:
throw new RuntimeException("Filter Sharpen does not support frames of " + "target " + target + "!");
}
mTarget = target;
}
Aggregations