Search in sources :

Example 66 with ShaderProgram

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

the class DuotoneFilter method initProgram.

public void initProgram(FilterContext context, int target) {
    switch(target) {
        case FrameFormat.TARGET_GPU:
            ShaderProgram shaderProgram = new ShaderProgram(context, mDuotoneShader);
            shaderProgram.setMaximumTileSize(mTileSize);
            mProgram = shaderProgram;
            break;
        default:
            throw new RuntimeException("Filter Duotone does not support frames of " + "target " + target + "!");
    }
    mTarget = target;
}
Also used : ShaderProgram(android.filterfw.core.ShaderProgram)

Example 67 with ShaderProgram

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

the class StraightenFilter method updateParameters.

private void updateParameters() {
    float cosTheta = (float) Math.cos(mAngle * DEGREE_TO_RADIAN);
    float sinTheta = (float) Math.sin(mAngle * DEGREE_TO_RADIAN);
    if (mMaxAngle <= 0)
        throw new RuntimeException("Max angle is out of range (0-180).");
    mMaxAngle = (mMaxAngle > 90) ? 90 : mMaxAngle;
    Point p0 = new Point(-cosTheta * mWidth + sinTheta * mHeight, -sinTheta * mWidth - cosTheta * mHeight);
    Point p1 = new Point(cosTheta * mWidth + sinTheta * mHeight, sinTheta * mWidth - cosTheta * mHeight);
    Point p2 = new Point(-cosTheta * mWidth - sinTheta * mHeight, -sinTheta * mWidth + cosTheta * mHeight);
    Point p3 = new Point(cosTheta * mWidth - sinTheta * mHeight, sinTheta * mWidth + cosTheta * mHeight);
    float maxWidth = (float) Math.max(Math.abs(p0.x), Math.abs(p1.x));
    float maxHeight = (float) Math.max(Math.abs(p0.y), Math.abs(p1.y));
    float scale = 0.5f * Math.min(mWidth / maxWidth, mHeight / maxHeight);
    p0.set(scale * p0.x / mWidth + 0.5f, scale * p0.y / mHeight + 0.5f);
    p1.set(scale * p1.x / mWidth + 0.5f, scale * p1.y / mHeight + 0.5f);
    p2.set(scale * p2.x / mWidth + 0.5f, scale * p2.y / mHeight + 0.5f);
    p3.set(scale * p3.x / mWidth + 0.5f, scale * p3.y / mHeight + 0.5f);
    Quad quad = new Quad(p0, p1, p2, p3);
    ((ShaderProgram) mProgram).setSourceRegion(quad);
}
Also used : Quad(android.filterfw.geometry.Quad) ShaderProgram(android.filterfw.core.ShaderProgram) Point(android.filterfw.geometry.Point)

Example 68 with ShaderProgram

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

the class ToGrayFilter method getShaderProgram.

@Override
protected Program getShaderProgram(FilterContext context) {
    int inputChannels = getInputFormat("image").getBytesPerSample();
    if (inputChannels != 4) {
        throw new RuntimeException("Unsupported GL input channels: " + inputChannels + "! Channels must be 4!");
    }
    ShaderProgram program = new ShaderProgram(context, mColorToGray4Shader);
    program.setMaximumTileSize(mTileSize);
    if (mInvertSource)
        program.setSourceRect(0.0f, 1.0f, 1.0f, -1.0f);
    return program;
}
Also used : ShaderProgram(android.filterfw.core.ShaderProgram)

Example 69 with ShaderProgram

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

the class FillLightFilter method initProgram.

public void initProgram(FilterContext context, int target) {
    switch(target) {
        case FrameFormat.TARGET_GPU:
            ShaderProgram shaderProgram = new ShaderProgram(context, mFillLightShader);
            Log.e("FillLight", "tile size: " + mTileSize);
            shaderProgram.setMaximumTileSize(mTileSize);
            mProgram = shaderProgram;
            break;
        default:
            throw new RuntimeException("Filter FillLight does not support frames of " + "target " + target + "!");
    }
    mTarget = target;
}
Also used : ShaderProgram(android.filterfw.core.ShaderProgram)

Example 70 with ShaderProgram

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

the class FlipFilter method initProgram.

public void initProgram(FilterContext context, int target) {
    switch(target) {
        case FrameFormat.TARGET_GPU:
            ShaderProgram shaderProgram = ShaderProgram.createIdentity(context);
            shaderProgram.setMaximumTileSize(mTileSize);
            mProgram = shaderProgram;
            break;
        default:
            throw new RuntimeException("Filter Sharpen does not support frames of " + "target " + target + "!");
    }
    mTarget = target;
    updateParameters();
}
Also used : ShaderProgram(android.filterfw.core.ShaderProgram)

Aggregations

ShaderProgram (android.filterfw.core.ShaderProgram)198 Frame (android.filterfw.core.Frame)18 MutableFrameFormat (android.filterfw.core.MutableFrameFormat)18 Quad (android.filterfw.geometry.Quad)18 FrameFormat (android.filterfw.core.FrameFormat)12 Point (android.filterfw.geometry.Point)12 NativeFrame (android.filterfw.core.NativeFrame)1