From a938f569ce206c1ed68d736181016b5b708c0084 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Thu, 13 Sep 2012 20:31:08 -0700 Subject: Fix modulation and gamma correction issues Modulation is normally enabled in a shader when drawing with an alpha mask (A8 texture.) Modulation is used to do one of two things: - Colorize the primitive (to draw text in red for instance) - Apply extra translucency (50% translucent circle filled with a bitmap) The current implementation has four issues: 1. Unnecessary work is performed by assigning the modulation color to vec4 fragColor early in the shader 2. The modulation color's alpha is applied twice when the primitive is drawn with an SkShader 3. The decision to modulate is wrong and triggers when any of the RGB channels is < 1.0. Only the alpha channel needs to be taken into account to make the decision 4. Gamma correction is not applied properly This change addresses all four issues above. Change-Id: I73fcc74efc4b094bf2d1b835f10ffaa2ea4b9eb9 --- libs/hwui/Program.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'libs/hwui/Program.h') diff --git a/libs/hwui/Program.h b/libs/hwui/Program.h index a3bfaa43657d..a821a9cab5b6 100644 --- a/libs/hwui/Program.h +++ b/libs/hwui/Program.h @@ -204,8 +204,7 @@ struct ProgramDescription { * be provided with a modulation color. */ bool setColor(const float r, const float g, const float b, const float a) { - modulate = a < COLOR_COMPONENT_THRESHOLD || r < COLOR_COMPONENT_THRESHOLD || - g < COLOR_COMPONENT_THRESHOLD || b < COLOR_COMPONENT_THRESHOLD; + modulate = a < COLOR_COMPONENT_THRESHOLD; return modulate; } -- cgit v1.2.3-59-g8ed1b