diff options
author | Romain Guy <romainguy@google.com> | 2016-12-12 18:21:32 -0800 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2016-12-12 18:50:07 -0800 |
commit | a0ed6f03f6f06eb41cbcc15c0a99b4a78fd91bef (patch) | |
tree | f6eeb56420b457fe9955f21548ca12e6cf7ec68e /libs/hwui/ProgramCache.cpp | |
parent | 84cac20dfdff35932901e978e6b6d3da843a2fa7 (diff) |
Pre-multiply gradient colors the right way
Alpha pre-multiplication must be done after applying the
opto-electronic transfer function when linear blending is
disabled. The correct way would be to pre-multiply before
gamma encoding but this leads to improper blending which
cannot be corrected without using sRGB frame buffers and
texture sampling.
Bug: 33010587
Test: cts-tradefed run singleCommand cts-dev --module CtsUiRenderingTestCases --test android.uirendering.cts.testclasses.GradientTests
Change-Id: I5f04bda4cb9f63674537aef5931621c14d601884
Diffstat (limited to 'libs/hwui/ProgramCache.cpp')
-rw-r--r-- | libs/hwui/ProgramCache.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libs/hwui/ProgramCache.cpp b/libs/hwui/ProgramCache.cpp index 0c2309faf4ea..2688ba484212 100644 --- a/libs/hwui/ProgramCache.cpp +++ b/libs/hwui/ProgramCache.cpp @@ -175,10 +175,11 @@ const char* gFS_Gradient_Functions = const char* gFS_Gradient_Preamble[2] = { // Linear framebuffer "\nvec4 dither(const vec4 color) {\n" - " return vec4(color.rgb + (triangleNoise(gl_FragCoord.xy * screenSize.xy) / 255.0), color.a);" + " return vec4(color.rgb + (triangleNoise(gl_FragCoord.xy * screenSize.xy) / 255.0), color.a);\n" "}\n" "\nvec4 gammaMix(const vec4 a, const vec4 b, float v) {\n" - " return pow(mix(a, b, v), vec4(vec3(1.0 / 2.2), 1.0));" + " vec4 c = pow(mix(a, b, v), vec4(vec3(1.0 / 2.2), 1.0));\n" + " return vec4(c.rgb * c.a, c.a);\n" "}\n", // sRGB framebuffer "\nvec4 dither(const vec4 color) {\n" @@ -186,7 +187,8 @@ const char* gFS_Gradient_Preamble[2] = { " return vec4(dithered * dithered, color.a);\n" "}\n" "\nvec4 gammaMix(const vec4 a, const vec4 b, float v) {\n" - " return mix(a, b, v);" + " vec4 c = mix(a, b, v);\n" + " return vec4(c.rgb * c.a, c.a);\n" "}\n" }; |