Search in sources :

Example 91 with FrameFormat

use of android.filterfw.core.FrameFormat in project android_frameworks_base by DirtyUnicorns.

the class SimpleFrame method wrapObject.

static SimpleFrame wrapObject(Object object, FrameManager frameManager) {
    FrameFormat format = ObjectFormat.fromObject(object, FrameFormat.TARGET_SIMPLE);
    SimpleFrame result = new SimpleFrame(format, frameManager);
    result.setObjectValue(object);
    return result;
}
Also used : FrameFormat(android.filterfw.core.FrameFormat)

Example 92 with FrameFormat

use of android.filterfw.core.FrameFormat in project android_frameworks_base by DirtyUnicorns.

the class SimpleFrame method setGenericObjectValue.

@Override
protected void setGenericObjectValue(Object object) {
    // Update the FrameFormat class
    // TODO: Take this out! FrameFormats should not be modified and convenience formats used
    // instead!
    FrameFormat format = getFormat();
    if (format.getObjectClass() == null) {
        setFormatObjectClass(object.getClass());
    } else if (!format.getObjectClass().isAssignableFrom(object.getClass())) {
        throw new RuntimeException("Attempting to set object value of type '" + object.getClass() + "' on " + "SimpleFrame of type '" + format.getObjectClass() + "'!");
    }
    // Set the object value
    mObject = object;
}
Also used : FrameFormat(android.filterfw.core.FrameFormat)

Example 93 with FrameFormat

use of android.filterfw.core.FrameFormat in project android_frameworks_base by DirtyUnicorns.

the class GLFrame method init.

void init(GLEnvironment glEnv) {
    FrameFormat format = getFormat();
    mGLEnvironment = glEnv;
    // Check that we have a valid format
    if (format.getBytesPerSample() != 4) {
        throw new IllegalArgumentException("GL frames must have 4 bytes per sample!");
    } else if (format.getDimensionCount() != 2) {
        throw new IllegalArgumentException("GL frames must be 2-dimensional!");
    } else if (getFormat().getSize() < 0) {
        throw new IllegalArgumentException("Initializing GL frame with zero size!");
    }
    // Create correct frame
    int bindingType = getBindingType();
    boolean reusable = true;
    if (bindingType == Frame.NO_BINDING) {
        initNew(false);
    } else if (bindingType == EXTERNAL_TEXTURE) {
        initNew(true);
        reusable = false;
    } else if (bindingType == EXISTING_TEXTURE_BINDING) {
        initWithTexture((int) getBindingId());
    } else if (bindingType == EXISTING_FBO_BINDING) {
        initWithFbo((int) getBindingId());
    } else if (bindingType == NEW_TEXTURE_BINDING) {
        initWithTexture((int) getBindingId());
    } else if (bindingType == NEW_FBO_BINDING) {
        initWithFbo((int) getBindingId());
    } else {
        throw new RuntimeException("Attempting to create GL frame with unknown binding type " + bindingType + "!");
    }
    setReusable(reusable);
}
Also used : FrameFormat(android.filterfw.core.FrameFormat)

Example 94 with FrameFormat

use of android.filterfw.core.FrameFormat in project android_frameworks_base by AOSPA.

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) FrameManager(android.filterfw.core.FrameManager)

Example 95 with FrameFormat

use of android.filterfw.core.FrameFormat in project android_frameworks_base by AOSPA.

the class NegativeFilter method process.

@Override
public void process(FilterContext context) {
    // Get input frame
    Frame input = pullInput("image");
    FrameFormat inputFormat = input.getFormat();
    // Create output frame
    Frame output = context.getFrameManager().newFrame(inputFormat);
    // Create program if not created already
    if (mProgram == null || inputFormat.getTarget() != mTarget) {
        initProgram(context, inputFormat.getTarget());
    }
    // Process
    mProgram.process(input, output);
    // Push output
    pushOutput("image", output);
    // Release pushed frame
    output.release();
}
Also used : FrameFormat(android.filterfw.core.FrameFormat) Frame(android.filterfw.core.Frame)

Aggregations

FrameFormat (android.filterfw.core.FrameFormat)270 Frame (android.filterfw.core.Frame)198 MutableFrameFormat (android.filterfw.core.MutableFrameFormat)39 NativeFrame (android.filterfw.core.NativeFrame)25 GLFrame (android.filterfw.core.GLFrame)18 ShaderProgram (android.filterfw.core.ShaderProgram)12 Quad (android.filterfw.geometry.Quad)12 FrameManager (android.filterfw.core.FrameManager)6 Point (android.filterfw.geometry.Point)6 Bitmap (android.graphics.Bitmap)6 Paint (android.graphics.Paint)6 CachedFrameManager (android.filterfw.core.CachedFrameManager)1