Loading tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java +41 −3 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ package com.android.rs.image; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.graphics.BitmapFactory; import android.graphics.Bitmap; import android.graphics.Canvas; Loading Loading @@ -82,12 +84,38 @@ public class ImageProcessingActivity extends Activity private boolean mDoingBenchmark; private TestBase mTest; private int mRunCount; public void updateDisplay() { mHandler.sendMessage(Message.obtain()); } private Handler mHandler = new Handler() { // Allow the filter to complete without blocking the UI // thread. When the message arrives that the op is complete // we will either mark completion or start a new filter if // more work is ready. Either way, display the result. @Override public void handleMessage(Message msg) { mTest.updateBitmap(mBitmapOut); mDisplayView.invalidate(); boolean doTest = false; synchronized(this) { if (mRunCount > 0) { mRunCount--; if (mRunCount > 0) { doTest = true; } } } if (doTest) { mTest.runTestSendMessage(); } } }; public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { Loading @@ -103,8 +131,18 @@ public class ImageProcessingActivity extends Activity mTest.onBar5Changed(progress); } mTest.runTest(); updateDisplay(); boolean doTest = false; synchronized(this) { if (mRunCount == 0) { doTest = true; mRunCount = 1; } else { mRunCount = 2; } } if (doTest) { mTest.runTestSendMessage(); } } } Loading tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/TestBase.java +20 −0 Original line number Diff line number Diff line Loading @@ -45,9 +45,22 @@ public class TestBase { protected Allocation mInPixelsAllocation; protected Allocation mInPixelsAllocation2; protected Allocation mOutPixelsAllocation; protected ScriptC_msg mMessageScript; protected ImageProcessingActivity act; private class MessageProcessor extends RenderScript.RSMessageHandler { ImageProcessingActivity mAct; MessageProcessor(ImageProcessingActivity act) { mAct = act; } public void run() { mAct.updateDisplay(); } } // Override to use UI elements public void onBar1Changed(int progress) { } Loading Loading @@ -96,6 +109,8 @@ public class TestBase { public final void createBaseTest(ImageProcessingActivity ipact, Bitmap b, Bitmap b2) { act = ipact; mRS = RenderScript.create(act); mRS.setMessageHandler(new MessageProcessor(act)); mMessageScript = new ScriptC_msg(mRS); mInPixelsAllocation = Allocation.createFromBitmap(mRS, b, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT); Loading @@ -117,6 +132,11 @@ public class TestBase { public void runTest() { } final public void runTestSendMessage() { runTest(); mMessageScript.invoke_sendMsg(); } public void finish() { mRS.finish(); } Loading tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/msg.rs 0 → 100644 +23 −0 Original line number Diff line number Diff line /* * Copyright (C) 2012 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. */ #pragma version(1) #pragma rs java_package_name(com.android.rs.image) void sendMsg() { rsSendToClientBlocking(0); } Loading
tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java +41 −3 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ package com.android.rs.image; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.graphics.BitmapFactory; import android.graphics.Bitmap; import android.graphics.Canvas; Loading Loading @@ -82,12 +84,38 @@ public class ImageProcessingActivity extends Activity private boolean mDoingBenchmark; private TestBase mTest; private int mRunCount; public void updateDisplay() { mHandler.sendMessage(Message.obtain()); } private Handler mHandler = new Handler() { // Allow the filter to complete without blocking the UI // thread. When the message arrives that the op is complete // we will either mark completion or start a new filter if // more work is ready. Either way, display the result. @Override public void handleMessage(Message msg) { mTest.updateBitmap(mBitmapOut); mDisplayView.invalidate(); boolean doTest = false; synchronized(this) { if (mRunCount > 0) { mRunCount--; if (mRunCount > 0) { doTest = true; } } } if (doTest) { mTest.runTestSendMessage(); } } }; public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { Loading @@ -103,8 +131,18 @@ public class ImageProcessingActivity extends Activity mTest.onBar5Changed(progress); } mTest.runTest(); updateDisplay(); boolean doTest = false; synchronized(this) { if (mRunCount == 0) { doTest = true; mRunCount = 1; } else { mRunCount = 2; } } if (doTest) { mTest.runTestSendMessage(); } } } Loading
tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/TestBase.java +20 −0 Original line number Diff line number Diff line Loading @@ -45,9 +45,22 @@ public class TestBase { protected Allocation mInPixelsAllocation; protected Allocation mInPixelsAllocation2; protected Allocation mOutPixelsAllocation; protected ScriptC_msg mMessageScript; protected ImageProcessingActivity act; private class MessageProcessor extends RenderScript.RSMessageHandler { ImageProcessingActivity mAct; MessageProcessor(ImageProcessingActivity act) { mAct = act; } public void run() { mAct.updateDisplay(); } } // Override to use UI elements public void onBar1Changed(int progress) { } Loading Loading @@ -96,6 +109,8 @@ public class TestBase { public final void createBaseTest(ImageProcessingActivity ipact, Bitmap b, Bitmap b2) { act = ipact; mRS = RenderScript.create(act); mRS.setMessageHandler(new MessageProcessor(act)); mMessageScript = new ScriptC_msg(mRS); mInPixelsAllocation = Allocation.createFromBitmap(mRS, b, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT); Loading @@ -117,6 +132,11 @@ public class TestBase { public void runTest() { } final public void runTestSendMessage() { runTest(); mMessageScript.invoke_sendMsg(); } public void finish() { mRS.finish(); } Loading
tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/msg.rs 0 → 100644 +23 −0 Original line number Diff line number Diff line /* * Copyright (C) 2012 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. */ #pragma version(1) #pragma rs java_package_name(com.android.rs.image) void sendMsg() { rsSendToClientBlocking(0); }