Apply shaders/filters to text drop shadows.
Bug #4318323
This change also fixes the fact that shaders were not modulated
by the paint's color when drawing paths.
Change-Id: Id88804143aea06c895d4cbcdbe106d660230aa5a
diff --git a/libs/hwui/ProgramCache.cpp b/libs/hwui/ProgramCache.cpp
index b873bb8..80b1917 100644
--- a/libs/hwui/ProgramCache.cpp
+++ b/libs/hwui/ProgramCache.cpp
@@ -179,6 +179,8 @@
// General case
const char* gFS_Main_FetchColor =
" fragColor = color;\n";
+const char* gFS_Main_ModulateColor =
+ " fragColor *= color.a;\n";
const char* gFS_Main_AccountForWidth =
" if (distance < boundaryWidth) {\n"
" fragColor *= (distance * inverseBoundaryWidth);\n"
@@ -581,6 +583,7 @@
shader.append(gFS_Main_FetchBitmapNpot);
}
}
+ bool applyModulate = false;
// Case when we have two shaders set
if (description.hasGradient && description.hasBitmap) {
int op = description.hasAlpha8Texture ? MODULATE_OP_MODULATE_A8 : modulateOp;
@@ -590,15 +593,21 @@
shader.append(gFS_Main_BlendShadersGB);
}
shader.append(gFS_Main_BlendShaders_Modulate[op]);
+ applyModulate = true;
} else {
if (description.hasGradient) {
int op = description.hasAlpha8Texture ? MODULATE_OP_MODULATE_A8 : modulateOp;
shader.append(gFS_Main_GradientShader_Modulate[op]);
+ applyModulate = true;
} else if (description.hasBitmap) {
int op = description.hasAlpha8Texture ? MODULATE_OP_MODULATE_A8 : modulateOp;
shader.append(gFS_Main_BitmapShader_Modulate[op]);
+ applyModulate = true;
}
}
+ if (description.modulate && applyModulate) {
+ shader.append(gFS_Main_ModulateColor);
+ }
// Apply the color op if needed
shader.append(gFS_Main_ApplyColorOp[description.colorOp]);
// Output the fragment