summaryrefslogtreecommitdiff
path: root/libs/hwui/TextureCache.cpp
diff options
context:
space:
mode:
author Romain Guy <romainguy@android.com> 2010-08-07 23:49:15 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2010-08-07 23:49:15 -0700
commit1ad7343409442a4a027c0092d07beff1b412a7dc (patch)
tree03181a0402d8728d64c1314406276333ace652e7 /libs/hwui/TextureCache.cpp
parenta30e7e0b798eecf4d5ef7b3e2ce89a1edea3900d (diff)
parent9cccc2b9bdd4850a3f9679569aaec3ab98477a5d (diff)
Merge "Enforce maximum texture size."
Diffstat (limited to 'libs/hwui/TextureCache.cpp')
-rw-r--r--libs/hwui/TextureCache.cpp10
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) {