diff options
author | 2012-07-20 11:36:03 -0700 | |
---|---|---|
committer | 2012-07-20 11:47:57 -0700 | |
commit | 8dcfd5e836341b4a803b04d104a930bb312182d3 (patch) | |
tree | cd2b75a4431f7ecfd869e007c5c15031e74298ed /libs/hwui/GradientCache.cpp | |
parent | 0aa87bbfc41e8b5f52de701ac17b4e66a7a7b609 (diff) |
Clamp gradient textures to max GL texture size
Change-Id: I8ce4e50988f5194fe5ce4bde7945ec01673af3cd
Diffstat (limited to 'libs/hwui/GradientCache.cpp')
-rw-r--r-- | libs/hwui/GradientCache.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/libs/hwui/GradientCache.cpp b/libs/hwui/GradientCache.cpp index 0016b8145fda..c7ab9c5ad5cd 100644 --- a/libs/hwui/GradientCache.cpp +++ b/libs/hwui/GradientCache.cpp @@ -16,8 +16,6 @@ #define LOG_TAG "OpenGLRenderer" -#include <GLES2/gl2.h> - #include <SkCanvas.h> #include <SkGradientShader.h> @@ -45,6 +43,8 @@ GradientCache::GradientCache(): INIT_LOGD(" Using default gradient cache size of %.2fMB", DEFAULT_GRADIENT_CACHE_SIZE); } + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize); + mCache.setOnEntryRemovedListener(this); } @@ -116,8 +116,11 @@ void GradientCache::clear() { Texture* GradientCache::addLinearGradient(GradientCacheEntry& gradient, uint32_t* colors, float* positions, int count, SkShader::TileMode tileMode) { + int width = 256 * (count - 1); + width = width < mMaxTextureSize ? width : mMaxTextureSize; + SkBitmap bitmap; - bitmap.setConfig(SkBitmap::kARGB_8888_Config, 256 * (count - 1), 1); + bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, 1); bitmap.allocPixels(); bitmap.eraseColor(0); |