summaryrefslogtreecommitdiff
path: root/libs/hwui/ProgramCache.cpp
diff options
context:
space:
mode:
authorChris Craik <ccraik@google.com>2014-08-11 16:00:44 -0700
committerChris Craik <ccraik@google.com>2014-08-12 12:44:59 -0700
commitbf75945e7a1ae7c1000682716643c942c1e19ba6 (patch)
tree5be8c8acfb85bb0a6077691e2c0255232cace2ae /libs/hwui/ProgramCache.cpp
parentc28aceb11e736382bc7ee749483ea5f23299ad78 (diff)
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
Diffstat (limited to 'libs/hwui/ProgramCache.cpp')
-rw-r--r--libs/hwui/ProgramCache.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/libs/hwui/ProgramCache.cpp b/libs/hwui/ProgramCache.cpp
index 3ef2a716905d..2dd89b857107 100644
--- a/libs/hwui/ProgramCache.cpp
+++ b/libs/hwui/ProgramCache.cpp
@@ -121,8 +121,12 @@ const char* gVS_Main_OutBitmapTexCoords =
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 @@ const char* gFS_Main_ModulateColor =
" 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 @@ String8 ProgramCache::generateVertexShader(const ProgramDescription& description
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 @@ String8 ProgramCache::generateFragmentShader(const ProgramDescription& descripti
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