diff options
Diffstat (limited to 'libs/hwui/VertexBuffer.h')
-rw-r--r-- | libs/hwui/VertexBuffer.h | 20 |
1 files changed, 20 insertions, 0 deletions
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 @@ public: 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 @@ public: } } + /** + * 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; } |