Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
flutter_runner::FlatlandConnection Class Referencefinal

#include <flatland_connection.h>

Public Member Functions

 FlatlandConnection (const std::string &debug_label, fuchsia::ui::composition::FlatlandHandle flatland, fml::closure error_callback, on_frame_presented_event on_frame_presented_callback, async_dispatcher_t *dispatcher=async_get_default_dispatcher())
 
 ~FlatlandConnection ()
 
void Present ()
 
void AwaitVsync (FireCallbackCallback callback)
 
void AwaitVsyncForSecondaryCallback (FireCallbackCallback callback)
 
fuchsia::ui::composition::Flatland * flatland ()
 
fuchsia::ui::composition::TransformId NextTransformId ()
 
fuchsia::ui::composition::ContentId NextContentId ()
 
void EnqueueAcquireFence (zx::event fence)
 
void EnqueueReleaseFence (zx::event fence)
 

Detailed Description

Definition at line 51 of file flatland_connection.h.

Constructor & Destructor Documentation

◆ FlatlandConnection()

flutter_runner::FlatlandConnection::FlatlandConnection ( const std::string &  debug_label,
fuchsia::ui::composition::FlatlandHandle  flatland,
fml::closure  error_callback,
on_frame_presented_event  on_frame_presented_callback,
async_dispatcher_t *  dispatcher = async_get_default_dispatcher() 
)

Definition at line 30 of file flatland_connection.cc.

36 : dispatcher_(dispatcher),
37 flatland_(flatland.Bind()),
38 error_callback_(std::move(error_callback)),
39 on_frame_presented_callback_(std::move(on_frame_presented_callback)) {
40 flatland_.set_error_handler([callback = error_callback_](zx_status_t status) {
41 FML_LOG(ERROR) << "Flatland disconnected: " << zx_status_get_string(status);
42 callback();
43 });
44 debug_label_ = debug_label;
45 flatland_->SetDebugName(debug_label);
46 flatland_.events().OnError =
47 fit::bind_member(this, &FlatlandConnection::OnError);
48 flatland_.events().OnFramePresented =
49 fit::bind_member(this, &FlatlandConnection::OnFramePresented);
50 flatland_.events().OnNextFrameBegin =
51 fit::bind_member(this, &FlatlandConnection::OnNextFrameBegin);
52}
fuchsia::ui::composition::Flatland * flatland()
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
#define FML_LOG(severity)
Definition: logging.h:82
#define ERROR(message)
Definition: elf_loader.cc:260

◆ ~FlatlandConnection()

flutter_runner::FlatlandConnection::~FlatlandConnection ( )
default

Member Function Documentation

◆ AwaitVsync()

void flutter_runner::FlatlandConnection::AwaitVsync ( FireCallbackCallback  callback)

Definition at line 170 of file flatland_connection.cc.

170 {
171 TRACE_DURATION("flutter", "FlatlandConnection::AwaitVsync");
172
173 std::scoped_lock<std::mutex> lock(threadsafe_state_.mutex_);
174 threadsafe_state_.pending_fire_callback_ = nullptr;
175 const auto now = fml::TimePoint::Now();
176
177 // Initial case.
178 if (MaybeRunInitialVsyncCallback(now, callback)) {
179 return;
180 }
181
182 // Throttle case.
183 if (threadsafe_state_.present_credits_ == 0) {
184 threadsafe_state_.pending_fire_callback_ = std::move(callback);
185 return;
186 }
187
188 // Regular case.
189 RunVsyncCallback(now, callback);
190}
static TimePoint Now()
Definition: time_point.cc:49

◆ AwaitVsyncForSecondaryCallback()

void flutter_runner::FlatlandConnection::AwaitVsyncForSecondaryCallback ( FireCallbackCallback  callback)

Definition at line 193 of file flatland_connection.cc.

194 {
195 TRACE_DURATION("flutter",
196 "FlatlandConnection::AwaitVsyncForSecondaryCallback");
197
198 std::scoped_lock<std::mutex> lock(threadsafe_state_.mutex_);
199 const auto now = fml::TimePoint::Now();
200
201 // Initial case.
202 if (MaybeRunInitialVsyncCallback(now, callback)) {
203 return;
204 }
205
206 // Regular case.
207 RunVsyncCallback(now, callback);
208}

◆ EnqueueAcquireFence()

void flutter_runner::FlatlandConnection::EnqueueAcquireFence ( zx::event  fence)

Definition at line 408 of file flatland_connection.cc.

408 {
409 Enqueue(std::move(fence), &acquire_fences_, &acquire_overflow_);
410}
static void Enqueue(zx::event fence, std::vector< zx::event > *fences, std::shared_ptr< Overflow > *overflow)

◆ EnqueueReleaseFence()

void flutter_runner::FlatlandConnection::EnqueueReleaseFence ( zx::event  fence)

Definition at line 413 of file flatland_connection.cc.

413 {
414 Enqueue(std::move(fence), &current_present_release_fences_,
415 &current_release_overflow_);
416}

◆ flatland()

fuchsia::ui::composition::Flatland * flutter_runner::FlatlandConnection::flatland ( )
inline

Definition at line 70 of file flatland_connection.h.

70{ return flatland_.get(); }

◆ NextContentId()

fuchsia::ui::composition::ContentId flutter_runner::FlatlandConnection::NextContentId ( )
inline

Definition at line 76 of file flatland_connection.h.

76 {
77 return {++next_content_id_};
78 }

◆ NextTransformId()

fuchsia::ui::composition::TransformId flutter_runner::FlatlandConnection::NextTransformId ( )
inline

Definition at line 72 of file flatland_connection.h.

72 {
73 return {++next_transform_id_};
74 }

◆ Present()

void flutter_runner::FlatlandConnection::Present ( )

Definition at line 57 of file flatland_connection.cc.

57 {
58 TRACE_DURATION("flutter", "FlatlandConnection::Present");
59 std::scoped_lock<std::mutex> lock(threadsafe_state_.mutex_);
60 if (threadsafe_state_.present_credits_ > 0) {
61 DoPresent();
62 } else {
63 present_waiting_for_credit_ = true;
64 }
65}

Member Data Documentation

◆ first_feedback_received_

bool flutter_runner::FlatlandConnection::first_feedback_received_ = false

Definition at line 140 of file flatland_connection.h.

◆ last_presentation_time_

fml::TimePoint flutter_runner::FlatlandConnection::last_presentation_time_

Definition at line 137 of file flatland_connection.h.

◆ mutex_

std::mutex flutter_runner::FlatlandConnection::mutex_

Definition at line 133 of file flatland_connection.h.

◆ next_presentation_times_

std::queue<fml::TimePoint> flutter_runner::FlatlandConnection::next_presentation_times_

Definition at line 134 of file flatland_connection.h.

◆ pending_fire_callback_

FireCallbackCallback flutter_runner::FlatlandConnection::pending_fire_callback_

Definition at line 138 of file flatland_connection.h.

◆ present_credits_

uint32_t flutter_runner::FlatlandConnection::present_credits_ = 1

Definition at line 139 of file flatland_connection.h.

◆ vsync_interval_

fml::TimeDelta flutter_runner::FlatlandConnection::vsync_interval_ = kInitialFlatlandVsyncOffset

Definition at line 135 of file flatland_connection.h.

◆ vsync_offset_

fml::TimeDelta flutter_runner::FlatlandConnection::vsync_offset_ = kInitialFlatlandVsyncOffset

Definition at line 136 of file flatland_connection.h.


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