summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJason Sams <jsams@google.com>2012-09-05 13:48:58 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-09-05 13:48:58 -0700
commit3e777c79707d6c65e41ecd5a9b0e8f252ceafc90 (patch)
tree59d2a901a1efa49fcdb85195b29dda5df65796c6 /tests
parent27230f076a0f3a3e461405cc61088fa306d9847c (diff)
parent5729fcdf950eb909b0ab90a49af58731ed8f92cd (diff)
downloadframeworks_base-3e777c79707d6c65e41ecd5a9b0e8f252ceafc90.zip
frameworks_base-3e777c79707d6c65e41ecd5a9b0e8f252ceafc90.tar.gz
frameworks_base-3e777c79707d6c65e41ecd5a9b0e8f252ceafc90.tar.bz2
Merge "Add ColorMatrix Intrinsic." into jb-mr1-dev
Diffstat (limited to 'tests')
-rw-r--r--tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ColorMatrix.java64
-rw-r--r--tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Convolve3x3.java74
-rw-r--r--tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Copy.java (renamed from tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Intrinsics.java)33
-rw-r--r--tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java22
-rw-r--r--tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/copy.rs24
5 files changed, 186 insertions, 31 deletions
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ColorMatrix.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ColorMatrix.java
new file mode 100644
index 0000000..87a2de1
--- /dev/null
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ColorMatrix.java
@@ -0,0 +1,64 @@
+/*
+ * 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 ColorMatrix extends TestBase {
+ private ScriptC_colormatrix mScript;
+ private ScriptIntrinsicColorMatrix mIntrinsic;
+ private boolean mUseIntrinsic;
+
+ public ColorMatrix(boolean useIntrinsic) {
+ mUseIntrinsic = useIntrinsic;
+ }
+
+ public void createTest(android.content.res.Resources res) {
+ Matrix4f m = new Matrix4f();
+ m.set(1, 0, 0.2f);
+ m.set(1, 1, 0.9f);
+ m.set(1, 2, 0.2f);
+
+ if (mUseIntrinsic) {
+ mIntrinsic = ScriptIntrinsicColorMatrix.create(mRS, Element.U8_4(mRS));
+ mIntrinsic.setColorMatrix(m);
+ } else {
+ mScript = new ScriptC_colormatrix(mRS, res, R.raw.colormatrix);
+ mScript.invoke_setMatrix(m);
+ }
+ }
+
+ public void runTest() {
+ if (mUseIntrinsic) {
+ mIntrinsic.forEach(mInPixelsAllocation, mOutPixelsAllocation);
+ } else {
+ mScript.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
+ }
+ }
+
+}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Convolve3x3.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Convolve3x3.java
new file mode 100644
index 0000000..51794db
--- /dev/null
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Convolve3x3.java
@@ -0,0 +1,74 @@
+/*
+ * 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.ScriptIntrinsicConvolve3x3;
+import android.renderscript.Type;
+import android.util.Log;
+
+public class Convolve3x3 extends TestBase {
+ private ScriptC_convolve3x3 mScript;
+ private ScriptIntrinsicConvolve3x3 mIntrinsic;
+
+ private int mWidth;
+ private int mHeight;
+ private boolean mUseIntrinsic;
+
+ public Convolve3x3(boolean useIntrinsic) {
+ mUseIntrinsic = useIntrinsic;
+ }
+
+ public void createTest(android.content.res.Resources res) {
+ mWidth = mInPixelsAllocation.getType().getX();
+ mHeight = mInPixelsAllocation.getType().getY();
+
+ float f[] = new float[9];
+ f[0] = 0.f; f[1] = -1.f; f[2] = 0.f;
+ f[3] = -1.f; f[4] = 5.f; f[5] = -1.f;
+ f[6] = 0.f; f[7] = -1.f; f[8] = 0.f;
+
+ if (mUseIntrinsic) {
+ mIntrinsic = ScriptIntrinsicConvolve3x3.create(mRS, Element.U8_4(mRS));
+ mIntrinsic.setColorMatrix(f);
+ mIntrinsic.setInput(mInPixelsAllocation);
+ } else {
+ mScript = new ScriptC_convolve3x3(mRS, res, R.raw.convolve3x3);
+ mScript.set_gCoeffs(f);
+ mScript.set_gIn(mInPixelsAllocation);
+ mScript.set_gWidth(mWidth);
+ mScript.set_gHeight(mHeight);
+ }
+ }
+
+ public void runTest() {
+ if (mUseIntrinsic) {
+ mIntrinsic.forEach(mOutPixelsAllocation);
+ } else {
+ mScript.forEach_root(mOutPixelsAllocation);
+ }
+ }
+
+}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Intrinsics.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Copy.java
index dab8111..efca0b5 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Intrinsics.java
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Copy.java
@@ -22,42 +22,19 @@ import android.renderscript.Allocation;
import android.renderscript.Element;
import android.renderscript.RenderScript;
import android.renderscript.Script;
-import android.renderscript.ScriptIntrinsicConvolve3x3;
+import android.renderscript.ScriptC;
import android.renderscript.Type;
import android.util.Log;
-import android.widget.SeekBar;
-import android.widget.TextView;
-
-public class Intrinsics extends TestBase {
- private ScriptIntrinsicConvolve3x3 mScript;
-
- Intrinsics(int id) {
- }
-
- public boolean onBar1Setup(SeekBar b, TextView t) {
- t.setText("Strength");
- b.setProgress(50);
- return true;
- }
-
- public void onBar1Changed(int progress) {
- float s = progress / 100.0f;
- float v[] = new float[9];
- v[0] = 0.f; v[1] = -s; v[2] = 0.f;
- v[3] = -s; v[4] = s*4+1; v[5] = -s;
- v[6] = 0.f; v[7] = -s; v[8] = 0.f;
- mScript.setColorMatrix(v);
- }
+public class Copy extends TestBase {
+ private ScriptC_copy mScript;
public void createTest(android.content.res.Resources res) {
- mScript = ScriptIntrinsicConvolve3x3.create(mRS, Element.RGBA_8888(mRS));
+ mScript = new ScriptC_copy(mRS, res, R.raw.copy);
}
public void runTest() {
- mScript.setInput(mInPixelsAllocation);
- mScript.forEach(mOutPixelsAllocation);
+ 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 327ff06..3f34128 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
@@ -174,7 +174,19 @@ public class ImageProcessingActivity extends Activity
mTest = new GroupTest(true);
break;
case 17:
- mTest = new Intrinsics(0);
+ mTest = new Convolve3x3(false);
+ break;
+ case 18:
+ mTest = new Convolve3x3(true);
+ break;
+ case 19:
+ mTest = new ColorMatrix(false);
+ break;
+ case 20:
+ mTest = new ColorMatrix(true);
+ break;
+ case 21:
+ mTest = new Copy();
break;
}
@@ -188,7 +200,7 @@ public class ImageProcessingActivity extends Activity
}
void setupTests() {
- mTestNames = new String[18];
+ mTestNames = new String[22];
mTestNames[0] = "Levels Vec3 Relaxed";
mTestNames[1] = "Levels Vec4 Relaxed";
mTestNames[2] = "Levels Vec3 Full";
@@ -206,7 +218,11 @@ public class ImageProcessingActivity extends Activity
mTestNames[14] = "Vignette Approximate Relaxed";
mTestNames[15] = "Group Test (emulated)";
mTestNames[16] = "Group Test (native)";
- mTestNames[17] = "Intrinsics Convolve 3x3";
+ mTestNames[17] = "Convolve 3x3";
+ mTestNames[18] = "Intrinsics Convolve 3x3";
+ mTestNames[19] = "ColorMatrix";
+ mTestNames[20] = "Intrinsics ColorMatrix";
+ mTestNames[21] = "Copy";
mTestSpinner.setAdapter(new ArrayAdapter<String>(
this, R.layout.spinner_layout, mTestNames));
}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/copy.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/copy.rs
new file mode 100644
index 0000000..9eb5d43
--- /dev/null
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/copy.rs
@@ -0,0 +1,24 @@
+/*
+ * 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 root(const uchar4 *v_in, uchar4 *v_out) {
+ *v_out = *v_in;
+}
+
+