Revert "Don't clear timestamps when enabling HW vsync."
This reverts commit 2db205d8d24d381a5d52e0407312daa4fc7caf15.
Reason for revert: b/285086044, b/285401355
Change-Id: I0f642f0ead5a70daec649095855ec0209d2c0682
diff --git a/services/surfaceflinger/Scheduler/VsyncSchedule.cpp b/services/surfaceflinger/Scheduler/VsyncSchedule.cpp
index 5691792..ff3f29d 100644
--- a/services/surfaceflinger/Scheduler/VsyncSchedule.cpp
+++ b/services/surfaceflinger/Scheduler/VsyncSchedule.cpp
@@ -17,7 +17,6 @@
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
#include <ftl/fake_guard.h>
-#include <gui/TraceUtils.h>
#include <scheduler/Fps.h>
#include <scheduler/Timer.h>
@@ -145,14 +144,6 @@
}
bool VsyncSchedule::addResyncSample(TimePoint timestamp, ftl::Optional<Period> hwcVsyncPeriod) {
- ATRACE_CALL();
-
- if (mClearTimestampsOnNextSample) {
- ATRACE_FORMAT("clearing sample after HW vsync enabled", __func__);
- getTracker().resetModel();
- mClearTimestampsOnNextSample = false;
- }
-
bool needsHwVsync = false;
bool periodFlushed = false;
{
@@ -179,7 +170,7 @@
void VsyncSchedule::enableHardwareVsyncLocked() {
if (mHwVsyncState == HwVsyncState::Disabled) {
- mClearTimestampsOnNextSample = true;
+ getTracker().resetModel();
mRequestHardwareVsync(mId, true);
mHwVsyncState = HwVsyncState::Enabled;
}
diff --git a/services/surfaceflinger/Scheduler/VsyncSchedule.h b/services/surfaceflinger/Scheduler/VsyncSchedule.h
index c037ac8..0757b57 100644
--- a/services/surfaceflinger/Scheduler/VsyncSchedule.h
+++ b/services/surfaceflinger/Scheduler/VsyncSchedule.h
@@ -150,11 +150,6 @@
// device is off.
HwVsyncState mPendingHwVsyncState GUARDED_BY(kMainThreadContext) = HwVsyncState::Disabled;
- // Whether to reset the timestamps stored in the vsync model on the next hw vsync sample. This
- // is to avoid clearing the model when hw vsync is enabled, in order to be consistent with the
- // stale timestamps. Instead, clear the model on the first hw vsync callback.
- bool mClearTimestampsOnNextSample = false;
-
class PredictedVsyncTracer;
using TracerPtr = std::unique_ptr<PredictedVsyncTracer>;
diff --git a/services/surfaceflinger/tests/unittests/SurfaceFlinger_SetPowerModeInternalTest.cpp b/services/surfaceflinger/tests/unittests/SurfaceFlinger_SetPowerModeInternalTest.cpp
index 4780e49..cf3fab3 100644
--- a/services/surfaceflinger/tests/unittests/SurfaceFlinger_SetPowerModeInternalTest.cpp
+++ b/services/surfaceflinger/tests/unittests/SurfaceFlinger_SetPowerModeInternalTest.cpp
@@ -91,16 +91,18 @@
};
struct DispSyncIsSupportedVariant {
- static void setupStartPeriodTransitionCallExpectations(DisplayTransactionTest* test) {
+ static void setupResetModelCallExpectations(DisplayTransactionTest* test) {
auto vsyncSchedule = test->mFlinger.scheduler()->getVsyncSchedule();
EXPECT_CALL(static_cast<mock::VsyncController&>(vsyncSchedule->getController()),
startPeriodTransition(DEFAULT_VSYNC_PERIOD, false))
.Times(1);
+ EXPECT_CALL(static_cast<mock::VSyncTracker&>(vsyncSchedule->getTracker()), resetModel())
+ .Times(1);
}
};
struct DispSyncNotSupportedVariant {
- static void setupStartPeriodTransitionCallExpectations(DisplayTransactionTest* /* test */) {}
+ static void setupResetModelCallExpectations(DisplayTransactionTest* /* test */) {}
};
// --------------------------------------------------------------------
@@ -123,7 +125,7 @@
static void setupCallExpectations(DisplayTransactionTest* test) {
Case::setupComposerCallExpectations(test, IComposerClient::PowerMode::ON);
Case::EventThread::setupEnableVsyncCallExpectations(test);
- Case::DispSync::setupStartPeriodTransitionCallExpectations(test);
+ Case::DispSync::setupResetModelCallExpectations(test);
Case::setupRepaintEverythingCallExpectations(test);
}
@@ -184,7 +186,7 @@
template <typename Case>
static void setupCallExpectations(DisplayTransactionTest* test) {
Case::EventThread::setupEnableVsyncCallExpectations(test);
- Case::DispSync::setupStartPeriodTransitionCallExpectations(test);
+ Case::DispSync::setupResetModelCallExpectations(test);
Case::setupComposerCallExpectations(test, Case::Doze::ACTUAL_POWER_MODE_FOR_DOZE);
}
};
@@ -202,7 +204,7 @@
template <typename Case>
static void setupCallExpectations(DisplayTransactionTest* test) {
Case::EventThread::setupEnableVsyncCallExpectations(test);
- Case::DispSync::setupStartPeriodTransitionCallExpectations(test);
+ Case::DispSync::setupResetModelCallExpectations(test);
Case::setupComposerCallExpectations(test, IComposerClient::PowerMode::ON);
}
};