Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
flutter_runner::FlatlandConnection Class Referencefinal

#include <flatland_connection.h>

Public Member Functions

 FlatlandConnection (std::string debug_label, fuchsia::ui::composition::FlatlandHandle flatland, fml::closure error_callback, on_frame_presented_event on_frame_presented_callback)
 
 ~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 34 of file flatland_connection.h.

Constructor & Destructor Documentation

◆ FlatlandConnection()

flutter_runner::FlatlandConnection::FlatlandConnection ( std::string  debug_label,
fuchsia::ui::composition::FlatlandHandle  flatland,
fml::closure  error_callback,
on_frame_presented_event  on_frame_presented_callback 
)

Definition at line 24 of file flatland_connection.cc.

29 : flatland_(flatland.Bind()),
30 error_callback_(error_callback),
31 on_frame_presented_callback_(std::move(on_frame_presented_callback)) {
32 flatland_.set_error_handler([callback = error_callback_](zx_status_t status) {
33 FML_LOG(ERROR) << "Flatland disconnected: " << zx_status_get_string(status);
34 callback();
35 });
36 debug_label_ = debug_label;
37 flatland_->SetDebugName(debug_label);
38 flatland_.events().OnError =
39 fit::bind_member(this, &FlatlandConnection::OnError);
40 flatland_.events().OnFramePresented =
41 fit::bind_member(this, &FlatlandConnection::OnFramePresented);
42 flatland_.events().OnNextFrameBegin =
43 fit::bind_member(this, &FlatlandConnection::OnNextFrameBegin);
44}
fuchsia::ui::composition::Flatland * flatland()
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
#define FML_LOG(severity)
Definition logging.h:82
#define ERROR(message)

◆ ~FlatlandConnection()

flutter_runner::FlatlandConnection::~FlatlandConnection ( )
default

Member Function Documentation

◆ AwaitVsync()

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

Definition at line 88 of file flatland_connection.cc.

88 {
89 TRACE_DURATION("flutter", "FlatlandConnection::AwaitVsync");
90
91 std::scoped_lock<std::mutex> lock(threadsafe_state_.mutex_);
92 threadsafe_state_.pending_fire_callback_ = nullptr;
93 const auto now = fml::TimePoint::Now();
94
95 // Initial case.
96 if (MaybeRunInitialVsyncCallback(now, callback))
97 return;
98
99 // Throttle case.
100 if (threadsafe_state_.present_credits_ == 0) {
101 threadsafe_state_.pending_fire_callback_ = callback;
102 return;
103 }
104
105 // Regular case.
106 RunVsyncCallback(now, callback);
107}
static TimePoint Now()
Definition time_point.cc:49

◆ AwaitVsyncForSecondaryCallback()

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

Definition at line 110 of file flatland_connection.cc.

111 {
112 TRACE_DURATION("flutter",
113 "FlatlandConnection::AwaitVsyncForSecondaryCallback");
114
115 std::scoped_lock<std::mutex> lock(threadsafe_state_.mutex_);
116 const auto now = fml::TimePoint::Now();
117
118 // Initial case.
119 if (MaybeRunInitialVsyncCallback(now, callback))
120 return;
121
122 // Regular case.
123 RunVsyncCallback(now, callback);
124}

◆ EnqueueAcquireFence()

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

Definition at line 264 of file flatland_connection.cc.

264 {
265 acquire_fences_.push_back(std::move(fence));
266}

◆ EnqueueReleaseFence()

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

Definition at line 269 of file flatland_connection.cc.

269 {
270 current_present_release_fences_.push_back(std::move(fence));
271}

◆ flatland()

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

Definition at line 51 of file flatland_connection.h.

51{ return flatland_.get(); }

◆ NextContentId()

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

Definition at line 57 of file flatland_connection.h.

57 {
58 return {++next_content_id_};
59 }

◆ NextTransformId()

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

Definition at line 53 of file flatland_connection.h.

53 {
54 return {++next_transform_id_};
55 }

◆ Present()

void flutter_runner::FlatlandConnection::Present ( )

Definition at line 49 of file flatland_connection.cc.

49 {
50 TRACE_DURATION("flutter", "FlatlandConnection::Present");
51 std::scoped_lock<std::mutex> lock(threadsafe_state_.mutex_);
52 if (threadsafe_state_.present_credits_ > 0) {
53 DoPresent();
54 } else {
55 present_waiting_for_credit_ = true;
56 }
57}

Member Data Documentation

◆ first_feedback_received_

bool flutter_runner::FlatlandConnection::first_feedback_received_ = false

Definition at line 102 of file flatland_connection.h.

◆ last_presentation_time_

fml::TimePoint flutter_runner::FlatlandConnection::last_presentation_time_

Definition at line 99 of file flatland_connection.h.

◆ mutex_

std::mutex flutter_runner::FlatlandConnection::mutex_

Definition at line 95 of file flatland_connection.h.

◆ next_presentation_times_

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

Definition at line 96 of file flatland_connection.h.

◆ pending_fire_callback_

FireCallbackCallback flutter_runner::FlatlandConnection::pending_fire_callback_

Definition at line 100 of file flatland_connection.h.

◆ present_credits_

uint32_t flutter_runner::FlatlandConnection::present_credits_ = 1

Definition at line 101 of file flatland_connection.h.

◆ vsync_interval_

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

Definition at line 97 of file flatland_connection.h.

◆ vsync_offset_

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

Definition at line 98 of file flatland_connection.h.


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