Moving renderscript GL code into the HAL
This change affects
 - shaders
 - meshes
 - fonts
 - quad rendering

Change-Id: I2a53acb4cd1fa8f4c6e67668f6ee969f3d7f7aa1
diff --git a/rsMesh.h b/rsMesh.h
index 3e080e2..1e279f4 100644
--- a/rsMesh.h
+++ b/rsMesh.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2011 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.
@@ -29,57 +29,65 @@
 class Mesh : public ObjectBase {
 public:
     Mesh(Context *);
+    Mesh(Context *, uint32_t vertexBuffersCount, uint32_t primitivesCount);
     ~Mesh();
 
-    // Contains vertex data
-    // Position, normal, texcoord, etc could either be strided in one allocation
-    // of provided separetely in multiple ones
-    ObjectBaseRef<Allocation> *mVertexBuffers;
-    uint32_t mVertexBufferCount;
-
     // 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
-    {
+    struct Primitive_t {
         ObjectBaseRef<Allocation> mIndexBuffer;
-
         RsPrimitive mPrimitive;
-        uint32_t mGLPrimitive;
     };
 
+    // compatibility to not break the build
+    ObjectBaseRef<Allocation> *mVertexBuffers;
+    uint32_t mVertexBufferCount;
     Primitive_t ** mPrimitives;
     uint32_t mPrimitivesCount;
+    // end compatibility
 
     virtual void serialize(OStream *stream) const;
     virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_MESH; }
     static Mesh *createFromStream(Context *rsc, IStream *stream);
+    void init();
 
-#ifndef ANDROID_RS_SERIALIZE
+    struct Hal {
+        mutable void *drv;
+
+        struct State {
+            // Contains vertex data
+            // Position, normal, texcoord, etc could either be strided in one allocation
+            // of provided separetely in multiple ones
+            ObjectBaseRef<Allocation> *vertexBuffers;
+            uint32_t vertexBuffersCount;
+
+            Primitive_t ** primitives;
+            uint32_t primitivesCount;
+        };
+        State state;
+    };
+    Hal mHal;
+
+    void setVertexBuffer(Allocation *vb, uint32_t index) {
+        mHal.state.vertexBuffers[index].set(vb);
+    }
+
+    void setPrimitive(Allocation *idx, RsPrimitive prim, uint32_t index) {
+        mHal.state.primitives[index]->mIndexBuffer.set(idx);
+        mHal.state.primitives[index]->mPrimitive = prim;
+    }
+
     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();
-
-
 
     // Bounding volumes
     float mBBoxMin[3];
     float mBBoxMax[3];
     void computeBBox();
-
-    void initVertexAttribs();
-
 protected:
-    bool isValidGLComponent(const Element *elem, uint32_t fieldIdx);
-    // Attribues that allow us to map to GL
-    VertexArray::Attrib *mAttribs;
-    // This allows us to figure out which allocation the attribute
-    // belongs to. In the event the allocation is uploaded to GL
-    // buffer, it lets us properly map it
-    uint32_t *mAttribAllocationIndex;
-    uint32_t mAttribCount;
-#endif
+    bool mInitialized;
 };
 
 class MeshContext {
@@ -92,7 +100,7 @@
 
 }
 }
-#endif //ANDROID_RS_TRIANGLE_MESH_H
+#endif //ANDROID_RS_MESH_H