summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorztenghui <ztenghui@google.com>2014-01-31 17:17:55 -0800
committerztenghui <ztenghui@google.com>2014-01-31 17:44:07 -0800
commit5176c974f1d9af833b7584e895fcba61e6e7427a (patch)
treee1321a70afad524605a683b29d808bc58bfb1e02 /libs
parentdb7516e3bd24589525c42b9b4761381b547dc3be (diff)
downloadframeworks_base-5176c974f1d9af833b7584e895fcba61e6e7427a.zip
frameworks_base-5176c974f1d9af833b7584e895fcba61e6e7427a.tar.gz
frameworks_base-5176c974f1d9af833b7584e895fcba61e6e7427a.tar.bz2
Fixing a bad bug when there is no real umbra
This fixed most of the issues when the light's Z postion is low. Change-Id: If49afbf8aa90b1ce32fd628a62ed982a1a473da2
Diffstat (limited to 'libs')
-rw-r--r--libs/hwui/SpotShadow.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/libs/hwui/SpotShadow.cpp b/libs/hwui/SpotShadow.cpp
index 5d489a7..389aa50 100644
--- a/libs/hwui/SpotShadow.cpp
+++ b/libs/hwui/SpotShadow.cpp
@@ -629,11 +629,9 @@ void SpotShadow::computeSpotShadow(const Vector3* lightPoly, int lightPolyLength
Vector2 penumbra[k];
int penumbraLength = hull(shadowRegion, shadowRegionLength, penumbra);
- // no real umbra make a fake one
+ Vector2 fakeUmbra[polyLength];
if (umbraLength < 3) {
- // The shadow from the centroid of the light polygon.
- Vector2 centShadow[polyLength];
-
+ // If there is no real umbra, make a fake one.
for (int i = 0; i < polyLength; i++) {
float t = lightCenter.z - poly[i].z;
if (t == 0) {
@@ -643,23 +641,23 @@ void SpotShadow::computeSpotShadow(const Vector3* lightPoly, int lightPolyLength
float x = lightCenter.x - t * (lightCenter.x - poly[i].x);
float y = lightCenter.y - t * (lightCenter.y - poly[i].y);
- centShadow[i].x = x;
- centShadow[i].y = y;
+ fakeUmbra[i].x = x;
+ fakeUmbra[i].y = y;
}
// Shrink the centroid's shadow by 10%.
// TODO: Study the magic number of 10%.
- Vector2 shadowCentroid = centroid2d(centShadow, polyLength);
+ Vector2 shadowCentroid = centroid2d(fakeUmbra, polyLength);
for (int i = 0; i < polyLength; i++) {
- centShadow[i] = shadowCentroid * (1.0f - SHADOW_SHRINK_SCALE) +
- centShadow[i] * SHADOW_SHRINK_SCALE;
+ fakeUmbra[i] = shadowCentroid * (1.0f - SHADOW_SHRINK_SCALE) +
+ fakeUmbra[i] * SHADOW_SHRINK_SCALE;
}
#if DEBUG_SHADOW
ALOGD("No real umbra make a fake one, centroid2d = %f , %f",
shadowCentroid.x, shadowCentroid.y);
#endif
// Set the fake umbra, whose size is the same as the original polygon.
- umbra = centShadow;
+ umbra = fakeUmbra;
umbraLength = polyLength;
}