Reset pending commands
Allow takePendingCommands to have ownership for mComamnds so commands
are reset on each call. resetCommands methods are removed since they
are not really used.
Bug: 273525126
Test: manual
Change-Id: If91cf6253b0d8f0d8c5d761f7cf257d090fcaf6f
diff --git a/services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp b/services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp
index f28bfd4..f7049b9 100644
--- a/services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp
+++ b/services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp
@@ -329,14 +329,6 @@
}
}
-void AidlComposer::resetCommands(Display display) {
- mMutex.lock_shared();
- if (auto writer = getWriter(display)) {
- writer->get().reset();
- }
- mMutex.unlock_shared();
-}
-
Error AidlComposer::executeCommands(Display display) {
mMutex.lock_shared();
auto error = execute(display);
@@ -1054,9 +1046,8 @@
return Error::BAD_DISPLAY;
}
- const auto& commands = writer->get().getPendingCommands();
+ auto commands = writer->get().takePendingCommands();
if (commands.empty()) {
- writer->get().reset();
return Error::NONE;
}
@@ -1088,8 +1079,6 @@
}
}
- writer->get().reset();
-
return error;
}
diff --git a/services/surfaceflinger/DisplayHardware/AidlComposerHal.h b/services/surfaceflinger/DisplayHardware/AidlComposerHal.h
index 8313c09..ce05b38 100644
--- a/services/surfaceflinger/DisplayHardware/AidlComposerHal.h
+++ b/services/surfaceflinger/DisplayHardware/AidlComposerHal.h
@@ -72,10 +72,6 @@
void registerCallback(HWC2::ComposerCallback& callback) override;
- // Reset all pending commands in the command buffer. Useful if you want to
- // skip a frame but have already queued some commands.
- void resetCommands(Display) override;
-
// Explicitly flush all pending commands in the command buffer.
Error executeCommands(Display) override;
diff --git a/services/surfaceflinger/DisplayHardware/ComposerHal.h b/services/surfaceflinger/DisplayHardware/ComposerHal.h
index c65c572..cf67795 100644
--- a/services/surfaceflinger/DisplayHardware/ComposerHal.h
+++ b/services/surfaceflinger/DisplayHardware/ComposerHal.h
@@ -110,10 +110,6 @@
virtual void registerCallback(HWC2::ComposerCallback& callback) = 0;
- // Reset all pending commands in the command buffer. Useful if you want to
- // skip a frame but have already queued some commands.
- virtual void resetCommands(Display) = 0;
-
// Explicitly flush all pending commands in the command buffer.
virtual Error executeCommands(Display) = 0;
diff --git a/services/surfaceflinger/DisplayHardware/HidlComposerHal.cpp b/services/surfaceflinger/DisplayHardware/HidlComposerHal.cpp
index 23de4fa..e0f6c45 100644
--- a/services/surfaceflinger/DisplayHardware/HidlComposerHal.cpp
+++ b/services/surfaceflinger/DisplayHardware/HidlComposerHal.cpp
@@ -293,10 +293,6 @@
}
}
-void HidlComposer::resetCommands(Display) {
- mWriter.reset();
-}
-
Error HidlComposer::executeCommands(Display) {
return execute();
}
diff --git a/services/surfaceflinger/DisplayHardware/HidlComposerHal.h b/services/surfaceflinger/DisplayHardware/HidlComposerHal.h
index d04652b..0521acf 100644
--- a/services/surfaceflinger/DisplayHardware/HidlComposerHal.h
+++ b/services/surfaceflinger/DisplayHardware/HidlComposerHal.h
@@ -174,10 +174,6 @@
void registerCallback(HWC2::ComposerCallback& callback) override;
- // Reset all pending commands in the command buffer. Useful if you want to
- // skip a frame but have already queued some commands.
- void resetCommands(Display) override;
-
// Explicitly flush all pending commands in the command buffer.
Error executeCommands(Display) override;
diff --git a/services/surfaceflinger/fuzzer/surfaceflinger_displayhardware_fuzzer.cpp b/services/surfaceflinger/fuzzer/surfaceflinger_displayhardware_fuzzer.cpp
index a9247fe..9fac14e 100644
--- a/services/surfaceflinger/fuzzer/surfaceflinger_displayhardware_fuzzer.cpp
+++ b/services/surfaceflinger/fuzzer/surfaceflinger_displayhardware_fuzzer.cpp
@@ -327,7 +327,6 @@
invokeComposerHal2_4(&composer, display, outLayer);
composer.executeCommands(display);
- composer.resetCommands(display);
composer.destroyLayer(display, outLayer);
composer.destroyVirtualDisplay(display);
diff --git a/services/surfaceflinger/tests/unittests/mock/DisplayHardware/MockComposer.h b/services/surfaceflinger/tests/unittests/mock/DisplayHardware/MockComposer.h
index 5dc3490..d3fb9fc 100644
--- a/services/surfaceflinger/tests/unittests/mock/DisplayHardware/MockComposer.h
+++ b/services/surfaceflinger/tests/unittests/mock/DisplayHardware/MockComposer.h
@@ -55,7 +55,6 @@
std::vector<aidl::android::hardware::graphics::composer3::Capability>());
MOCK_METHOD0(dumpDebugInfo, std::string());
MOCK_METHOD1(registerCallback, void(HWC2::ComposerCallback&));
- MOCK_METHOD1(resetCommands, void(Display));
MOCK_METHOD1(executeCommands, Error(Display));
MOCK_METHOD0(getMaxVirtualDisplayCount, uint32_t());
MOCK_METHOD4(createVirtualDisplay, Error(uint32_t, uint32_t, PixelFormat*, Display*));