Add clipped kernel tests to CTS.
Change-Id: I322e48765adac44e65d3612a593545c955e5229f
diff --git a/tests/src/android/renderscript/cts/kernel_clip.rs b/tests/src/android/renderscript/cts/kernel_clip.rs
new file mode 100644
index 0000000..834bf33
--- /dev/null
+++ b/tests/src/android/renderscript/cts/kernel_clip.rs
@@ -0,0 +1,25 @@
+#pragma version(1)
+#pragma rs java_package_name(android.renderscript.cts)
+
+int dimX;
+int dimY;
+int xStart = 0;
+int xEnd = 0;
+int yStart = 0;
+int yEnd = 0;
+
+rs_script s;
+rs_allocation ain;
+rs_allocation aout;
+
+void run_clipped_script() {
+ rs_script_call_t rssc = {0};
+ rssc.strategy = RS_FOR_EACH_STRATEGY_DONT_CARE;
+ rssc.xStart = xStart;
+ rssc.xEnd = xEnd;
+ rssc.yStart = yStart;
+ rssc.yEnd = yEnd;
+
+ rsForEach(s, ain, aout, NULL, 0, &rssc);
+
+}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ImageProcessingTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ImageProcessingTest.java
index fae20f4..26fe05f 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/ImageProcessingTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ImageProcessingTest.java
@@ -50,6 +50,8 @@
import android.renderscript.Type;
+import android.renderscript.Script;
+
import android.renderscript.ScriptGroup;
import android.renderscript.ScriptIntrinsicBlend;
@@ -76,6 +78,29 @@
a2 = Allocation.createTyped(mRS, t);
}
+ protected void runClippedIntrinsic(Script s,
+ Allocation ain,
+ Allocation aout) {
+ int xStart = 16;
+ int xEnd = 127;
+ int yStart = 48;
+ int yEnd = 63;
+
+ ScriptC_kernel_clip clip = new ScriptC_kernel_clip(mRS);
+ clip.set_xStart(xStart);
+ clip.set_xEnd(xEnd);
+ clip.set_yStart(yStart);
+ clip.set_yEnd(yEnd);
+
+ clip.set_s(s);
+ clip.set_ain(ain);
+ clip.set_aout(aout);
+
+ clip.invoke_run_clipped_script();
+ mRS.finish();
+
+ }
+
public void testBlur() {
ScriptIntrinsicBlur mBlur;
mBlur = ScriptIntrinsicBlur.create(mRS, Element.U8_4(mRS));
@@ -91,6 +116,8 @@
mBlur.setRadius(i);
mBlur.setInput(a1_copy);
+ runClippedIntrinsic(mBlur, a1_copy, a2_copy);
+
mBlur.forEach(a2_copy);
// validate
@@ -182,6 +209,8 @@
a1_copy.copy2DRangeFrom(0, 0, a1.getType().getX(), a1.getType().getY(), a1, 0, 0);
a2_copy.copy2DRangeFrom(0, 0, a2.getType().getX(), a2.getType().getY(), a2, 0, 0);
+ runClippedIntrinsic(mColorMatrix, a1_copy, a2_copy);
+
mColorMatrix.forEach(a1_copy, a2_copy);
//validate greyscale
@@ -193,6 +222,8 @@
a1_copy.copy2DRangeFrom(0, 0, a1.getType().getX(), a1.getType().getY(), a1, 0, 0);
a2_copy.copy2DRangeFrom(0, 0, a2.getType().getX(), a2.getType().getY(), a2, 0, 0);
+ runClippedIntrinsic(mColorMatrix, a1_copy, a2_copy);
+
mColorMatrix.forEach(a1_copy, a2_copy);
//validate color matrix
@@ -218,6 +249,9 @@
mConvolve3x3.setCoefficients(f);
mConvolve3x3.setInput(a1_copy);
+
+ runClippedIntrinsic(mConvolve3x3, a1_copy, a2_copy);
+
mConvolve3x3.forEach(a2_copy);
// validate
@@ -243,6 +277,9 @@
mConvolve5x5.setCoefficients(f);
mConvolve5x5.setInput(a1_copy);
+
+ runClippedIntrinsic(mConvolve5x5, a1_copy, a2_copy);
+
mConvolve5x5.forEach(a2_copy);
// validate
@@ -286,6 +323,8 @@
mLUT.forEach(a1_copy, a2_copy);
+ runClippedIntrinsic(mLUT, a1_copy, a2_copy);
+
// validate
}