Make error handling kill context activity. Add parameter validation.

bug 10427951

Change-Id: I4abba969e34903265b84ee88d6a90bc9b9df5481
diff --git a/cpp/rsCppStructs.h b/cpp/rsCppStructs.h
index f6cb1dd..ef354f8 100644
--- a/cpp/rsCppStructs.h
+++ b/cpp/rsCppStructs.h
@@ -48,6 +48,7 @@
      RS_SUCCESS = 0,
      RS_ERROR_INVALID_PARAMETER = 1,
      RS_ERROR_RUNTIME_ERROR = 2,
+     RS_ERROR_INVALID_ELEMENT = 3,
      RS_ERROR_MAX = 9999
 
  };
@@ -67,6 +68,7 @@
     MessageHandlerFunc_t getMessageHandler() { return mMessageFunc; }
 
     void throwError(RSError error, const char *errMsg);
+    RSError getError();
 
     RsContext getContext() { return mContext; }
 
@@ -322,6 +324,10 @@
         return mSizeBytes;
     }
 
+    uint32_t getVectorSize() const {
+        return mVectorSize;
+    }
+
     static sp<const Element> BOOLEAN(sp<RS> rs);
     static sp<const Element> U8(sp<RS> rs);
     static sp<const Element> I8(sp<RS> rs);
@@ -389,7 +395,7 @@
     static sp<const Element> createUser(sp<RS> rs, RsDataType dt);
     static sp<const Element> createVector(sp<RS> rs, RsDataType dt, uint32_t size);
     static sp<const Element> createPixel(sp<RS> rs, RsDataType dt, RsDataKind dk);
-    bool isCompatible(sp<const Element>e);
+    bool isCompatible(sp<const Element>e) const;
 
     Element(void *id, sp<RS> rs,
             std::vector<sp<Element> > &elements,
@@ -669,6 +675,7 @@
 
 class ScriptIntrinsic : public Script {
  protected:
+    sp<const Element> mElement;
     ScriptIntrinsic(sp<RS> rs, int id, sp<const Element> e);
     virtual ~ScriptIntrinsic();
 };
@@ -720,6 +727,7 @@
  public:
     static sp<ScriptIntrinsicColorMatrix> create(sp<RS> rs, sp<const Element> e);
     void forEach(sp<Allocation> in, sp<Allocation> out);
+    void setAdd(float* add);
     void setColorMatrix3(float* m);
     void setColorMatrix4(float* m);
     void setGreyscale();
@@ -750,8 +758,9 @@
 class ScriptIntrinsicHistogram : public ScriptIntrinsic {
  private:
     ScriptIntrinsicHistogram(sp<RS> rs, sp<const Element> e);
+    sp<Allocation> mOut;
  public:
-    static sp<ScriptIntrinsicHistogram> create(sp<RS> rs, sp<const Element> e);
+    static sp<ScriptIntrinsicHistogram> create(sp<RS> rs);
     void setOutput(sp<Allocation> aout);
     void setDotCoefficients(float r, float g, float b, float a);
     void forEach(sp<Allocation> ain);