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

ImageProcessingActivityJB

public class ImageProcessingActivityJB extends android.app.Activity implements SeekBar.OnSeekBarChangeListener, TextureView.SurfaceTextureListener

Fields Summary
private final String
TAG
private android.widget.Spinner
mSpinner
private android.widget.SeekBar
mBar1
private android.widget.SeekBar
mBar2
private android.widget.SeekBar
mBar3
private android.widget.SeekBar
mBar4
private android.widget.SeekBar
mBar5
private int[]
mBars
private int[]
mBarsOld
private android.widget.TextView
mText1
private android.widget.TextView
mText2
private android.widget.TextView
mText3
private android.widget.TextView
mText4
private android.widget.TextView
mText5
private SizedTV
mDisplayView
private int[]
mTestList
private float[]
mTestResults
private boolean
mToggleIO
private boolean
mToggleDVFS
private boolean
mToggleLong
private boolean
mTogglePause
private boolean
mToggleAnimate
private boolean
mToggleDisplay
private int
mBitmapWidth
private int
mBitmapHeight
private boolean
mDemoMode
private int
mUpdatesPending
private int
mShowsPending
DVFSWorkaround
mDvfsWar
private boolean
mDoingBenchmark
public Processor
mProcessor
Constructors Summary
Methods Summary
TestBasechangeTest(IPTestListJB.TestName t, boolean setupUI)


         
        TestBase tb = IPTestListJB.newTest(t);

        tb.createBaseTest(this);
        if (setupUI) {
            setupBars(tb);
        }
        return tb;
    
TestBasechangeTest(int id, boolean setupUI)

        IPTestListJB.TestName t = IPTestListJB.TestName.values()[id];
        return changeTest(t, setupUI);
    
voidhideBars()

        mSpinner.setVisibility(View.INVISIBLE);

        mBar1.setVisibility(View.INVISIBLE);
        mText1.setVisibility(View.INVISIBLE);

        mBar2.setVisibility(View.INVISIBLE);
        mText2.setVisibility(View.INVISIBLE);

        mBar3.setVisibility(View.INVISIBLE);
        mText3.setVisibility(View.INVISIBLE);

        mBar4.setVisibility(View.INVISIBLE);
        mText4.setVisibility(View.INVISIBLE);

        mBar5.setVisibility(View.INVISIBLE);
        mText5.setVisibility(View.INVISIBLE);
    
public voidonBenchmarkFinish(boolean ok)

        if (ok) {
            Intent intent = new Intent();
            intent.putExtra("tests", mTestList);
            intent.putExtra("results", mTestResults);
            setResult(RESULT_OK, intent);
        } else {
            setResult(RESULT_CANCELED);
        }
        finish();
    
protected voidonCreate(android.os.Bundle savedInstanceState)

        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mDisplayView = (SizedTV) findViewById(R.id.display);

        mSpinner = (Spinner) findViewById(R.id.spinner1);

        mBar1 = (SeekBar) findViewById(R.id.slider1);
        mBar2 = (SeekBar) findViewById(R.id.slider2);
        mBar3 = (SeekBar) findViewById(R.id.slider3);
        mBar4 = (SeekBar) findViewById(R.id.slider4);
        mBar5 = (SeekBar) findViewById(R.id.slider5);

        mBar1.setOnSeekBarChangeListener(this);
        mBar2.setOnSeekBarChangeListener(this);
        mBar3.setOnSeekBarChangeListener(this);
        mBar4.setOnSeekBarChangeListener(this);
        mBar5.setOnSeekBarChangeListener(this);

        mText1 = (TextView) findViewById(R.id.slider1Text);
        mText2 = (TextView) findViewById(R.id.slider2Text);
        mText3 = (TextView) findViewById(R.id.slider3Text);
        mText4 = (TextView) findViewById(R.id.slider4Text);
        mText5 = (TextView) findViewById(R.id.slider5Text);
    
protected voidonDestroy()

        super.onDestroy();
    
protected voidonPause()

        super.onPause();
        mProcessor.exit();
    
public voidonProgressChanged(android.widget.SeekBar seekBar, int progress, boolean fromUser)

        if (fromUser) {
            if (seekBar == mBar1) {
                mBars[0] = progress;
            } else if (seekBar == mBar2) {
                mBars[1] = progress;
            } else if (seekBar == mBar3) {
                mBars[2] = progress;
            } else if (seekBar == mBar4) {
                mBars[3] = progress;
            } else if (seekBar == mBar5) {
                mBars[4] = progress;
            }
            mProcessor.update();
        }
    
protected voidonResume()

        super.onResume();
        Intent i = getIntent();
        mTestList = i.getIntArrayExtra("tests");

        mToggleIO = i.getBooleanExtra("enable io", false);
        mToggleDVFS = i.getBooleanExtra("enable dvfs", false);
        mToggleLong = i.getBooleanExtra("enable long", false);
        mTogglePause = i.getBooleanExtra("enable pause", false);
        mToggleAnimate = i.getBooleanExtra("enable animate", false);
        mToggleDisplay = i.getBooleanExtra("enable display", false);
        mBitmapWidth = i.getIntExtra("resolution X", 0);
        mBitmapHeight = i.getIntExtra("resolution Y", 0);
        mDemoMode = i.getBooleanExtra("demo", false);

        mTestResults = new float[mTestList.length];

        startProcessor();
    
public voidonStartTrackingTouch(android.widget.SeekBar seekBar)

    
public voidonStopTrackingTouch(android.widget.SeekBar seekBar)

    
public voidonSurfaceTextureAvailable(android.graphics.SurfaceTexture surface, int width, int height)

        mProcessor.setSurface(new Surface(surface));
    
public booleanonSurfaceTextureDestroyed(android.graphics.SurfaceTexture surface)

        mProcessor.setSurface(null);
        return true;
    
public voidonSurfaceTextureSizeChanged(android.graphics.SurfaceTexture surface, int width, int height)

        mProcessor.setSurface(new Surface(surface));
    
public voidonSurfaceTextureUpdated(android.graphics.SurfaceTexture surface)

    
voidsetupBars(TestBase t)

        mSpinner.setVisibility(View.VISIBLE);
        t.onSpinner1Setup(mSpinner);

        mBar1.setVisibility(View.VISIBLE);
        mText1.setVisibility(View.VISIBLE);
        t.onBar1Setup(mBar1, mText1);

        mBar2.setVisibility(View.VISIBLE);
        mText2.setVisibility(View.VISIBLE);
        t.onBar2Setup(mBar2, mText2);

        mBar3.setVisibility(View.VISIBLE);
        mText3.setVisibility(View.VISIBLE);
        t.onBar3Setup(mBar3, mText3);

        mBar4.setVisibility(View.VISIBLE);
        mText4.setVisibility(View.VISIBLE);
        t.onBar4Setup(mBar4, mText4);

        mBar5.setVisibility(View.VISIBLE);
        mText5.setVisibility(View.VISIBLE);
        t.onBar5Setup(mBar5, mText5);
    
voidstartProcessor()

        if (!mDemoMode) {
            hideBars();
        }

        Point size = new Point();
        getWindowManager().getDefaultDisplay().getSize(size);

        int mScreenWidth = size.x;
        int mScreenHeight = size.y;

        int tw = mBitmapWidth;
        int th = mBitmapHeight;

        if (tw > mScreenWidth || th > mScreenHeight) {
            float s1 = (float)tw / (float)mScreenWidth;
            float s2 = (float)th / (float)mScreenHeight;

            if (s1 > s2) {
                tw /= s1;
                th /= s1;
            } else {
                tw /= s2;
                th /= s2;
            }
        }

        android.util.Log.v("rs", "TV sizes " + tw + ", " + th);

        mDisplayView.mWidth = tw;
        mDisplayView.mHeight = th;
        //mDisplayView.setTransform(new android.graphics.Matrix());

        mProcessor = new Processor(RenderScript.create(this), mDisplayView, !mDemoMode);
        mDisplayView.setSurfaceTextureListener(this);

        if (mDemoMode) {
            mProcessor.mTest = changeTest(mTestList[0], true);
        }