Use pre-computed index to draw the shadow.
Also draw the umbra part as triangle fans instead of zig zag fashion.
b/12840179
Change-Id: Iaa5d15e77351acdd71f076bd8f9bb2d4d2b92faf
diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp
index 21cf658..1d58d96 100644
--- a/libs/hwui/Caches.cpp
+++ b/libs/hwui/Caches.cpp
@@ -23,6 +23,7 @@
#include "DisplayListRenderer.h"
#include "Properties.h"
#include "LayerRenderer.h"
+#include "ShadowTessellator.h"
namespace android {
@@ -86,7 +87,7 @@
mRegionMesh = NULL;
mMeshIndices = 0;
-
+ mShadowStripsIndices = 0;
blend = false;
lastSrcMode = GL_ZERO;
lastDstMode = GL_ZERO;
@@ -223,6 +224,9 @@
mMeshIndices = 0;
mRegionMesh = NULL;
+ glDeleteBuffers(1, &mShadowStripsIndices);
+ mShadowStripsIndices = 0;
+
fboCache.clear();
programCache.clear();
@@ -404,7 +408,7 @@
return false;
}
-bool Caches::bindIndicesBuffer(const GLuint buffer) {
+bool Caches::bindIndicesBufferInternal(const GLuint buffer) {
if (mCurrentIndicesBuffer != buffer) {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer);
mCurrentIndicesBuffer = buffer;
@@ -413,7 +417,7 @@
return false;
}
-bool Caches::bindIndicesBuffer() {
+bool Caches::bindQuadIndicesBuffer() {
if (!mMeshIndices) {
uint16_t* regionIndices = new uint16_t[gMaxNumberOfQuads * 6];
for (uint32_t i = 0; i < gMaxNumberOfQuads; i++) {
@@ -428,7 +432,7 @@
}
glGenBuffers(1, &mMeshIndices);
- bool force = bindIndicesBuffer(mMeshIndices);
+ bool force = bindIndicesBufferInternal(mMeshIndices);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, gMaxNumberOfQuads * 6 * sizeof(uint16_t),
regionIndices, GL_STATIC_DRAW);
@@ -436,7 +440,23 @@
return force;
}
- return bindIndicesBuffer(mMeshIndices);
+ return bindIndicesBufferInternal(mMeshIndices);
+}
+
+bool Caches::bindShadowIndicesBuffer() {
+ if (!mShadowStripsIndices) {
+ uint16_t* shadowIndices = new uint16_t[SHADOW_INDEX_COUNT];
+ ShadowTessellator::generateShadowIndices(shadowIndices);
+ glGenBuffers(1, &mShadowStripsIndices);
+ bool force = bindIndicesBufferInternal(mShadowStripsIndices);
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, SHADOW_INDEX_COUNT * sizeof(uint16_t),
+ shadowIndices, GL_STATIC_DRAW);
+
+ delete[] shadowIndices;
+ return force;
+ }
+
+ return bindIndicesBufferInternal(mShadowStripsIndices);
}
bool Caches::unbindIndicesBuffer() {