Output::presentFrameAndReleaseLayers: flush pending commands for OFF displays
Most work from this method can be skipped if the display is not enabled.
However, uncaching buffers should still occur. If the display is
disabled and there are buffers to uncache, still flush pending commands.
They should only contain commands that are meaningful for a disabled
display, like bufferSlotsToClear.
Bug: 330806421
Test: libcompositionengine_test
Flag: flush_buffer_slots_to_uncache
Change-Id: I7baa3e76af86329fb266395e63e92a0ba38967f4
diff --git a/services/surfaceflinger/CompositionEngine/src/Output.cpp b/services/surfaceflinger/CompositionEngine/src/Output.cpp
index 84f3f25..5b9a102 100644
--- a/services/surfaceflinger/CompositionEngine/src/Output.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/Output.cpp
@@ -479,8 +479,9 @@
devOptRepaintFlash(refreshArgs);
finishFrame(std::move(result));
ftl::Future<std::monostate> future;
+ const bool flushEvenWhenDisabled = !refreshArgs.bufferIdsToUncache.empty();
if (mOffloadPresent) {
- future = presentFrameAndReleaseLayersAsync();
+ future = presentFrameAndReleaseLayersAsync(flushEvenWhenDisabled);
// Only offload for this frame. The next frame will determine whether it
// needs to be offloaded. Leave the HwcAsyncWorker in place. For one thing,
@@ -488,7 +489,7 @@
// we don't want to churn.
mOffloadPresent = false;
} else {
- presentFrameAndReleaseLayers();
+ presentFrameAndReleaseLayers(flushEvenWhenDisabled);
future = ftl::yield<std::monostate>({});
}
renderCachedSets(refreshArgs);
@@ -1100,9 +1101,9 @@
finishPrepareFrame();
}
-ftl::Future<std::monostate> Output::presentFrameAndReleaseLayersAsync() {
+ftl::Future<std::monostate> Output::presentFrameAndReleaseLayersAsync(bool flushEvenWhenDisabled) {
return ftl::Future<bool>(std::move(mHwComposerAsyncWorker->send([&]() {
- presentFrameAndReleaseLayers();
+ presentFrameAndReleaseLayers(flushEvenWhenDisabled);
return true;
})))
.then([](bool) { return std::monostate{}; });
@@ -1177,7 +1178,8 @@
}
}
- presentFrameAndReleaseLayers();
+ constexpr bool kFlushEvenWhenDisabled = false;
+ presentFrameAndReleaseLayers(kFlushEvenWhenDisabled);
std::this_thread::sleep_for(*refreshArgs.devOptFlashDirtyRegionsDelay);
@@ -1567,11 +1569,16 @@
return false;
}
-void Output::presentFrameAndReleaseLayers() {
+void Output::presentFrameAndReleaseLayers(bool flushEvenWhenDisabled) {
ATRACE_FORMAT("%s for %s", __func__, mNamePlusId.c_str());
ALOGV(__FUNCTION__);
if (!getState().isEnabled) {
+ if (flushEvenWhenDisabled && FlagManager::getInstance().flush_buffer_slots_to_uncache()) {
+ // Some commands, like clearing buffer slots, should still be executed
+ // even if the display is not enabled.
+ executeCommands();
+ }
return;
}