Don't import GPU inaccessible buffers in RenderEngine
SurfaceFlinger already rejects those buffers from being added to
drawLayers, but mapExternalTextureBuffer() is still called for all
buffers arriving into SurfaceFlinger. Let's not trigger undefined
behavior.
Bug: 300155347
Test: builds, boots
Change-Id: I3ced5f11f47af6fdcd2c1575cbbbac99075588b8
diff --git a/libs/renderengine/skia/SkiaRenderEngine.cpp b/libs/renderengine/skia/SkiaRenderEngine.cpp
index 1f18b94..dbf020a 100644
--- a/libs/renderengine/skia/SkiaRenderEngine.cpp
+++ b/libs/renderengine/skia/SkiaRenderEngine.cpp
@@ -399,7 +399,10 @@
// simply match the existing behavior for protected buffers.) We also never cache any
// buffers while in a protected context.
const bool isProtectedBuffer = buffer->getUsage() & GRALLOC_USAGE_PROTECTED;
- if (isProtectedBuffer || isProtected()) {
+ // Don't attempt to map buffers if we're not gpu sampleable. Callers shouldn't send a buffer
+ // over to RenderEngine.
+ const bool isGpuSampleable = buffer->getUsage() & GRALLOC_USAGE_HW_TEXTURE;
+ if (isProtectedBuffer || isProtected() || !isGpuSampleable) {
return;
}
ATRACE_CALL();