Improve performance of linear gradients.
Change-Id: If1caee31fc045dea13a4c5c10f25f2ffd325c4f8
diff --git a/libs/hwui/ProgramCache.cpp b/libs/hwui/ProgramCache.cpp
index 439e6fb..63e92a51 100644
--- a/libs/hwui/ProgramCache.cpp
+++ b/libs/hwui/ProgramCache.cpp
@@ -50,7 +50,7 @@
"varying vec2 outBitmapTexCoords;\n";
const char* gVS_Header_Varyings_HasGradient[3] = {
// Linear
- "varying float index;\n",
+ "varying vec2 linear;\n",
// Circular
"varying vec2 circular;\n",
// Sweep
@@ -62,7 +62,7 @@
" outTexCoords = texCoords;\n";
const char* gVS_Main_OutGradient[3] = {
// Linear
- " index = (screenSpace * position).x;\n",
+ " linear = vec2((screenSpace * position).x, 0.5);\n",
// Circular
" circular = (screenSpace * position).xy;\n",
// Sweep
@@ -121,7 +121,7 @@
" fragColor = color * texture2D(sampler, outTexCoords).a;\n";
const char* gFS_Main_FetchGradient[3] = {
// Linear
- " vec4 gradientColor = texture2D(gradientSampler, vec2(index, 0.5));\n",
+ " vec4 gradientColor = texture2D(gradientSampler, linear);\n",
// Circular
" float index = length(circular);\n"
" vec4 gradientColor = texture2D(gradientSampler, vec2(index, 0.5));\n",