summaryrefslogtreecommitdiffstats
path: root/libs/hwui/VertexBuffer.h
diff options
context:
space:
mode:
authorztenghui <ztenghui@google.com>2014-08-13 15:48:02 -0700
committerztenghui <ztenghui@google.com>2014-08-29 13:40:42 -0700
commitd5e8ade498b41b42874273cbfa375aed7b4d6a08 (patch)
treebb2a44cdafde4f5a350e1531f276765f5b8bd18d /libs/hwui/VertexBuffer.h
parentc50a03d78aaedd0003377e98710e7038bda330e9 (diff)
downloadframeworks_base-d5e8ade498b41b42874273cbfa375aed7b4d6a08.zip
frameworks_base-d5e8ade498b41b42874273cbfa375aed7b4d6a08.tar.gz
frameworks_base-d5e8ade498b41b42874273cbfa375aed7b4d6a08.tar.bz2
Ambient shadow tessellation improvement.
Using the vertices, instead of ray casting for the triangulation. This request a dynamic index buffer associated with vertex buffer, so we update the VertexBuffer to support it. The ambient shadow could be 3x-6x times faster for circle and rect now. b/16712006 b/14257173 Change-Id: I2f22a8fe19bc59acee5c18e4a3a395acd5042a66
Diffstat (limited to 'libs/hwui/VertexBuffer.h')
-rw-r--r--libs/hwui/VertexBuffer.h39
1 files changed, 38 insertions, 1 deletions
diff --git a/libs/hwui/VertexBuffer.h b/libs/hwui/VertexBuffer.h
index 3837f88..966fa4e 100644
--- a/libs/hwui/VertexBuffer.h
+++ b/libs/hwui/VertexBuffer.h
@@ -17,6 +17,7 @@
#ifndef ANDROID_HWUI_VERTEX_BUFFER_H
#define ANDROID_HWUI_VERTEX_BUFFER_H
+#include "utils/MathUtils.h"
namespace android {
namespace uirenderer {
@@ -26,19 +27,27 @@ public:
enum Mode {
kStandard = 0,
kOnePolyRingShadow = 1,
- kTwoPolyRingShadow = 2
+ kTwoPolyRingShadow = 2,
+ kIndices = 3
};
VertexBuffer()
: mBuffer(0)
+ , mIndices(0)
, mVertexCount(0)
+ , mIndexCount(0)
+ , mAllocatedVertexCount(0)
+ , mAllocatedIndexCount(0)
, mByteCount(0)
, mMode(kStandard)
+ , mReallocBuffer(0)
, mCleanupMethod(NULL)
+ , mCleanupIndexMethod(NULL)
{}
~VertexBuffer() {
if (mCleanupMethod) mCleanupMethod(mBuffer);
+ if (mCleanupIndexMethod) mCleanupIndexMethod(mIndices);
}
/**
@@ -59,6 +68,7 @@ public:
mReallocBuffer = reallocBuffer + vertexCount;
return reallocBuffer;
}
+ mAllocatedVertexCount = vertexCount;
mVertexCount = vertexCount;
mByteCount = mVertexCount * sizeof(TYPE);
mReallocBuffer = mBuffer = (void*)new TYPE[vertexCount];
@@ -69,6 +79,17 @@ public:
}
template <class TYPE>
+ TYPE* allocIndices(int indexCount) {
+ mAllocatedIndexCount = indexCount;
+ mIndexCount = indexCount;
+ mIndices = (void*)new TYPE[indexCount];
+
+ mCleanupIndexMethod = &(cleanup<TYPE>);
+
+ return (TYPE*)mIndices;
+ }
+
+ template <class TYPE>
void copyInto(const VertexBuffer& srcBuffer, float xOffset, float yOffset) {
int verticesToCopy = srcBuffer.getVertexCount();
@@ -103,9 +124,17 @@ public:
}
const void* getBuffer() const { return mBuffer; }
+ const void* getIndices() const { return mIndices; }
const Rect& getBounds() const { return mBounds; }
unsigned int getVertexCount() const { return mVertexCount; }
unsigned int getSize() const { return mByteCount; }
+ unsigned int getIndexCount() const { return mIndexCount; }
+ void updateIndexCount(unsigned int newCount) {
+ mIndexCount = MathUtils::min(newCount, mAllocatedIndexCount);
+ }
+ void updateVertexCount(unsigned int newCount) {
+ newCount = MathUtils::min(newCount, mAllocatedVertexCount);
+ }
Mode getMode() const { return mMode; }
void setBounds(Rect bounds) { mBounds = bounds; }
@@ -127,14 +156,22 @@ private:
}
Rect mBounds;
+
void* mBuffer;
+ void* mIndices;
+
unsigned int mVertexCount;
+ unsigned int mIndexCount;
+ unsigned int mAllocatedVertexCount;
+ unsigned int mAllocatedIndexCount;
unsigned int mByteCount;
+
Mode mMode;
void* mReallocBuffer; // used for multi-allocation
void (*mCleanupMethod)(void*);
+ void (*mCleanupIndexMethod)(void*);
};
}; // namespace uirenderer