summaryrefslogtreecommitdiffstats
path: root/tests/RenderScriptTests
diff options
context:
space:
mode:
authorJason Sams <jsams@google.com>2012-12-28 11:53:45 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-12-28 11:53:46 -0800
commit69bf687e5335db07d32fd68438ff64e18b9e9e8a (patch)
tree72373056552458e58db299a9297c3072180c3d3e /tests/RenderScriptTests
parente2d3156badd95ecb1b4f6e4b07f4e3acf2f5dffa (diff)
parentd1c306a9e66f8e541f866a6f3740959ed8cc70a6 (diff)
downloadframeworks_base-69bf687e5335db07d32fd68438ff64e18b9e9e8a.zip
frameworks_base-69bf687e5335db07d32fd68438ff64e18b9e9e8a.tar.gz
frameworks_base-69bf687e5335db07d32fd68438ff64e18b9e9e8a.tar.bz2
Merge "Add API support for 3D allocations."
Diffstat (limited to 'tests/RenderScriptTests')
-rw-r--r--tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ColorCube.java83
-rw-r--r--tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java6
-rw-r--r--tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colorcube.rs55
3 files changed, 143 insertions, 1 deletions
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ColorCube.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ColorCube.java
new file mode 100644
index 0000000..d03466d
--- /dev/null
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ColorCube.java
@@ -0,0 +1,83 @@
+/*
+ * 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.
+ */
+
+package com.android.rs.image;
+
+import java.lang.Math;
+
+import android.renderscript.Allocation;
+import android.renderscript.Element;
+import android.renderscript.Matrix4f;
+import android.renderscript.RenderScript;
+import android.renderscript.Script;
+import android.renderscript.ScriptC;
+import android.renderscript.ScriptGroup;
+import android.renderscript.ScriptIntrinsicColorMatrix;
+import android.renderscript.Type;
+import android.util.Log;
+
+public class ColorCube extends TestBase {
+ private Allocation mCube;
+ private ScriptC_colorcube mScript;
+
+ public ColorCube() {
+ }
+
+ private void initCube() {
+ final int sx = 32;
+ final int sy = 32;
+ final int sz = 16;
+
+ Type.Builder tb = new Type.Builder(mRS, Element.U8_4(mRS));
+ tb.setX(sx);
+ tb.setY(sy);
+ tb.setZ(sz);
+ Type t = tb.create();
+ mCube = Allocation.createTyped(mRS, t);
+
+ int dat[] = new int[sx * sy * sz];
+ for (int z = 0; z < sz; z++) {
+ for (int y = 0; y < sy; y++) {
+ for (int x = 0; x < sx; x++ ) {
+
+ dat[z*sy*sx + y*sx + x] = 0xff000000 |
+ ((x | (x<<2)) << 16) |
+ ((y | (y<<2)) << 8) |
+ ((z | (z<<2)) << 0);
+
+
+ }
+ }
+ }
+
+ mCube.copyFromUnchecked(dat);
+ }
+
+ public void createTest(android.content.res.Resources res) {
+ mScript = new ScriptC_colorcube(mRS, res, R.raw.colorcube);
+
+ initCube();
+ mScript.invoke_setCube(mCube);
+
+
+ //mScript.invoke_setMatrix(m);
+ }
+
+ public void runTest() {
+ mScript.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
+ }
+
+}
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 ac72688..18f438a 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
@@ -291,6 +291,9 @@ public class ImageProcessingActivity extends Activity
case 35:
mTest = new WhiteBalance();
break;
+ case 36:
+ mTest = new ColorCube();
+ break;
}
mTest.createBaseTest(this, mBitmapIn, mBitmapIn2, mBitmapOut);
@@ -302,7 +305,7 @@ public class ImageProcessingActivity extends Activity
}
void setupTests() {
- mTestNames = new String[36];
+ mTestNames = new String[37];
mTestNames[0] = "Levels Vec3 Relaxed";
mTestNames[1] = "Levels Vec4 Relaxed";
mTestNames[2] = "Levels Vec3 Full";
@@ -339,6 +342,7 @@ public class ImageProcessingActivity extends Activity
mTestNames[33] = "Contrast";
mTestNames[34] = "Exposure";
mTestNames[35] = "White Balance";
+ mTestNames[36] = "Color Cube";
mTestSpinner.setAdapter(new ArrayAdapter<String>(
this, R.layout.spinner_layout, mTestNames));
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colorcube.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colorcube.rs
new file mode 100644
index 0000000..97bb429
--- /dev/null
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colorcube.rs
@@ -0,0 +1,55 @@
+/*
+ * 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)
+#pragma rs_fp_relaxed
+
+
+static rs_allocation gCube;
+static int4 gDims;
+static int4 gFracMask;
+static int4 gFracBits;
+
+void setCube(rs_allocation c) {
+ gCube = c;
+ gDims.x = rsAllocationGetDimX(gCube);
+ gDims.y = rsAllocationGetDimY(gCube);
+ gDims.z = rsAllocationGetDimZ(gCube);
+ gDims.w = 0;
+
+ gFracMask = gDims - 1;
+ gFracBits = (int4)32 - clz(gFracMask);
+
+ rsDebug("dims", gDims);
+ rsDebug("gFracMask", gFracMask);
+ rsDebug("gFracBits", gFracBits);
+}
+
+void root(const uchar4 *in, uchar4 *out) {
+ //rsDebug("root", in);
+
+ int4 coord1 = convert_int4(*in);
+ int4 coord2 = min(coord1 + 1, gDims);
+
+ uchar4 v1 = rsGetElementAt_uchar4(gCube, coord1.x >> 3, coord1.y >> 3, coord1.z >> 4);
+
+ //rsDebug("coord1", coord1);
+ //rsDebug("coord2", coord2);
+
+ *out = v1;
+}
+