summaryrefslogtreecommitdiff
path: root/libs/hwui/ProgramCache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/hwui/ProgramCache.cpp')
-rw-r--r--libs/hwui/ProgramCache.cpp44
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);
}
}