Search in sources :

Example 1 with Frame

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;
}
Also used : FrameFormat(android.filterfw.core.FrameFormat) Frame(android.filterfw.core.Frame) GLFrame(android.filterfw.core.GLFrame) CachedFrameManager(android.filterfw.core.CachedFrameManager) FrameManager(android.filterfw.core.FrameManager)

Example 2 with 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();
}
Also used : Frame(android.filterfw.core.Frame)

Example 3 with Frame

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();
}
Also used : Frame(android.filterfw.core.Frame)

Example 4 with Frame

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();
    }
}
Also used : Frame(android.filterfw.core.Frame)

Example 5 with Frame

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;
}
Also used : Frame(android.filterfw.core.Frame) TreeMap(java.util.TreeMap) Map(java.util.Map) SortedMap(java.util.SortedMap)

Aggregations

Frame (android.filterfw.core.Frame)414 FrameFormat (android.filterfw.core.FrameFormat)198 GLFrame (android.filterfw.core.GLFrame)73 MutableFrameFormat (android.filterfw.core.MutableFrameFormat)47 NativeFrame (android.filterfw.core.NativeFrame)38 Quad (android.filterfw.geometry.Quad)24 GLEnvironment (android.filterfw.core.GLEnvironment)18 ShaderProgram (android.filterfw.core.ShaderProgram)18 ByteBuffer (java.nio.ByteBuffer)18 Point (android.filterfw.geometry.Point)12 IOException (java.io.IOException)12 FrameManager (android.filterfw.core.FrameManager)6 Bitmap (android.graphics.Bitmap)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 Map (java.util.Map)6 SortedMap (java.util.SortedMap)6 TreeMap (java.util.TreeMap)6 CachedFrameManager (android.filterfw.core.CachedFrameManager)1