Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | List of all members
flutter::VsyncWaiterEmbedder Class Referencefinal

#include <vsync_waiter_embedder.h>

Inheritance diagram for flutter::VsyncWaiterEmbedder:
flutter::VsyncWaiter

Public Types

using VsyncCallback = std::function< void(intptr_t)>
 
- Public Types inherited from flutter::VsyncWaiter
using Callback = std::function< void(std::unique_ptr< FrameTimingsRecorder >)>
 

Public Member Functions

 VsyncWaiterEmbedder (const VsyncCallback &callback, const flutter::TaskRunners &task_runners)
 
 ~VsyncWaiterEmbedder () override
 
- Public Member Functions inherited from flutter::VsyncWaiter
virtual ~VsyncWaiter ()
 
void AsyncWaitForVsync (const Callback &callback)
 
void ScheduleSecondaryCallback (uintptr_t id, const fml::closure &callback)
 

Static Public Member Functions

static bool OnEmbedderVsync (const flutter::TaskRunners &task_runners, intptr_t baton, fml::TimePoint frame_start_time, fml::TimePoint frame_target_time)
 

Private Member Functions

void AwaitVSync () override
 

Additional Inherited Members

- Protected Member Functions inherited from flutter::VsyncWaiter
 VsyncWaiter (const TaskRunners &task_runners)
 
virtual void AwaitVSyncForSecondaryCallback ()
 
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 13 of file vsync_waiter_embedder.h.

Member Typedef Documentation

◆ VsyncCallback

using flutter::VsyncWaiterEmbedder::VsyncCallback = std::function<void(intptr_t)>

Definition at line 15 of file vsync_waiter_embedder.h.

Constructor & Destructor Documentation

◆ VsyncWaiterEmbedder()

flutter::VsyncWaiterEmbedder::VsyncWaiterEmbedder ( const VsyncCallback callback,
const flutter::TaskRunners task_runners 
)

Definition at line 9 of file vsync_waiter_embedder.cc.

12 : VsyncWaiter(task_runners), vsync_callback_(vsync_callback) {
13 FML_DCHECK(vsync_callback_);
14}
VsyncWaiter(const TaskRunners &task_runners)
#define FML_DCHECK(condition)
Definition logging.h:103

◆ ~VsyncWaiterEmbedder()

flutter::VsyncWaiterEmbedder::~VsyncWaiterEmbedder ( )
overridedefault

Member Function Documentation

◆ AwaitVSync()

void flutter::VsyncWaiterEmbedder::AwaitVSync ( )
overrideprivatevirtual

Implements flutter::VsyncWaiter.

Definition at line 19 of file vsync_waiter_embedder.cc.

19 {
20 auto* weak_waiter = new std::weak_ptr<VsyncWaiter>(shared_from_this());
21 intptr_t baton = reinterpret_cast<intptr_t>(weak_waiter);
22 vsync_callback_(baton);
23}

◆ OnEmbedderVsync()

bool flutter::VsyncWaiterEmbedder::OnEmbedderVsync ( const flutter::TaskRunners task_runners,
intptr_t  baton,
fml::TimePoint  frame_start_time,
fml::TimePoint  frame_target_time 
)
static

Definition at line 26 of file vsync_waiter_embedder.cc.

30 {
31 if (baton == 0) {
32 return false;
33 }
34
35 // If the time here is in the future, the contract for `FlutterEngineOnVsync`
36 // says that the engine will only process the frame when the time becomes
37 // current.
38 task_runners.GetUITaskRunner()->PostTaskForTime(
39 [frame_start_time, frame_target_time, baton]() {
40 std::weak_ptr<VsyncWaiter>* weak_waiter =
41 reinterpret_cast<std::weak_ptr<VsyncWaiter>*>(baton);
42 auto vsync_waiter = weak_waiter->lock();
43 delete weak_waiter;
44 if (vsync_waiter) {
45 vsync_waiter->FireCallback(frame_start_time, frame_target_time);
46 }
47 },
48 frame_start_time);
49
50 return true;
51}
fml::RefPtr< fml::TaskRunner > GetUITaskRunner() const
virtual void PostTaskForTime(const fml::closure &task, fml::TimePoint target_time)

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