From 669b15a93548b82135c73196665bcb7f03d87795 Mon Sep 17 00:00:00 2001 From: Derek Sollenberger Date: Fri, 31 Mar 2017 12:09:24 -0400 Subject: Fix HWUI/Skia Gradients to premultiply the colors prior to interpolation This is fixed in Skia by passing the appropriate flag when the shader is generated. The fix in HWUI is to reverse the premultiplication and interpolation steps. Test: bit CtsUiRenderingTestCases:.testclasses.ShaderTests Bug: 34323783 Change-Id: I3417141949f62fcc696b6d8213a4b446d7d0cbf8 --- libs/hwui/ProgramCache.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'libs/hwui/ProgramCache.cpp') diff --git a/libs/hwui/ProgramCache.cpp b/libs/hwui/ProgramCache.cpp index 1f78e09b5a58..d0f0949d5e78 100644 --- a/libs/hwui/ProgramCache.cpp +++ b/libs/hwui/ProgramCache.cpp @@ -295,10 +295,6 @@ const char* gFS_GradientPreamble[2] = { vec4 dither(const vec4 color) { return color + (triangleNoise(gl_FragCoord.xy * screenSize.xy) / 255.0); } - vec4 gradientMix(const vec4 a, const vec4 b, float v) { - vec4 c = mix(a, b, v); - return vec4(c.rgb * c.a, c.a); - } )__SHADER__", // sRGB framebuffer R"__SHADER__( @@ -306,10 +302,6 @@ const char* gFS_GradientPreamble[2] = { vec3 dithered = sqrt(color.rgb) + (triangleNoise(gl_FragCoord.xy * screenSize.xy) / 255.0); return vec4(dithered * dithered, color.a); } - vec4 gradientMixMix(const vec4 a, const vec4 b, float v) { - vec4 c = mix(a, b, v); - return vec4(c.rgb * c.a, c.a); - } )__SHADER__", }; @@ -364,19 +356,19 @@ const char* gFS_Main_FetchGradient[6] = { // Linear " vec4 gradientColor = texture2D(gradientSampler, linear);\n", - " vec4 gradientColor = gradientMix(startColor, endColor, clamp(linear, 0.0, 1.0));\n", + " vec4 gradientColor = mix(startColor, endColor, clamp(linear, 0.0, 1.0));\n", // Circular " vec4 gradientColor = texture2D(gradientSampler, vec2(length(circular), 0.5));\n", - " vec4 gradientColor = gradientMix(startColor, endColor, clamp(length(circular), 0.0, 1.0));\n", + " vec4 gradientColor = mix(startColor, endColor, clamp(length(circular), 0.0, 1.0));\n", // Sweep " highp float index = atan(sweep.y, sweep.x) * 0.15915494309; // inv(2 * PI)\n" " vec4 gradientColor = texture2D(gradientSampler, vec2(index - floor(index), 0.5));\n", " highp float index = atan(sweep.y, sweep.x) * 0.15915494309; // inv(2 * PI)\n" - " vec4 gradientColor = gradientMix(startColor, endColor, clamp(index - floor(index), 0.0, 1.0));\n" + " vec4 gradientColor = mix(startColor, endColor, clamp(index - floor(index), 0.0, 1.0));\n" }; const char* gFS_Main_FetchBitmap = " vec4 bitmapColor = colorConvert(texture2D(bitmapSampler, outBitmapTexCoords));\n"; -- cgit v1.2.3-59-g8ed1b