diff options
author | Romain Guy <romainguy@google.com> | 2012-08-08 16:05:42 -0700 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2012-08-08 16:05:42 -0700 |
commit | 320d46bf844b84351cb80c5d4a4768d86447ac81 (patch) | |
tree | fee65370216aee9df6116a46ebae0edfd8de1272 /libs/hwui/GradientCache.cpp | |
parent | c89b14bba0f6cc2c91629080617f7ed215f697f3 (diff) |
Reduce gradients textures size whenever possible
Change-Id: Ifd58625ee62edac3b5d20b77553cb98b6fa2b46e
Diffstat (limited to 'libs/hwui/GradientCache.cpp')
-rw-r--r-- | libs/hwui/GradientCache.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libs/hwui/GradientCache.cpp b/libs/hwui/GradientCache.cpp index b1c4dfee2bb2..726b57c792bb 100644 --- a/libs/hwui/GradientCache.cpp +++ b/libs/hwui/GradientCache.cpp @@ -18,6 +18,7 @@ #include <utils/threads.h> +#include "Caches.h" #include "Debug.h" #include "GradientCache.h" #include "Properties.h" @@ -128,9 +129,13 @@ void GradientCache::clear() { void GradientCache::getGradientInfo(const uint32_t* colors, const int count, GradientInfo& info) { - uint32_t width = 1 << (31 - __builtin_clz(256 * (count - 1))); - bool hasAlpha = false; + uint32_t width = 256 * (count - 1); + + if (!Caches::getInstance().extensions.hasNPot()) { + width = 1 << (31 - __builtin_clz(width)); + } + bool hasAlpha = false; for (int i = 0; i < count; i++) { if (((colors[i] >> 24) & 0xff) < 255) { hasAlpha = true; |