OSDN Git Service

Move the kernel launch to specific intrinsic class.
authorJason Sams <jsams@google.com>
Tue, 21 Aug 2012 22:53:29 +0000 (15:53 -0700)
committerJason Sams <jsams@google.com>
Tue, 21 Aug 2012 22:53:29 +0000 (15:53 -0700)
This allows support of both input types. Kernel source
and global source.

Change-Id: Iea60bebd79c786795eae81c14cbec352b470a9c0

graphics/java/android/renderscript/ScriptIntrinsic.java
graphics/java/android/renderscript/ScriptIntrinsicConvolve3x3.java
tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Intrinsics.java

index 6ad1527..f275fee 100644 (file)
@@ -28,8 +28,4 @@ public class ScriptIntrinsic extends Script {
     ScriptIntrinsic(int id, RenderScript rs) {
         super(id, rs);
     }
-
-    public void forEach(Allocation ain, Allocation aout) {
-        forEach(0, ain, aout, null);
-    }
 }
index 0ae1449..c7465a7 100644 (file)
@@ -32,6 +32,7 @@ import java.util.HashMap;
  **/
 public class ScriptIntrinsicConvolve3x3 extends ScriptIntrinsic {
     private float[] mValues = new float[9];
+    private Allocation mInput;
 
     ScriptIntrinsicConvolve3x3(int id, RenderScript rs) {
         super(id, rs);
@@ -52,8 +53,12 @@ public class ScriptIntrinsicConvolve3x3 extends ScriptIntrinsic {
 
     }
 
+    public void setInput(Allocation ain) {
+        mInput = ain;
+        bindAllocation(ain, 1);
+    }
 
-    public void setValues(float v[]) {
+    public void setColorMatrix(float v[]) {
         FieldPacker fp = new FieldPacker(9*4);
         for (int ct=0; ct < mValues.length; ct++) {
             mValues[ct] = v[ct];
@@ -61,5 +66,10 @@ public class ScriptIntrinsicConvolve3x3 extends ScriptIntrinsic {
         }
         setVar(0, fp);
     }
+
+    public void forEach(Allocation aout) {
+        forEach(0, null, aout, null);
+    }
+
 }
 
index ea8a018..dab8111 100644 (file)
@@ -46,7 +46,7 @@ public class Intrinsics extends TestBase {
         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.setValues(v);
+        mScript.setColorMatrix(v);
     }
 
 
@@ -55,7 +55,8 @@ public class Intrinsics extends TestBase {
     }
 
     public void runTest() {
-        mScript.forEach(mInPixelsAllocation, mOutPixelsAllocation);
+        mScript.setInput(mInPixelsAllocation);
+        mScript.forEach(mOutPixelsAllocation);
     }
 
 }