Processor(RenderScript rs, TextureView v, boolean benchmarkMode) { mRS = rs; mDisplayView = v; switch (mBitmapWidth) { case 3840: mInPixelsAllocation = Allocation.createFromBitmapResource(mRS, getResources(), R.drawable.img3840x2160a); mInPixelsAllocation2 = Allocation.createFromBitmapResource(mRS, getResources(), R.drawable.img3840x2160b); break; case 1920: mInPixelsAllocation = Allocation.createFromBitmapResource(mRS, getResources(), R.drawable.img1920x1080a); mInPixelsAllocation2 = Allocation.createFromBitmapResource(mRS, getResources(), R.drawable.img1920x1080b); break; case 1280: mInPixelsAllocation = Allocation.createFromBitmapResource(mRS, getResources(), R.drawable.img1280x720a); mInPixelsAllocation2 = Allocation.createFromBitmapResource(mRS, getResources(), R.drawable.img1280x720b); break; case 800: mInPixelsAllocation = Allocation.createFromBitmapResource(mRS, getResources(), R.drawable.img800x450a); mInPixelsAllocation2 = Allocation.createFromBitmapResource(mRS, getResources(), R.drawable.img800x450b); break; } mOutDisplayAllocation = Allocation.createTyped( mRS, mInPixelsAllocation.getType(), Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT | Allocation.USAGE_IO_OUTPUT); mOutPixelsAllocation = mOutDisplayAllocation; if (!mToggleIO) { // Not using USAGE_IO for the script so create a non-io kernel to copy from mOutPixelsAllocation = Allocation.createTyped( mRS, mInPixelsAllocation.getType(), Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT); } mBenchmarkMode = benchmarkMode; start(); }
private Allocation loadTexture(int id) { final Allocation allocation = Allocation.createFromBitmapResource(mRS, mResources, id); return allocation; }