summaryrefslogtreecommitdiff
path: root/libs/hwui/TextureCache.cpp
diff options
context:
space:
mode:
author Yohann Roussel <yroussel@google.com> 2014-12-11 11:10:50 +0100
committer Yohann Roussel <yroussel@google.com> 2014-12-11 11:10:50 +0100
commit59cf734f9ee8fa0154d199f0f36779a6ffe0dfb5 (patch)
treec57440c0cbe027e40c20e0ff9c233c45ca5c721e /libs/hwui/TextureCache.cpp
parent9f2d0d27ac2e30d641e26775761e2909fa863f9a (diff)
parentd67bb5015f716c094beff02b2c5e77c9bb7d11a0 (diff)
resolved conflicts for merge of d67bb501 to master
Change-Id: I40698ce1e382cb41eec7af5ea49ac0e2f997d555
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 3677face1743..8109433d8aed 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 "Texture.h"
#include "TextureCache.h"
@@ -40,7 +41,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);
@@ -63,7 +64,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();
}
@@ -125,6 +126,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()) {
@@ -144,6 +149,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) {