summaryrefslogtreecommitdiffstats
path: root/tests/RenderScriptTests
diff options
context:
space:
mode:
authorJason Sams <jsams@google.com>2013-02-22 12:45:54 -0800
committerJason Sams <jsams@google.com>2013-02-22 12:45:54 -0800
commit72226e0543461133b9e177a3e78ae50b0c65e797 (patch)
tree6d86fb635d269961fd5ee1684187c0360b473164 /tests/RenderScriptTests
parentec6156f9e884ba85c76a9c4683f83f18b3f64afa (diff)
downloadframeworks_base-72226e0543461133b9e177a3e78ae50b0c65e797.zip
frameworks_base-72226e0543461133b9e177a3e78ae50b0c65e797.tar.gz
frameworks_base-72226e0543461133b9e177a3e78ae50b0c65e797.tar.bz2
Implement USAGE_IO_INPUT
Change-Id: Id5b9e3d0a17e4df15eec36d542fde6dc626138b2
Diffstat (limited to 'tests/RenderScriptTests')
-rw-r--r--tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java6
-rw-r--r--tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/UsageIO.java66
2 files changed, 71 insertions, 1 deletions
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
index 0a78908..d2139ea 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
@@ -97,7 +97,8 @@ public class ImageProcessingActivity extends Activity
EXPOSURE ("Exposure"),
WHITE_BALANCE ("White Balance"),
COLOR_CUBE ("Color Cube"),
- COLOR_CUBE_3D_INTRINSIC ("Color Cube (3D LUT intrinsic)");
+ COLOR_CUBE_3D_INTRINSIC ("Color Cube (3D LUT intrinsic)"),
+ USAGE_IO ("Usage io)");
private final String name;
@@ -352,6 +353,9 @@ public class ImageProcessingActivity extends Activity
case COLOR_CUBE_3D_INTRINSIC:
mTest = new ColorCube(true);
break;
+ case USAGE_IO:
+ mTest = new UsageIO();
+ break;
}
mTest.createBaseTest(this, mBitmapIn, mBitmapIn2, mBitmapOut);
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/UsageIO.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/UsageIO.java
new file mode 100644
index 0000000..3f86311
--- /dev/null
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/UsageIO.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2013 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.image;
+
+import java.lang.Math;
+
+import android.view.Surface;
+import android.renderscript.Allocation;
+import android.renderscript.Element;
+import android.renderscript.RenderScript;
+import android.renderscript.ScriptIntrinsicConvolve3x3;
+import android.renderscript.ScriptIntrinsicColorMatrix;
+import android.renderscript.Type;
+import android.renderscript.Matrix4f;
+import android.renderscript.ScriptGroup;
+import android.util.Log;
+
+public class UsageIO extends TestBase {
+ private ScriptIntrinsicColorMatrix mMatrix;
+
+ private Allocation mScratchPixelsAllocation1;
+ private Allocation mScratchPixelsAllocation2;
+
+ public UsageIO() {
+ }
+
+ public void createTest(android.content.res.Resources res) {
+ mMatrix = ScriptIntrinsicColorMatrix.create(mRS, Element.U8_4(mRS));
+
+ Matrix4f m = new Matrix4f();
+ m.set(1, 0, 0.2f);
+ m.set(1, 1, 0.9f);
+ m.set(1, 2, 0.2f);
+ mMatrix.setColorMatrix(m);
+
+ Type connect = mInPixelsAllocation.getType();
+
+ mScratchPixelsAllocation1 = Allocation.createTyped(mRS, connect, Allocation.USAGE_IO_OUTPUT | Allocation.USAGE_SCRIPT);
+ mScratchPixelsAllocation2 = Allocation.createTyped(mRS, connect, Allocation.USAGE_IO_INPUT | Allocation.USAGE_SCRIPT);
+
+ Surface s = mScratchPixelsAllocation2.getSurface();
+ mScratchPixelsAllocation1.setSurface(s);
+ }
+
+ public void runTest() {
+ mScratchPixelsAllocation1.copyFrom(mInPixelsAllocation);
+ mScratchPixelsAllocation1.ioSend();
+ mScratchPixelsAllocation2.ioReceive();
+ mMatrix.forEach(mScratchPixelsAllocation2, mOutPixelsAllocation);
+ }
+
+}