diff options
author | 2010-08-07 23:49:15 -0700 | |
---|---|---|
committer | 2010-08-07 23:49:15 -0700 | |
commit | 1ad7343409442a4a027c0092d07beff1b412a7dc (patch) | |
tree | 03181a0402d8728d64c1314406276333ace652e7 /libs/hwui/TextureCache.cpp | |
parent | a30e7e0b798eecf4d5ef7b3e2ce89a1edea3900d (diff) | |
parent | 9cccc2b9bdd4850a3f9679569aaec3ab98477a5d (diff) |
Merge "Enforce maximum texture size."
Diffstat (limited to 'libs/hwui/TextureCache.cpp')
-rw-r--r-- | libs/hwui/TextureCache.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libs/hwui/TextureCache.cpp b/libs/hwui/TextureCache.cpp index 59903b70a6a1..1cb593267ae4 100644 --- a/libs/hwui/TextureCache.cpp +++ b/libs/hwui/TextureCache.cpp @@ -31,6 +31,11 @@ TextureCache::TextureCache(uint32_t maxByteSize): mCache(GenerationCache<SkBitmap*, Texture*>::kUnlimitedCapacity), mSize(0), mMaxSize(maxByteSize) { mCache.setOnEntryRemovedListener(this); + + GLint maxTextureSize; + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize); + LOGD("Maximum texture dimension is %d pixels", maxTextureSize); + mMaxTextureSize = maxTextureSize; } TextureCache::~TextureCache() { @@ -79,6 +84,11 @@ void TextureCache::operator()(SkBitmap*& bitmap, Texture*& texture) { Texture* TextureCache::get(SkBitmap* bitmap) { Texture* texture = mCache.get(bitmap); if (!texture) { + if (bitmap->width() > mMaxTextureSize || bitmap->height() > mMaxTextureSize) { + LOGW("Bitmap too large to be uploaded into a texture"); + return NULL; + } + const uint32_t size = bitmap->rowBytes() * bitmap->height(); // Don't even try to cache a bitmap that's bigger than the cache if (size < mMaxSize) { |