I can get two separate intrinsics working, but not together in a ScriptGroup. I found document on how to use Script Group is extremely sparse.
Here is my code:
mRS = RenderScript.create(getActivity());
mInAllocation = Allocation.createFromBitmap(mRS, mBitmapIn,
Allocation.MipmapControl.MIPMAP_NONE,
Allocation.USAGE_SCRIPT |
Allocation.USAGE_GRAPHICS_TEXTURE |
Allocation.USAGE_SHARED);
mOutAllocation = Allocation.createFromBitmap(mRS, mBitmapOut,
Allocation.MipmapControl.MIPMAP_NONE,
Allocation.USAGE_SCRIPT |
Allocation.USAGE_SHARED);
ScriptIntrinsicColorMatrix gray = ScriptIntrinsicColorMatrix.create(mRS, Element.U8_4(mRS));
gray.setGreyscale();
ScriptIntrinsicBlur blur = ScriptIntrinsicBlur.create(mRS, Element.U8_4(mRS));
blur.setRadius(20.f);
blur.setInput(mInAllocation);
//gray.forEach(mInAllocation, mOutAllocation);
blur.forEach(mOutAllocation);
mOutAllocation.copyTo(mBitmapOut);
Both gray and blur work. And then I tried putting them together, the result is blank. Code:
// gray.forEach(mInAllocation, mOutAllocation);
// blur.forEach(mOutAllocation);
// mOutAllocation.copyTo(mBitmapOut);
ScriptGroup.Builder builder = new ScriptGroup.Builder(mRS);
builder.addKernel(gray.getKernelID());
builder.addKernel(blur.getKernelID());
builder.addConnection(mInAllocation.getType(), gray.getKernelID(), blur.getKernelID());
ScriptGroup group = builder.create();
group.setInput(gray.getKernelID(), mInAllocation);
group.setOutput(blur.getKernelID(), mOutAllocation);
group.execute();
mOutAllocation.copyTo(mBitmapOut);