Tessellate on worker threads

Tessellate and cache (where possible) shadow and round rect
tessellation tasks.

Change-Id: I2cfda8e11d83d51ea74af871235cf26e8f831d40
diff --git a/libs/hwui/VertexBuffer.h b/libs/hwui/VertexBuffer.h
index 8b6872e..55d566b 100644
--- a/libs/hwui/VertexBuffer.h
+++ b/libs/hwui/VertexBuffer.h
@@ -23,10 +23,18 @@
 
 class VertexBuffer {
 public:
-    VertexBuffer():
-        mBuffer(0),
-        mVertexCount(0),
-        mCleanupMethod(NULL)
+    enum Mode {
+        kStandard = 0,
+        kOnePolyRingShadow = 1,
+        kTwoPolyRingShadow = 2
+    };
+
+    VertexBuffer()
+            : mBuffer(0)
+            , mVertexCount(0)
+            , mByteCount(0)
+            , mMode(kStandard)
+            , mCleanupMethod(NULL)
     {}
 
     ~VertexBuffer() {
@@ -37,7 +45,7 @@
        This should be the only method used by the Tessellator. Subsequent calls to
        alloc will allocate space within the first allocation (useful if you want to
        eventually allocate multiple regions within a single VertexBuffer, such as
-       with PathTessellator::tesselateLines())
+       with PathTessellator::tessellateLines())
      */
     template <class TYPE>
     TYPE* alloc(int vertexCount) {
@@ -52,6 +60,7 @@
             return reallocBuffer;
         }
         mVertexCount = vertexCount;
+        mByteCount = mVertexCount * sizeof(TYPE);
         mReallocBuffer = mBuffer = (void*)new TYPE[vertexCount];
         mCleanupMethod = &(cleanup<TYPE>);
 
@@ -71,7 +80,13 @@
     }
 
     const void* getBuffer() const { return mBuffer; }
+    const Rect& getBounds() const { return mBounds; }
     unsigned int getVertexCount() const { return mVertexCount; }
+    unsigned int getSize() const { return mByteCount; }
+    Mode getMode() const { return mMode; }
+
+    void setBounds(Rect bounds) { mBounds = bounds; }
+    void setMode(Mode mode) { mMode = mode; }
 
     template <class TYPE>
     void createDegenerateSeparators(int allocSize) {
@@ -88,8 +103,11 @@
         delete[] (TYPE*)buffer;
     }
 
+    Rect mBounds;
     void* mBuffer;
     unsigned int mVertexCount;
+    unsigned int mByteCount;
+    Mode mMode;
 
     void* mReallocBuffer; // used for multi-allocation