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

Commit 33ac264b authored by Alec Mouri's avatar Alec Mouri Committed by Automerger Merge Worker
Browse files

Merge "Swap contexts when unmapping ExternalTextures" into sc-dev am: 95c0a889

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

Change-Id: I2ceb27c0246bf7c79d118fe6358aad1aa5338c2c
parents bd624fb2 95c0a889
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -552,10 +552,25 @@ void SkiaGLRenderEngine::unmapExternalTextureBuffer(const sp<GraphicBuffer>& buf

        iter->second--;

        // Swap contexts if needed prior to deleting this buffer
        // See Issue 1 of
        // https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_protected_content.txt: even
        // when a protected context and an unprotected context are part of the same share group,
        // protected surfaces may not be accessed by an unprotected context, implying that protected
        // surfaces may only be freed when a protected context is active.
        const bool inProtected = mInProtectedContext;
        useProtectedContext(buffer->getUsage() & GRALLOC_USAGE_PROTECTED);

        if (iter->second == 0) {
            mTextureCache.erase(buffer->getId());
            mGraphicBufferExternalRefs.erase(buffer->getId());
        }

        // Swap back to the previous context so that cached values of isProtected in SurfaceFlinger
        // are up-to-date.
        if (inProtected != mInProtectedContext) {
            useProtectedContext(inProtected);
        }
    }
}