[SF] Adds notifyExpectedPresent call for timeoutNs
Update notifyExpectedPresent to notifyExpectedPresentIfRequired
BUG: 296636253
BUG: 284845445
Test: atest HWComposerTest &&
libsurfaceflinger_unittest
Change-Id: Ibb2b70cd6073be7c0c2be0507b47e6f5732a9303
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index d6ef203..fb6089d 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -31,6 +31,7 @@
#include <compositionengine/OutputLayer.h>
#include <compositionengine/impl/OutputLayerCompositionState.h>
#include <ftl/concat.h>
+#include <gui/TraceUtils.h>
#include <log/log.h>
#include <ui/DebugUtils.h>
#include <ui/GraphicBuffer.h>
@@ -484,6 +485,7 @@
}();
displayData.validateWasSkipped = false;
+ displayData.lastExpectedPresentTimestamp = expectedPresentTime;
if (canSkipValidate) {
sp<Fence> outPresentFence;
uint32_t state = UINT32_MAX;
@@ -876,12 +878,23 @@
return NO_ERROR;
}
-status_t HWComposer::notifyExpectedPresent(PhysicalDisplayId displayId, nsecs_t expectedPresentTime,
- int32_t frameIntervalNs) {
- ATRACE_CALL();
+status_t HWComposer::notifyExpectedPresentIfRequired(PhysicalDisplayId displayId,
+ nsecs_t expectedPresentTime,
+ int32_t frameIntervalNs, int32_t timeoutNs) {
RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);
- const auto error = mComposer->notifyExpectedPresent(mDisplayData[displayId].hwcDisplay->getId(),
+
+ auto& displayData = mDisplayData[displayId];
+ if (expectedPresentTime >= displayData.lastExpectedPresentTimestamp &&
+ expectedPresentTime < displayData.lastExpectedPresentTimestamp + timeoutNs) {
+ return NO_ERROR;
+ }
+
+ displayData.lastExpectedPresentTimestamp = expectedPresentTime;
+ ATRACE_FORMAT("%s ExpectedPresentTime %" PRId64 " frameIntervalNs %d", __func__,
+ expectedPresentTime, frameIntervalNs);
+ const auto error = mComposer->notifyExpectedPresent(displayData.hwcDisplay->getId(),
expectedPresentTime, frameIntervalNs);
+
if (error != hal::Error::NONE) {
ALOGE("Error in notifyExpectedPresent call %s", to_string(error).c_str());
return INVALID_OPERATION;