diff options
author | Romain Guy <romainguy@google.com> | 2012-08-29 21:49:00 -0700 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2012-08-29 21:56:18 -0700 |
commit | d679b57ef279239cf11bb6c9bd14fb99b07971c9 (patch) | |
tree | 8755627bed9d9ffc8045cdd06e54d729f6cab5f3 /libs/hwui/GradientCache.cpp | |
parent | 2c577f1777a9227c581d41d5c08d674740e39ea9 (diff) |
Pre-multiply color components for 2-stop gradients
Bug #7033344
Change-Id: Ia168501f1dc56ba7a1bb0c55078320432309a66a
Diffstat (limited to 'libs/hwui/GradientCache.cpp')
-rw-r--r-- | libs/hwui/GradientCache.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/libs/hwui/GradientCache.cpp b/libs/hwui/GradientCache.cpp index 726b57c792bb..2e4e3492df03 100644 --- a/libs/hwui/GradientCache.cpp +++ b/libs/hwui/GradientCache.cpp @@ -217,10 +217,12 @@ void GradientCache::generateTexture(uint32_t* colors, float* positions, float amount = (pos - start) / distance; float oppAmount = 1.0f - amount; - *p++ = uint8_t(startR * oppAmount + endR * amount); - *p++ = uint8_t(startG * oppAmount + endG * amount); - *p++ = uint8_t(startB * oppAmount + endB * amount); - *p++ = uint8_t(startA * oppAmount + endA * amount); + const float alpha = startA * oppAmount + endA * amount; + const float a = alpha / 255.0f; + *p++ = uint8_t(a * (startR * oppAmount + endR * amount)); + *p++ = uint8_t(a * (startG * oppAmount + endG * amount)); + *p++ = uint8_t(a * (startB * oppAmount + endB * amount)); + *p++ = uint8_t(alpha); } for (int i = 1; i < GRADIENT_TEXTURE_HEIGHT; i++) { |