Add raster object to control point and line params. Add flag to force SW rendering.
diff --git a/libs/rs/Android.mk b/libs/rs/Android.mk
index bc466be..2c17599 100644
--- a/libs/rs/Android.mk
+++ b/libs/rs/Android.mk
@@ -90,6 +90,7 @@
 	rsProgram.cpp \
 	rsProgramFragment.cpp \
 	rsProgramFragmentStore.cpp \
+	rsProgramRaster.cpp \
 	rsProgramVertex.cpp \
 	rsSampler.cpp \
 	rsScript.cpp \
diff --git a/libs/rs/RenderScript.h b/libs/rs/RenderScript.h
index 1e24cd2..9f18b78 100644
--- a/libs/rs/RenderScript.h
+++ b/libs/rs/RenderScript.h
@@ -45,9 +45,16 @@
 typedef void * RsProgramVertex;
 typedef void * RsProgramFragment;
 typedef void * RsProgramFragmentStore;
+typedef void * RsProgramRaster;
+
+enum RsDeviceParam {
+    RS_DEVICE_PARAM_FORCE_SOFTWARE_GL,
+    RS_DEVICE_PARAM_COUNT
+};
 
 RsDevice rsDeviceCreate();
 void rsDeviceDestroy(RsDevice);
+void rsDeviceSetConfig(RsDevice, RsDeviceParam, int32_t value);
 
 RsContext rsContextCreate(RsDevice, void *, uint32_t version, bool useDepth);
 void rsContextDestroy(RsContext);
diff --git a/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java b/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java
index 7826161..1b07f98 100644
--- a/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java
+++ b/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java
@@ -52,7 +52,7 @@
     public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
         super.surfaceChanged(holder, format, w, h);
 
-        mRS = createRenderScript(false);
+        mRS = createRenderScript(false, true);
         mRender = new FountainRS();
         mRender.init(mRS, getResources(), w, h);
     }
diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec
index 87ad97c..d7ae532 100644
--- a/libs/rs/rs.spec
+++ b/libs/rs/rs.spec
@@ -16,6 +16,10 @@
 	param RsProgramVertex pgm
 	}
 
+ContextBindProgramRaster {
+	param RsProgramRaster pgm
+	}
+
 ContextSetDefineF {
     param const char* name
     param float value
@@ -369,6 +373,24 @@
 	ret RsProgramFragmentStore
 	}
 
+ProgramRasterCreate {
+	param RsElement in
+	param RsElement out
+	param bool pointSmooth
+	param bool lineSmooth
+	param bool pointSprite
+	ret RsProgramRaster
+}
+
+ProgramRasterSetLineWidth {
+	param RsProgramRaster pr
+	param float lw
+}
+
+ProgramRasterSetPointSize{
+	param RsProgramRaster pr
+	param float ps
+}
 
 
 ProgramFragmentBegin {
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp
index 3e4c9af..ab8d0653 100644
--- a/libs/rs/rsContext.cpp
+++ b/libs/rs/rsContext.cpp
@@ -46,6 +46,12 @@
         configAttribsPtr += 2;
     }
 
+    if (mDev->mForceSW) {
+        configAttribsPtr[0] = EGL_CONFIG_CAVEAT;
+        configAttribsPtr[1] = EGL_SLOW_CONFIG;
+        configAttribsPtr += 2;
+    }
+
     configAttribsPtr[0] = EGL_NONE;
     rsAssert(configAttribsPtr < (configAttribs + (sizeof(configAttribs) / sizeof(EGLint))));
 
@@ -116,7 +122,7 @@
     eglQuerySurface(mEGL.mDisplay, mEGL.mSurface, EGL_HEIGHT, &mEGL.mHeight);
     glViewport(0, 0, mEGL.mWidth, mEGL.mHeight);
     glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
-    glEnable(GL_POINT_SMOOTH);
+    //glEnable(GL_POINT_SMOOTH);
 
     glClearColor(mRootScript->mEnviroment.mClearColor[0],
                  mRootScript->mEnviroment.mClearColor[1],
@@ -192,16 +198,10 @@
 
 void Context::setupCheck()
 {
-    if (mFragmentStore.get()) {
-        mFragmentStore->setupGL(this, &mStateFragmentStore);
-    }
-    if (mFragment.get()) {
-        mFragment->setupGL(this, &mStateFragment);
-    }
-    if (mVertex.get()) {
-        mVertex->setupGL(this, &mStateVertex);
-    }
-
+    mFragmentStore->setupGL(this, &mStateFragmentStore);
+    mFragment->setupGL(this, &mStateFragment);
+    mRaster->setupGL(this, &mStateRaster);
+    mVertex->setupGL(this, &mStateVertex);
 }
 
 
@@ -223,6 +223,8 @@
          LOGE("pthread_setspecific %i", status);
      }
 
+     rsc->mStateRaster.init(rsc, rsc->mEGL.mWidth, rsc->mEGL.mHeight);
+     rsc->setRaster(NULL);
      rsc->mStateVertex.init(rsc, rsc->mEGL.mWidth, rsc->mEGL.mHeight);
      rsc->setVertex(NULL);
      rsc->mStateFragment.init(rsc, rsc->mEGL.mWidth, rsc->mEGL.mHeight);
@@ -350,6 +352,15 @@
     }
 }
 
+void Context::setRaster(ProgramRaster *pr)
+{
+    if (pr == NULL) {
+        mRaster.set(mStateRaster.mDefault);
+    } else {
+        mRaster.set(pr);
+    }
+}
+
 void Context::allocationCheck(const Allocation *a)
 {
     mVertex->checkUpdatedAllocation(a);
@@ -519,6 +530,12 @@
     rsc->setFragment(pf);
 }
 
+void rsi_ContextBindProgramRaster(Context *rsc, RsProgramRaster vpr)
+{
+    ProgramRaster *pr = static_cast<ProgramRaster *>(vpr);
+    rsc->setRaster(pr);
+}
+
 void rsi_ContextBindProgramVertex(Context *rsc, RsProgramVertex vpv)
 {
     ProgramVertex *pv = static_cast<ProgramVertex *>(vpv);
diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h
index 634416b..3e07f3e 100644
--- a/libs/rs/rsContext.h
+++ b/libs/rs/rsContext.h
@@ -36,6 +36,7 @@
 #include "rsLight.h"
 #include "rsProgramFragment.h"
 #include "rsProgramFragmentStore.h"
+#include "rsProgramRaster.h"
 #include "rsProgramVertex.h"
 
 #include "rsgApiStructs.h"
@@ -65,6 +66,7 @@
     SamplerState mStateSampler;
     ProgramFragmentState mStateFragment;
     ProgramFragmentStoreState mStateFragmentStore;
+    ProgramRasterState mStateRaster;
     ProgramVertexState mStateVertex;
     LightState mStateLight;
 
@@ -74,6 +76,7 @@
 
     void swapBuffers();
     void setRootScript(Script *);
+    void setRaster(ProgramRaster *);
     void setVertex(ProgramVertex *);
     void setFragment(ProgramFragment *);
     void setFragmentStore(ProgramFragmentStore *);
@@ -82,6 +85,7 @@
 
     const ProgramFragment * getFragment() {return mFragment.get();}
     const ProgramFragmentStore * getFragmentStore() {return mFragmentStore.get();}
+    const ProgramRaster * getRaster() {return mRaster.get();}
     const ProgramVertex * getVertex() {return mVertex.get();}
 
     void setupCheck();
@@ -102,6 +106,9 @@
     ProgramFragmentStore * getDefaultProgramFragmentStore() const {
         return mStateFragmentStore.mDefault.get();
     }
+    ProgramRaster * getDefaultProgramRaster() const {
+        return mStateRaster.mDefault.get();
+    }
 
     void addInt32Define(const char* name, int32_t value) {
         mInt32Defines.add(String8(name), value);
@@ -172,6 +179,7 @@
     ObjectBaseRef<ProgramFragment> mFragment;
     ObjectBaseRef<ProgramVertex> mVertex;
     ObjectBaseRef<ProgramFragmentStore> mFragmentStore;
+    ObjectBaseRef<ProgramRaster> mRaster;
 
 
     struct ObjDestroyOOB {
diff --git a/libs/rs/rsDevice.cpp b/libs/rs/rsDevice.cpp
index 1b3c41b..b670ad4 100644
--- a/libs/rs/rsDevice.cpp
+++ b/libs/rs/rsDevice.cpp
@@ -22,6 +22,7 @@
 
 Device::Device()
 {
+    mForceSW = false;
 
 }
 
@@ -60,3 +61,13 @@
 
 }
 
+void rsDeviceSetConfig(RsDevice dev, RsDeviceParam p, int32_t value)
+{
+    Device * d = static_cast<Device *>(dev);
+    if (p == RS_DEVICE_PARAM_FORCE_SOFTWARE_GL) {
+        d->mForceSW = value != 0;
+        return;
+    }
+    rsAssert(0);
+}
+
diff --git a/libs/rs/rsDevice.h b/libs/rs/rsDevice.h
index 156315f..a8a4e77 100644
--- a/libs/rs/rsDevice.h
+++ b/libs/rs/rsDevice.h
@@ -33,6 +33,8 @@
     void addContext(Context *);
     void removeContext(Context *);
 
+    bool mForceSW;
+
 protected:
     Vector<Context *> mContexts;
 
diff --git a/libs/rs/rsProgramRaster.cpp b/libs/rs/rsProgramRaster.cpp
new file mode 100644
index 0000000..0f5ec51
--- /dev/null
+++ b/libs/rs/rsProgramRaster.cpp
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "rsContext.h"
+#include "rsProgramRaster.h"
+
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+
+using namespace android;
+using namespace android::renderscript;
+
+
+ProgramRaster::ProgramRaster(Element *in,
+                             Element *out,
+                             bool pointSmooth,
+                             bool lineSmooth,
+                             bool pointSprite) :
+    Program(in, out)
+{
+    mPointSmooth = pointSmooth;
+    mLineSmooth = lineSmooth;
+    mPointSprite = pointSprite;
+
+    mPointSize = 1.0f;
+    mLineWidth = 1.0f;
+}
+
+ProgramRaster::~ProgramRaster()
+{
+}
+
+void ProgramRaster::setLineWidth(float s)
+{
+    mLineWidth = s;
+}
+
+void ProgramRaster::setPointSize(float s)
+{
+    mPointSize = s;
+}
+
+void ProgramRaster::setupGL(const Context *rsc, ProgramRasterState *state)
+{
+    if (state->mLast.get() == this) {
+        return;
+    }
+    state->mLast.set(this);
+
+    LOGE("setup %i %i %i %f %f", mPointSmooth, mLineSmooth, mPointSprite, mPointSize, mLineWidth);
+
+    glPointSize(mPointSize);
+    if (mPointSmooth) {
+        glEnable(GL_POINT_SMOOTH);
+    } else {
+        glDisable(GL_POINT_SMOOTH);
+    }
+
+    glLineWidth(mLineWidth);
+    if (mLineSmooth) {
+        glEnable(GL_LINE_SMOOTH);
+    } else {
+        glEnable(GL_LINE_SMOOTH);
+    }
+
+    if (rsc->checkVersion1_1()) {
+        if (mPointSprite) {
+            glEnable(GL_POINT_SPRITE_OES);
+        } else {
+            glDisable(GL_POINT_SPRITE_OES);
+        }
+    }
+}
+
+
+
+ProgramRasterState::ProgramRasterState()
+{
+}
+
+ProgramRasterState::~ProgramRasterState()
+{
+}
+
+void ProgramRasterState::init(Context *rsc, int32_t w, int32_t h)
+{
+    ProgramRaster *pr = new ProgramRaster(NULL, NULL, false, false, false);
+    mDefault.set(pr);
+}
+
+
+namespace android {
+namespace renderscript {
+
+RsProgramRaster rsi_ProgramRasterCreate(Context * rsc, RsElement in, RsElement out,
+                                      bool pointSmooth,
+                                      bool lineSmooth,
+                                      bool pointSprite)
+{
+    ProgramRaster *pr = new ProgramRaster(static_cast<Element *>(in),
+                                          static_cast<Element *>(out),
+                                          pointSmooth,
+                                          lineSmooth,
+                                          pointSprite);
+    pr->incUserRef();
+    return pr;
+}
+
+void rsi_ProgramRasterSetPointSize(Context * rsc, RsProgramRaster vpr, float s)
+{
+    ProgramRaster *pr = static_cast<ProgramRaster *>(vpr);
+    pr->setPointSize(s);
+}
+
+void rsi_ProgramRasterSetLineWidth(Context * rsc, RsProgramRaster vpr, float s)
+{
+    ProgramRaster *pr = static_cast<ProgramRaster *>(vpr);
+    pr->setLineWidth(s);
+}
+
+
+}
+}
+
diff --git a/libs/rs/rsProgramRaster.h b/libs/rs/rsProgramRaster.h
new file mode 100644
index 0000000..5984868
--- /dev/null
+++ b/libs/rs/rsProgramRaster.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_RS_PROGRAM_RASTER_H
+#define ANDROID_RS_PROGRAM_RASTER_H
+
+#include "rsProgram.h"
+
+// ---------------------------------------------------------------------------
+namespace android {
+namespace renderscript {
+
+class ProgramRasterState;
+
+class ProgramRaster : public Program
+{
+public:
+    ProgramRaster(Element *in,
+                  Element *out,
+                  bool pointSmooth,
+                  bool lineSmooth,
+                  bool pointSprite);
+    virtual ~ProgramRaster();
+
+    virtual void setupGL(const Context *, ProgramRasterState *);
+
+    void setLineWidth(float w);
+    void setPointSize(float s);
+
+protected:
+    bool mPointSmooth;
+    bool mLineSmooth;
+    bool mPointSprite;
+
+    float mPointSize;
+    float mLineWidth;
+
+
+};
+
+class ProgramRasterState
+{
+public:
+    ProgramRasterState();
+    ~ProgramRasterState();
+    void init(Context *rsc, int32_t w, int32_t h);
+
+    ObjectBaseRef<ProgramRaster> mDefault;
+    ObjectBaseRef<ProgramRaster> mLast;
+};
+
+
+}
+}
+#endif
+
+
+
+