77#include " flutter/fml/make_copyable.h"
88#include " flutter/fml/trace_event.h"
99
10- #include " vsync_recorder.h"
1110#include " vsync_waiter.h"
1211
1312namespace flutter_runner {
@@ -200,8 +199,8 @@ DefaultSessionConnection::DefaultSessionConnection(
200199 num_presents_handled);
201200 FML_DCHECK (frames_in_flight_ >= 0 );
202201
203- VsyncRecorder::GetInstance (). UpdateFramePresentedInfo (
204- zx::time (info.actual_presentation_time ));
202+ last_presentation_time_ = fml::TimePoint::FromEpochDelta (
203+ fml::TimeDelta::FromNanoseconds (info.actual_presentation_time ));
205204
206205 // Call the client-provided callback once we are done using |info|.
207206 on_frame_presented_callback_ (std::move (info));
@@ -230,8 +229,7 @@ DefaultSessionConnection::DefaultSessionConnection(
230229 // If Scenic alloted us 0 frames to begin with, we should fail here.
231230 FML_CHECK (frames_in_flight_allowed_ > 0 );
232231
233- VsyncRecorder::GetInstance ().UpdateNextPresentationInfo (
234- std::move (info));
232+ UpdateNextPresentationInfo (std::move (info));
235233
236234 initialized_ = true ;
237235
@@ -314,7 +312,7 @@ void DefaultSessionConnection::PresentSession() {
314312 // tasks.
315313
316314 fml::TimeDelta presentation_interval =
317- VsyncRecorder::GetInstance (). GetCurrentVsyncInfo ().presentation_interval ;
315+ GetCurrentVsyncInfo ().presentation_interval ;
318316
319317 fml::TimePoint next_latch_point = CalculateNextLatchPoint (
320318 fml::TimePoint::Now (), present_requested_time_,
@@ -344,8 +342,7 @@ void DefaultSessionConnection::PresentSession() {
344342 }
345343
346344 frames_in_flight_allowed_ = info.remaining_presents_in_flight_allowed ;
347- VsyncRecorder::GetInstance ().UpdateNextPresentationInfo (
348- std::move (info));
345+ UpdateNextPresentationInfo (std::move (info));
349346 });
350347}
351348
@@ -373,13 +370,11 @@ void DefaultSessionConnection::FireCallbackMaybe() {
373370FlutterFrameTimes DefaultSessionConnection::GetTargetTimesHelper (
374371 bool secondary_callback) {
375372 fml::TimeDelta presentation_interval =
376- VsyncRecorder::GetInstance (). GetCurrentVsyncInfo ().presentation_interval ;
373+ GetCurrentVsyncInfo ().presentation_interval ;
377374
378- fml::TimePoint next_vsync =
379- VsyncRecorder::GetInstance ().GetCurrentVsyncInfo ().presentation_time ;
375+ fml::TimePoint next_vsync = GetCurrentVsyncInfo ().presentation_time ;
380376 fml::TimePoint now = fml::TimePoint::Now ();
381- fml::TimePoint last_presentation_time =
382- VsyncRecorder::GetInstance ().GetLastPresentationTime ();
377+ fml::TimePoint last_presentation_time = last_presentation_time_;
383378 if (next_vsync <= now) {
384379 next_vsync =
385380 SnapToNextPhase (now, last_presentation_time, presentation_interval);
@@ -391,4 +386,24 @@ FlutterFrameTimes DefaultSessionConnection::GetTargetTimesHelper(
391386 last_targetted_vsync, now, next_vsync);
392387}
393388
389+ void DefaultSessionConnection::UpdateNextPresentationInfo (
390+ fuchsia::scenic::scheduling::FuturePresentationTimes info) {
391+ auto next_time = next_presentation_info_.presentation_time ();
392+ // Get the earliest vsync time that is after our recorded |presentation_time|.
393+ for (auto & presentation_info : info.future_presentations ) {
394+ auto current_time = presentation_info.presentation_time ();
395+
396+ if (current_time > next_time) {
397+ next_presentation_info_.set_presentation_time (current_time);
398+ return ;
399+ }
400+ }
401+ }
402+
403+ VsyncInfo DefaultSessionConnection::GetCurrentVsyncInfo () const {
404+ return {fml::TimePoint::FromEpochDelta (fml::TimeDelta::FromNanoseconds (
405+ next_presentation_info_.presentation_time ())),
406+ kDefaultPresentationInterval };
407+ }
408+
394409} // namespace flutter_runner
0 commit comments