Switch to cos interpolation of shadow alpha
bug:16852257
Updates default shadow opacities to compensate.
Also, update variable/constant naming related to vertex alpha.
Change-Id: I9055b4ac3c9ac305ca9d515f21b52d6aa6dc9c5c
diff --git a/libs/hwui/ProgramCache.cpp b/libs/hwui/ProgramCache.cpp
index 2dd89b8..c802b18 100644
--- a/libs/hwui/ProgramCache.cpp
+++ b/libs/hwui/ProgramCache.cpp
@@ -46,7 +46,7 @@
"attribute vec2 texCoords;\n";
const char* gVS_Header_Attributes_Colors =
"attribute vec4 colors;\n";
-const char* gVS_Header_Attributes_AAVertexShapeParameters =
+const char* gVS_Header_Attributes_VertexAlphaParameters =
"attribute float vtxAlpha;\n";
const char* gVS_Header_Uniforms_TextureTransform =
"uniform mat4 mainTextureTransform;\n";
@@ -64,7 +64,7 @@
"varying vec2 outTexCoords;\n";
const char* gVS_Header_Varyings_HasColors =
"varying vec4 outColors;\n";
-const char* gVS_Header_Varyings_IsAAVertexShape =
+const char* gVS_Header_Varyings_HasVertexAlpha =
"varying float alpha;\n";
const char* gVS_Header_Varyings_HasBitmap =
"varying highp vec2 outBitmapTexCoords;\n";
@@ -122,9 +122,7 @@
" 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 =
+const char* gVS_Main_VertexAlpha =
" alpha = vtxAlpha;\n";
const char* gVS_Main_HasRoundRectClip =
@@ -239,10 +237,10 @@
" fragColor = color;\n";
const char* gFS_Main_ModulateColor =
" fragColor *= color.a;\n";
-const char* gFS_Main_AccountForAAVertexShape =
+const char* gFS_Main_ApplyVertexAlphaLinearInterp =
" fragColor *= alpha;\n";
-const char* gFS_Main_AccountForShadowAAVertexShape =
- " fragColor *= pow(alpha, 1.5);\n";
+const char* gFS_Main_ApplyVertexAlphaShadowInterp =
+ " fragColor *= (1.0 - cos(alpha)) / 2.0;\n";
const char* gFS_Main_FetchTexture[2] = {
// Don't modulate
@@ -473,8 +471,8 @@
if (description.hasTexture || description.hasExternalTexture) {
shader.append(gVS_Header_Attributes_TexCoords);
}
- if (description.isAA) {
- shader.append(gVS_Header_Attributes_AAVertexShapeParameters);
+ if (description.hasVertexAlpha) {
+ shader.append(gVS_Header_Attributes_VertexAlphaParameters);
}
if (description.hasColors) {
shader.append(gVS_Header_Attributes_Colors);
@@ -497,8 +495,8 @@
if (description.hasTexture || description.hasExternalTexture) {
shader.append(gVS_Header_Varyings_HasTexture);
}
- if (description.isAA) {
- shader.append(gVS_Header_Varyings_IsAAVertexShape);
+ if (description.hasVertexAlpha) {
+ shader.append(gVS_Header_Varyings_HasVertexAlpha);
}
if (description.hasColors) {
shader.append(gVS_Header_Varyings_HasColors);
@@ -520,12 +518,8 @@
} else if (description.hasTexture || description.hasExternalTexture) {
shader.append(gVS_Main_OutTexCoords);
}
- if (description.isAA) {
- if (description.isShadowAA) {
- shader.append(gVS_Main_ShadowAAVertexShape);
- } else {
- shader.append(gVS_Main_AAVertexShape);
- }
+ if (description.hasVertexAlpha) {
+ shader.append(gVS_Main_VertexAlpha);
}
if (description.hasColors) {
shader.append(gVS_Main_OutColors);
@@ -575,8 +569,8 @@
if (description.hasTexture || description.hasExternalTexture) {
shader.append(gVS_Header_Varyings_HasTexture);
}
- if (description.isAA) {
- shader.append(gVS_Header_Varyings_IsAAVertexShape);
+ if (description.hasVertexAlpha) {
+ shader.append(gVS_Header_Varyings_HasVertexAlpha);
}
if (description.hasColors) {
shader.append(gVS_Header_Varyings_HasColors);
@@ -617,7 +611,7 @@
}
// Optimization for common cases
- if (!description.isAA
+ if (!description.hasVertexAlpha
&& !blendFramebuffer
&& !description.hasColors
&& description.colorOp == ProgramDescription::kColorNone
@@ -759,11 +753,11 @@
// Apply the color op if needed
shader.append(gFS_Main_ApplyColorOp[description.colorOp]);
- if (description.isAA) {
- if (description.isShadowAA) {
- shader.append(gFS_Main_AccountForShadowAAVertexShape);
+ if (description.hasVertexAlpha) {
+ if (description.useShadowAlphaInterp) {
+ shader.append(gFS_Main_ApplyVertexAlphaShadowInterp);
} else {
- shader.append(gFS_Main_AccountForAAVertexShape);
+ shader.append(gFS_Main_ApplyVertexAlphaLinearInterp);
}
}