summaryrefslogtreecommitdiffstats
path: root/libs/hwui/AmbientShadow.cpp
diff options
context:
space:
mode:
authorChris Craik <ccraik@google.com>2014-07-23 17:21:25 -0700
committerChris Craik <ccraik@google.com>2014-07-24 17:49:23 +0000
commit9a89bc6524620c87c7a321433470c668e2b95d69 (patch)
tree56330712c30ea18aee3843316a33d7084f4d297f /libs/hwui/AmbientShadow.cpp
parent1b1f1b611c8e648b9737e7930e6982cf117134ce (diff)
downloadframeworks_base-9a89bc6524620c87c7a321433470c668e2b95d69.zip
frameworks_base-9a89bc6524620c87c7a321433470c668e2b95d69.tar.gz
frameworks_base-9a89bc6524620c87c7a321433470c668e2b95d69.tar.bz2
Compute layer bounds over subset of VertexBuffer verts
bug:15538815 Change-Id: I0dbb54f656a6ae99a87c5734761107e1c2351b65
Diffstat (limited to 'libs/hwui/AmbientShadow.cpp')
-rw-r--r--libs/hwui/AmbientShadow.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/libs/hwui/AmbientShadow.cpp b/libs/hwui/AmbientShadow.cpp
index b9d7b12..75cbfa1 100644
--- a/libs/hwui/AmbientShadow.cpp
+++ b/libs/hwui/AmbientShadow.cpp
@@ -48,7 +48,6 @@ void AmbientShadow::createAmbientShadow(bool isCasterOpaque,
const Vector3* vertices, int vertexCount, const Vector3& centroid3d,
float heightFactor, float geomFactor, VertexBuffer& shadowVertexBuffer) {
const int rays = SHADOW_RAY_COUNT;
- VertexBuffer::Mode mode = VertexBuffer::kOnePolyRingShadow;
// Validate the inputs.
if (vertexCount < 3 || heightFactor <= 0 || rays <= 0
|| geomFactor <= 0) {
@@ -124,19 +123,23 @@ void AmbientShadow::createAmbientShadow(bool isCasterOpaque,
opacity);
}
- // If caster isn't opaque, we need to to fill the umbra by storing the umbra's
- // centroid in the innermost ring of vertices.
- if (!isCasterOpaque) {
- mode = VertexBuffer::kTwoPolyRingShadow;
+ if (isCasterOpaque) {
+ // skip inner ring, calc bounds over filled portion of buffer
+ shadowVertexBuffer.computeBounds<AlphaVertex>(2 * rays);
+ shadowVertexBuffer.setMode(VertexBuffer::kOnePolyRingShadow);
+ } else {
+ // If caster isn't opaque, we need to to fill the umbra by storing the umbra's
+ // centroid in the innermost ring of vertices.
float centroidAlpha = 1.0 / (1 + centroid3d.z * heightFactor);
AlphaVertex centroidXYA;
AlphaVertex::set(&centroidXYA, centroid2d.x, centroid2d.y, centroidAlpha);
for (int rayIndex = 0; rayIndex < rays; rayIndex++) {
shadowVertices[2 * rays + rayIndex] = centroidXYA;
}
+ // calc bounds over entire buffer
+ shadowVertexBuffer.computeBounds<AlphaVertex>();
+ shadowVertexBuffer.setMode(VertexBuffer::kTwoPolyRingShadow);
}
- shadowVertexBuffer.setMode(mode);
- shadowVertexBuffer.computeBounds<AlphaVertex>();
#if DEBUG_SHADOW
for (int i = 0; i < SHADOW_VERTEX_COUNT; i++) {