summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chris Craik <ccraik@google.com> 2015-07-18 01:05:25 +0000
committer Android Git Automerger <android-git-automerger@android.com> 2015-07-18 01:05:25 +0000
commit011550e1f2f20e66c429c2d854dcaf18c1f6c30c (patch)
tree580bd7b4b9540c25b3369655e072ea01eb64d444
parentef53ecbfd37220254bd9b458ab2d675c856fa176 (diff)
parent3699c60323aca45eb0e385d6b4a27bd5861fadf2 (diff)
am 3699c603: am 62a2696c: am fbd2d949: am b6e41a08: am 0bb5c26b: Merge "Fix AssetAtlas usage in BitmapShaders" into mnc-dev
* commit '3699c60323aca45eb0e385d6b4a27bd5861fadf2': Fix AssetAtlas usage in BitmapShaders
-rw-r--r--libs/hwui/SkiaShader.cpp8
-rw-r--r--libs/hwui/TextureCache.cpp10
-rw-r--r--libs/hwui/TextureCache.h23
3 files changed, 31 insertions, 10 deletions
diff --git a/libs/hwui/SkiaShader.cpp b/libs/hwui/SkiaShader.cpp
index 6b5eb41300d2..1f959469fb56 100644
--- a/libs/hwui/SkiaShader.cpp
+++ b/libs/hwui/SkiaShader.cpp
@@ -201,7 +201,13 @@ bool tryStoreBitmap(Caches& caches, const SkShader& shader, const Matrix4& model
return false;
}
- outData->bitmapTexture = caches.textureCache.get(&bitmap);
+ /*
+ * Bypass the AssetAtlas, since those textures:
+ * 1) require UV mapping, which isn't implemented in matrix computation below
+ * 2) can't handle REPEAT simply
+ * 3) are safe to upload here (outside of sync stage), since they're static
+ */
+ outData->bitmapTexture = caches.textureCache.getAndBypassAtlas(&bitmap);
if (!outData->bitmapTexture) return false;
outData->bitmapSampler = (*textureUnit)++;
diff --git a/libs/hwui/TextureCache.cpp b/libs/hwui/TextureCache.cpp
index 5b57c9186a3f..386da72e0557 100644
--- a/libs/hwui/TextureCache.cpp
+++ b/libs/hwui/TextureCache.cpp
@@ -137,8 +137,8 @@ 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)) {
+Texture* TextureCache::getCachedTexture(const SkBitmap* bitmap, AtlasUsageType atlasUsageType) {
+ if (CC_LIKELY(mAssetAtlas != nullptr) && atlasUsageType == AtlasUsageType::Use) {
AssetAtlas::Entry* entry = mAssetAtlas->getEntry(bitmap);
if (CC_UNLIKELY(entry)) {
return entry->texture;
@@ -187,15 +187,15 @@ Texture* TextureCache::getCachedTexture(const SkBitmap* bitmap) {
}
bool TextureCache::prefetchAndMarkInUse(const SkBitmap* bitmap) {
- Texture* texture = getCachedTexture(bitmap);
+ Texture* texture = getCachedTexture(bitmap, AtlasUsageType::Use);
if (texture) {
texture->isInUse = true;
}
return texture;
}
-Texture* TextureCache::get(const SkBitmap* bitmap) {
- Texture* texture = getCachedTexture(bitmap);
+Texture* TextureCache::get(const SkBitmap* bitmap, AtlasUsageType atlasUsageType) {
+ Texture* texture = getCachedTexture(bitmap, atlasUsageType);
if (!texture) {
if (!canMakeTextureFromBitmap(bitmap)) {
diff --git a/libs/hwui/TextureCache.h b/libs/hwui/TextureCache.h
index e7fc990a6588..83c6e91ec55c 100644
--- a/libs/hwui/TextureCache.h
+++ b/libs/hwui/TextureCache.h
@@ -76,10 +76,20 @@ public:
bool prefetchAndMarkInUse(const SkBitmap* bitmap);
/**
- * Returns the texture associated with the specified bitmap. If the texture
- * cannot be found in the cache, a new texture is generated.
+ * Returns the texture associated with the specified bitmap from either within the cache, or
+ * the AssetAtlas. If the texture cannot be found in the cache, a new texture is generated.
*/
- Texture* get(const SkBitmap* bitmap);
+ Texture* get(const SkBitmap* bitmap) {
+ return get(bitmap, AtlasUsageType::Use);
+ }
+
+ /**
+ * Returns the texture associated with the specified bitmap. If the texture cannot be found in
+ * the cache, a new texture is generated, even if it resides in the AssetAtlas.
+ */
+ Texture* getAndBypassAtlas(const SkBitmap* bitmap) {
+ return get(bitmap, AtlasUsageType::Bypass);
+ }
/**
* Removes the texture associated with the specified pixelRef. This is meant
@@ -123,10 +133,15 @@ public:
void setAssetAtlas(AssetAtlas* assetAtlas);
private:
+ enum class AtlasUsageType {
+ Use,
+ Bypass,
+ };
bool canMakeTextureFromBitmap(const SkBitmap* bitmap);
- Texture* getCachedTexture(const SkBitmap* bitmap);
+ Texture* get(const SkBitmap* bitmap, AtlasUsageType atlasUsageType);
+ Texture* getCachedTexture(const SkBitmap* bitmap, AtlasUsageType atlasUsageType);
/**
* Generates the texture from a bitmap into the specified texture structure.