diff options
author | Alec Mouri <alecmouri@google.com> | 2021-06-18 23:48:03 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2021-06-18 23:48:03 +0000 |
commit | 95c0a889007264dac4c6053d663f269cc1324046 (patch) | |
tree | a577662918c4a80451f01f59dd87196428bed215 | |
parent | 26953ee25d470a7f54d3b789ab57a1f304327a6a (diff) | |
parent | c2ffeb45690a3617ff9892c48de86afa421c476a (diff) | |
download | native-95c0a889007264dac4c6053d663f269cc1324046.tar.gz |
Merge "Swap contexts when unmapping ExternalTextures" into sc-dev
-rw-r--r-- | libs/renderengine/skia/SkiaGLRenderEngine.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/libs/renderengine/skia/SkiaGLRenderEngine.cpp b/libs/renderengine/skia/SkiaGLRenderEngine.cpp index d28d623b7f..cb80ef4ada 100644 --- a/libs/renderengine/skia/SkiaGLRenderEngine.cpp +++ b/libs/renderengine/skia/SkiaGLRenderEngine.cpp @@ -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); + } } } |