FileDocCategorySizeDatePackage
LevelsV4.javaAPI DocAndroid 5.1 API5017Thu Mar 12 22:22:54 GMT 2015com.android.rs.imagejb

LevelsV4

public class LevelsV4 extends TestBase

Fields Summary
private ScriptC_levels_relaxed
mScriptR
private ScriptC_levels_full
mScriptF
private float
mInBlack
private float
mOutBlack
private float
mInWhite
private float
mOutWhite
private float
mSaturation
android.renderscript.Matrix3f
satMatrix
float
mInWMinInB
float
mOutWMinOutB
float
mOverInWMinInB
boolean
mUseFull
boolean
mUseV4
Constructors Summary
LevelsV4(boolean useFull, boolean useV4)


        
        mUseFull = useFull;
        mUseV4 = useV4;
    
Methods Summary
public voidanimateBars(float time)

        mSaturation = time % 2.f;
        setSaturation();
    
public voidcreateTest(android.content.res.Resources res)

        mScriptR = new ScriptC_levels_relaxed(mRS);
        mScriptF = new ScriptC_levels_full(mRS);
        setSaturation();
        setLevels();
    
public voidonBar1Changed(int progress)

        mSaturation = (float)progress / 50.0f;
        setSaturation();
    
public booleanonBar1Setup(android.widget.SeekBar b, android.widget.TextView t)

        b.setProgress(50);
        t.setText("Saturation");
        return true;
    
public voidonBar2Changed(int progress)

        mInBlack = (float)progress;
        setLevels();
    
public booleanonBar2Setup(android.widget.SeekBar b, android.widget.TextView t)

        b.setMax(128);
        b.setProgress(0);
        t.setText("In Black");
        return true;
    
public voidonBar3Changed(int progress)

        mOutBlack = (float)progress;
        setLevels();
    
public booleanonBar3Setup(android.widget.SeekBar b, android.widget.TextView t)

        b.setMax(128);
        b.setProgress(0);
        t.setText("Out Black");
        return true;
    
public voidonBar4Changed(int progress)

        mInWhite = (float)progress + 127.0f;
        setLevels();
    
public booleanonBar4Setup(android.widget.SeekBar b, android.widget.TextView t)

        b.setMax(128);
        b.setProgress(128);
        t.setText("In White");
        return true;
    
public voidonBar5Changed(int progress)

        mOutWhite = (float)progress + 127.0f;
        setLevels();
    
public booleanonBar5Setup(android.widget.SeekBar b, android.widget.TextView t)

        b.setMax(128);
        b.setProgress(128);
        t.setText("Out White");
        return true;
    
public voidrunTest()

        if (mUseFull) {
            if (mUseV4) {
                mScriptF.forEach_root4(mInPixelsAllocation, mOutPixelsAllocation);
            } else {
                mScriptF.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
            }
        } else {
            if (mUseV4) {
                mScriptR.forEach_root4(mInPixelsAllocation, mOutPixelsAllocation);
            } else {
                mScriptR.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
            }
        }
    
private voidsetLevels()

        mInWMinInB = mInWhite - mInBlack;
        mOutWMinOutB = mOutWhite - mOutBlack;
        mOverInWMinInB = 1.f / mInWMinInB;

        mScriptR.set_inBlack(mInBlack);
        mScriptR.set_outBlack(mOutBlack);
        mScriptR.set_inWMinInB(mInWMinInB);
        mScriptR.set_outWMinOutB(mOutWMinOutB);
        mScriptR.set_overInWMinInB(mOverInWMinInB);
        mScriptF.set_inBlack(mInBlack);
        mScriptF.set_outBlack(mOutBlack);
        mScriptF.set_inWMinInB(mInWMinInB);
        mScriptF.set_outWMinOutB(mOutWMinOutB);
        mScriptF.set_overInWMinInB(mOverInWMinInB);
    
private voidsetSaturation()

        float rWeight = 0.299f;
        float gWeight = 0.587f;
        float bWeight = 0.114f;
        float oneMinusS = 1.0f - mSaturation;

        satMatrix.set(0, 0, oneMinusS * rWeight + mSaturation);
        satMatrix.set(0, 1, oneMinusS * rWeight);
        satMatrix.set(0, 2, oneMinusS * rWeight);
        satMatrix.set(1, 0, oneMinusS * gWeight);
        satMatrix.set(1, 1, oneMinusS * gWeight + mSaturation);
        satMatrix.set(1, 2, oneMinusS * gWeight);
        satMatrix.set(2, 0, oneMinusS * bWeight);
        satMatrix.set(2, 1, oneMinusS * bWeight);
        satMatrix.set(2, 2, oneMinusS * bWeight + mSaturation);
        mScriptR.set_colorMat(satMatrix);
        mScriptF.set_colorMat(satMatrix);