Fields Summary |
---|
private final String | TAG |
public final String | RESULT_FILE |
android.renderscript.RenderScript | mRS |
android.renderscript.Allocation | mInPixelsAllocation |
android.renderscript.Allocation | mInPixelsAllocation2 |
android.renderscript.Allocation | mOutPixelsAllocation |
android.graphics.Bitmap | mBitmapOut |
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 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 android.widget.TextView | mBenchmarkResult |
private android.widget.Spinner | mTestSpinner |
private android.widget.ImageView | mDisplayView |
private boolean | mDoingBenchmark |
private TestBase | mTest |
private int | mRunCount |
private android.os.Handler | mHandler |
private AdapterView.OnItemSelectedListener | mTestSpinnerListener |
Methods Summary |
---|
public void | benchmark(android.view.View v)
float t = getBenchmark();
//long javaTime = javaFilter();
//mBenchmarkResult.setText("RS: " + t + " ms Java: " + javaTime + " ms");
mBenchmarkResult.setText("Result: " + t + " ms");
Log.v(TAG, "getBenchmark: Renderscript frame time core ms " + t);
|
public void | benchmark_all(android.view.View v)
// write result into a file
File externalStorage = Environment.getExternalStorageDirectory();
if (!externalStorage.canWrite()) {
Log.v(TAG, "sdcard is not writable");
return;
}
File resultFile = new File(externalStorage, RESULT_FILE);
resultFile.setWritable(true, false);
try {
BufferedWriter rsWriter = new BufferedWriter(new FileWriter(resultFile));
Log.v(TAG, "Saved results in: " + resultFile.getAbsolutePath());
for (TestName tn: TestName.values()) {
changeTest(tn);
float t = getBenchmark();
String s = new String("" + tn.toString() + ", " + t);
rsWriter.write(s + "\n");
Log.v(TAG, "Test " + s + "ms\n");
}
rsWriter.close();
} catch (IOException e) {
Log.v(TAG, "Unable to write result file " + e.getMessage());
}
changeTest(TestName.LEVELS_VEC3_RELAXED);
|
void | changeTest(com.android.rs.image.ImageProcessingActivity$TestName testName)
if (mTest != null) {
mTest.destroy();
}
switch(testName) {
case LEVELS_VEC3_RELAXED:
mTest = new LevelsV4(false, false);
break;
case LEVELS_VEC4_RELAXED:
mTest = new LevelsV4(false, true);
break;
case LEVELS_VEC3_FULL:
mTest = new LevelsV4(true, false);
break;
case LEVELS_VEC4_FULL:
mTest = new LevelsV4(true, true);
break;
case BLUR_RADIUS_25:
mTest = new Blur25(false);
break;
case INTRINSIC_BLUE_RADIUS_25:
mTest = new Blur25(true);
break;
case GREYSCALE:
mTest = new Greyscale();
break;
case GRAIN:
mTest = new Grain();
break;
case FISHEYE_FULL:
mTest = new Fisheye(false, false);
break;
case FISHEYE_RELAXED:
mTest = new Fisheye(false, true);
break;
case FISHEYE_APPROXIMATE_FULL:
mTest = new Fisheye(true, false);
break;
case FISHEYE_APPROXIMATE_RELAXED:
mTest = new Fisheye(true, true);
break;
case VIGNETTE_FULL:
mTest = new Vignette(false, false);
break;
case VIGNETTE_RELAXED:
mTest = new Vignette(false, true);
break;
case VIGNETTE_APPROXIMATE_FULL:
mTest = new Vignette(true, false);
break;
case VIGNETTE_APPROXIMATE_RELAXED:
mTest = new Vignette(true, true);
break;
case GROUP_TEST_EMULATED:
mTest = new GroupTest(false);
break;
case GROUP_TEST_NATIVE:
mTest = new GroupTest(true);
break;
case CONVOLVE_3X3:
mTest = new Convolve3x3(false);
break;
case INTRINSICS_CONVOLVE_3X3:
mTest = new Convolve3x3(true);
break;
case COLOR_MATRIX:
mTest = new ColorMatrix(false, false);
break;
case INTRINSICS_COLOR_MATRIX:
mTest = new ColorMatrix(true, false);
break;
case INTRINSICS_COLOR_MATRIX_GREY:
mTest = new ColorMatrix(true, true);
break;
case COPY:
mTest = new Copy();
break;
case CROSS_PROCESS_USING_LUT:
mTest = new CrossProcess();
break;
case CONVOLVE_5X5:
mTest = new Convolve5x5(false);
break;
case INTRINSICS_CONVOLVE_5X5:
mTest = new Convolve5x5(true);
break;
case MANDELBROT_FLOAT:
mTest = new Mandelbrot(false);
break;
case INTRINSICS_BLEND:
mTest = new Blend();
break;
case INTRINSICS_BLUR_25G:
mTest = new Blur25G();
break;
case VIBRANCE:
mTest = new Vibrance();
break;
case BW_FILTER:
mTest = new BWFilter();
break;
case SHADOWS:
mTest = new Shadows();
break;
case CONTRAST:
mTest = new Contrast();
break;
case EXPOSURE:
mTest = new Exposure();
break;
case WHITE_BALANCE:
mTest = new WhiteBalance();
break;
case COLOR_CUBE:
mTest = new ColorCube(false);
break;
case COLOR_CUBE_3D_INTRINSIC:
mTest = new ColorCube(true);
break;
case USAGE_IO:
mTest = new UsageIO();
break;
case ARTISTIC_1:
mTest = new Artistic1();
break;
case HISTOGRAM:
mTest = new Histogram();
break;
case MANDELBROT_DOUBLE:
mTest = new Mandelbrot(true);
break;
case RESIZE_BICUBIC_SCRIPT:
mTest = new Resize(false);
break;
case RESIZE_BICUBIC_INTRINSIC:
mTest = new Resize(true);
break;
case MIRROR:
mTest = new Mirror();
break;
}
mTest.createBaseTest(this);
setupBars();
mTest.runTest();
updateDisplay();
mBenchmarkResult.setText("Result: not run");
|
void | cleanup()
synchronized(this) {
RenderScript rs = mRS;
mRS = null;
while(mDoingBenchmark) {
try {
Thread.sleep(1, 0);
} catch(InterruptedException e) {
}
}
rs.destroy();
}
mInPixelsAllocation = null;
mInPixelsAllocation2 = null;
mOutPixelsAllocation = null;
mBitmapOut = null;
|
public float | getBenchmark()
if (mRS == null) {
return 0;
}
mDoingBenchmark = true;
mTest.setupBenchmark();
long result = 0;
//Log.v(TAG, "Warming");
long t = java.lang.System.currentTimeMillis() + 250;
do {
mTest.runTest();
mTest.finish();
} while (t > java.lang.System.currentTimeMillis());
//Log.v(TAG, "Benchmarking");
int ct = 0;
t = java.lang.System.currentTimeMillis();
do {
mTest.runTest();
mTest.finish();
ct++;
} while ((t+1000) > java.lang.System.currentTimeMillis());
t = java.lang.System.currentTimeMillis() - t;
float ft = (float)t;
ft /= ct;
mTest.exitBenchmark();
mDoingBenchmark = false;
return ft;
|
void | init()
mRS = RenderScript.create(this);
mInPixelsAllocation = Allocation.createFromBitmapResource(
mRS, getResources(), R.drawable.img1600x1067);
mInPixelsAllocation2 = Allocation.createFromBitmapResource(
mRS, getResources(), R.drawable.img1600x1067b);
mBitmapOut = Bitmap.createBitmap(mInPixelsAllocation.getType().getX(),
mInPixelsAllocation.getType().getY(),
Bitmap.Config.ARGB_8888);
mBitmapOut.setHasAlpha(false);
mOutPixelsAllocation = Allocation.createFromBitmap(mRS, mBitmapOut);
mDisplayView = (ImageView) findViewById(R.id.display);
mDisplayView.setImageBitmap(mBitmapOut);
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);
mTestSpinner = (Spinner) findViewById(R.id.filterselection);
mTestSpinner.setOnItemSelectedListener(mTestSpinnerListener);
mBenchmarkResult = (TextView) findViewById(R.id.benchmarkText);
mBenchmarkResult.setText("Result: not run");
setupTests();
changeTest(TestName.LEVELS_VEC3_RELAXED);
|
protected void | onCreate(android.os.Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
init();
|
protected void | onPause()
super.onPause();
cleanup();
|
public void | onProgressChanged(android.widget.SeekBar seekBar, int progress, boolean fromUser)
if (fromUser) {
if (seekBar == mBar1) {
mTest.onBar1Changed(progress);
} else if (seekBar == mBar2) {
mTest.onBar2Changed(progress);
} else if (seekBar == mBar3) {
mTest.onBar3Changed(progress);
} else if (seekBar == mBar4) {
mTest.onBar4Changed(progress);
} else if (seekBar == mBar5) {
mTest.onBar5Changed(progress);
}
boolean doTest = false;
synchronized(this) {
if (mRunCount == 0) {
doTest = true;
mRunCount = 1;
} else {
mRunCount = 2;
}
}
if (doTest) {
mTest.runTestSendMessage();
}
}
|
protected void | onResume()
super.onResume();
if (null == mRS) {
init();
}
|
public void | onStartTrackingTouch(android.widget.SeekBar seekBar)
|
public void | onStopTrackingTouch(android.widget.SeekBar seekBar)
|
void | setupBars()
mSpinner.setVisibility(View.VISIBLE);
mTest.onSpinner1Setup(mSpinner);
mBar1.setVisibility(View.VISIBLE);
mText1.setVisibility(View.VISIBLE);
mTest.onBar1Setup(mBar1, mText1);
mBar2.setVisibility(View.VISIBLE);
mText2.setVisibility(View.VISIBLE);
mTest.onBar2Setup(mBar2, mText2);
mBar3.setVisibility(View.VISIBLE);
mText3.setVisibility(View.VISIBLE);
mTest.onBar3Setup(mBar3, mText3);
mBar4.setVisibility(View.VISIBLE);
mText4.setVisibility(View.VISIBLE);
mTest.onBar4Setup(mBar4, mText4);
mBar5.setVisibility(View.VISIBLE);
mText5.setVisibility(View.VISIBLE);
mTest.onBar5Setup(mBar5, mText5);
|
void | setupTests()
mTestSpinner.setAdapter(new ArrayAdapter<TestName>(
this, R.layout.spinner_layout, TestName.values()));
|
public void | updateDisplay()
mHandler.sendMessage(Message.obtain());
|