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
This commit is contained in:
Chris Craik
2014-09-16 17:32:13 -07:00
parent c1e1550bf4
commit 73821c8d2b
2 changed files with 5 additions and 1 deletions

View File

@ -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"
};