Rework shadow interpolation
bug:16852257
Use pow(alpha, 1.5) to avoid harsh edges on shadow alpha ramps.
Also adjusts shadow constants to compensate.
Change-Id: I5869956d7d292db2a8e496bc320084b6d64c3fb7
diff --git a/libs/hwui/ProgramCache.cpp b/libs/hwui/ProgramCache.cpp
index 3ef2a71..2dd89b8 100644
--- a/libs/hwui/ProgramCache.cpp
+++ b/libs/hwui/ProgramCache.cpp
@@ -121,8 +121,12 @@
const char* gVS_Main_Position =
" vec4 transformedPosition = projection * transform * position;\n"
" gl_Position = transformedPosition;\n";
+
+const char* gVS_Main_ShadowAAVertexShape =
+ " alpha = pow(vtxAlpha, 0.667);\n";
const char* gVS_Main_AAVertexShape =
" alpha = vtxAlpha;\n";
+
const char* gVS_Main_HasRoundRectClip =
" roundRectPos = (roundRectInvTransform * transformedPosition).xy;\n";
const char* gVS_Footer =
@@ -237,6 +241,8 @@
" fragColor *= color.a;\n";
const char* gFS_Main_AccountForAAVertexShape =
" fragColor *= alpha;\n";
+const char* gFS_Main_AccountForShadowAAVertexShape =
+ " fragColor *= pow(alpha, 1.5);\n";
const char* gFS_Main_FetchTexture[2] = {
// Don't modulate
@@ -515,7 +521,11 @@
shader.append(gVS_Main_OutTexCoords);
}
if (description.isAA) {
- shader.append(gVS_Main_AAVertexShape);
+ if (description.isShadowAA) {
+ shader.append(gVS_Main_ShadowAAVertexShape);
+ } else {
+ shader.append(gVS_Main_AAVertexShape);
+ }
}
if (description.hasColors) {
shader.append(gVS_Main_OutColors);
@@ -750,7 +760,11 @@
shader.append(gFS_Main_ApplyColorOp[description.colorOp]);
if (description.isAA) {
- shader.append(gFS_Main_AccountForAAVertexShape);
+ if (description.isShadowAA) {
+ shader.append(gFS_Main_AccountForShadowAAVertexShape);
+ } else {
+ shader.append(gFS_Main_AccountForAAVertexShape);
+ }
}
// Output the fragment