drm_hwcomposer: Avoid resetting vsync timestamp
last_timestamp_ tracks the most recent timestamp from a vblank event. Do
not reset it when toggling vsync tracking on/off. This allows for
GetPhasedVSync to calculate a more precise approximation of the next
vsync relative to the current time, even if a vsync hasn't happened for
a while.
Reset last_timestamp_ when the vsync period changes, since the phased
vsync calculation is based on the current vsync.
Also change last_timestamp_ to std::optional type.
Change-Id: I101b36f87d6ba8197c321c83ac0bc230fba9cf7e
Signed-off-by: Drew Davenport <ddavenport@google.com>
diff --git a/hwc2_device/HwcDisplay.cpp b/hwc2_device/HwcDisplay.cpp
index 121f04f..977ab1a 100644
--- a/hwc2_device/HwcDisplay.cpp
+++ b/hwc2_device/HwcDisplay.cpp
@@ -822,7 +822,6 @@
}
if (new_vsync_period_ns) {
- vsync_worker_->SetVsyncPeriodNs(new_vsync_period_ns.value());
staged_mode_config_id_.reset();
vsync_worker_->SetVsyncTimestampTracking(false);
@@ -832,6 +831,7 @@
last_vsync_ts +
prev_vperiod_ns);
}
+ vsync_worker_->SetVsyncPeriodNs(new_vsync_period_ns.value());
}
return HWC2::Error::None;