diff options
author | Chris Craik <ccraik@google.com> | 2014-08-12 14:31:35 -0700 |
---|---|---|
committer | Chris Craik <ccraik@google.com> | 2014-08-12 16:00:09 -0700 |
commit | 91a8c7c62913c2597e3bf5a6d59d2ed5fc7ba4e0 (patch) | |
tree | 22f6e0e41bccc3df2b4b053a5decddabe5382c95 /libs/hwui/ProgramCache.cpp | |
parent | ddc122ee5015f9ca0cc124a53c175aadf85f50ad (diff) |
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
Diffstat (limited to 'libs/hwui/ProgramCache.cpp')
-rw-r--r-- | libs/hwui/ProgramCache.cpp | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/libs/hwui/ProgramCache.cpp b/libs/hwui/ProgramCache.cpp index 2dd89b857107..c802b183d41c 100644 --- a/libs/hwui/ProgramCache.cpp +++ b/libs/hwui/ProgramCache.cpp @@ -46,7 +46,7 @@ const char* gVS_Header_Attributes_TexCoords = "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 @@ const char* gVS_Header_Varyings_HasTexture = "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 @@ 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 = +const char* gVS_Main_VertexAlpha = " alpha = vtxAlpha;\n"; const char* gVS_Main_HasRoundRectClip = @@ -239,10 +237,10 @@ const char* gFS_Main_FetchColor = " 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 @@ String8 ProgramCache::generateVertexShader(const ProgramDescription& description 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 @@ String8 ProgramCache::generateVertexShader(const ProgramDescription& description 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 @@ String8 ProgramCache::generateVertexShader(const ProgramDescription& description } 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 @@ String8 ProgramCache::generateFragmentShader(const ProgramDescription& descripti 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 @@ String8 ProgramCache::generateFragmentShader(const ProgramDescription& descripti } // Optimization for common cases - if (!description.isAA + if (!description.hasVertexAlpha && !blendFramebuffer && !description.hasColors && description.colorOp == ProgramDescription::kColorNone @@ -759,11 +753,11 @@ String8 ProgramCache::generateFragmentShader(const ProgramDescription& descripti // 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); } } |