OSDN Git Service

Make umbra lighter when the blocker is too high and has no real umbra area.
authorTeng-Hui Zhu <ztenghui@google.com>
Mon, 3 Oct 2016 21:26:21 +0000 (14:26 -0700)
committerTeng-Hui Zhu <ztenghui@google.com>
Wed, 5 Oct 2016 00:26:09 +0000 (17:26 -0700)
b/31939390
Test: CTS testShadowLayout && Manual FrameworkShadow test

Change-Id: Ib0b6c4239ac8a521a827be246e912daf2ad3b885

libs/hwui/SpotShadow.cpp

index 760d814..cc96a13 100644 (file)
@@ -942,9 +942,13 @@ void SpotShadow::generateTriangleStrip(bool isCasterOpaque, float shadowStrength
         AlphaVertex::set(&shadowVertices[vertexBufferIndex++], newPenumbra[i].x,
                 newPenumbra[i].y, PENUMBRA_ALPHA);
     }
+    // Since the umbra can be a faked one when the occluder is too high, the umbra should be lighter
+    // in this case.
+    float scaledUmbraAlpha = UMBRA_ALPHA * shadowStrengthScale;
+
     for (int i = 0; i < umbraLength; i++) {
         AlphaVertex::set(&shadowVertices[vertexBufferIndex++], umbra[i].x, umbra[i].y,
-                UMBRA_ALPHA);
+                scaledUmbraAlpha);
     }
 
     for (int i = 0; i < verticesPairIndex; i++) {
@@ -984,14 +988,14 @@ void SpotShadow::generateTriangleStrip(bool isCasterOpaque, float shadowStrength
             indexBuffer[indexBufferIndex++] = newPenumbraLength + i;
             indexBuffer[indexBufferIndex++] = vertexBufferIndex;
             AlphaVertex::set(&shadowVertices[vertexBufferIndex++],
-                    closerVertex.x, closerVertex.y, UMBRA_ALPHA);
+                    closerVertex.x, closerVertex.y, scaledUmbraAlpha);
         }
     } else {
         // If there is no occluded umbra at all, then draw the triangle fan
         // starting from the centroid to all umbra vertices.
         int lastCentroidIndex = vertexBufferIndex;
         AlphaVertex::set(&shadowVertices[vertexBufferIndex++], centroid.x,
-                centroid.y, UMBRA_ALPHA);
+                centroid.y, scaledUmbraAlpha);
         for (int i = 0; i < umbraLength; i++) {
             indexBuffer[indexBufferIndex++] = newPenumbraLength + i;
             indexBuffer[indexBufferIndex++] = lastCentroidIndex;