Flutter Engine
flutter_runner::VsyncWaiter Class Referencefinal

#include <vsync_waiter.h>

Inheritance diagram for flutter_runner::VsyncWaiter:
flutter::VsyncWaiter

Public Member Functions

 VsyncWaiter (AwaitVsyncCallback await_vsync_callback, AwaitVsyncForSecondaryCallbackCallback await_vsync_for_secondary_callback_callback, flutter::TaskRunners task_runners)
 
 ~VsyncWaiter () override
 
- Public Member Functions inherited from flutter::VsyncWaiter
void AsyncWaitForVsync (const Callback &callback)
 
void ScheduleSecondaryCallback (uintptr_t id, const fml::closure &callback)
 

Additional Inherited Members

- Public Types inherited from flutter::VsyncWaiter
using Callback = std::function< void(std::unique_ptr< FrameTimingsRecorder >)>
 
- Protected Member Functions inherited from flutter::VsyncWaiter
 VsyncWaiter (TaskRunners task_runners)
 
void FireCallback (fml::TimePoint frame_start_time, fml::TimePoint frame_target_time, bool pause_secondary_tasks=true)
 
- Protected Attributes inherited from flutter::VsyncWaiter
const TaskRunners task_runners_
 

Detailed Description

Definition at line 27 of file vsync_waiter.h.

Constructor & Destructor Documentation

◆ VsyncWaiter()

flutter_runner::VsyncWaiter::VsyncWaiter ( AwaitVsyncCallback  await_vsync_callback,
AwaitVsyncForSecondaryCallbackCallback  await_vsync_for_secondary_callback_callback,
flutter::TaskRunners  task_runners 
)

Definition at line 21 of file vsync_waiter.cc.

References flutter::TaskRunners::GetUITaskRunner(), fml::MakeCopyable(), fml::TaskRunner::PostTaskForTime(), fml::TaskRunner::RunNowOrPostTask(), and flutter::VsyncWaiter::task_runners_.

25  : flutter::VsyncWaiter(task_runners),
26  await_vsync_callback_(await_vsync_callback),
27  await_vsync_for_secondary_callback_callback_(
28  await_vsync_for_secondary_callback_callback),
29  weak_factory_ui_(nullptr),
30  weak_factory_(this) {
31  fire_callback_callback_ = [this](fml::TimePoint frame_start,
32  fml::TimePoint frame_end) {
34  [frame_start, frame_end, weak_this = weak_ui_]() {
35  if (weak_this) {
36  // Note: It is VERY important to set |pause_secondary_tasks| to
37  // false, else Animator will almost immediately crash on Fuchsia.
38  // FML_LOG(INFO) << "CRASH:: VsyncWaiter about to FireCallback";
39  weak_this->FireCallback(frame_start, frame_end,
40  /*pause_secondary_tasks*/ false);
41  }
42  },
43  frame_start);
44  };
45 
46  // Generate a WeakPtrFactory for use with the UI thread. This does not need
47  // to wait on a latch because we only ever use the WeakPtrFactory on the UI
48  // thread so we have ordering guarantees (see ::AwaitVSync())
50  task_runners_.GetUITaskRunner(), fml::MakeCopyable([this]() mutable {
51  weak_factory_ui_ =
52  std::make_unique<fml::WeakPtrFactory<VsyncWaiter>>(this);
53  weak_ui_ = weak_factory_ui_->GetWeakPtr();
54  }));
55 }
static void RunNowOrPostTask(fml::RefPtr< fml::TaskRunner > runner, const fml::closure &task)
Definition: task_runner.cc:55
virtual void PostTaskForTime(const fml::closure &task, fml::TimePoint target_time)
Definition: task_runner.cc:28
internal::CopyableLambda< T > MakeCopyable(T lambda)
Definition: make_copyable.h:57
fml::RefPtr< fml::TaskRunner > GetUITaskRunner() const
Definition: task_runners.cc:34
const TaskRunners task_runners_
Definition: vsync_waiter.h:41

◆ ~VsyncWaiter()

flutter_runner::VsyncWaiter::~VsyncWaiter ( )
overridevirtual

Reimplemented from flutter::VsyncWaiter.

Definition at line 57 of file vsync_waiter.cc.

References flutter::TaskRunners::GetUITaskRunner(), fml::MakeCopyable(), fml::TaskRunner::RunNowOrPostTask(), fml::AutoResetWaitableEvent::Signal(), flutter::VsyncWaiter::task_runners_, and fml::AutoResetWaitableEvent::Wait().

57  {
62  [weak_factory_ui = std::move(weak_factory_ui_), &ui_latch]() mutable {
63  weak_factory_ui.reset();
64  ui_latch.Signal();
65  }));
66  ui_latch.Wait();
67 }
static void RunNowOrPostTask(fml::RefPtr< fml::TaskRunner > runner, const fml::closure &task)
Definition: task_runner.cc:55
internal::CopyableLambda< T > MakeCopyable(T lambda)
Definition: make_copyable.h:57
fml::RefPtr< fml::TaskRunner > GetUITaskRunner() const
Definition: task_runners.cc:34
const TaskRunners task_runners_
Definition: vsync_waiter.h:41

The documentation for this class was generated from the following files: