Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a3c63e5b authored by Alex Sakhartchouk's avatar Alex Sakhartchouk Committed by Android (Google) Code Review
Browse files

Merge "More work on the renderscript sample"

parents 3ded7cb5 d36f248e
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -67,17 +67,46 @@ public class ProgramRaster extends BaseObj {
        mRS.nProgramRasterSetCullMode(mID, m.mID);
    }

    public static ProgramRaster CULL_BACK(RenderScript rs) {
        if(rs.mProgramRaster_CULL_BACK == null) {
            ProgramRaster.Builder builder = new ProgramRaster.Builder(rs);
            builder.setCullMode(CullMode.BACK);
            rs.mProgramRaster_CULL_BACK = builder.create();
        }
        return rs.mProgramRaster_CULL_BACK;
    }

    public static ProgramRaster CULL_FRONT(RenderScript rs) {
        if(rs.mProgramRaster_CULL_FRONT == null) {
            ProgramRaster.Builder builder = new ProgramRaster.Builder(rs);
            builder.setCullMode(CullMode.FRONT);
            rs.mProgramRaster_CULL_FRONT = builder.create();
        }
        return rs.mProgramRaster_CULL_FRONT;
    }

    public static ProgramRaster CULL_NONE(RenderScript rs) {
        if(rs.mProgramRaster_CULL_NONE == null) {
            ProgramRaster.Builder builder = new ProgramRaster.Builder(rs);
            builder.setCullMode(CullMode.NONE);
            rs.mProgramRaster_CULL_NONE = builder.create();
        }
        return rs.mProgramRaster_CULL_NONE;
    }

    public static class Builder {
        RenderScript mRS;
        boolean mPointSprite;
        boolean mPointSmooth;
        boolean mLineSmooth;
        CullMode mCullMode;

        public Builder(RenderScript rs) {
            mRS = rs;
            mPointSmooth = false;
            mLineSmooth = false;
            mPointSprite = false;
            mCullMode = CullMode.BACK;
        }

        public Builder setPointSpriteEnable(boolean enable) {
@@ -95,9 +124,15 @@ public class ProgramRaster extends BaseObj {
            return this;
        }

        public Builder setCullMode(CullMode m) {
            mCullMode = m;
            return this;
        }

        static synchronized ProgramRaster internalCreate(RenderScript rs, Builder b) {
            int id = rs.nProgramRasterCreate(b.mPointSmooth, b.mLineSmooth, b.mPointSprite);
            ProgramRaster pr = new ProgramRaster(id, rs);
            pr.setCullMode(b.mCullMode);
            return pr;
        }

+48 −48
Original line number Diff line number Diff line
@@ -79,139 +79,139 @@ public class ProgramStore extends BaseObj {
        super(id, rs);
    }

    public static ProgramStore BlendNone_DepthTest(RenderScript rs) {
        if(rs.mProgramStore_BlendNone_DepthTest == null) {
    public static ProgramStore BLEND_NONE_DEPTH_TEST(RenderScript rs) {
        if(rs.mProgramStore_BLEND_NONE_DEPTH_TEST == null) {
            ProgramStore.Builder builder = new ProgramStore.Builder(rs);
            builder.setDepthFunc(ProgramStore.DepthFunc.LESS);
            builder.setBlendFunc(BlendSrcFunc.ONE, BlendDstFunc.ZERO);
            builder.setDitherEnable(false);
            builder.setDepthMask(true);
            rs.mProgramStore_BlendNone_DepthTest = builder.create();
            rs.mProgramStore_BLEND_NONE_DEPTH_TEST = builder.create();
        }
        return rs.mProgramStore_BlendNone_DepthTest;
        return rs.mProgramStore_BLEND_NONE_DEPTH_TEST;
    }
    public static ProgramStore BlendNone_DepthNoDepth(RenderScript rs) {
        if(rs.mProgramStore_BlendNone_DepthNoDepth == null) {
    public static ProgramStore BLEND_NONE_DEPTH_NO_DEPTH(RenderScript rs) {
        if(rs.mProgramStore_BLEND_NONE_DEPTH_NO_DEPTH == null) {
            ProgramStore.Builder builder = new ProgramStore.Builder(rs);
            builder.setDepthFunc(ProgramStore.DepthFunc.ALWAYS);
            builder.setBlendFunc(BlendSrcFunc.ONE, BlendDstFunc.ZERO);
            builder.setDitherEnable(false);
            builder.setDepthMask(false);
            rs.mProgramStore_BlendNone_DepthNoDepth = builder.create();
            rs.mProgramStore_BLEND_NONE_DEPTH_NO_DEPTH = builder.create();
        }
        return rs.mProgramStore_BlendNone_DepthNoDepth;
        return rs.mProgramStore_BLEND_NONE_DEPTH_NO_DEPTH;
    }
    public static ProgramStore BlendNone_DepthNoTest(RenderScript rs) {
        if(rs.mProgramStore_BlendNone_DepthNoTest == null) {
    public static ProgramStore BLEND_NONE_DEPTH_NO_TEST(RenderScript rs) {
        if(rs.mProgramStore_BLEND_NONE_DEPTH_NO_TEST == null) {
            ProgramStore.Builder builder = new ProgramStore.Builder(rs);
            builder.setDepthFunc(ProgramStore.DepthFunc.ALWAYS);
            builder.setBlendFunc(BlendSrcFunc.ONE, BlendDstFunc.ZERO);
            builder.setDitherEnable(false);
            builder.setDepthMask(true);
            rs.mProgramStore_BlendNone_DepthNoTest = builder.create();
            rs.mProgramStore_BLEND_NONE_DEPTH_NO_TEST = builder.create();
        }
        return rs.mProgramStore_BlendNone_DepthNoTest;
        return rs.mProgramStore_BLEND_NONE_DEPTH_NO_TEST;
    }
    public static ProgramStore BlendNone_DepthNoWrite(RenderScript rs) {
        if(rs.mProgramStore_BlendNone_DepthNoWrite == null) {
    public static ProgramStore BLEND_NONE_DEPTH_NO_WRITE(RenderScript rs) {
        if(rs.mProgramStore_BLEND_NONE_DEPTH_NO_WRITE == null) {
            ProgramStore.Builder builder = new ProgramStore.Builder(rs);
            builder.setDepthFunc(ProgramStore.DepthFunc.LESS);
            builder.setBlendFunc(BlendSrcFunc.ONE, BlendDstFunc.ZERO);
            builder.setDitherEnable(false);
            builder.setDepthMask(false);
            rs.mProgramStore_BlendNone_DepthNoWrite = builder.create();
            rs.mProgramStore_BLEND_NONE_DEPTH_NO_WRITE = builder.create();
        }
        return rs.mProgramStore_BlendNone_DepthNoWrite;
        return rs.mProgramStore_BLEND_NONE_DEPTH_NO_WRITE;
    }

    public static ProgramStore BlendAlpha_DepthTest(RenderScript rs) {
        if(rs.mProgramStore_BlendAlpha_DepthTest == null) {
    public static ProgramStore BLEND_ALPHA_DEPTH_TEST(RenderScript rs) {
        if(rs.mProgramStore_BLEND_ALPHA_DEPTH_TEST == null) {
            ProgramStore.Builder builder = new ProgramStore.Builder(rs);
            builder.setDepthFunc(ProgramStore.DepthFunc.LESS);
            builder.setBlendFunc(BlendSrcFunc.SRC_ALPHA, BlendDstFunc.ONE_MINUS_SRC_ALPHA);
            builder.setDitherEnable(false);
            builder.setDepthMask(true);
            rs.mProgramStore_BlendAlpha_DepthTest = builder.create();
            rs.mProgramStore_BLEND_ALPHA_DEPTH_TEST = builder.create();
        }
        return rs.mProgramStore_BlendAlpha_DepthTest;
        return rs.mProgramStore_BLEND_ALPHA_DEPTH_TEST;
    }
    public static ProgramStore BlendAlpha_DepthNoDepth(RenderScript rs) {
        if(rs.mProgramStore_BlendAlpha_DepthNoDepth == null) {
    public static ProgramStore BLEND_ALPHA_DEPTH_NO_DEPTH(RenderScript rs) {
        if(rs.mProgramStore_BLEND_ALPHA_DEPTH_NO_DEPTH == null) {
            ProgramStore.Builder builder = new ProgramStore.Builder(rs);
            builder.setDepthFunc(ProgramStore.DepthFunc.ALWAYS);
            builder.setBlendFunc(BlendSrcFunc.SRC_ALPHA, BlendDstFunc.ONE_MINUS_SRC_ALPHA);
            builder.setDitherEnable(false);
            builder.setDepthMask(false);
            rs.mProgramStore_BlendAlpha_DepthNoDepth = builder.create();
            rs.mProgramStore_BLEND_ALPHA_DEPTH_NO_DEPTH = builder.create();
        }
        return rs.mProgramStore_BlendAlpha_DepthNoDepth;
        return rs.mProgramStore_BLEND_ALPHA_DEPTH_NO_DEPTH;
    }
    public static ProgramStore BlendAlpha_DepthNoTest(RenderScript rs) {
        if(rs.mProgramStore_BlendAlpha_DepthNoTest == null) {
    public static ProgramStore BLEND_ALPHA_DEPTH_NO_TEST(RenderScript rs) {
        if(rs.mProgramStore_BLEND_ALPHA_DEPTH_NO_TEST == null) {
            ProgramStore.Builder builder = new ProgramStore.Builder(rs);
            builder.setDepthFunc(ProgramStore.DepthFunc.ALWAYS);
            builder.setBlendFunc(BlendSrcFunc.SRC_ALPHA, BlendDstFunc.ONE_MINUS_SRC_ALPHA);
            builder.setDitherEnable(false);
            builder.setDepthMask(true);
            rs.mProgramStore_BlendAlpha_DepthNoTest = builder.create();
            rs.mProgramStore_BLEND_ALPHA_DEPTH_NO_TEST = builder.create();
        }
        return rs.mProgramStore_BlendAlpha_DepthNoTest;
        return rs.mProgramStore_BLEND_ALPHA_DEPTH_NO_TEST;
    }
    public static ProgramStore BlendAlpha_DepthNoWrite(RenderScript rs) {
        if(rs.mProgramStore_BlendAlpha_DepthNoWrite == null) {
    public static ProgramStore BLEND_ALPHA_DEPTH_NO_WRITE(RenderScript rs) {
        if(rs.mProgramStore_BLEND_ALPHA_DEPTH_NO_WRITE == null) {
            ProgramStore.Builder builder = new ProgramStore.Builder(rs);
            builder.setDepthFunc(ProgramStore.DepthFunc.LESS);
            builder.setBlendFunc(BlendSrcFunc.SRC_ALPHA, BlendDstFunc.ONE_MINUS_SRC_ALPHA);
            builder.setDitherEnable(false);
            builder.setDepthMask(false);
            rs.mProgramStore_BlendAlpha_DepthNoWrite = builder.create();
            rs.mProgramStore_BLEND_ALPHA_DEPTH_NO_WRITE = builder.create();
        }
        return rs.mProgramStore_BlendAlpha_DepthNoWrite;
        return rs.mProgramStore_BLEND_ALPHA_DEPTH_NO_WRITE;
    }

    public static ProgramStore BlendAdd_DepthTest(RenderScript rs) {
        if(rs.mProgramStore_BlendAdd_DepthTest == null) {
    public static ProgramStore BLEND_ADD_DEPTH_TEST(RenderScript rs) {
        if(rs.mProgramStore_BLEND_ADD_DEPTH_TEST == null) {
            ProgramStore.Builder builder = new ProgramStore.Builder(rs);
            builder.setDepthFunc(ProgramStore.DepthFunc.LESS);
            builder.setBlendFunc(BlendSrcFunc.ONE, BlendDstFunc.ONE);
            builder.setDitherEnable(false);
            builder.setDepthMask(true);
            rs.mProgramStore_BlendAdd_DepthTest = builder.create();
            rs.mProgramStore_BLEND_ADD_DEPTH_TEST = builder.create();
        }
        return rs.mProgramStore_BlendAdd_DepthTest;
        return rs.mProgramStore_BLEND_ADD_DEPTH_TEST;
    }
    public static ProgramStore BlendAdd_DepthNoDepth(RenderScript rs) {
        if(rs.mProgramStore_BlendAdd_DepthNoDepth == null) {
    public static ProgramStore BLEND_ADD_DEPTH_NO_DEPTH(RenderScript rs) {
        if(rs.mProgramStore_BLEND_ADD_DEPTH_NO_DEPTH == null) {
            ProgramStore.Builder builder = new ProgramStore.Builder(rs);
            builder.setDepthFunc(ProgramStore.DepthFunc.ALWAYS);
            builder.setBlendFunc(BlendSrcFunc.ONE, BlendDstFunc.ONE);
            builder.setDitherEnable(false);
            builder.setDepthMask(false);
            rs.mProgramStore_BlendAdd_DepthNoDepth = builder.create();
            rs.mProgramStore_BLEND_ADD_DEPTH_NO_DEPTH = builder.create();
        }
        return rs.mProgramStore_BlendAdd_DepthNoDepth;
        return rs.mProgramStore_BLEND_ADD_DEPTH_NO_DEPTH;
    }
    public static ProgramStore BlendAdd_DepthNoTest(RenderScript rs) {
        if(rs.mProgramStore_BlendAdd_DepthNoTest == null) {
    public static ProgramStore BLEND_ADD_DEPTH_NO_TEST(RenderScript rs) {
        if(rs.mProgramStore_BLEND_ADD_DEPTH_NO_TEST == null) {
            ProgramStore.Builder builder = new ProgramStore.Builder(rs);
            builder.setDepthFunc(ProgramStore.DepthFunc.ALWAYS);
            builder.setBlendFunc(BlendSrcFunc.ONE, BlendDstFunc.ONE);
            builder.setDitherEnable(false);
            builder.setDepthMask(true);
            rs.mProgramStore_BlendAdd_DepthNoDepth = builder.create();
            rs.mProgramStore_BLEND_ADD_DEPTH_NO_DEPTH = builder.create();
        }
        return rs.mProgramStore_BlendAdd_DepthNoTest;
        return rs.mProgramStore_BLEND_ADD_DEPTH_NO_TEST;
    }
    public static ProgramStore BlendAdd_DepthNoWrite(RenderScript rs) {
        if(rs.mProgramStore_BlendAdd_DepthNoWrite == null) {
    public static ProgramStore BLEND_ADD_DEPTH_NO_WRITE(RenderScript rs) {
        if(rs.mProgramStore_BLEND_ADD_DEPTH_NO_WRITE == null) {
            ProgramStore.Builder builder = new ProgramStore.Builder(rs);
            builder.setDepthFunc(ProgramStore.DepthFunc.ALWAYS);
            builder.setBlendFunc(BlendSrcFunc.ONE, BlendDstFunc.ONE);
            builder.setDitherEnable(false);
            builder.setDepthMask(false);
            rs.mProgramStore_BlendAdd_DepthNoWrite = builder.create();
            rs.mProgramStore_BLEND_ADD_DEPTH_NO_WRITE = builder.create();
        }
        return rs.mProgramStore_BlendAdd_DepthNoWrite;
        return rs.mProgramStore_BLEND_ADD_DEPTH_NO_WRITE;
    }

    public static class Builder {
+16 −13
Original line number Diff line number Diff line
@@ -549,19 +549,22 @@ public class RenderScript {
    Sampler mSampler_WRAP_LINEAR;
    Sampler mSampler_WRAP_LINEAR_MIP_LINEAR;

    ProgramStore mProgramStore_BlendNone_DepthTest;
    ProgramStore mProgramStore_BlendNone_DepthNoDepth;
    ProgramStore mProgramStore_BlendNone_DepthNoTest;
    ProgramStore mProgramStore_BlendNone_DepthNoWrite;
    ProgramStore mProgramStore_BlendAlpha_DepthTest;
    ProgramStore mProgramStore_BlendAlpha_DepthNoDepth;
    ProgramStore mProgramStore_BlendAlpha_DepthNoTest;
    ProgramStore mProgramStore_BlendAlpha_DepthNoWrite;
    ProgramStore mProgramStore_BlendAdd_DepthTest;
    ProgramStore mProgramStore_BlendAdd_DepthNoDepth;
    ProgramStore mProgramStore_BlendAdd_DepthNoTest;
    ProgramStore mProgramStore_BlendAdd_DepthNoWrite;

    ProgramStore mProgramStore_BLEND_NONE_DEPTH_TEST;
    ProgramStore mProgramStore_BLEND_NONE_DEPTH_NO_DEPTH;
    ProgramStore mProgramStore_BLEND_NONE_DEPTH_NO_TEST;
    ProgramStore mProgramStore_BLEND_NONE_DEPTH_NO_WRITE;
    ProgramStore mProgramStore_BLEND_ALPHA_DEPTH_TEST;
    ProgramStore mProgramStore_BLEND_ALPHA_DEPTH_NO_DEPTH;
    ProgramStore mProgramStore_BLEND_ALPHA_DEPTH_NO_TEST;
    ProgramStore mProgramStore_BLEND_ALPHA_DEPTH_NO_WRITE;
    ProgramStore mProgramStore_BLEND_ADD_DEPTH_TEST;
    ProgramStore mProgramStore_BLEND_ADD_DEPTH_NO_DEPTH;
    ProgramStore mProgramStore_BLEND_ADD_DEPTH_NO_TEST;
    ProgramStore mProgramStore_BLEND_ADD_DEPTH_NO_WRITE;

    ProgramRaster mProgramRaster_CULL_BACK;
    ProgramRaster mProgramRaster_CULL_FRONT;
    ProgramRaster mProgramRaster_CULL_NONE;

    ///////////////////////////////////////////////////////////////////////////////////
    //
+2 −2
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ public class Sampler extends BaseObj {
        if(rs.mSampler_CLAMP_LINEAR_MIP_LINEAR == null) {
            Builder b = new Builder(rs);
            b.setMin(Value.LINEAR_MIP_LINEAR);
            b.setMag(Value.LINEAR_MIP_LINEAR);
            b.setMag(Value.LINEAR);
            b.setWrapS(Value.CLAMP);
            b.setWrapT(Value.CLAMP);
            rs.mSampler_CLAMP_LINEAR_MIP_LINEAR = b.create();
@@ -114,7 +114,7 @@ public class Sampler extends BaseObj {
        if(rs.mSampler_WRAP_LINEAR_MIP_LINEAR == null) {
            Builder b = new Builder(rs);
            b.setMin(Value.LINEAR_MIP_LINEAR);
            b.setMag(Value.LINEAR_MIP_LINEAR);
            b.setMag(Value.LINEAR);
            b.setWrapS(Value.WRAP);
            b.setWrapT(Value.WRAP);
            rs.mSampler_WRAP_LINEAR_MIP_LINEAR = b.create();
+46 KiB
Loading image diff...
Loading