use of android.filterfw.core.Frame in project platform_frameworks_base by android.
the class SurfaceTextureTarget method process.
@Override
public synchronized void process(FilterContext context) {
// Surface is not registered. Nothing to render into.
if (mSurfaceId <= 0) {
return;
}
GLEnvironment glEnv = context.getGLEnvironment();
// Get input frame
Frame input = pullInput("frame");
boolean createdFrame = false;
float currentAspectRatio = (float) input.getFormat().getWidth() / input.getFormat().getHeight();
if (currentAspectRatio != mAspectRatio) {
if (mLogVerbose) {
Log.v(TAG, "Process. New aspect ratio: " + currentAspectRatio + ", previously: " + mAspectRatio + ". Thread: " + Thread.currentThread());
}
mAspectRatio = currentAspectRatio;
updateTargetRect();
}
// See if we need to copy to GPU
Frame gpuFrame = null;
int target = input.getFormat().getTarget();
if (target != FrameFormat.TARGET_GPU) {
gpuFrame = context.getFrameManager().duplicateFrameToTarget(input, FrameFormat.TARGET_GPU);
createdFrame = true;
} else {
gpuFrame = input;
}
// Activate our surface
glEnv.activateSurfaceWithId(mSurfaceId);
// Process
mProgram.process(gpuFrame, mScreen);
glEnv.setSurfaceTimestamp(input.getTimestamp());
// And swap buffers
glEnv.swapBuffers();
if (createdFrame) {
gpuFrame.release();
}
}
use of android.filterfw.core.Frame in project android_frameworks_base by ParanoidAndroid.
the class FilterEffect method frameFromTexture.
/**
* Converts a texture into a Frame.
*/
protected Frame frameFromTexture(int texId, int width, int height) {
FrameManager manager = getFilterContext().getFrameManager();
FrameFormat format = ImageFormat.create(width, height, ImageFormat.COLORSPACE_RGBA, FrameFormat.TARGET_GPU);
Frame frame = manager.newBoundFrame(format, GLFrame.EXISTING_TEXTURE_BINDING, texId);
frame.setTimestamp(Frame.TIMESTAMP_UNKNOWN);
return frame;
}
use of android.filterfw.core.Frame in project android_frameworks_base by ParanoidAndroid.
the class SingleFilterEffect method apply.
@Override
public void apply(int inputTexId, int width, int height, int outputTexId) {
beginGLEffect();
Frame inputFrame = frameFromTexture(inputTexId, width, height);
Frame outputFrame = frameFromTexture(outputTexId, width, height);
Frame resultFrame = mFunction.executeWithArgList(mInputName, inputFrame);
outputFrame.setDataFromFrame(resultFrame);
inputFrame.release();
outputFrame.release();
resultFrame.release();
endGLEffect();
}
use of android.filterfw.core.Frame in project android_frameworks_base by ParanoidAndroid.
the class SizeChangeEffect method apply.
@Override
public void apply(int inputTexId, int width, int height, int outputTexId) {
beginGLEffect();
Frame inputFrame = frameFromTexture(inputTexId, width, height);
Frame resultFrame = mFunction.executeWithArgList(mInputName, inputFrame);
int outputWidth = resultFrame.getFormat().getWidth();
int outputHeight = resultFrame.getFormat().getHeight();
Frame outputFrame = frameFromTexture(outputTexId, outputWidth, outputHeight);
outputFrame.setDataFromFrame(resultFrame);
inputFrame.release();
outputFrame.release();
resultFrame.release();
endGLEffect();
}
use of android.filterfw.core.Frame in project android_frameworks_base by ParanoidAndroid.
the class FilterContext method removeFrame.
public synchronized void removeFrame(String key) {
Frame frame = mStoredFrames.get(key);
if (frame != null) {
mStoredFrames.remove(key);
frame.release();
}
}
Aggregations