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

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

Merge "Renderscript samples. Resolving name conflict in model viewer. Adding...

Merge "Renderscript samples. Resolving name conflict in model viewer. Adding fov projection matrix function. Adding helper methods for blending."
parents c275c76c 32e09b58
Loading
Loading
Loading
Loading
+146 −1
Original line number Diff line number Diff line
@@ -79,7 +79,140 @@ public class ProgramStore extends BaseObj {
        super(id, rs);
    }

    public static ProgramStore BlendNone_DepthTest(RenderScript rs) {
        if(rs.mProgramStore_BlendNone_DepthTest == 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();
        }
        return rs.mProgramStore_BlendNone_DepthTest;
    }
    public static ProgramStore BlendNone_DepthNoDepth(RenderScript rs) {
        if(rs.mProgramStore_BlendNone_DepthNoDepth == 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();
        }
        return rs.mProgramStore_BlendNone_DepthNoDepth;
    }
    public static ProgramStore BlendNone_DepthNoTest(RenderScript rs) {
        if(rs.mProgramStore_BlendNone_DepthNoTest == 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();
        }
        return rs.mProgramStore_BlendNone_DepthNoTest;
    }
    public static ProgramStore BlendNone_DepthNoWrite(RenderScript rs) {
        if(rs.mProgramStore_BlendNone_DepthNoWrite == 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();
        }
        return rs.mProgramStore_BlendNone_DepthNoWrite;
    }

    public static ProgramStore BlendAlpha_DepthTest(RenderScript rs) {
        if(rs.mProgramStore_BlendAlpha_DepthTest == 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();
        }
        return rs.mProgramStore_BlendAlpha_DepthTest;
    }
    public static ProgramStore BlendAlpha_DepthNoDepth(RenderScript rs) {
        if(rs.mProgramStore_BlendAlpha_DepthNoDepth == 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();
        }
        return rs.mProgramStore_BlendAlpha_DepthNoDepth;
    }
    public static ProgramStore BlendAlpha_DepthNoTest(RenderScript rs) {
        if(rs.mProgramStore_BlendAlpha_DepthNoTest == 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();
        }
        return rs.mProgramStore_BlendAlpha_DepthNoTest;
    }
    public static ProgramStore BlendAlpha_DepthNoWrite(RenderScript rs) {
        if(rs.mProgramStore_BlendAlpha_DepthNoWrite == 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();
        }
        return rs.mProgramStore_BlendAlpha_DepthNoWrite;
    }

    public static ProgramStore BlendAdd_DepthTest(RenderScript rs) {
        if(rs.mProgramStore_BlendAdd_DepthTest == 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();
        }
        return rs.mProgramStore_BlendAdd_DepthTest;
    }
    public static ProgramStore BlendAdd_DepthNoDepth(RenderScript rs) {
        if(rs.mProgramStore_BlendAdd_DepthNoDepth == 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();
        }
        return rs.mProgramStore_BlendAdd_DepthNoDepth;
    }
    public static ProgramStore BlendAdd_DepthNoTest(RenderScript rs) {
        if(rs.mProgramStore_BlendAdd_DepthNoTest == 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();
        }
        return rs.mProgramStore_BlendAdd_DepthNoTest;
    }
    public static ProgramStore BlendAdd_DepthNoWrite(RenderScript rs) {
        if(rs.mProgramStore_BlendAdd_DepthNoWrite == 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();
        }
        return rs.mProgramStore_BlendAdd_DepthNoWrite;
    }

    public static class Builder {
        RenderScript mRS;
@@ -109,8 +242,20 @@ public class ProgramStore extends BaseObj {
            mColorMaskA = true;
            mBlendSrc = BlendSrcFunc.ONE;
            mBlendDst = BlendDstFunc.ZERO;
        }


        public Builder(RenderScript rs) {
            mRS = rs;
            mIn = null;
            mOut = null;
            mDepthFunc = DepthFunc.ALWAYS;
            mDepthMask = false;
            mColorMaskR = true;
            mColorMaskG = true;
            mColorMaskB = true;
            mColorMaskA = true;
            mBlendSrc = BlendSrcFunc.ONE;
            mBlendDst = BlendDstFunc.ZERO;
        }

        public Builder setDepthFunc(DepthFunc func) {
+3 −0
Original line number Diff line number Diff line
@@ -46,6 +46,9 @@ public class ProgramVertex extends Program {
        public Builder(RenderScript rs, Element in, Element out) {
            mRS = rs;
        }
        public Builder(RenderScript rs) {
            mRS = rs;
        }

        public Builder setTextureMatrixEnable(boolean enable) {
            mTextureMatrixEnable = enable;
+14 −0
Original line number Diff line number Diff line
@@ -549,6 +549,20 @@ 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;


    ///////////////////////////////////////////////////////////////////////////////////
    //

+0 −7
Original line number Diff line number Diff line
@@ -50,13 +50,6 @@ public class Sampler extends BaseObj {
        super(id, rs);
    }

    Sampler mSampler_CLAMP_NEAREST;
    Sampler mSampler_CLAMP_LINEAR;
    Sampler mSampler_CLAMP_LINEAR_MIP;
    Sampler mSampler_WRAP_NEAREST;
    Sampler mSampler_WRAP_LINEAR;
    Sampler mSampler_WRAP_LINEAR_MIP;

    public static Sampler CLAMP_NEAREST(RenderScript rs) {
        if(rs.mSampler_CLAMP_NEAREST == null) {
            Builder b = new Builder(rs);
+2 −1
Original line number Diff line number Diff line
@@ -2,7 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.modelviewer">
    <application android:label="ModelViewer">
        <activity android:name="ModelViewer"
        <activity android:name="SimpleModel"
                  android:label="SimpleModel"
                  android:screenOrientation="portrait"
                  android:theme="@android:style/Theme.Black.NoTitleBar">
            <intent-filter>
Loading