Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1fddd3ef authored by John Reck's avatar John Reck Committed by Android (Google) Code Review
Browse files

Merge "Mark isInUse per-window" into mnc-dev

parents 55a116d0 00e79c99
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -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);
    }
}
@@ -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];
+1 −1
Original line number Diff line number Diff line
@@ -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:
    /**
+6 −4
Original line number Diff line number Diff line
@@ -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;
        }
    }
}

@@ -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;
}
+2 −2
Original line number Diff line number Diff line
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -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