Loading libs/rs/java/Samples/src/com/android/samples/RsList.java +2 −2 Original line number Diff line number Diff line Loading @@ -54,7 +54,7 @@ public class RsList extends Activity { @Override protected void onResume() { // Ideally a game should implement onResume() and onPause() // to take appropriate action when the activity looses focus // to take appropriate action when the activity loses focus super.onResume(); mView.onResume(); } Loading @@ -62,7 +62,7 @@ public class RsList extends Activity { @Override protected void onPause() { // Ideally a game should implement onResume() and onPause() // to take appropriate action when the activity looses focus // to take appropriate action when the activity loses focus super.onPause(); mView.onPause(); } Loading libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java +73 −16 Original line number Diff line number Diff line Loading @@ -19,10 +19,13 @@ package com.android.rs.test; import android.content.res.Resources; import android.renderscript.*; import android.util.Log; import java.util.ArrayList; import java.util.ListIterator; public class RSTestCore { public static final int PART_COUNT = 50000; int mWidth; int mHeight; public RSTestCore() { } Loading @@ -30,31 +33,85 @@ public class RSTestCore { private Resources mRes; private RenderScriptGL mRS; private ScriptC_test_root mRootScript; private Font mFont; ScriptField_ListAllocs_s mListAllocs; int mLastX; int mLastY; private ScriptC_rslist mScript; private boolean fp_mad() { ScriptC_fp_mad s = new ScriptC_fp_mad(mRS, mRes, R.raw.fp_mad, true); s.invoke_doTest(0, 0); return true; } private boolean rs_primitives_test() { ScriptC_primitives s = new ScriptC_primitives(mRS, mRes, R.raw.primitives, true); s.invoke_rs_primitives_test(0, 0); return true; } private ArrayList<UnitTest> unitTests; public void init(RenderScriptGL rs, Resources res, int width, int height) { mRS = rs; mRes = res; mWidth = width; mHeight = height; mScript = new ScriptC_rslist(mRS, mRes, R.raw.rslist, true); unitTests = new ArrayList<UnitTest>(); unitTests.add(new UT_primitives(mRes)); unitTests.add(new UT_fp_mad(mRes)); /* unitTests.add(new UnitTest("<Pass>", 1)); unitTests.add(new UnitTest()); unitTests.add(new UnitTest("<Fail>", -1)); */ mRootScript = new ScriptC_test_root(mRS, mRes, R.raw.test_root, true); UnitTest [] uta = new UnitTest[unitTests.size()]; uta = unitTests.toArray(uta); rs_primitives_test(); fp_mad(); /* Run the actual unit tests */ ListIterator<UnitTest> test_iter = unitTests.listIterator(); while (test_iter.hasNext()) { UnitTest t = test_iter.next(); t.start(); try { t.join(); } catch (InterruptedException e) { } } 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); listElem.result = uta[i].result; mListAllocs.set(listElem, i, false); } mListAllocs.copyAll(); mScript.bind_gList(mListAllocs); mFont = Font.createFromFamily(mRS, mRes, "serif", Font.Style.BOLD, 8); mScript.set_gFont(mFont); mRS.contextBindRootScript(mScript); mRS.finish(); } 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; } 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; } } libs/rs/java/tests/src/com/android/rs/test/RSTestView.java +16 −28 Original line number Diff line number Diff line Loading @@ -67,40 +67,28 @@ public class RSTestView extends RSSurfaceView { } } /* @Override public boolean onTouchEvent(MotionEvent ev) public boolean onKeyDown(int keyCode, KeyEvent event) { int act = ev.getActionMasked(); if (act == ev.ACTION_UP) { mRender.newTouchPosition(0, 0, 0, ev.getPointerId(0)); return false; } else if (act == MotionEvent.ACTION_POINTER_UP) { // only one pointer going up, we can get the index like this int pointerIndex = ev.getActionIndex(); int pointerId = ev.getPointerId(pointerIndex); mRender.newTouchPosition(0, 0, 0, pointerId); return super.onKeyDown(keyCode, event); } int count = ev.getHistorySize(); int pcount = ev.getPointerCount(); for (int p=0; p < pcount; p++) { int id = ev.getPointerId(p); mRender.newTouchPosition(ev.getX(p), ev.getY(p), ev.getPressure(p), id); for (int i=0; i < count; i++) { mRender.newTouchPosition(ev.getHistoricalX(p, i), ev.getHistoricalY(p, i), ev.getHistoricalPressure(p, i), id); @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 true; return ret; } */ } libs/rs/java/tests/src/com/android/rs/test/UT_fp_mad.java 0 → 100644 +39 −0 Original line number Diff line number Diff line /* * Copyright (C) 2010 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.res.Resources; import android.renderscript.*; public class UT_fp_mad extends UnitTest { private Resources mRes; protected UT_fp_mad(Resources res) { super("Fp_Mad"); mRes = res; } public void run() { RenderScript pRS = RenderScript.create(); ScriptC_fp_mad s = new ScriptC_fp_mad(pRS, mRes, R.raw.fp_mad, true); pRS.mMessageCallback = mRsMessage; s.invoke_fp_mad_test(0, 0); pRS.finish(); pRS.destroy(); } } libs/rs/java/tests/src/com/android/rs/test/UT_primitives.java 0 → 100644 +41 −0 Original line number Diff line number Diff line /* * Copyright (C) 2010 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.res.Resources; import android.renderscript.*; public class UT_primitives extends UnitTest { private Resources mRes; protected UT_primitives(Resources res) { super("Primitives"); mRes = res; } public void run() { RenderScript pRS = RenderScript.create(); ScriptC_primitives s = new ScriptC_primitives(pRS, mRes, R.raw.primitives, true); pRS.mMessageCallback = mRsMessage; s.invoke_primitives_test(0, 0); pRS.finish(); //android.util.Log.v("UT", "After pRS.finish"); pRS.destroy(); } } Loading
libs/rs/java/Samples/src/com/android/samples/RsList.java +2 −2 Original line number Diff line number Diff line Loading @@ -54,7 +54,7 @@ public class RsList extends Activity { @Override protected void onResume() { // Ideally a game should implement onResume() and onPause() // to take appropriate action when the activity looses focus // to take appropriate action when the activity loses focus super.onResume(); mView.onResume(); } Loading @@ -62,7 +62,7 @@ public class RsList extends Activity { @Override protected void onPause() { // Ideally a game should implement onResume() and onPause() // to take appropriate action when the activity looses focus // to take appropriate action when the activity loses focus super.onPause(); mView.onPause(); } Loading
libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java +73 −16 Original line number Diff line number Diff line Loading @@ -19,10 +19,13 @@ package com.android.rs.test; import android.content.res.Resources; import android.renderscript.*; import android.util.Log; import java.util.ArrayList; import java.util.ListIterator; public class RSTestCore { public static final int PART_COUNT = 50000; int mWidth; int mHeight; public RSTestCore() { } Loading @@ -30,31 +33,85 @@ public class RSTestCore { private Resources mRes; private RenderScriptGL mRS; private ScriptC_test_root mRootScript; private Font mFont; ScriptField_ListAllocs_s mListAllocs; int mLastX; int mLastY; private ScriptC_rslist mScript; private boolean fp_mad() { ScriptC_fp_mad s = new ScriptC_fp_mad(mRS, mRes, R.raw.fp_mad, true); s.invoke_doTest(0, 0); return true; } private boolean rs_primitives_test() { ScriptC_primitives s = new ScriptC_primitives(mRS, mRes, R.raw.primitives, true); s.invoke_rs_primitives_test(0, 0); return true; } private ArrayList<UnitTest> unitTests; public void init(RenderScriptGL rs, Resources res, int width, int height) { mRS = rs; mRes = res; mWidth = width; mHeight = height; mScript = new ScriptC_rslist(mRS, mRes, R.raw.rslist, true); unitTests = new ArrayList<UnitTest>(); unitTests.add(new UT_primitives(mRes)); unitTests.add(new UT_fp_mad(mRes)); /* unitTests.add(new UnitTest("<Pass>", 1)); unitTests.add(new UnitTest()); unitTests.add(new UnitTest("<Fail>", -1)); */ mRootScript = new ScriptC_test_root(mRS, mRes, R.raw.test_root, true); UnitTest [] uta = new UnitTest[unitTests.size()]; uta = unitTests.toArray(uta); rs_primitives_test(); fp_mad(); /* Run the actual unit tests */ ListIterator<UnitTest> test_iter = unitTests.listIterator(); while (test_iter.hasNext()) { UnitTest t = test_iter.next(); t.start(); try { t.join(); } catch (InterruptedException e) { } } 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); listElem.result = uta[i].result; mListAllocs.set(listElem, i, false); } mListAllocs.copyAll(); mScript.bind_gList(mListAllocs); mFont = Font.createFromFamily(mRS, mRes, "serif", Font.Style.BOLD, 8); mScript.set_gFont(mFont); mRS.contextBindRootScript(mScript); mRS.finish(); } 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; } 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; } }
libs/rs/java/tests/src/com/android/rs/test/RSTestView.java +16 −28 Original line number Diff line number Diff line Loading @@ -67,40 +67,28 @@ public class RSTestView extends RSSurfaceView { } } /* @Override public boolean onTouchEvent(MotionEvent ev) public boolean onKeyDown(int keyCode, KeyEvent event) { int act = ev.getActionMasked(); if (act == ev.ACTION_UP) { mRender.newTouchPosition(0, 0, 0, ev.getPointerId(0)); return false; } else if (act == MotionEvent.ACTION_POINTER_UP) { // only one pointer going up, we can get the index like this int pointerIndex = ev.getActionIndex(); int pointerId = ev.getPointerId(pointerIndex); mRender.newTouchPosition(0, 0, 0, pointerId); return super.onKeyDown(keyCode, event); } int count = ev.getHistorySize(); int pcount = ev.getPointerCount(); for (int p=0; p < pcount; p++) { int id = ev.getPointerId(p); mRender.newTouchPosition(ev.getX(p), ev.getY(p), ev.getPressure(p), id); for (int i=0; i < count; i++) { mRender.newTouchPosition(ev.getHistoricalX(p, i), ev.getHistoricalY(p, i), ev.getHistoricalPressure(p, i), id); @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 true; return ret; } */ }
libs/rs/java/tests/src/com/android/rs/test/UT_fp_mad.java 0 → 100644 +39 −0 Original line number Diff line number Diff line /* * Copyright (C) 2010 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.res.Resources; import android.renderscript.*; public class UT_fp_mad extends UnitTest { private Resources mRes; protected UT_fp_mad(Resources res) { super("Fp_Mad"); mRes = res; } public void run() { RenderScript pRS = RenderScript.create(); ScriptC_fp_mad s = new ScriptC_fp_mad(pRS, mRes, R.raw.fp_mad, true); pRS.mMessageCallback = mRsMessage; s.invoke_fp_mad_test(0, 0); pRS.finish(); pRS.destroy(); } }
libs/rs/java/tests/src/com/android/rs/test/UT_primitives.java 0 → 100644 +41 −0 Original line number Diff line number Diff line /* * Copyright (C) 2010 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.res.Resources; import android.renderscript.*; public class UT_primitives extends UnitTest { private Resources mRes; protected UT_primitives(Resources res) { super("Primitives"); mRes = res; } public void run() { RenderScript pRS = RenderScript.create(); ScriptC_primitives s = new ScriptC_primitives(pRS, mRes, R.raw.primitives, true); pRS.mMessageCallback = mRsMessage; s.invoke_primitives_test(0, 0); pRS.finish(); //android.util.Log.v("UT", "After pRS.finish"); pRS.destroy(); } }