summaryrefslogtreecommitdiff
path: root/libs/hwui/TextureCache.cpp
diff options
context:
space:
mode:
author John Reck <jreck@google.com> 2014-12-11 01:23:06 +0000
committer Android Git Automerger <android-git-automerger@android.com> 2014-12-11 01:23:06 +0000
commite4a6ed9d6d8721c9fad018b0d43dfe7daf4b24e7 (patch)
tree99aa756317f05265102236d812f303fe943f628a /libs/hwui/TextureCache.cpp
parentaaf2e190d363f5934e5bc2fd3293d41aa9ac00aa (diff)
parenteb2dcc791e649e07ec8114e00752b54965c46e65 (diff)
am eb2dcc79: Merge "Don\'t preload textures for AssetAtlas" into lmp-mr1-dev
* commit 'eb2dcc791e649e07ec8114e00752b54965c46e65': Don't preload textures for AssetAtlas
Diffstat (limited to 'libs/hwui/TextureCache.cpp')
-rw-r--r--libs/hwui/TextureCache.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/libs/hwui/TextureCache.cpp b/libs/hwui/TextureCache.cpp
index 5bad2fc43e6f..63454d8ef7c9 100644
--- a/libs/hwui/TextureCache.cpp
+++ b/libs/hwui/TextureCache.cpp
@@ -24,6 +24,7 @@
#include <utils/Mutex.h>
+#include "AssetAtlas.h"
#include "Caches.h"
#include "TextureCache.h"
#include "Properties.h"
@@ -39,7 +40,7 @@ namespace uirenderer {
TextureCache::TextureCache():
mCache(LruCache<uint32_t, Texture*>::kUnlimitedCapacity),
mSize(0), mMaxSize(MB(DEFAULT_TEXTURE_CACHE_SIZE)),
- mFlushRate(DEFAULT_TEXTURE_CACHE_FLUSH_RATE) {
+ mFlushRate(DEFAULT_TEXTURE_CACHE_FLUSH_RATE), mAssetAtlas(0) {
char property[PROPERTY_VALUE_MAX];
if (property_get(PROPERTY_TEXTURE_CACHE_SIZE, property, NULL) > 0) {
INIT_LOGD(" Setting texture cache size to %sMB", property);
@@ -62,7 +63,7 @@ TextureCache::TextureCache():
TextureCache::TextureCache(uint32_t maxByteSize):
mCache(LruCache<uint32_t, Texture*>::kUnlimitedCapacity),
- mSize(0), mMaxSize(maxByteSize) {
+ mSize(0), mMaxSize(maxByteSize), mAssetAtlas(0) {
init();
}
@@ -124,6 +125,10 @@ void TextureCache::operator()(uint32_t&, Texture*& texture) {
// Caching
///////////////////////////////////////////////////////////////////////////////
+void TextureCache::setAssetAtlas(AssetAtlas* assetAtlas) {
+ mAssetAtlas = assetAtlas;
+}
+
void TextureCache::resetMarkInUse() {
LruCache<uint32_t, Texture*>::Iterator iter(mCache);
while (iter.next()) {
@@ -143,6 +148,13 @@ bool TextureCache::canMakeTextureFromBitmap(const SkBitmap* bitmap) {
// Returns a prepared Texture* that either is already in the cache or can fit
// in the cache (and is thus added to the cache)
Texture* TextureCache::getCachedTexture(const SkBitmap* bitmap) {
+ if (CC_LIKELY(mAssetAtlas)) {
+ AssetAtlas::Entry* entry = mAssetAtlas->getEntry(bitmap);
+ if (CC_UNLIKELY(entry)) {
+ return entry->texture;
+ }
+ }
+
Texture* texture = mCache.get(bitmap->pixelRef()->getStableID());
if (!texture) {