Build layer damage bounds for shadows

bug:15538815

Change-Id: I703afeb7e31c28002bd1aff9ce448ec8cdc4e70d
diff --git a/libs/hwui/VertexBuffer.h b/libs/hwui/VertexBuffer.h
index 55d566b..5875f25 100644
--- a/libs/hwui/VertexBuffer.h
+++ b/libs/hwui/VertexBuffer.h
@@ -62,6 +62,8 @@
         mVertexCount = vertexCount;
         mByteCount = mVertexCount * sizeof(TYPE);
         mReallocBuffer = mBuffer = (void*)new TYPE[vertexCount];
+        memset(mBuffer, 0, sizeof(TYPE) * vertexCount);
+
         mCleanupMethod = &(cleanup<TYPE>);
 
         return (TYPE*)mBuffer;
@@ -79,6 +81,24 @@
         }
     }
 
+    /**
+     * Brute force bounds computation, used only if the producer of this
+     * vertex buffer can't determine bounds more simply/efficiently
+     */
+    template <class TYPE>
+    void computeBounds() {
+        if (!mVertexCount) {
+            mBounds.setEmpty();
+            return;
+        }
+        TYPE* current = (TYPE*)mBuffer;
+        TYPE* end = current + mVertexCount;
+        mBounds.set(current->x, current->y, current->x, current->y);
+        for (; current < end; current++) {
+            mBounds.expandToCoverVertex(current->x, current->y);
+        }
+    }
+
     const void* getBuffer() const { return mBuffer; }
     const Rect& getBounds() const { return mBounds; }
     unsigned int getVertexCount() const { return mVertexCount; }