Start of mesh API cleanup.
Switched all native code to go through Mesh class.
Removed SimpleMesh
Added java Mesh class
Will need to port all existing code to use java Mesh, then remove java SimpleMesh.

Change-Id: Idb9c03d0b06b4ef87db28dffcffa1881d39120e5
diff --git a/rsMesh.h b/rsMesh.h
index 8c7e8a4..66174b7 100644
--- a/rsMesh.h
+++ b/rsMesh.h
@@ -32,43 +32,35 @@
     Mesh(Context *);
     ~Mesh();
 
-    struct Verticies_t
-    {
-        Allocation ** mAllocations;
-        uint32_t mAllocationCount;
+    // Contains vertex data
+    // Position, normal, texcoord, etc could either be strided in one allocation
+    // of provided separetely in multiple ones
+    ObjectBaseRef<Allocation> *mVertexBuffers;
+    ObjectBaseRef<const Type> *mVertexTypes;
+    uint32_t mVertexBufferCount;
 
-        size_t mVertexDataSize;
-
-        size_t mOffsetCoord;
-        size_t mOffsetTex;
-        size_t mOffsetNorm;
-
-        size_t mSizeCoord;
-        size_t mSizeTex;
-        size_t mSizeNorm;
-
-        uint32_t mBufferObject;
-    };
-
+    // Either mIndexBuffer, mPrimitiveBuffer or both could have a NULL reference
+    // If both are null, mPrimitive only would be used to render the mesh
     struct Primitive_t
     {
-        RsPrimitive mType;
-        Verticies_t *mVerticies;
+        ObjectBaseRef<Allocation> mIndexBuffer;
+        ObjectBaseRef<Allocation> mPrimitiveBuffer;
+        ObjectBaseRef<const Type> mIndexType;
+        ObjectBaseRef<const Type> mPrimitiveType;
 
-        uint32_t mIndexCount;
-        uint16_t *mIndicies;
-
-        uint32_t mRestartCounts;
-        uint16_t *mRestarts;
+        RsPrimitive mPrimitive;
+        uint32_t mGLPrimitive;
     };
 
-    Verticies_t ** mVerticies;
-    uint32_t mVerticiesCount;
-
     Primitive_t ** mPrimitives;
     uint32_t mPrimitivesCount;
 
-    void analyzeElement();
+    void render(Context *) const;
+    void renderPrimitive(Context *, uint32_t primIndex) const;
+    void renderPrimitiveRange(Context *, uint32_t primIndex, uint32_t start, uint32_t len) const;
+    void uploadAll(Context *);
+    void updateGLPrimitives();
+
     virtual void serialize(OStream *stream) const;
     virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_MESH; }
     static Mesh *createFromStream(Context *rsc, IStream *stream);
@@ -90,3 +82,4 @@
 #endif //ANDROID_RS_TRIANGLE_MESH_H
 
 
+