FileDocCategorySizeDatePackage
ColorCube.javaAPI DocAndroid 5.1 API2711Thu Mar 12 22:22:54 GMT 2015com.android.rs.image

ColorCube

public class ColorCube extends TestBase

Fields Summary
private android.renderscript.Allocation
mCube
private ScriptC_colorcube
mScript
private android.renderscript.ScriptIntrinsic3DLUT
mIntrinsic
private boolean
mUseIntrinsic
Constructors Summary
public ColorCube(boolean useIntrinsic)

        mUseIntrinsic = useIntrinsic;
    
Methods Summary
public voidcreateTest(android.content.res.Resources res)

        mScript = new ScriptC_colorcube(mRS);
        mIntrinsic = ScriptIntrinsic3DLUT.create(mRS, Element.U8_4(mRS));

        initCube();
        mScript.invoke_setCube(mCube);
        mIntrinsic.setLUT(mCube);
    
private voidinitCube()

        final int sx = 32;
        final int sy = 32;
        final int sz = 16;

        Type.Builder tb = new Type.Builder(mRS, Element.U8_4(mRS));
        tb.setX(sx);
        tb.setY(sy);
        tb.setZ(sz);
        Type t = tb.create();
        mCube = Allocation.createTyped(mRS, t);

        int dat[] = new int[sx * sy * sz];
        for (int z = 0; z < sz; z++) {
            for (int y = 0; y < sy; y++) {
                for (int x = 0; x < sx; x++ ) {
                    int v = 0xff000000;
                    v |= (0xff * x / (sx - 1));
                    v |= (0xff * y / (sy - 1)) << 8;
                    v |= (0xff * z / (sz - 1)) << 16;
                    dat[z*sy*sx + y*sx + x] = v;
                }
            }
        }

        mCube.copyFromUnchecked(dat);
    
public voidrunTest()

        if (mUseIntrinsic) {
            mIntrinsic.forEach(mInPixelsAllocation, mOutPixelsAllocation);
        } else {
            mScript.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
        }