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;
}
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;
}
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);
}
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;
}
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();
}
Aggregations