diff options
author | John Reck <jreck@google.com> | 2014-12-11 01:25:54 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2014-12-11 01:25:54 +0000 |
commit | d67bb5015f716c094beff02b2c5e77c9bb7d11a0 (patch) | |
tree | 4f23359e87a1bb079bd499f922d763e45c7a8752 /libs/hwui/DisplayListOp.h | |
parent | 934d8d85be221b86cb5097625c0f48391b3a71b2 (diff) | |
parent | e4a6ed9d6d8721c9fad018b0d43dfe7daf4b24e7 (diff) | |
download | frameworks_base-d67bb5015f716c094beff02b2c5e77c9bb7d11a0.zip frameworks_base-d67bb5015f716c094beff02b2c5e77c9bb7d11a0.tar.gz frameworks_base-d67bb5015f716c094beff02b2c5e77c9bb7d11a0.tar.bz2 |
am eb2dcc79: Merge "Don\'t preload textures for AssetAtlas" into lmp-mr1-dev
automerge: e4a6ed9
* commit 'e4a6ed9d6d8721c9fad018b0d43dfe7daf4b24e7':
Don't preload textures for AssetAtlas
Diffstat (limited to 'libs/hwui/DisplayListOp.h')
-rw-r--r-- | libs/hwui/DisplayListOp.h | 58 |
1 files changed, 25 insertions, 33 deletions
diff --git a/libs/hwui/DisplayListOp.h b/libs/hwui/DisplayListOp.h index 4afa2cf..2b05aa1 100644 --- a/libs/hwui/DisplayListOp.h +++ b/libs/hwui/DisplayListOp.h @@ -32,6 +32,7 @@ #include "AssetAtlas.h" #include "DeferredDisplayList.h" #include "DisplayListRenderer.h" +#include "RenderState.h" #include "UvMapper.h" #include "utils/LinearAllocator.h" @@ -647,24 +648,17 @@ public: DrawBitmapOp(const SkBitmap* bitmap, const SkPaint* paint) : DrawBoundedOp(0, 0, bitmap->width(), bitmap->height(), paint) , mBitmap(bitmap) - , mAtlas(Caches::getInstance().assetAtlas) { - mEntry = mAtlas.getEntry(bitmap); - if (mEntry) { - mEntryGenerationId = mAtlas.getGenerationId(); - mUvMapper = mEntry->uvMapper; - } + , mEntryValid(false), mEntry(NULL) { } virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& /* dirty */) { return renderer.drawBitmap(mBitmap, getPaint(renderer)); } - AssetAtlas::Entry* getAtlasEntry() { - // The atlas entry is stale, let's get a new one - if (mEntry && mEntryGenerationId != mAtlas.getGenerationId()) { - mEntryGenerationId = mAtlas.getGenerationId(); - mEntry = mAtlas.getEntry(mBitmap); - mUvMapper = mEntry->uvMapper; + AssetAtlas::Entry* getAtlasEntry(OpenGLRenderer& renderer) { + if (!mEntryValid) { + mEntryValid = true; + mEntry = renderer.renderState().assetAtlas().getEntry(mBitmap); } return mEntry; } @@ -700,7 +694,7 @@ public: pureTranslate &= state.mMatrix.isPureTranslate(); Rect texCoords(0, 0, 1, 1); - ((DrawBitmapOp*) ops[i].op)->mUvMapper.map(texCoords); + ((DrawBitmapOp*) ops[i].op)->uvMap(renderer, texCoords); SET_TEXTURE(vertex, opBounds, bounds, texCoords, left, top); SET_TEXTURE(vertex, opBounds, bounds, texCoords, right, top); @@ -729,7 +723,7 @@ public: virtual void onDefer(OpenGLRenderer& /* renderer */, DeferInfo& deferInfo, const DeferredDisplayState& state) { deferInfo.batchId = DeferredDisplayList::kOpBatch_Bitmap; - deferInfo.mergeId = getAtlasEntry() ? + deferInfo.mergeId = getAtlasEntry(renderer) ? (mergeid_t) mEntry->getMergeId() : (mergeid_t) mBitmap; // Don't merge non-simply transformed or neg scale ops, SET_TEXTURE doesn't handle rotation @@ -742,13 +736,17 @@ public: (mBitmap->colorType() != kAlpha_8_SkColorType); } + void uvMap(OpenGLRenderer& renderer, Rect& texCoords) { + if (getAtlasEntry(renderer)) { + mEntry->uvMapper.map(texCoords); + } + } + const SkBitmap* bitmap() { return mBitmap; } protected: const SkBitmap* mBitmap; - const AssetAtlas& mAtlas; - uint32_t mEntryGenerationId; + bool mEntryValid; AssetAtlas::Entry* mEntry; - UvMapper mUvMapper; }; class DrawBitmapRectOp : public DrawBoundedOp { @@ -841,18 +839,13 @@ public: float left, float top, float right, float bottom, const SkPaint* paint) : DrawBoundedOp(left, top, right, bottom, paint), mBitmap(bitmap), mPatch(patch), mGenerationId(0), mMesh(NULL), - mAtlas(Caches::getInstance().assetAtlas) { - mEntry = mAtlas.getEntry(bitmap); - if (mEntry) { - mEntryGenerationId = mAtlas.getGenerationId(); - } + mEntryValid(false), mEntry(NULL) { }; - AssetAtlas::Entry* getAtlasEntry() { - // The atlas entry is stale, let's get a new one - if (mEntry && mEntryGenerationId != mAtlas.getGenerationId()) { - mEntryGenerationId = mAtlas.getGenerationId(); - mEntry = mAtlas.getEntry(mBitmap); + AssetAtlas::Entry* getAtlasEntry(OpenGLRenderer& renderer) { + if (!mEntryValid) { + mEntryValid = true; + mEntry = renderer.renderState().assetAtlas().getEntry(mBitmap); } return mEntry; } @@ -860,7 +853,7 @@ public: const Patch* getMesh(OpenGLRenderer& renderer) { if (!mMesh || renderer.getCaches().patchCache.getGenerationId() != mGenerationId) { PatchCache& cache = renderer.getCaches().patchCache; - mMesh = cache.get(getAtlasEntry(), mBitmap->width(), mBitmap->height(), + mMesh = cache.get(getAtlasEntry(renderer), mBitmap->width(), mBitmap->height(), mLocalBounds.getWidth(), mLocalBounds.getHeight(), mPatch); mGenerationId = cache.getGenerationId(); } @@ -942,14 +935,14 @@ public: indexCount += opMesh->indexCount; } - return renderer.drawPatches(mBitmap, getAtlasEntry(), + return renderer.drawPatches(mBitmap, getAtlasEntry(renderer), &vertices[0], indexCount, getPaint(renderer)); } virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& /* dirty */) { // We're not calling the public variant of drawPatch() here // This method won't perform the quickReject() since we've already done it at this point - return renderer.drawPatch(mBitmap, getMesh(renderer), getAtlasEntry(), + return renderer.drawPatch(mBitmap, getMesh(renderer), getAtlasEntry(renderer), mLocalBounds.left, mLocalBounds.top, mLocalBounds.right, mLocalBounds.bottom, getPaint(renderer)); } @@ -964,7 +957,7 @@ public: virtual void onDefer(OpenGLRenderer& /* renderer */, DeferInfo& deferInfo, const DeferredDisplayState& state) { deferInfo.batchId = DeferredDisplayList::kOpBatch_Patch; - deferInfo.mergeId = getAtlasEntry() ? (mergeid_t) mEntry->getMergeId() : (mergeid_t) mBitmap; + deferInfo.mergeId = getAtlasEntry(renderer) ? (mergeid_t) mEntry->getMergeId() : (mergeid_t) mBitmap; deferInfo.mergeable = state.mMatrix.isPureTranslate() && OpenGLRenderer::getXfermodeDirect(mPaint) == SkXfermode::kSrcOver_Mode; deferInfo.opaqueOverBounds = isOpaqueOverBounds(state) && mBitmap->isOpaque(); @@ -977,8 +970,7 @@ private: uint32_t mGenerationId; const Patch* mMesh; - const AssetAtlas& mAtlas; - uint32_t mEntryGenerationId; + bool mEntryValid; AssetAtlas::Entry* mEntry; }; |