diff options
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++) { |