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

Commit b2dc2e4f authored by Derek Sollenberger's avatar Derek Sollenberger Committed by Automerger Merge Worker
Browse files

Merge "If requested then cache unprotected buffers even in protected mode"...

Merge "If requested then cache unprotected buffers even in protected mode" into sc-dev am: b3d39f5e

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/14939033

Change-Id: I75deaeea75b64981151f9d28798d3d4a3644ec0b
parents b4866de8 b3d39f5e
Loading
Loading
Loading
Loading
+8 −14
Original line number Diff line number Diff line
@@ -507,17 +507,18 @@ void SkiaGLRenderEngine::mapExternalTextureBuffer(const sp<GraphicBuffer>& buffe
        return;
    }
    // We currently don't attempt to map a buffer if the buffer contains protected content
    // or we are using a protected context because GPU resources for protected buffers is
    // much more limited.
    // because GPU resources for protected buffers is much more limited.
    const bool isProtectedBuffer = buffer->getUsage() & GRALLOC_USAGE_PROTECTED;
    if (isProtectedBuffer || mInProtectedContext) {
    if (isProtectedBuffer) {
        return;
    }
    ATRACE_CALL();

    // If we were to support caching protected buffers then we will need to switch the currently
    // bound context if we are not already using the protected context (and subsequently switch
    // back after the buffer is cached).
    // If we were to support caching protected buffers then we will need to switch the
    // currently bound context if we are not already using the protected context (and subsequently
    // switch back after the buffer is cached).  However, for non-protected content we can bind
    // the texture in either GL context because they are initialized with the same share_context
    // which allows the texture state to be shared between them.
    auto grContext = getActiveGrContext();
    auto& cache = mTextureCache;

@@ -551,7 +552,6 @@ void SkiaGLRenderEngine::unmapExternalTextureBuffer(const sp<GraphicBuffer>& buf

        if (iter->second == 0) {
            mTextureCache.erase(buffer->getId());
            mProtectedTextureCache.erase(buffer->getId());
            mGraphicBufferExternalRefs.erase(buffer->getId());
        }
    }
@@ -703,7 +703,7 @@ status_t SkiaGLRenderEngine::drawLayers(const DisplaySettings& display,
    validateOutputBufferUsage(buffer->getBuffer());

    auto grContext = getActiveGrContext();
    auto& cache = mInProtectedContext ? mProtectedTextureCache : mTextureCache;
    auto& cache = mTextureCache;

    std::shared_ptr<AutoBackendTexture::LocalRef> surfaceTextureRef;
    if (const auto& it = cache.find(buffer->getBuffer()->getId()); it != cache.end()) {
@@ -1446,12 +1446,6 @@ void SkiaGLRenderEngine::dump(std::string& result) {
        StringAppendF(&result, "Skia's Protected Wrapped Objects:\n");
        gpuProtectedReporter.logOutput(result, true);

        StringAppendF(&result, "RenderEngine protected AHB/BackendTexture cache size: %zu\n",
                      mProtectedTextureCache.size());
        StringAppendF(&result, "Dumping buffer ids...\n");
        for (const auto& [id, unused] : mProtectedTextureCache) {
            StringAppendF(&result, "- 0x%" PRIx64 "\n", id);
        }
        StringAppendF(&result, "\n");
        StringAppendF(&result, "RenderEngine runtime effects: %zu\n", mRuntimeEffects.size());
        for (const auto& [linearEffect, unused] : mRuntimeEffects) {
+1 −3
Original line number Diff line number Diff line
@@ -126,11 +126,9 @@ private:
    // Number of external holders of ExternalTexture references, per GraphicBuffer ID.
    std::unordered_map<GraphicBufferId, int32_t> mGraphicBufferExternalRefs
            GUARDED_BY(mRenderingMutex);
    // Cache of GL textures that we'll store per GraphicBuffer ID, sliced by GPU context.
    // Cache of GL textures that we'll store per GraphicBuffer ID, shared between GPU contexts.
    std::unordered_map<GraphicBufferId, std::shared_ptr<AutoBackendTexture::LocalRef>> mTextureCache
            GUARDED_BY(mRenderingMutex);
    std::unordered_map<GraphicBufferId, std::shared_ptr<AutoBackendTexture::LocalRef>>
            mProtectedTextureCache GUARDED_BY(mRenderingMutex);
    std::unordered_map<LinearEffect, sk_sp<SkRuntimeEffect>, LinearEffectHasher> mRuntimeEffects;

    StretchShaderFactory mStretchShaderFactory;