diff options
author | Stephen Hines <srhines@google.com> | 2014-06-13 14:43:31 -0700 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2014-06-13 14:43:31 -0700 |
commit | 64af0822b0b7c71cea3a39c9aad10d1cdbf851ef (patch) | |
tree | 86020e17f9d4c3687e12cae090d707cd9517f9c5 | |
parent | f6328b8db3b5de20fb27812157db2ff8bda4669c (diff) | |
download | rs-64af0822b0b7c71cea3a39c9aad10d1cdbf851ef.tar.gz |
Remove all graphics API usage from RSTest.
This brings it closer to RSTest_CompatLib.
Change-Id: Ib7e22772d1549ba8ec0ac4df4d04832358863116
14 files changed, 50 insertions, 859 deletions
diff --git a/java/tests/RSTest_CompatLib/src/com/android/rs/test/RSTestCore.java b/java/tests/RSTest_CompatLib/src/com/android/rs/test/RSTestCore.java index 462e4f44..3eabee03 100644 --- a/java/tests/RSTest_CompatLib/src/com/android/rs/test/RSTestCore.java +++ b/java/tests/RSTest_CompatLib/src/com/android/rs/test/RSTestCore.java @@ -107,7 +107,6 @@ public class RSTestCore { mListAllocs = new ScriptField_ListAllocs_s(mRS, uta.length); for (int i = 0; i < uta.length; i++) { - ScriptField_ListAllocs_s.Item listElem = new ScriptField_ListAllocs_s.Item(); listElem.text = Allocation.createFromString(mRS, uta[i].name, Allocation.USAGE_SCRIPT); listElem.result = uta[i].getResult(); diff --git a/java/tests/RsTest/src/com/android/rs/test/RSTest.java b/java/tests/RsTest/src/com/android/rs/test/RSTest.java index d1b23fa6..4ebb7331 100644 --- a/java/tests/RsTest/src/com/android/rs/test/RSTest.java +++ b/java/tests/RsTest/src/com/android/rs/test/RSTest.java @@ -16,10 +16,9 @@ package com.android.rs.test; -import android.renderscript.RSSurfaceView; import android.renderscript.RenderScript; -import android.app.Activity; +import android.app.ListActivity; import android.content.res.Configuration; import android.os.Bundle; import android.os.Handler; @@ -33,52 +32,28 @@ import android.view.View; import android.view.Window; import android.widget.Button; import android.widget.ListView; +import android.widget.ArrayAdapter; import java.lang.Runtime; -public class RSTest extends Activity { - //EventListener mListener = new EventListener(); +public class RSTest extends ListActivity { private static final String LOG_TAG = "RSTest"; private static final boolean DEBUG = false; private static final boolean LOG_ENABLED = false; - private RSTestView mView; + private RenderScript mRS; + private RSTestCore RSTC; - // get the current looper (from your Activity UI thread for instance + String mTestNames[]; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); + mRS = RenderScript.create(this); - // Create our Preview view and set it as the content of our - // Activity - mView = new RSTestView(this); - setContentView(mView); - } - - @Override - protected void onResume() { - // Ideally a game should implement onResume() and onPause() - // to take appropriate action when the activity loses focus - super.onResume(); - mView.resume(); - } - - @Override - protected void onPause() { - // Ideally a game should implement onResume() and onPause() - // to take appropriate action when the activity loses focus - super.onPause(); - mView.pause(); - } - - @Override - protected void onStop() { - // Actually kill the app if we are stopping. We don't want to - // continue/resume this test ever. It should always start fresh. - finish(); - super.onStop(); + RSTC = new RSTestCore(this); + RSTC.init(mRS, getResources()); } static void log(String message) { diff --git a/java/tests/RsTest/src/com/android/rs/test/RSTestCore.java b/java/tests/RsTest/src/com/android/rs/test/RSTestCore.java index 34b6938b..e9d5268a 100644 --- a/java/tests/RsTest/src/com/android/rs/test/RSTestCore.java +++ b/java/tests/RsTest/src/com/android/rs/test/RSTestCore.java @@ -24,44 +24,37 @@ import java.util.ArrayList; import java.util.ListIterator; import java.util.Timer; import java.util.TimerTask; - +import android.app.ListActivity; +import android.widget.ArrayAdapter; public class RSTestCore { - int mWidth; - int mHeight; - Context mCtx; + ListActivity mCtx; - public RSTestCore(Context ctx) { + public RSTestCore(ListActivity ctx) { mCtx = ctx; } private Resources mRes; - private RenderScriptGL mRS; - - private Font mFont; - ScriptField_ListAllocs_s mListAllocs; - int mLastX; - int mLastY; - private ScriptC_rslist mScript; + private RenderScript mRS; private ArrayList<UnitTest> unitTests; private ListIterator<UnitTest> test_iter; private UnitTest activeTest; private boolean stopTesting; + private ScriptField_ListAllocs_s mListAllocs; + + private ArrayAdapter<UnitTest> testAdapter; + /* Periodic timer for ensuring future tests get scheduled */ private Timer mTimer; public static final int RS_TIMER_PERIOD = 100; - public void init(RenderScriptGL rs, Resources res, int width, int height) { + public void init(RenderScript rs, Resources res) { mRS = rs; mRes = res; - mWidth = width; - mHeight = height; stopTesting = false; - mScript = new ScriptC_rslist(mRS); - unitTests = new ArrayList<UnitTest>(); unitTests.add(new UT_primitives(this, mRes, mCtx)); @@ -97,9 +90,9 @@ public class RSTestCore { unitTests.add(new UT_int4(this, mRes, mCtx)); unitTests.add(new UT_element(this, mRes, mCtx)); unitTests.add(new UT_sampler(this, mRes, mCtx)); - unitTests.add(new UT_program_store(this, mRes, mCtx)); + /*unitTests.add(new UT_program_store(this, mRes, mCtx)); unitTests.add(new UT_program_raster(this, mRes, mCtx)); - unitTests.add(new UT_mesh(this, mRes, mCtx)); + unitTests.add(new UT_mesh(this, mRes, mCtx));*/ unitTests.add(new UT_fp_mad(this, mRes, mCtx)); /* @@ -126,12 +119,8 @@ public class RSTestCore { mListAllocs.copyAll(); - mScript.bind_gList(mListAllocs); - - mFont = Font.create(mRS, mRes, "serif", Font.Style.BOLD, 8); - mScript.set_gFont(mFont); - - mRS.bindRootScript(mScript); + testAdapter = new ArrayAdapter<UnitTest>(mCtx, android.R.layout.simple_list_item_1, unitTests); + mCtx.setListAdapter(testAdapter); test_iter = unitTests.listIterator(); refreshTestResults(); /* Kick off the first test */ @@ -147,6 +136,13 @@ public class RSTestCore { } public void checkAndRunNextTest() { + mCtx.runOnUiThread(new Runnable() { + public void run() { + if (testAdapter != null) + testAdapter.notifyDataSetChanged(); + } + }); + if (activeTest != null) { if (!activeTest.isAlive()) { /* Properly clean up on our last test */ @@ -179,13 +175,6 @@ public class RSTestCore { public void refreshTestResults() { checkAndRunNextTest(); - - if (mListAllocs != null && mScript != null && mRS != null) { - mListAllocs.copyAll(); - - mScript.bind_gList(mListAllocs); - mRS.bindRootScript(mScript); - } } public void cleanup() { @@ -211,28 +200,4 @@ public class RSTestCore { } - public void newTouchPosition(float x, float y, float pressure, int id) { - } - - public void onActionDown(int x, int y) { - mScript.set_gDY(0.0f); - mLastX = x; - mLastY = y; - refreshTestResults(); - } - - public void onActionMove(int x, int y) { - int dx = mLastX - x; - int dy = mLastY - y; - - if (Math.abs(dy) <= 2) { - dy = 0; - } - - mScript.set_gDY(dy); - - mLastX = x; - mLastY = y; - refreshTestResults(); - } } diff --git a/java/tests/RsTest/src/com/android/rs/test/RSTestView.java b/java/tests/RsTest/src/com/android/rs/test/RSTestView.java deleted file mode 100644 index 368f2866..00000000 --- a/java/tests/RsTest/src/com/android/rs/test/RSTestView.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.rs.test; - -import java.io.Writer; -import java.util.ArrayList; -import java.util.concurrent.Semaphore; - -import android.renderscript.RSSurfaceView; -import android.renderscript.RenderScript; -import android.renderscript.RenderScriptGL; - -import android.content.Context; -import android.content.res.Resources; -import android.graphics.Bitmap; -import android.graphics.drawable.BitmapDrawable; -import android.graphics.drawable.Drawable; -import android.os.Handler; -import android.os.Message; -import android.util.AttributeSet; -import android.util.Log; -import android.view.Surface; -import android.view.SurfaceHolder; -import android.view.SurfaceView; -import android.view.KeyEvent; -import android.view.MotionEvent; - -public class RSTestView extends RSSurfaceView { - - private Context mCtx; - - public RSTestView(Context context) { - super(context); - mCtx = context; - //setFocusable(true); - } - - private RenderScriptGL mRS; - private RSTestCore mRender; - - public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { - super.surfaceChanged(holder, format, w, h); - if (mRS == null) { - RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig(); - mRS = createRenderScriptGL(sc); - mRS.setSurface(holder, w, h); - mRender = new RSTestCore(mCtx); - mRender.init(mRS, getResources(), w, h); - } - } - - @Override - protected void onDetachedFromWindow() { - if(mRS != null) { - mRender.cleanup(); - mRS = null; - destroyRenderScriptGL(); - } - } - - @Override - public boolean onKeyDown(int keyCode, KeyEvent event) - { - return super.onKeyDown(keyCode, event); - } - - @Override - public boolean onTouchEvent(MotionEvent ev) - { - boolean ret = false; - int act = ev.getAction(); - if (act == ev.ACTION_DOWN) { - mRender.onActionDown((int)ev.getX(), (int)ev.getY()); - ret = true; - } - else if (act == ev.ACTION_MOVE) { - mRender.onActionMove((int)ev.getX(), (int)ev.getY()); - ret = true; - } - - return ret; - } -} diff --git a/java/tests/RsTest/src/com/android/rs/test/UT_mesh.java b/java/tests/RsTest/src/com/android/rs/test/UT_mesh.java deleted file mode 100644 index 29e50253..00000000 --- a/java/tests/RsTest/src/com/android/rs/test/UT_mesh.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.rs.test; - -import android.content.Context; -import android.content.res.Resources; -import android.renderscript.*; -import android.renderscript.Mesh.*; - -public class UT_mesh extends UnitTest { - private Resources mRes; - - Mesh mesh; - - protected UT_mesh(RSTestCore rstc, Resources res, Context ctx) { - super(rstc, "Mesh", ctx); - mRes = res; - } - - private void initializeGlobals(RenderScript RS, ScriptC_mesh s) { - Allocation vAlloc0 = Allocation.createSized(RS, Element.F32(RS), 10); - Allocation vAlloc1 = Allocation.createSized(RS, Element.F32_2(RS), 10); - - Allocation iAlloc0 = Allocation.createSized(RS, Element.I16(RS), 10); - Allocation iAlloc2 = Allocation.createSized(RS, Element.I16(RS), 10); - - Mesh.AllocationBuilder mBuilder = new Mesh.AllocationBuilder(RS); - mBuilder.addVertexAllocation(vAlloc0); - mBuilder.addVertexAllocation(vAlloc1); - - mBuilder.addIndexSetAllocation(iAlloc0, Primitive.POINT); - mBuilder.addIndexSetType(Primitive.LINE); - mBuilder.addIndexSetAllocation(iAlloc2, Primitive.TRIANGLE); - - s.set_mesh(mBuilder.create()); - s.set_vertexAlloc0(vAlloc0); - s.set_vertexAlloc1(vAlloc1); - s.set_indexAlloc0(iAlloc0); - s.set_indexAlloc2(iAlloc2); - } - - private void testScriptSide(RenderScript pRS) { - ScriptC_mesh s = new ScriptC_mesh(pRS); - pRS.setMessageHandler(mRsMessage); - initializeGlobals(pRS, s); - s.invoke_mesh_test(); - pRS.finish(); - waitForMessage(); - } - - private void testJavaSide(RenderScript RS) { - } - - public void run() { - RenderScript pRS = RenderScript.create(mCtx); - testScriptSide(pRS); - testJavaSide(pRS); - passTest(); - pRS.destroy(); - } -} diff --git a/java/tests/RsTest/src/com/android/rs/test/UT_program_raster.java b/java/tests/RsTest/src/com/android/rs/test/UT_program_raster.java deleted file mode 100644 index 046a2158..00000000 --- a/java/tests/RsTest/src/com/android/rs/test/UT_program_raster.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.rs.test; - -import android.content.Context; -import android.content.res.Resources; -import android.renderscript.*; -import android.renderscript.ProgramRaster; -import android.renderscript.ProgramRaster.CullMode; - -public class UT_program_raster extends UnitTest { - private Resources mRes; - - ProgramRaster pointSpriteEnabled; - ProgramRaster cullMode; - - protected UT_program_raster(RSTestCore rstc, Resources res, Context ctx) { - super(rstc, "ProgramRaster", ctx); - mRes = res; - } - - private ProgramRaster.Builder getDefaultBuilder(RenderScript RS) { - ProgramRaster.Builder b = new ProgramRaster.Builder(RS); - b.setCullMode(CullMode.BACK); - b.setPointSpriteEnabled(false); - return b; - } - - private void initializeGlobals(RenderScript RS, ScriptC_program_raster s) { - ProgramRaster.Builder b = getDefaultBuilder(RS); - pointSpriteEnabled = b.setPointSpriteEnabled(true).create(); - b = getDefaultBuilder(RS); - cullMode = b.setCullMode(CullMode.FRONT).create(); - - s.set_pointSpriteEnabled(pointSpriteEnabled); - s.set_cullMode(cullMode); - } - - private void testScriptSide(RenderScript pRS) { - ScriptC_program_raster s = new ScriptC_program_raster(pRS); - pRS.setMessageHandler(mRsMessage); - initializeGlobals(pRS, s); - s.invoke_program_raster_test(); - pRS.finish(); - waitForMessage(); - } - - private void testJavaSide(RenderScript RS) { - _RS_ASSERT("pointSpriteEnabled.isPointSpriteEnabled() == true", - pointSpriteEnabled.isPointSpriteEnabled() == true); - _RS_ASSERT("pointSpriteEnabled.getCullMode() == ProgramRaster.CullMode.BACK", - pointSpriteEnabled.getCullMode() == ProgramRaster.CullMode.BACK); - - _RS_ASSERT("cullMode.isPointSpriteEnabled() == false", - cullMode.isPointSpriteEnabled() == false); - _RS_ASSERT("cullMode.getCullMode() == ProgramRaster.CullMode.FRONT", - cullMode.getCullMode() == ProgramRaster.CullMode.FRONT); - } - - public void run() { - RenderScript pRS = RenderScript.create(mCtx); - testScriptSide(pRS); - testJavaSide(pRS); - passTest(); - pRS.destroy(); - } -} diff --git a/java/tests/RsTest/src/com/android/rs/test/UT_program_store.java b/java/tests/RsTest/src/com/android/rs/test/UT_program_store.java deleted file mode 100644 index 6510b6bb..00000000 --- a/java/tests/RsTest/src/com/android/rs/test/UT_program_store.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.rs.test; - -import android.content.Context; -import android.content.res.Resources; -import android.renderscript.*; -import android.renderscript.ProgramStore.BlendDstFunc; -import android.renderscript.ProgramStore.BlendSrcFunc; -import android.renderscript.ProgramStore.Builder; -import android.renderscript.ProgramStore.DepthFunc; - -public class UT_program_store extends UnitTest { - private Resources mRes; - - ProgramStore ditherEnable; - ProgramStore colorRWriteEnable; - ProgramStore colorGWriteEnable; - ProgramStore colorBWriteEnable; - ProgramStore colorAWriteEnable; - ProgramStore blendSrc; - ProgramStore blendDst; - ProgramStore depthWriteEnable; - ProgramStore depthFunc; - - protected UT_program_store(RSTestCore rstc, Resources res, Context ctx) { - super(rstc, "ProgramStore", ctx); - mRes = res; - } - - private ProgramStore.Builder getDefaultBuilder(RenderScript RS) { - ProgramStore.Builder b = new ProgramStore.Builder(RS); - b.setBlendFunc(ProgramStore.BlendSrcFunc.ZERO, ProgramStore.BlendDstFunc.ZERO); - b.setColorMaskEnabled(false, false, false, false); - b.setDepthFunc(ProgramStore.DepthFunc.ALWAYS); - b.setDepthMaskEnabled(false); - b.setDitherEnabled(false); - return b; - } - - private void initializeGlobals(RenderScript RS, ScriptC_program_store s) { - ProgramStore.Builder b = getDefaultBuilder(RS); - ditherEnable = b.setDitherEnabled(true).create(); - - b = getDefaultBuilder(RS); - colorRWriteEnable = b.setColorMaskEnabled(true, false, false, false).create(); - - b = getDefaultBuilder(RS); - colorGWriteEnable = b.setColorMaskEnabled(false, true, false, false).create(); - - b = getDefaultBuilder(RS); - colorBWriteEnable = b.setColorMaskEnabled(false, false, true, false).create(); - - b = getDefaultBuilder(RS); - colorAWriteEnable = b.setColorMaskEnabled(false, false, false, true).create(); - - b = getDefaultBuilder(RS); - blendSrc = b.setBlendFunc(ProgramStore.BlendSrcFunc.DST_COLOR, - ProgramStore.BlendDstFunc.ZERO).create(); - - b = getDefaultBuilder(RS); - blendDst = b.setBlendFunc(ProgramStore.BlendSrcFunc.ZERO, - ProgramStore.BlendDstFunc.DST_ALPHA).create(); - - b = getDefaultBuilder(RS); - depthWriteEnable = b.setDepthMaskEnabled(true).create(); - - b = getDefaultBuilder(RS); - depthFunc = b.setDepthFunc(ProgramStore.DepthFunc.GREATER).create(); - - s.set_ditherEnable(ditherEnable); - s.set_colorRWriteEnable(colorRWriteEnable); - s.set_colorGWriteEnable(colorGWriteEnable); - s.set_colorBWriteEnable(colorBWriteEnable); - s.set_colorAWriteEnable(colorAWriteEnable); - s.set_blendSrc(blendSrc); - s.set_blendDst(blendDst); - s.set_depthWriteEnable(depthWriteEnable); - s.set_depthFunc(depthFunc); - } - - private void testScriptSide(RenderScript pRS) { - ScriptC_program_store s = new ScriptC_program_store(pRS); - pRS.setMessageHandler(mRsMessage); - initializeGlobals(pRS, s); - s.invoke_program_store_test(); - pRS.finish(); - waitForMessage(); - } - - void checkObject(ProgramStore ps, - boolean depthMask, - DepthFunc df, - BlendSrcFunc bsf, - BlendDstFunc bdf, - boolean R, - boolean G, - boolean B, - boolean A, - boolean dither) { - _RS_ASSERT("ps.isDepthMaskEnabled() == depthMask", ps.isDepthMaskEnabled() == depthMask); - _RS_ASSERT("ps.getDepthFunc() == df", ps.getDepthFunc() == df); - _RS_ASSERT("ps.getBlendSrcFunc() == bsf", ps.getBlendSrcFunc() == bsf); - _RS_ASSERT("ps.getBlendDstFunc() == bdf", ps.getBlendDstFunc() == bdf); - _RS_ASSERT("ps.isColorMaskRedEnabled() == R", ps.isColorMaskRedEnabled() == R); - _RS_ASSERT("ps.isColorMaskGreenEnabled() == G", ps.isColorMaskGreenEnabled() == G); - _RS_ASSERT("ps.isColorMaskBlueEnabled () == B", ps.isColorMaskBlueEnabled () == B); - _RS_ASSERT("ps.isColorMaskAlphaEnabled() == A", ps.isColorMaskAlphaEnabled() == A); - _RS_ASSERT("ps.isDitherEnabled() == dither", ps.isDitherEnabled() == dither); - } - - void varyBuilderColorAndDither(ProgramStore.Builder pb, - boolean depthMask, - DepthFunc df, - BlendSrcFunc bsf, - BlendDstFunc bdf) { - for (int r = 0; r <= 1; r++) { - boolean isR = (r == 1); - for (int g = 0; g <= 1; g++) { - boolean isG = (g == 1); - for (int b = 0; b <= 1; b++) { - boolean isB = (b == 1); - for (int a = 0; a <= 1; a++) { - boolean isA = (a == 1); - for (int dither = 0; dither <= 1; dither++) { - boolean isDither = (dither == 1); - pb.setDitherEnabled(isDither); - pb.setColorMaskEnabled(isR, isG, isB, isA); - ProgramStore ps = pb.create(); - checkObject(ps, depthMask, df, bsf, bdf, isR, isG, isB, isA, isDither); - } - } - } - } - } - } - - public void testJavaSide(RenderScript RS) { - for (int depth = 0; depth <= 1; depth++) { - boolean depthMask = (depth == 1); - for (DepthFunc df : DepthFunc.values()) { - for (BlendSrcFunc bsf : BlendSrcFunc.values()) { - for (BlendDstFunc bdf : BlendDstFunc.values()) { - ProgramStore.Builder b = new ProgramStore.Builder(RS); - b.setDepthFunc(df); - b.setDepthMaskEnabled(depthMask); - b.setBlendFunc(bsf, bdf); - varyBuilderColorAndDither(b, depthMask, df, bsf, bdf); - } - } - } - } - } - - public void run() { - RenderScript pRS = RenderScript.create(mCtx); - testJavaSide(pRS); - testScriptSide(pRS); - pRS.destroy(); - } -} diff --git a/java/tests/RsTest/src/com/android/rs/test/UT_sampler.java b/java/tests/RsTest/src/com/android/rs/test/UT_sampler.java index 00c850c5..c2e570f0 100644 --- a/java/tests/RsTest/src/com/android/rs/test/UT_sampler.java +++ b/java/tests/RsTest/src/com/android/rs/test/UT_sampler.java @@ -19,8 +19,6 @@ package com.android.rs.test; import android.content.Context; import android.content.res.Resources; import android.renderscript.*; -import android.renderscript.Sampler; -import android.renderscript.Sampler.Value; public class UT_sampler extends UnitTest { private Resources mRes; @@ -38,29 +36,29 @@ public class UT_sampler extends UnitTest { private Sampler.Builder getDefaultBuilder(RenderScript RS) { Sampler.Builder b = new Sampler.Builder(RS); - b.setMinification(Value.NEAREST); - b.setMagnification(Value.NEAREST); - b.setWrapS(Value.CLAMP); - b.setWrapT(Value.CLAMP); + b.setMinification(Sampler.Value.NEAREST); + b.setMagnification(Sampler.Value.NEAREST); + b.setWrapS(Sampler.Value.CLAMP); + b.setWrapT(Sampler.Value.CLAMP); b.setAnisotropy(1.0f); return b; } private void initializeGlobals(RenderScript RS, ScriptC_sampler s) { Sampler.Builder b = getDefaultBuilder(RS); - b.setMinification(Value.LINEAR_MIP_LINEAR); + b.setMinification(Sampler.Value.LINEAR_MIP_LINEAR); minification = b.create(); b = getDefaultBuilder(RS); - b.setMagnification(Value.LINEAR); + b.setMagnification(Sampler.Value.LINEAR); magnification = b.create(); b = getDefaultBuilder(RS); - b.setWrapS(Value.WRAP); + b.setWrapS(Sampler.Value.WRAP); wrapS = b.create(); b = getDefaultBuilder(RS); - b.setWrapT(Value.WRAP); + b.setWrapT(Sampler.Value.WRAP); wrapT = b.create(); b = getDefaultBuilder(RS); diff --git a/java/tests/RsTest/src/com/android/rs/test/UnitTest.java b/java/tests/RsTest/src/com/android/rs/test/UnitTest.java index fbac124b..064ab48d 100644 --- a/java/tests/RsTest/src/com/android/rs/test/UnitTest.java +++ b/java/tests/RsTest/src/com/android/rs/test/UnitTest.java @@ -120,6 +120,17 @@ public class UnitTest extends Thread { updateUI(); } + public String toString() { + String out = name; + if (result == 1) { + out += " - PASSED"; + } + else if (result == -1) { + out += " - FAILED"; + } + return out; + } + public void setItem(ScriptField_ListAllocs_s.Item item) { mItem = item; } diff --git a/java/tests/RsTest/src/com/android/rs/test/mesh.rs b/java/tests/RsTest/src/com/android/rs/test/mesh.rs deleted file mode 100644 index 1354897a..00000000 --- a/java/tests/RsTest/src/com/android/rs/test/mesh.rs +++ /dev/null @@ -1,64 +0,0 @@ -#include "shared.rsh" -#include "rs_graphics.rsh" - -rs_mesh mesh; -rs_allocation vertexAlloc0; -rs_allocation vertexAlloc1; - -rs_allocation indexAlloc0; -rs_allocation indexAlloc2; - -static bool test_mesh_getters() { - bool failed = false; - - _RS_ASSERT(rsgMeshGetVertexAllocationCount(mesh) == 2); - _RS_ASSERT(rsgMeshGetPrimitiveCount(mesh) == 3); - - rs_allocation meshV0 = rsgMeshGetVertexAllocation(mesh, 0); - rs_allocation meshV1 = rsgMeshGetVertexAllocation(mesh, 1); - rs_allocation meshV2 = rsgMeshGetVertexAllocation(mesh, 2); - _RS_ASSERT(meshV0.p == vertexAlloc0.p); - _RS_ASSERT(meshV1.p == vertexAlloc1.p); - _RS_ASSERT(!rsIsObject(meshV2)); - - rs_allocation meshI0 = rsgMeshGetIndexAllocation(mesh, 0); - rs_allocation meshI1 = rsgMeshGetIndexAllocation(mesh, 1); - rs_allocation meshI2 = rsgMeshGetIndexAllocation(mesh, 2); - rs_allocation meshI3 = rsgMeshGetIndexAllocation(mesh, 3); - _RS_ASSERT(meshI0.p == indexAlloc0.p); - _RS_ASSERT(!rsIsObject(meshI1)); - _RS_ASSERT(meshI2.p == indexAlloc2.p); - _RS_ASSERT(!rsIsObject(meshI3)); - - rs_primitive p0 = rsgMeshGetPrimitive(mesh, 0); - rs_primitive p1 = rsgMeshGetPrimitive(mesh, 1); - rs_primitive p2 = rsgMeshGetPrimitive(mesh, 2); - rs_primitive p3 = rsgMeshGetPrimitive(mesh, 3); - - _RS_ASSERT(p0 == RS_PRIMITIVE_POINT); - _RS_ASSERT(p1 == RS_PRIMITIVE_LINE); - _RS_ASSERT(p2 == RS_PRIMITIVE_TRIANGLE); - _RS_ASSERT(p3 == RS_PRIMITIVE_INVALID); - - if (failed) { - rsDebug("test_mesh_getters FAILED", 0); - } - else { - rsDebug("test_mesh_getters PASSED", 0); - } - - return failed; -} - -void mesh_test() { - bool failed = false; - failed |= test_mesh_getters(); - - if (failed) { - rsSendToClientBlocking(RS_MSG_TEST_FAILED); - } - else { - rsSendToClientBlocking(RS_MSG_TEST_PASSED); - } -} - diff --git a/java/tests/RsTest/src/com/android/rs/test/program_raster.rs b/java/tests/RsTest/src/com/android/rs/test/program_raster.rs deleted file mode 100644 index 3d6b5027..00000000 --- a/java/tests/RsTest/src/com/android/rs/test/program_raster.rs +++ /dev/null @@ -1,37 +0,0 @@ -#include "shared.rsh" -#include "rs_graphics.rsh" - -rs_program_raster pointSpriteEnabled; -rs_program_raster cullMode; - -static bool test_program_raster_getters() { - bool failed = false; - - _RS_ASSERT(rsgProgramRasterIsPointSpriteEnabled(pointSpriteEnabled) == true); - _RS_ASSERT(rsgProgramRasterGetCullMode(pointSpriteEnabled) == RS_CULL_BACK); - - _RS_ASSERT(rsgProgramRasterIsPointSpriteEnabled(cullMode) == false); - _RS_ASSERT(rsgProgramRasterGetCullMode(cullMode) == RS_CULL_FRONT); - - if (failed) { - rsDebug("test_program_raster_getters FAILED", 0); - } - else { - rsDebug("test_program_raster_getters PASSED", 0); - } - - return failed; -} - -void program_raster_test() { - bool failed = false; - failed |= test_program_raster_getters(); - - if (failed) { - rsSendToClientBlocking(RS_MSG_TEST_FAILED); - } - else { - rsSendToClientBlocking(RS_MSG_TEST_PASSED); - } -} - diff --git a/java/tests/RsTest/src/com/android/rs/test/program_store.rs b/java/tests/RsTest/src/com/android/rs/test/program_store.rs deleted file mode 100644 index 2ae5636f..00000000 --- a/java/tests/RsTest/src/com/android/rs/test/program_store.rs +++ /dev/null @@ -1,128 +0,0 @@ -#include "shared.rsh" -#include "rs_graphics.rsh" - -rs_program_store ditherEnable; -rs_program_store colorRWriteEnable; -rs_program_store colorGWriteEnable; -rs_program_store colorBWriteEnable; -rs_program_store colorAWriteEnable; -rs_program_store blendSrc; -rs_program_store blendDst; -rs_program_store depthWriteEnable; -rs_program_store depthFunc; - -static bool test_program_store_getters() { - bool failed = false; - - _RS_ASSERT(rsgProgramStoreGetDepthFunc(depthFunc) == RS_DEPTH_FUNC_GREATER); - _RS_ASSERT(rsgProgramStoreIsDepthMaskEnabled(depthFunc) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskRedEnabled(depthFunc) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskGreenEnabled(depthFunc) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskBlueEnabled(depthFunc) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskAlphaEnabled( depthFunc) == false); - _RS_ASSERT(rsgProgramStoreIsDitherEnabled(depthFunc) == false); - _RS_ASSERT(rsgProgramStoreGetBlendSrcFunc(depthFunc) == RS_BLEND_SRC_ZERO); - _RS_ASSERT(rsgProgramStoreGetBlendDstFunc(depthFunc) == RS_BLEND_DST_ZERO); - - _RS_ASSERT(rsgProgramStoreGetDepthFunc(depthWriteEnable) == RS_DEPTH_FUNC_ALWAYS); - _RS_ASSERT(rsgProgramStoreIsDepthMaskEnabled(depthWriteEnable) == true); - _RS_ASSERT(rsgProgramStoreIsColorMaskRedEnabled(depthWriteEnable) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskGreenEnabled(depthWriteEnable) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskBlueEnabled(depthWriteEnable) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskAlphaEnabled( depthWriteEnable) == false); - _RS_ASSERT(rsgProgramStoreIsDitherEnabled(depthWriteEnable) == false); - _RS_ASSERT(rsgProgramStoreGetBlendSrcFunc(depthWriteEnable) == RS_BLEND_SRC_ZERO); - _RS_ASSERT(rsgProgramStoreGetBlendDstFunc(depthWriteEnable) == RS_BLEND_DST_ZERO); - - _RS_ASSERT(rsgProgramStoreGetDepthFunc(colorRWriteEnable) == RS_DEPTH_FUNC_ALWAYS); - _RS_ASSERT(rsgProgramStoreIsDepthMaskEnabled(colorRWriteEnable) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskRedEnabled(colorRWriteEnable) == true); - _RS_ASSERT(rsgProgramStoreIsColorMaskGreenEnabled(colorRWriteEnable) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskBlueEnabled(colorRWriteEnable) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskAlphaEnabled( colorRWriteEnable) == false); - _RS_ASSERT(rsgProgramStoreIsDitherEnabled(colorRWriteEnable) == false); - _RS_ASSERT(rsgProgramStoreGetBlendSrcFunc(colorRWriteEnable) == RS_BLEND_SRC_ZERO); - _RS_ASSERT(rsgProgramStoreGetBlendDstFunc(colorRWriteEnable) == RS_BLEND_DST_ZERO); - - _RS_ASSERT(rsgProgramStoreGetDepthFunc(colorGWriteEnable) == RS_DEPTH_FUNC_ALWAYS); - _RS_ASSERT(rsgProgramStoreIsDepthMaskEnabled(colorGWriteEnable) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskRedEnabled(colorGWriteEnable) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskGreenEnabled(colorGWriteEnable) == true); - _RS_ASSERT(rsgProgramStoreIsColorMaskBlueEnabled(colorGWriteEnable) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskAlphaEnabled( colorGWriteEnable) == false); - _RS_ASSERT(rsgProgramStoreIsDitherEnabled(colorGWriteEnable) == false); - _RS_ASSERT(rsgProgramStoreGetBlendSrcFunc(colorGWriteEnable) == RS_BLEND_SRC_ZERO); - _RS_ASSERT(rsgProgramStoreGetBlendDstFunc(colorGWriteEnable) == RS_BLEND_DST_ZERO); - - _RS_ASSERT(rsgProgramStoreGetDepthFunc(colorBWriteEnable) == RS_DEPTH_FUNC_ALWAYS); - _RS_ASSERT(rsgProgramStoreIsDepthMaskEnabled(colorBWriteEnable) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskRedEnabled(colorBWriteEnable) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskGreenEnabled(colorBWriteEnable) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskBlueEnabled(colorBWriteEnable) == true); - _RS_ASSERT(rsgProgramStoreIsColorMaskAlphaEnabled( colorBWriteEnable) == false); - _RS_ASSERT(rsgProgramStoreIsDitherEnabled(colorBWriteEnable) == false); - _RS_ASSERT(rsgProgramStoreGetBlendSrcFunc(colorBWriteEnable) == RS_BLEND_SRC_ZERO); - _RS_ASSERT(rsgProgramStoreGetBlendDstFunc(colorBWriteEnable) == RS_BLEND_DST_ZERO); - - _RS_ASSERT(rsgProgramStoreGetDepthFunc(colorAWriteEnable) == RS_DEPTH_FUNC_ALWAYS); - _RS_ASSERT(rsgProgramStoreIsDepthMaskEnabled(colorAWriteEnable) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskRedEnabled(colorAWriteEnable) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskGreenEnabled(colorAWriteEnable) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskBlueEnabled(colorAWriteEnable) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskAlphaEnabled( colorAWriteEnable) == true); - _RS_ASSERT(rsgProgramStoreIsDitherEnabled(colorAWriteEnable) == false); - _RS_ASSERT(rsgProgramStoreGetBlendSrcFunc(colorAWriteEnable) == RS_BLEND_SRC_ZERO); - _RS_ASSERT(rsgProgramStoreGetBlendDstFunc(colorAWriteEnable) == RS_BLEND_DST_ZERO); - - _RS_ASSERT(rsgProgramStoreGetDepthFunc(ditherEnable) == RS_DEPTH_FUNC_ALWAYS); - _RS_ASSERT(rsgProgramStoreIsDepthMaskEnabled(ditherEnable) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskRedEnabled(ditherEnable) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskGreenEnabled(ditherEnable) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskBlueEnabled(ditherEnable) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskAlphaEnabled( ditherEnable) == false); - _RS_ASSERT(rsgProgramStoreIsDitherEnabled(ditherEnable) == true); - _RS_ASSERT(rsgProgramStoreGetBlendSrcFunc(ditherEnable) == RS_BLEND_SRC_ZERO); - _RS_ASSERT(rsgProgramStoreGetBlendDstFunc(ditherEnable) == RS_BLEND_DST_ZERO); - - _RS_ASSERT(rsgProgramStoreGetDepthFunc(blendSrc) == RS_DEPTH_FUNC_ALWAYS); - _RS_ASSERT(rsgProgramStoreIsDepthMaskEnabled(blendSrc) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskRedEnabled(blendSrc) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskGreenEnabled(blendSrc) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskBlueEnabled(blendSrc) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskAlphaEnabled( blendSrc) == false); - _RS_ASSERT(rsgProgramStoreIsDitherEnabled(blendSrc) == false); - _RS_ASSERT(rsgProgramStoreGetBlendSrcFunc(blendSrc) == RS_BLEND_SRC_DST_COLOR); - _RS_ASSERT(rsgProgramStoreGetBlendDstFunc(blendSrc) == RS_BLEND_DST_ZERO); - - _RS_ASSERT(rsgProgramStoreGetDepthFunc(blendDst) == RS_DEPTH_FUNC_ALWAYS); - _RS_ASSERT(rsgProgramStoreIsDepthMaskEnabled(blendDst) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskRedEnabled(blendDst) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskGreenEnabled(blendDst) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskBlueEnabled(blendDst) == false); - _RS_ASSERT(rsgProgramStoreIsColorMaskAlphaEnabled( blendDst) == false); - _RS_ASSERT(rsgProgramStoreIsDitherEnabled(blendDst) == false); - _RS_ASSERT(rsgProgramStoreGetBlendSrcFunc(blendDst) == RS_BLEND_SRC_ZERO); - _RS_ASSERT(rsgProgramStoreGetBlendDstFunc(blendDst) == RS_BLEND_DST_DST_ALPHA); - - if (failed) { - rsDebug("test_program_store_getters FAILED", 0); - } - else { - rsDebug("test_program_store_getters PASSED", 0); - } - - return failed; -} - -void program_store_test() { - bool failed = false; - failed |= test_program_store_getters(); - - if (failed) { - rsSendToClientBlocking(RS_MSG_TEST_FAILED); - } - else { - rsSendToClientBlocking(RS_MSG_TEST_PASSED); - } -} - diff --git a/java/tests/RsTest/src/com/android/rs/test/rslist.rs b/java/tests/RsTest/src/com/android/rs/test/rslist.rs index d8663fb5..877e0397 100644 --- a/java/tests/RsTest/src/com/android/rs/test/rslist.rs +++ b/java/tests/RsTest/src/com/android/rs/test/rslist.rs @@ -16,12 +16,6 @@ #pragma rs java_package_name(com.android.rs.test) -#include "rs_graphics.rsh" - -float gDY; - -rs_font gFont; - typedef struct ListAllocs_s { rs_allocation text; int result; @@ -29,79 +23,3 @@ typedef struct ListAllocs_s { ListAllocs *gList; -void init() { - gDY = 0.0f; -} - -int textPos = 0; - -int root(void) { - - rsgClearColor(0.0f, 0.0f, 0.0f, 0.0f); - rsgClearDepth(1.0f); - - textPos -= (int)gDY*2; - gDY *= 0.95; - - rsgFontColor(0.9f, 0.9f, 0.9f, 1.0f); - rsgBindFont(gFont); - - rs_allocation listAlloc; - listAlloc = rsGetAllocation(gList); - int allocSize = rsAllocationGetDimX(listAlloc); - - int width = rsgGetWidth(); - int height = rsgGetHeight(); - - int itemHeight = 80; - int totalItemHeight = itemHeight * allocSize; - - /* Prevent scrolling above the top of the list */ - int firstItem = height - totalItemHeight; - if (firstItem < 0) { - firstItem = 0; - } - - /* Prevent scrolling past the last line of the list */ - int lastItem = -1 * (totalItemHeight - height); - if (lastItem > 0) { - lastItem = 0; - } - - if (textPos > firstItem) { - textPos = firstItem; - } - else if (textPos < lastItem) { - textPos = lastItem; - } - - int currentYPos = itemHeight + textPos; - - for(int i = 0; i < allocSize; i ++) { - if(currentYPos - itemHeight > height) { - break; - } - - if(currentYPos > 0) { - switch(gList[i].result) { - case 1: /* Passed */ - rsgFontColor(0.5f, 0.9f, 0.5f, 1.0f); - break; - case -1: /* Failed */ - rsgFontColor(0.9f, 0.5f, 0.5f, 1.0f); - break; - case 0: /* Still Testing */ - rsgFontColor(0.9f, 0.9f, 0.5f, 1.0f); - break; - default: /* Unknown */ - rsgFontColor(0.9f, 0.9f, 0.9f, 1.0f); - break; - } - rsgDrawRect(0, currentYPos - 1, width, currentYPos, 0); - rsgDrawText(gList[i].text, 30, currentYPos - 32); - } - currentYPos += itemHeight; - } - - return 10; -} diff --git a/java/tests/RsTest/src/com/android/rs/test/rstypes.rs b/java/tests/RsTest/src/com/android/rs/test/rstypes.rs index 22d9c138..bec124dd 100644 --- a/java/tests/RsTest/src/com/android/rs/test/rstypes.rs +++ b/java/tests/RsTest/src/com/android/rs/test/rstypes.rs @@ -6,12 +6,6 @@ rs_type typeTest; rs_allocation allocationTest; rs_sampler samplerTest; rs_script scriptTest; -rs_mesh meshTest; -rs_program_fragment program_fragmentTest; -rs_program_vertex program_vertexTest; -rs_program_raster program_rasterTest; -rs_program_store program_storeTest; -rs_font fontTest; rs_matrix4x4 matrix4x4Test; rs_matrix3x3 matrix3x3Test; @@ -19,7 +13,7 @@ rs_matrix2x2 matrix2x2Test; struct my_struct { int i; - rs_font fontTestStruct; + rs_allocation banana; }; static bool basic_test(uint32_t index) { @@ -35,23 +29,11 @@ static bool basic_test(uint32_t index) { rs_allocation allocationTestLocal; rs_sampler samplerTestLocal; rs_script scriptTestLocal; - rs_mesh meshTestLocal; - rs_program_fragment program_fragmentTestLocal; - rs_program_vertex program_vertexTestLocal; - rs_program_raster program_rasterTestLocal; - rs_program_store program_storeTestLocal; - rs_font fontTestLocal; - - rs_font fontTestLocalArray[4]; - - rs_font fontTestLocalPreInit = fontTest; struct my_struct structTest; - fontTestLocal = fontTest; //allocationTestLocal = allocationTest; - fontTest = fontTestLocal; //allocationTest = allocationTestLocal; /*for (int i = 0; i < 4; i++) { |