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();
}
}
use of android.filterfw.core.Frame in project android_frameworks_base by ParanoidAndroid.
the class CachedFrameManager method findAvailableFrame.
private Frame findAvailableFrame(FrameFormat format, int bindingType, long bindingId) {
// Look for a frame that is compatible with the requested format
synchronized (mAvailableFrames) {
for (Map.Entry<Integer, Frame> entry : mAvailableFrames.entrySet()) {
Frame frame = entry.getValue();
// Check that format is compatible
if (frame.getFormat().isReplaceableBy(format)) {
// Check that binding is compatible (if frame is bound)
if ((bindingType == frame.getBindingType()) && (bindingType == Frame.NO_BINDING || bindingId == frame.getBindingId())) {
// We found one! Take it out of the set of available frames and attach the
// requested format to it.
super.retainFrame(frame);
mAvailableFrames.remove(entry.getKey());
frame.onFrameFetch();
frame.reset(format);
mStorageSize -= format.getSize();
return frame;
}
}
}
}
return null;
}
Aggregations