diff options
author | Romain Guy <romainguy@google.com> | 2013-08-07 01:36:24 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-08-07 01:36:24 +0000 |
commit | 271c719224d05f8a58d1d0cc6e1cf6c24a616b47 (patch) | |
tree | 2ccd6a170a3e5e8fc67db38d3fb61a5273f621ea | |
parent | 1377be0fb66b54de6646f05567e692509abde2bc (diff) | |
parent | 7f6d6b0370df4b5a9e0f45bffc31ea6caeeb509d (diff) | |
download | frameworks_base-271c719224d05f8a58d1d0cc6e1cf6c24a616b47.zip frameworks_base-271c719224d05f8a58d1d0cc6e1cf6c24a616b47.tar.gz frameworks_base-271c719224d05f8a58d1d0cc6e1cf6c24a616b47.tar.bz2 |
Merge "Split assets atlas batches Bug #10185769"
-rw-r--r-- | libs/hwui/AssetAtlas.cpp | 5 | ||||
-rw-r--r-- | libs/hwui/AssetAtlas.h | 17 | ||||
-rw-r--r-- | libs/hwui/DeferredDisplayList.h | 2 | ||||
-rw-r--r-- | libs/hwui/DisplayListOp.h | 4 |
4 files changed, 21 insertions, 7 deletions
diff --git a/libs/hwui/AssetAtlas.cpp b/libs/hwui/AssetAtlas.cpp index d98a538..eb8bb9f 100644 --- a/libs/hwui/AssetAtlas.cpp +++ b/libs/hwui/AssetAtlas.cpp @@ -100,6 +100,7 @@ struct DelegateTexture: public Texture { bool force = false, GLenum renderTarget = GL_TEXTURE_2D) { mDelegate->setFilterMinMag(min, mag, bindTexture, force, renderTarget); } + private: Texture* const mDelegate; }; // struct DelegateTexture @@ -125,12 +126,12 @@ void AssetAtlas::createEntries(Caches& caches, int* map, int count) { y / height, (y + bitmap->height()) / height); Texture* texture = new DelegateTexture(caches, mTexture); - Entry* entry = new Entry(bitmap, x, y, rotated, texture, mapper, *this); - texture->id = mTexture->id; texture->blend = !bitmap->isOpaque(); texture->width = bitmap->width(); texture->height = bitmap->height(); + + Entry* entry = new Entry(bitmap, x, y, rotated, texture, mapper, *this); texture->uvMapper = &entry->uvMapper; mEntries.add(entry->bitmap, entry); diff --git a/libs/hwui/AssetAtlas.h b/libs/hwui/AssetAtlas.h index 9afc54d..a28efc6 100644 --- a/libs/hwui/AssetAtlas.h +++ b/libs/hwui/AssetAtlas.h @@ -84,11 +84,20 @@ public: */ const AssetAtlas& atlas; + /** + * Unique identifier used to merge bitmaps and 9-patches stored + * in the atlas. + */ + const void* getMergeId() const { + return texture->blend ? &atlas.mBlendKey : &atlas.mOpaqueKey; + } + private: Entry(SkBitmap* bitmap, int x, int y, bool rotated, Texture* texture, const UvMapper& mapper, const AssetAtlas& atlas): bitmap(bitmap), x(x), y(y), rotated(rotated), - texture(texture), uvMapper(mapper), atlas(atlas) { } + texture(texture), uvMapper(mapper), atlas(atlas) { + } ~Entry() { delete texture; @@ -97,7 +106,8 @@ public: friend class AssetAtlas; }; - AssetAtlas(): mTexture(NULL), mImage(NULL), mGenerationId(0) { } + AssetAtlas(): mTexture(NULL), mImage(NULL), mGenerationId(0), + mBlendKey(true), mOpaqueKey(false) { } ~AssetAtlas() { terminate(); } /** @@ -173,6 +183,9 @@ private: uint32_t mGenerationId; + const bool mBlendKey; + const bool mOpaqueKey; + KeyedVector<SkBitmap*, Entry*> mEntries; }; // class AssetAtlas diff --git a/libs/hwui/DeferredDisplayList.h b/libs/hwui/DeferredDisplayList.h index 6c5a847..1ef0152 100644 --- a/libs/hwui/DeferredDisplayList.h +++ b/libs/hwui/DeferredDisplayList.h @@ -40,7 +40,7 @@ class Batch; class DrawBatch; class MergingDrawBatch; -typedef void* mergeid_t; +typedef const void* mergeid_t; class DeferredDisplayList { public: diff --git a/libs/hwui/DisplayListOp.h b/libs/hwui/DisplayListOp.h index 83de651..1b52b65 100644 --- a/libs/hwui/DisplayListOp.h +++ b/libs/hwui/DisplayListOp.h @@ -818,7 +818,7 @@ public: virtual void onDefer(OpenGLRenderer& renderer, DeferInfo& deferInfo) { deferInfo.batchId = DeferredDisplayList::kOpBatch_Bitmap; - deferInfo.mergeId = getAtlasEntry() ? (mergeid_t) &mEntry->atlas : (mergeid_t) mBitmap; + deferInfo.mergeId = getAtlasEntry() ? (mergeid_t) mEntry->getMergeId() : (mergeid_t) mBitmap; // Don't merge A8 bitmaps - the paint's color isn't compared by mergeId, or in // MergingDrawBatch::canMergeWith() @@ -1071,7 +1071,7 @@ public: virtual void onDefer(OpenGLRenderer& renderer, DeferInfo& deferInfo) { deferInfo.batchId = DeferredDisplayList::kOpBatch_Patch; - deferInfo.mergeId = getAtlasEntry() ? (mergeid_t) &mEntry->atlas : (mergeid_t) mBitmap; + deferInfo.mergeId = getAtlasEntry() ? (mergeid_t) mEntry->getMergeId() : (mergeid_t) mBitmap; deferInfo.mergeable = state.mMatrix.isPureTranslate() && OpenGLRenderer::getXfermodeDirect(mPaint) == SkXfermode::kSrcOver_Mode; deferInfo.opaqueOverBounds = isOpaqueOverBounds() && mBitmap->isOpaque(); |