Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | List of all members
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)
 

Private Member Functions

void AwaitVSync () override
 
void AwaitVSyncForSecondaryCallback () override
 

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 (const 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.

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 },
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())
51 weak_factory_ui_ =
52 std::make_unique<fml::WeakPtrFactory<VsyncWaiter>>(this);
53 weak_ui_ = weak_factory_ui_->GetWeakPtr();
54 }));
55}
fml::RefPtr< fml::TaskRunner > GetUITaskRunner() const
const TaskRunners task_runners_
static void RunNowOrPostTask(const fml::RefPtr< fml::TaskRunner > &runner, const fml::closure &task)
virtual void PostTaskForTime(const fml::closure &task, fml::TimePoint target_time)
internal::CopyableLambda< T > MakeCopyable(T lambda)

◆ ~VsyncWaiter()

flutter_runner::VsyncWaiter::~VsyncWaiter ( )
overridevirtual

Reimplemented from flutter::VsyncWaiter.

Definition at line 57 of file vsync_waiter.cc.

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}

Member Function Documentation

◆ AwaitVSync()

void flutter_runner::VsyncWaiter::AwaitVSync ( )
overrideprivatevirtual

Implements flutter::VsyncWaiter.

Definition at line 69 of file vsync_waiter.cc.

69 {
70 await_vsync_callback_(fire_callback_callback_);
71}

◆ AwaitVSyncForSecondaryCallback()

void flutter_runner::VsyncWaiter::AwaitVSyncForSecondaryCallback ( )
overrideprivatevirtual

Reimplemented from flutter::VsyncWaiter.

Definition at line 73 of file vsync_waiter.cc.

73 {
74 await_vsync_for_secondary_callback_callback_(fire_callback_callback_);
75}

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