Fixing asynchronous performance issues.

Change-Id: I10f02cd37a33a6c655814d24e0a4291dc044fba3
diff --git a/rsProgramRaster.h b/rsProgramRaster.h
index efdb948..09d7d54 100644
--- a/rsProgramRaster.h
+++ b/rsProgramRaster.h
@@ -27,19 +27,17 @@
 
 class ProgramRaster : public ProgramBase {
 public:
-    ProgramRaster(Context *rsc,
-                  bool pointSmooth,
-                  bool lineSmooth,
-                  bool pointSprite,
-                  float lineWidth,
-                  RsCullMode cull);
-    virtual ~ProgramRaster();
-
     virtual void setup(const Context *, ProgramRasterState *);
     virtual void serialize(OStream *stream) const;
     virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_RASTER; }
     static ProgramRaster *createFromStream(Context *rsc, IStream *stream);
 
+    static ObjectBaseRef<ProgramRaster> getProgramRaster(Context *rsc,
+                                                         bool pointSmooth,
+                                                         bool lineSmooth,
+                                                         bool pointSprite,
+                                                         float lineWidth,
+                                                         RsCullMode cull);
     struct Hal {
         mutable void *drv;
 
@@ -55,6 +53,17 @@
     Hal mHal;
 
 protected:
+    virtual void preDestroy() const;
+    virtual ~ProgramRaster();
+
+private:
+    ProgramRaster(Context *rsc,
+                  bool pointSmooth,
+                  bool lineSmooth,
+                  bool pointSprite,
+                  float lineWidth,
+                  RsCullMode cull);
+
 };
 
 class ProgramRasterState {
@@ -66,6 +75,9 @@
 
     ObjectBaseRef<ProgramRaster> mDefault;
     ObjectBaseRef<ProgramRaster> mLast;
+
+    // Cache of all existing raster programs.
+    Vector<ProgramRaster *> mRasterPrograms;
 };