[RenderEngine] Do not cache protected EGLImage between runs.
Normally on a device the amount of protected memory is limited, however,
currently RenderEngine caches all generated EGLImage until layer is
destroyed, and hence eventually we run out of memory when trying to
create a protected EGLImage. This patch makes sure we unbind the buffer
and destroy the EGLImage once it's finished.
Bug: b/171098727
Test: DRM contents with big buffers playback work
Change-Id: Id24000d5e89220c849bf3cdc4917a6fa6b59e471
diff --git a/services/surfaceflinger/BufferLayerConsumer.cpp b/services/surfaceflinger/BufferLayerConsumer.cpp
index 7c73df2..69d2d11 100644
--- a/services/surfaceflinger/BufferLayerConsumer.cpp
+++ b/services/surfaceflinger/BufferLayerConsumer.cpp
@@ -503,6 +503,9 @@
BufferLayerConsumer::Image::Image(const sp<GraphicBuffer>& graphicBuffer,
renderengine::RenderEngine& engine)
: mGraphicBuffer(graphicBuffer), mRE(engine) {
+ if (graphicBuffer != nullptr && (graphicBuffer->getUsage() & GRALLOC_USAGE_PROTECTED)) {
+ return;
+ }
mRE.cacheExternalTextureBuffer(mGraphicBuffer);
}