summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/RegionSamplingThread.cpp
diff options
context:
space:
mode:
author Alec Mouri <alecmouri@google.com> 2021-02-24 16:53:38 -0800
committer Alec Mouri <alecmouri@google.com> 2021-02-26 11:24:33 -0800
commit0d995106c0fb4480ac1de5f58667d918fa9aea62 (patch)
treefdac62f05e2462c9170981ec9b80dbf6ea75a6f2 /services/surfaceflinger/RegionSamplingThread.cpp
parentec1691271f4732807a21fd678bfddb3c7b25c3ae (diff)
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
Diffstat (limited to 'services/surfaceflinger/RegionSamplingThread.cpp')
-rw-r--r--services/surfaceflinger/RegionSamplingThread.cpp6
1 files changed, 6 insertions, 0 deletions
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<int>(samplingStep::noWorkNeeded));
}