diff options
author | Romain Guy <romainguy@google.com> | 2013-04-12 16:32:05 -0700 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2013-04-12 16:32:05 -0700 |
commit | 95aeff8f11968c8b29ae114bb5e1172c70cf7634 (patch) | |
tree | d2c4cb1a5c7d043c703c6ac828a9d5abd9c6ded3 /libs/hwui/GradientCache.cpp | |
parent | e203384f1627f27c81ff72426498927fb9d80698 (diff) |
Properly computer gradient textures width
Only on devices that do not have the npot extension
Change-Id: I472a13dc707d2abaf5fcc06f99c9da343b333558
Diffstat (limited to 'libs/hwui/GradientCache.cpp')
-rw-r--r-- | libs/hwui/GradientCache.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libs/hwui/GradientCache.cpp b/libs/hwui/GradientCache.cpp index eef366c409f9..507ed958da68 100644 --- a/libs/hwui/GradientCache.cpp +++ b/libs/hwui/GradientCache.cpp @@ -148,8 +148,11 @@ void GradientCache::getGradientInfo(const uint32_t* colors, const int count, GradientInfo& info) { uint32_t width = 256 * (count - 1); - if (!mHasNpot) { - width = 1 << (31 - __builtin_clz(width)); + // If the npot extension is not supported we cannot use non-clamp + // wrap modes. We therefore find the nearest largest power of 2 + // unless width is already a power of 2 + if (!mHasNpot && (width & (width - 1)) != 0) { + width = 1 << (32 - __builtin_clz(width)); } bool hasAlpha = false; |