Fix up reference times for period changes.

* When the model is reset, use the last seen reference time instead
of 0, since the reference time of 0 is guaranteed to yield inaccurate
pulses.
* When the DispSync model is updated, reduce the reference time by a
period to derisk spurious events firing when the model is updated.

Bug: 124383894
Test: systrace
Change-Id: Idb7fd5a9bacdd78133ab6451b5a79789a32e339e
diff --git a/services/surfaceflinger/Scheduler/DispSync.h b/services/surfaceflinger/Scheduler/DispSync.h
index f629697..6f3bd00 100644
--- a/services/surfaceflinger/Scheduler/DispSync.h
+++ b/services/surfaceflinger/Scheduler/DispSync.h
@@ -213,7 +213,7 @@
     // These member variables are the state used during the resynchronization
     // process to store information about the hardware vsync event times used
     // to compute the model.
-    nsecs_t mResyncSamples[MAX_RESYNC_SAMPLES];
+    nsecs_t mResyncSamples[MAX_RESYNC_SAMPLES] = {0};
     size_t mFirstResyncSample;
     size_t mNumResyncSamples;
     int mNumResyncSamplesSincePresent;