From 0d995106c0fb4480ac1de5f58667d918fa9aea62 Mon Sep 17 00:00:00 2001 From: Alec Mouri Date: Wed, 24 Feb 2021 16:53:38 -0800 Subject: Dispatch texture destruction off of render thread for screenshots This is only enabled when the skia threaded variant renderengine is enabled. This essentially defers texture deletion until after drawLayers() is invoked, which shaves off time from the main SF thread. Bug: 179959621 Bug: 180767535 Test: perfetto trace Change-Id: I333091d8792fdd0dc01076c73af2956da9ee73df --- services/surfaceflinger/RegionSamplingThread.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'services/surfaceflinger/RegionSamplingThread.cpp') diff --git a/services/surfaceflinger/RegionSamplingThread.cpp b/services/surfaceflinger/RegionSamplingThread.cpp index 09615f920d..e06bc88f7c 100644 --- a/services/surfaceflinger/RegionSamplingThread.cpp +++ b/services/surfaceflinger/RegionSamplingThread.cpp @@ -481,6 +481,12 @@ void RegionSamplingThread::captureSample() { // 1) The region sampling thread is the last owner of the buffer, and the freeing of the buffer // happens in this thread, as opposed to the main thread. // 2) The listener(s) receive their notifications prior to freeing the buffer. + if (mCachedBuffer != nullptr && mCachedBuffer != buffer) { + if (mFlinger.getRenderEngine().getRenderEngineType() == + renderengine::RenderEngine::RenderEngineType::SKIA_GL_THREADED) { + mFlinger.getRenderEngine().unbindExternalTextureBuffer(mCachedBuffer->getId()); + } + } mCachedBuffer = buffer; ATRACE_INT(lumaSamplingStepTag, static_cast(samplingStep::noWorkNeeded)); } -- cgit v1.2.3-59-g8ed1b