summaryrefslogtreecommitdiff
path: root/libs/hwui/ProgramCache.cpp
diff options
context:
space:
mode:
authorChris Craik <ccraik@google.com>2014-09-16 17:32:13 -0700
committerChris Craik <ccraik@google.com>2014-09-17 10:00:34 -0700
commit73821c8d2bd453de6bf3f516e1f1cdb9a132f4a7 (patch)
treef77d9133dcf359aa2a1933d3894f8bce6a593c60 /libs/hwui/ProgramCache.cpp
parentc1e1550bf489b5fafff70154232c24bc5026b7df (diff)
Handle premultiplication correctly for ColorMatrixColorFilters
bug:17405627 Previously, the input content to the color matrix computation was left premultiplied. Since the color matrix could reduce the alpha channel, the alpha was re-multiplied, but this was incomplete, and incorrect. Instead, apply the color matrix in unpremultiplied space. Change-Id: I87b8e03d2e228e6ded81f7bbfea952605d7a095c
Diffstat (limited to 'libs/hwui/ProgramCache.cpp')
-rw-r--r--libs/hwui/ProgramCache.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/libs/hwui/ProgramCache.cpp b/libs/hwui/ProgramCache.cpp
index a8b8b16826a3..06353c096adc 100644
--- a/libs/hwui/ProgramCache.cpp
+++ b/libs/hwui/ProgramCache.cpp
@@ -327,8 +327,10 @@ const char* gFS_Main_ApplyColorOp[3] = {
// None
"",
// Matrix
+ " fragColor.rgb /= (fragColor.a + 0.0019);\n" // un-premultiply
" fragColor *= colorMatrix;\n"
- " fragColor += colorMatrixVector;\n",
+ " fragColor += colorMatrixVector;\n"
+ " fragColor.rgb *= (fragColor.a + 0.0019);\n", // re-premultiply
// PorterDuff
" fragColor = blendColors(colorBlend, fragColor);\n"
};