More work on the renderscript sample

Change-Id: Ib1812bbaa38180ca63d6d53c9cc3aeeee4134725
diff --git a/graphics/java/android/renderscript/ProgramRaster.java b/graphics/java/android/renderscript/ProgramRaster.java
index 08065cf..fd89b6e 100644
--- a/graphics/java/android/renderscript/ProgramRaster.java
+++ b/graphics/java/android/renderscript/ProgramRaster.java
@@ -67,17 +67,46 @@
         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 @@
             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;
         }
 
diff --git a/graphics/java/android/renderscript/ProgramStore.java b/graphics/java/android/renderscript/ProgramStore.java
index e249842..32c0d01 100644
--- a/graphics/java/android/renderscript/ProgramStore.java
+++ b/graphics/java/android/renderscript/ProgramStore.java
@@ -79,139 +79,139 @@
         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 {
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java
index 37c01f5..ab1d7650 100644
--- a/graphics/java/android/renderscript/RenderScript.java
+++ b/graphics/java/android/renderscript/RenderScript.java
@@ -549,19 +549,22 @@
     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;
 
     ///////////////////////////////////////////////////////////////////////////////////
     //
diff --git a/graphics/java/android/renderscript/Sampler.java b/graphics/java/android/renderscript/Sampler.java
index ccd46bd..343fcdb 100644
--- a/graphics/java/android/renderscript/Sampler.java
+++ b/graphics/java/android/renderscript/Sampler.java
@@ -78,7 +78,7 @@
         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 @@
         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();