public ViewfinderProcessor(RenderScript rs, Size dimensions) {
Type.Builder yuvTypeBuilder = new Type.Builder(rs, Element.YUV(rs));
yuvTypeBuilder.setX(dimensions.getWidth());
yuvTypeBuilder.setY(dimensions.getHeight());
yuvTypeBuilder.setYuvFormat(ImageFormat.YUV_420_888);
mInputHdrAllocation = Allocation.createTyped(rs, yuvTypeBuilder.create(),
Allocation.USAGE_IO_INPUT | Allocation.USAGE_SCRIPT);
mInputNormalAllocation = Allocation.createTyped(rs, yuvTypeBuilder.create(),
Allocation.USAGE_IO_INPUT | Allocation.USAGE_SCRIPT);
Type.Builder rgbTypeBuilder = new Type.Builder(rs, Element.RGBA_8888(rs));
rgbTypeBuilder.setX(dimensions.getWidth());
rgbTypeBuilder.setY(dimensions.getHeight());
mPrevAllocation = Allocation.createTyped(rs, rgbTypeBuilder.create(),
Allocation.USAGE_SCRIPT);
mOutputAllocation = Allocation.createTyped(rs, rgbTypeBuilder.create(),
Allocation.USAGE_IO_OUTPUT | Allocation.USAGE_SCRIPT);
HandlerThread processingThread = new HandlerThread("ViewfinderProcessor");
processingThread.start();
mProcessingHandler = new Handler(processingThread.getLooper());
mHdrMergeScript = new ScriptC_hdr_merge(rs);
mHdrMergeScript.set_gPrevFrame(mPrevAllocation);
mHdrTask = new ProcessingTask(mInputHdrAllocation, dimensions.getWidth()/2, true);
mNormalTask = new ProcessingTask(mInputNormalAllocation, 0, false);
setRenderMode(MODE_NORMAL);
}