diff options
author | Alex Sakhartchouk <alexst@google.com> | 2010-08-23 10:24:10 -0700 |
---|---|---|
committer | Alex Sakhartchouk <alexst@google.com> | 2010-08-23 10:24:10 -0700 |
commit | 32e09b5891da0174f161d99e2d3ebe67d6efa39c (patch) | |
tree | 244b492ddfc2049b8d2c3a2330a4acef337a276e /graphics/java/android | |
parent | 526e7a3c8549f504850d7e9148f70682ad0c537e (diff) | |
download | frameworks_base-32e09b5891da0174f161d99e2d3ebe67d6efa39c.zip frameworks_base-32e09b5891da0174f161d99e2d3ebe67d6efa39c.tar.gz frameworks_base-32e09b5891da0174f161d99e2d3ebe67d6efa39c.tar.bz2 |
Renderscript samples.
Resolving name conflict in model viewer.
Adding fov projection matrix function.
Adding helper methods for blending.
Change-Id: Ibd3f1510436811398787c285845d050158bd6de8
Diffstat (limited to 'graphics/java/android')
4 files changed, 163 insertions, 8 deletions
diff --git a/graphics/java/android/renderscript/ProgramStore.java b/graphics/java/android/renderscript/ProgramStore.java index cce4064..e249842 100644 --- a/graphics/java/android/renderscript/ProgramStore.java +++ b/graphics/java/android/renderscript/ProgramStore.java @@ -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) { diff --git a/graphics/java/android/renderscript/ProgramVertex.java b/graphics/java/android/renderscript/ProgramVertex.java index ec377e2..c99efd6 100644 --- a/graphics/java/android/renderscript/ProgramVertex.java +++ b/graphics/java/android/renderscript/ProgramVertex.java @@ -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; diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index d82e524..37c01f5 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -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; + + /////////////////////////////////////////////////////////////////////////////////// // diff --git a/graphics/java/android/renderscript/Sampler.java b/graphics/java/android/renderscript/Sampler.java index 60c6cf4..ccd46bd 100644 --- a/graphics/java/android/renderscript/Sampler.java +++ b/graphics/java/android/renderscript/Sampler.java @@ -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); |