Loading libs/hwui/RenderNode.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -214,10 +214,10 @@ void RenderNode::pushLayerUpdate(TreeInfo& info) { info.renderer->pushLayerUpdate(mLayer); } if (CC_UNLIKELY(info.canvasContext)) { // If canvasContext is not null that means there are prefetched layers // that need to be accounted for. That might be us, so tell CanvasContext // that this layer is in the tree and should not be destroyed. if (info.canvasContext) { // There might be prefetched layers that need to be accounted for. // That might be us, so tell CanvasContext that this layer is in the // tree and should not be destroyed. info.canvasContext->markLayerInUse(this); } } Loading Loading @@ -339,7 +339,8 @@ void RenderNode::prepareSubTree(TreeInfo& info, bool functorsNeedLayer, DisplayL TextureCache& cache = Caches::getInstance().textureCache; info.out.hasFunctors |= subtree->functors.size(); for (size_t i = 0; info.prepareTextures && i < subtree->bitmapResources.size(); i++) { info.prepareTextures = cache.prefetchAndMarkInUse(subtree->bitmapResources[i]); info.prepareTextures = cache.prefetchAndMarkInUse( info.canvasContext, subtree->bitmapResources[i]); } for (size_t i = 0; i < subtree->children().size(); i++) { DrawRenderNodeOp* op = subtree->children()[i]; Loading libs/hwui/Texture.h +1 −1 Original line number Diff line number Diff line Loading @@ -97,7 +97,7 @@ public: * Whether or not the Texture is marked in use and thus not evictable for * the current frame. This is reset at the start of a new frame. */ bool isInUse = false; void* isInUse = nullptr; private: /** Loading libs/hwui/TextureCache.cpp +6 −4 Original line number Diff line number Diff line Loading @@ -122,10 +122,12 @@ void TextureCache::setAssetAtlas(AssetAtlas* assetAtlas) { mAssetAtlas = assetAtlas; } void TextureCache::resetMarkInUse() { void TextureCache::resetMarkInUse(void* ownerToken) { LruCache<uint32_t, Texture*>::Iterator iter(mCache); while (iter.next()) { iter.value()->isInUse = false; if (iter.value()->isInUse == ownerToken) { iter.value()->isInUse = nullptr; } } } Loading Loading @@ -189,10 +191,10 @@ Texture* TextureCache::getCachedTexture(const SkBitmap* bitmap, AtlasUsageType a return texture; } bool TextureCache::prefetchAndMarkInUse(const SkBitmap* bitmap) { bool TextureCache::prefetchAndMarkInUse(void* ownerToken, const SkBitmap* bitmap) { Texture* texture = getCachedTexture(bitmap, AtlasUsageType::Use); if (texture) { texture->isInUse = true; texture->isInUse = ownerToken; } return texture; } Loading libs/hwui/TextureCache.h +2 −2 Original line number Diff line number Diff line Loading @@ -66,14 +66,14 @@ public: /** * Resets all Textures to not be marked as in use */ void resetMarkInUse(); void resetMarkInUse(void* ownerToken); /** * Attempts to precache the SkBitmap. Returns true if a Texture was successfully * acquired for the bitmap, false otherwise. If a Texture was acquired it is * marked as in use. */ bool prefetchAndMarkInUse(const SkBitmap* bitmap); bool prefetchAndMarkInUse(void* ownerToken, const SkBitmap* bitmap); /** * Returns the texture associated with the specified bitmap from either within the cache, or Loading libs/hwui/TreeInfo.h +1 −1 Original line number Diff line number Diff line Loading @@ -95,7 +95,7 @@ public: // layer updates or similar. May be NULL. OpenGLRenderer* renderer; ErrorHandler* errorHandler; // TODO: Remove this? May be NULL // May be NULL (TODO: can it really?) renderthread::CanvasContext* canvasContext; struct Out { Loading Loading
libs/hwui/RenderNode.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -214,10 +214,10 @@ void RenderNode::pushLayerUpdate(TreeInfo& info) { info.renderer->pushLayerUpdate(mLayer); } if (CC_UNLIKELY(info.canvasContext)) { // If canvasContext is not null that means there are prefetched layers // that need to be accounted for. That might be us, so tell CanvasContext // that this layer is in the tree and should not be destroyed. if (info.canvasContext) { // There might be prefetched layers that need to be accounted for. // That might be us, so tell CanvasContext that this layer is in the // tree and should not be destroyed. info.canvasContext->markLayerInUse(this); } } Loading Loading @@ -339,7 +339,8 @@ void RenderNode::prepareSubTree(TreeInfo& info, bool functorsNeedLayer, DisplayL TextureCache& cache = Caches::getInstance().textureCache; info.out.hasFunctors |= subtree->functors.size(); for (size_t i = 0; info.prepareTextures && i < subtree->bitmapResources.size(); i++) { info.prepareTextures = cache.prefetchAndMarkInUse(subtree->bitmapResources[i]); info.prepareTextures = cache.prefetchAndMarkInUse( info.canvasContext, subtree->bitmapResources[i]); } for (size_t i = 0; i < subtree->children().size(); i++) { DrawRenderNodeOp* op = subtree->children()[i]; Loading
libs/hwui/Texture.h +1 −1 Original line number Diff line number Diff line Loading @@ -97,7 +97,7 @@ public: * Whether or not the Texture is marked in use and thus not evictable for * the current frame. This is reset at the start of a new frame. */ bool isInUse = false; void* isInUse = nullptr; private: /** Loading
libs/hwui/TextureCache.cpp +6 −4 Original line number Diff line number Diff line Loading @@ -122,10 +122,12 @@ void TextureCache::setAssetAtlas(AssetAtlas* assetAtlas) { mAssetAtlas = assetAtlas; } void TextureCache::resetMarkInUse() { void TextureCache::resetMarkInUse(void* ownerToken) { LruCache<uint32_t, Texture*>::Iterator iter(mCache); while (iter.next()) { iter.value()->isInUse = false; if (iter.value()->isInUse == ownerToken) { iter.value()->isInUse = nullptr; } } } Loading Loading @@ -189,10 +191,10 @@ Texture* TextureCache::getCachedTexture(const SkBitmap* bitmap, AtlasUsageType a return texture; } bool TextureCache::prefetchAndMarkInUse(const SkBitmap* bitmap) { bool TextureCache::prefetchAndMarkInUse(void* ownerToken, const SkBitmap* bitmap) { Texture* texture = getCachedTexture(bitmap, AtlasUsageType::Use); if (texture) { texture->isInUse = true; texture->isInUse = ownerToken; } return texture; } Loading
libs/hwui/TextureCache.h +2 −2 Original line number Diff line number Diff line Loading @@ -66,14 +66,14 @@ public: /** * Resets all Textures to not be marked as in use */ void resetMarkInUse(); void resetMarkInUse(void* ownerToken); /** * Attempts to precache the SkBitmap. Returns true if a Texture was successfully * acquired for the bitmap, false otherwise. If a Texture was acquired it is * marked as in use. */ bool prefetchAndMarkInUse(const SkBitmap* bitmap); bool prefetchAndMarkInUse(void* ownerToken, const SkBitmap* bitmap); /** * Returns the texture associated with the specified bitmap from either within the cache, or Loading
libs/hwui/TreeInfo.h +1 −1 Original line number Diff line number Diff line Loading @@ -95,7 +95,7 @@ public: // layer updates or similar. May be NULL. OpenGLRenderer* renderer; ErrorHandler* errorHandler; // TODO: Remove this? May be NULL // May be NULL (TODO: can it really?) renderthread::CanvasContext* canvasContext; struct Out { Loading