Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
platform_configuration.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
7#include <cstring>
8
22
23namespace flutter {
24namespace {
25
26Dart_Handle ToByteData(const fml::Mapping& buffer) {
27 return tonic::DartByteData::Create(buffer.GetMapping(), buffer.GetSize());
28}
29
30} // namespace
31
33
37
39
41 Dart_Handle library = Dart_LookupLibrary(tonic::ToDart("dart:ui"));
42
44 Dart_GetField(library, tonic::ToDart("_onError")));
46 Dart_GetField(library, tonic::ToDart("_addView")));
47 remove_view_.Set(tonic::DartState::Current(),
48 Dart_GetField(library, tonic::ToDart("_removeView")));
49 send_view_focus_event_.Set(
51 Dart_GetField(library, tonic::ToDart("_sendViewFocusEvent")));
52 set_engine_id_.Set(tonic::DartState::Current(),
53 Dart_GetField(library, tonic::ToDart("_setEngineId")));
54 update_window_metrics_.Set(
56 Dart_GetField(library, tonic::ToDart("_updateWindowMetrics")));
57 update_displays_.Set(
59 Dart_GetField(library, tonic::ToDart("_updateDisplays")));
60 update_locales_.Set(tonic::DartState::Current(),
61 Dart_GetField(library, tonic::ToDart("_updateLocales")));
62 update_user_settings_data_.Set(
64 Dart_GetField(library, tonic::ToDart("_updateUserSettingsData")));
65 update_initial_lifecycle_state_.Set(
67 Dart_GetField(library, tonic::ToDart("_updateInitialLifecycleState")));
68 update_semantics_enabled_.Set(
70 Dart_GetField(library, tonic::ToDart("_updateSemanticsEnabled")));
71 update_accessibility_features_.Set(
73 Dart_GetField(library, tonic::ToDart("_updateAccessibilityFeatures")));
74 dispatch_platform_message_.Set(
76 Dart_GetField(library, tonic::ToDart("_dispatchPlatformMessage")));
77 dispatch_pointer_data_packet_.Set(
79 Dart_GetField(library, tonic::ToDart("_dispatchPointerDataPacket")));
80 dispatch_semantics_action_.Set(
82 Dart_GetField(library, tonic::ToDart("_dispatchSemanticsAction")));
83 begin_frame_.Set(tonic::DartState::Current(),
84 Dart_GetField(library, tonic::ToDart("_beginFrame")));
85 draw_frame_.Set(tonic::DartState::Current(),
86 Dart_GetField(library, tonic::ToDart("_drawFrame")));
87 report_timings_.Set(tonic::DartState::Current(),
88 Dart_GetField(library, tonic::ToDart("_reportTimings")));
89}
90
92 const ViewportMetrics& view_metrics) {
93 auto [view_iterator, insertion_happened] =
94 metrics_.emplace(view_id, view_metrics);
95 if (!insertion_happened) {
96 FML_LOG(ERROR) << "View #" << view_id << " already exists.";
97 return false;
98 }
99
100 std::shared_ptr<tonic::DartState> dart_state = add_view_.dart_state().lock();
101 if (!dart_state) {
102 return false;
103 }
104 tonic::DartState::Scope scope(dart_state);
106 add_view_.Get(),
107 {
108 tonic::ToDart(view_id),
109 tonic::ToDart(view_metrics.device_pixel_ratio),
110 tonic::ToDart(view_metrics.physical_width),
111 tonic::ToDart(view_metrics.physical_height),
112 tonic::ToDart(view_metrics.physical_padding_top),
113 tonic::ToDart(view_metrics.physical_padding_right),
114 tonic::ToDart(view_metrics.physical_padding_bottom),
115 tonic::ToDart(view_metrics.physical_padding_left),
116 tonic::ToDart(view_metrics.physical_view_inset_top),
117 tonic::ToDart(view_metrics.physical_view_inset_right),
118 tonic::ToDart(view_metrics.physical_view_inset_bottom),
119 tonic::ToDart(view_metrics.physical_view_inset_left),
120 tonic::ToDart(view_metrics.physical_system_gesture_inset_top),
121 tonic::ToDart(view_metrics.physical_system_gesture_inset_right),
122 tonic::ToDart(view_metrics.physical_system_gesture_inset_bottom),
123 tonic::ToDart(view_metrics.physical_system_gesture_inset_left),
124 tonic::ToDart(view_metrics.physical_touch_slop),
125 tonic::ToDart(view_metrics.physical_display_features_bounds),
126 tonic::ToDart(view_metrics.physical_display_features_type),
127 tonic::ToDart(view_metrics.physical_display_features_state),
128 tonic::ToDart(view_metrics.display_id),
129 tonic::ToDart(view_metrics.physical_min_width_constraint),
130 tonic::ToDart(view_metrics.physical_max_width_constraint),
131 tonic::ToDart(view_metrics.physical_min_height_constraint),
132 tonic::ToDart(view_metrics.physical_max_height_constraint),
133 tonic::ToDart(view_metrics.physical_display_corner_radius_top_left),
134 tonic::ToDart(view_metrics.physical_display_corner_radius_top_right),
135 tonic::ToDart(
136 view_metrics.physical_display_corner_radius_bottom_right),
137 tonic::ToDart(
138 view_metrics.physical_display_corner_radius_bottom_left),
139 }));
140 return true;
141}
142
145 FML_LOG(FATAL) << "The implicit view #" << view_id << " cannot be removed.";
146 return false;
147 }
148 size_t erased_elements = metrics_.erase(view_id);
149 if (erased_elements == 0) {
150 FML_LOG(ERROR) << "View #" << view_id << " doesn't exist.";
151 return false;
152 }
153
154 std::shared_ptr<tonic::DartState> dart_state =
155 remove_view_.dart_state().lock();
156 if (!dart_state) {
157 return false;
158 }
159 tonic::DartState::Scope scope(dart_state);
161 tonic::DartInvoke(remove_view_.Get(), {
162 tonic::ToDart(view_id),
163 }));
164 return true;
165}
166
168 std::shared_ptr<tonic::DartState> dart_state =
169 remove_view_.dart_state().lock();
170 if (!dart_state) {
171 return false;
172 }
173 tonic::DartState::Scope scope(dart_state);
175 send_view_focus_event_.Get(), {
176 tonic::ToDart(event.view_id()),
177 tonic::ToDart(event.state()),
178 tonic::ToDart(event.direction()),
179 }));
180 return true;
181}
182
183bool PlatformConfiguration::SetEngineId(int64_t engine_id) {
184 std::shared_ptr<tonic::DartState> dart_state =
185 set_engine_id_.dart_state().lock();
186 if (!dart_state) {
187 return false;
188 }
189 tonic::DartState::Scope scope(dart_state);
191 tonic::DartInvoke(set_engine_id_.Get(), {
192 tonic::ToDart(engine_id),
193 }));
194 return true;
195}
196
198 int64_t view_id,
199 const ViewportMetrics& view_metrics) {
200 auto found_iter = metrics_.find(view_id);
201 if (found_iter == metrics_.end()) {
202 return false;
203 }
204
205 found_iter->second = view_metrics;
206
207 std::shared_ptr<tonic::DartState> dart_state =
208 update_window_metrics_.dart_state().lock();
209 if (!dart_state) {
210 return false;
211 }
212 tonic::DartState::Scope scope(dart_state);
214 update_window_metrics_.Get(),
215 {
216 tonic::ToDart(view_id),
217 tonic::ToDart(view_metrics.device_pixel_ratio),
218 tonic::ToDart(view_metrics.physical_width),
219 tonic::ToDart(view_metrics.physical_height),
220 tonic::ToDart(view_metrics.physical_padding_top),
221 tonic::ToDart(view_metrics.physical_padding_right),
222 tonic::ToDart(view_metrics.physical_padding_bottom),
223 tonic::ToDart(view_metrics.physical_padding_left),
224 tonic::ToDart(view_metrics.physical_view_inset_top),
225 tonic::ToDart(view_metrics.physical_view_inset_right),
226 tonic::ToDart(view_metrics.physical_view_inset_bottom),
227 tonic::ToDart(view_metrics.physical_view_inset_left),
228 tonic::ToDart(view_metrics.physical_system_gesture_inset_top),
229 tonic::ToDart(view_metrics.physical_system_gesture_inset_right),
230 tonic::ToDart(view_metrics.physical_system_gesture_inset_bottom),
231 tonic::ToDart(view_metrics.physical_system_gesture_inset_left),
232 tonic::ToDart(view_metrics.physical_touch_slop),
233 tonic::ToDart(view_metrics.physical_display_features_bounds),
234 tonic::ToDart(view_metrics.physical_display_features_type),
235 tonic::ToDart(view_metrics.physical_display_features_state),
236 tonic::ToDart(view_metrics.display_id),
237 tonic::ToDart(view_metrics.physical_min_width_constraint),
238 tonic::ToDart(view_metrics.physical_max_width_constraint),
239 tonic::ToDart(view_metrics.physical_min_height_constraint),
240 tonic::ToDart(view_metrics.physical_max_height_constraint),
241 tonic::ToDart(view_metrics.physical_display_corner_radius_top_left),
242 tonic::ToDart(view_metrics.physical_display_corner_radius_top_right),
243 tonic::ToDart(
244 view_metrics.physical_display_corner_radius_bottom_right),
245 tonic::ToDart(
246 view_metrics.physical_display_corner_radius_bottom_left),
247 }));
248 return true;
249}
250
252 const std::vector<DisplayData>& displays) {
253 std::vector<DisplayId> ids;
254 std::vector<double> widths;
255 std::vector<double> heights;
256 std::vector<double> device_pixel_ratios;
257 std::vector<double> refresh_rates;
258 for (const auto& display : displays) {
259 ids.push_back(display.id);
260 widths.push_back(display.width);
261 heights.push_back(display.height);
262 device_pixel_ratios.push_back(display.pixel_ratio);
263 refresh_rates.push_back(display.refresh_rate);
264 }
265 std::shared_ptr<tonic::DartState> dart_state =
266 update_displays_.dart_state().lock();
267 if (!dart_state) {
268 return;
269 }
270 tonic::DartState::Scope scope(dart_state);
272 update_displays_.Get(),
273 {
274 tonic::ToDart<std::vector<DisplayId>>(ids),
275 tonic::ToDart<std::vector<double>>(widths),
276 tonic::ToDart<std::vector<double>>(heights),
277 tonic::ToDart<std::vector<double>>(device_pixel_ratios),
278 tonic::ToDart<std::vector<double>>(refresh_rates),
279 }));
280}
281
283 const std::vector<std::string>& locales) {
284 std::shared_ptr<tonic::DartState> dart_state =
285 update_locales_.dart_state().lock();
286 if (!dart_state) {
287 return;
288 }
289
290 tonic::DartState::Scope scope(dart_state);
292 tonic::DartInvoke(update_locales_.Get(),
293 {
294 tonic::ToDart<std::vector<std::string>>(locales),
295 }));
296}
297
299 std::shared_ptr<tonic::DartState> dart_state =
300 update_user_settings_data_.dart_state().lock();
301 if (!dart_state) {
302 return;
303 }
304 tonic::DartState::Scope scope(dart_state);
305
306 tonic::CheckAndHandleError(tonic::DartInvoke(update_user_settings_data_.Get(),
307 {
308 tonic::StdStringToDart(data),
309 }));
310}
311
313 const std::string& data) {
314 std::shared_ptr<tonic::DartState> dart_state =
315 update_initial_lifecycle_state_.dart_state().lock();
316 if (!dart_state) {
317 return;
318 }
319 tonic::DartState::Scope scope(dart_state);
321 update_initial_lifecycle_state_.Get(), {
322 tonic::StdStringToDart(data),
323 }));
324}
325
327 std::shared_ptr<tonic::DartState> dart_state =
328 update_semantics_enabled_.dart_state().lock();
329 if (!dart_state) {
330 return;
331 }
332 tonic::DartState::Scope scope(dart_state);
334
335 tonic::CheckAndHandleError(tonic::DartInvoke(update_semantics_enabled_.Get(),
336 {tonic::ToDart(enabled)}));
337}
338
340 std::shared_ptr<tonic::DartState> dart_state =
341 update_accessibility_features_.dart_state().lock();
342 if (!dart_state) {
343 return;
344 }
345 tonic::DartState::Scope scope(dart_state);
346
348 update_accessibility_features_.Get(), {tonic::ToDart(values)}));
349}
350
352 std::unique_ptr<PlatformMessage> message) {
353 std::shared_ptr<tonic::DartState> dart_state =
354 dispatch_platform_message_.dart_state().lock();
355 if (!dart_state) {
356 FML_DLOG(WARNING)
357 << "Dropping platform message for lack of DartState on channel: "
358 << message->channel();
359 return;
360 }
361 tonic::DartState::Scope scope(dart_state);
362 Dart_Handle data_handle =
363 (message->hasData()) ? ToByteData(message->data()) : Dart_Null();
364 if (Dart_IsError(data_handle)) {
365 FML_DLOG(WARNING)
366 << "Dropping platform message because of a Dart error on channel: "
367 << message->channel();
368 return;
369 }
370
371 int response_id = 0;
372 if (auto response = message->response()) {
373 response_id = next_response_id_++;
374 pending_responses_[response_id] = response;
375 }
376
378 tonic::DartInvoke(dispatch_platform_message_.Get(),
379 {tonic::ToDart(message->channel()), data_handle,
380 tonic::ToDart(response_id)}));
381}
382
384 const PointerDataPacket& packet) {
385 std::shared_ptr<tonic::DartState> dart_state =
386 dispatch_pointer_data_packet_.dart_state().lock();
387 if (!dart_state) {
388 return;
389 }
390 tonic::DartState::Scope scope(dart_state);
391
392 const std::vector<uint8_t>& buffer = packet.data();
393 Dart_Handle data_handle =
395 if (Dart_IsError(data_handle)) {
396 return;
397 }
398
400 tonic::DartInvoke(dispatch_pointer_data_packet_.Get(), {data_handle}));
401}
402
404 int32_t node_id,
407 std::shared_ptr<tonic::DartState> dart_state =
408 dispatch_semantics_action_.dart_state().lock();
409 if (!dart_state) {
410 return;
411 }
412 tonic::DartState::Scope scope(dart_state);
413
414 Dart_Handle args_handle =
415 (args.GetSize() <= 0) ? Dart_Null() : ToByteData(args);
416
417 if (Dart_IsError(args_handle)) {
418 return;
419 }
420
422 dispatch_semantics_action_.Get(),
423 {tonic::ToDart(view_id), tonic::ToDart(node_id),
424 tonic::ToDart(static_cast<int32_t>(action)), args_handle}));
425}
426
428 uint64_t frame_number) {
429 std::shared_ptr<tonic::DartState> dart_state =
430 begin_frame_.dart_state().lock();
431 if (!dart_state) {
432 return;
433 }
434 tonic::DartState::Scope scope(dart_state);
435
436 if (last_frame_number_ > frame_number) {
437 FML_LOG(ERROR) << "Frame number is out of order: " << frame_number << " < "
438 << last_frame_number_;
439 }
440 last_frame_number_ = frame_number;
441
442 // frameTime is not a delta; its the timestamp of the presentation.
443 // This is just a type conversion.
444 int64_t microseconds = frameTime.ToEpochDelta().ToMicroseconds();
445 if (last_microseconds_ > microseconds) {
446 // Do not allow time traveling frametimes
447 // github.com/flutter/flutter/issues/106277
448 FML_LOG(ERROR)
449 << "Reported frame time is older than the last one; clamping. "
450 << microseconds << " < " << last_microseconds_
451 << " ~= " << last_microseconds_ - microseconds;
452 microseconds = last_microseconds_;
453 }
454 last_microseconds_ = microseconds;
455
457 tonic::DartInvoke(begin_frame_.Get(), {
458 Dart_NewInteger(microseconds),
459 Dart_NewInteger(frame_number),
460 }));
461
463
465}
466
467void PlatformConfiguration::ReportTimings(std::vector<int64_t> timings) {
468 std::shared_ptr<tonic::DartState> dart_state =
469 report_timings_.dart_state().lock();
470 if (!dart_state) {
471 return;
472 }
473 tonic::DartState::Scope scope(dart_state);
474
475 Dart_Handle data_handle =
476 Dart_NewTypedData(Dart_TypedData_kInt64, timings.size());
477
478 Dart_TypedData_Type type;
479 void* data = nullptr;
480 intptr_t num_acquired = 0;
481 FML_CHECK(!Dart_IsError(
482 Dart_TypedDataAcquireData(data_handle, &type, &data, &num_acquired)));
483 FML_DCHECK(num_acquired == static_cast<int>(timings.size()));
484
485 memcpy(data, timings.data(), sizeof(int64_t) * timings.size());
486 FML_CHECK(Dart_TypedDataReleaseData(data_handle));
487
489 tonic::DartInvoke(report_timings_.Get(), {
490 data_handle,
491 }));
492}
493
495 auto found = metrics_.find(view_id);
496 if (found != metrics_.end()) {
497 return &found->second;
498 } else {
499 return nullptr;
500 }
501}
502
504 int response_id) {
505 if (!response_id) {
506 return;
507 }
508 auto it = pending_responses_.find(response_id);
509 if (it == pending_responses_.end()) {
510 return;
511 }
512 auto response = std::move(it->second);
513 pending_responses_.erase(it);
514 response->CompleteEmpty();
515}
516
518 int response_id,
519 std::vector<uint8_t> data) {
520 if (!response_id) {
521 return;
522 }
523 auto it = pending_responses_.find(response_id);
524 if (it == pending_responses_.end()) {
525 return;
526 }
527 auto response = std::move(it->second);
528 pending_responses_.erase(it);
529 response->Complete(std::make_unique<fml::DataMapping>(std::move(data)));
530}
531
540
548
549namespace {
550Dart_Handle HandlePlatformMessage(
551 UIDartState* dart_state,
552 const std::string& name,
553 Dart_Handle data_handle,
554 const fml::RefPtr<PlatformMessageResponse>& response) {
555 if (Dart_IsNull(data_handle)) {
556 return dart_state->HandlePlatformMessage(
557 std::make_unique<PlatformMessage>(name, response));
558 } else {
559 tonic::DartByteData data(data_handle);
560 const uint8_t* buffer = static_cast<const uint8_t*>(data.data());
561 return dart_state->HandlePlatformMessage(std::make_unique<PlatformMessage>(
562 name, fml::MallocMapping::Copy(buffer, data.length_in_bytes()),
563 response));
564 }
565}
566} // namespace
567
569 const std::string& name,
570 Dart_Handle callback,
571 Dart_Handle data_handle) {
572 UIDartState* dart_state = UIDartState::Current();
573
574 if (!dart_state->platform_configuration()) {
575 return tonic::ToDart(
576 "SendPlatformMessage only works on the root isolate, see "
577 "SendPortPlatformMessage.");
578 }
579
581 if (!Dart_IsNull(callback)) {
582 response = fml::MakeRefCounted<PlatformMessageResponseDart>(
584 dart_state->GetTaskRunners().GetUITaskRunner(), name);
585 }
586
587 return HandlePlatformMessage(dart_state, name, data_handle, response);
588}
589
591 const std::string& name,
592 Dart_Handle identifier,
593 Dart_Handle send_port,
594 Dart_Handle data_handle) {
595 // This can be executed on any isolate.
596 UIDartState* dart_state = UIDartState::Current();
597
598 int64_t c_send_port = tonic::DartConverter<int64_t>::FromDart(send_port);
599 if (c_send_port == ILLEGAL_PORT) {
600 return tonic::ToDart("Invalid port specified");
601 }
602
604 fml::MakeRefCounted<PlatformMessageResponseDartPort>(
605 c_send_port, tonic::DartConverter<int64_t>::FromDart(identifier),
606 name);
607
608 return HandlePlatformMessage(dart_state, name, data_handle, response);
609}
610
612 int64_t state,
613 int64_t direction) {
615 static_cast<ViewFocusState>(state),
616 static_cast<ViewFocusDirection>(direction)};
617 UIDartState* dart_state = UIDartState::Current();
619 request);
620}
621
623 int response_id,
624 const tonic::DartByteData& data) {
625 if (Dart_IsNull(data.dart_handle())) {
629 } else {
630 // TODO(engine): Avoid this copy.
631 const uint8_t* buffer = static_cast<const uint8_t*>(data.data());
635 response_id,
636 std::vector<uint8_t>(buffer, buffer + data.length_in_bytes()));
637 }
638}
639
645
646Dart_PerformanceMode PlatformConfigurationNativeApi::current_performance_mode_ =
647 Dart_PerformanceMode_Default;
648
650 return current_performance_mode_;
651}
652
655 current_performance_mode_ = static_cast<Dart_PerformanceMode>(mode);
656 return Dart_SetPerformanceMode(current_performance_mode_);
657}
658
661
662 auto persistent_isolate_data = UIDartState::Current()
664 ->client()
666
667 if (!persistent_isolate_data) {
668 return Dart_Null();
669 }
670
671 return tonic::DartByteData::Create(persistent_isolate_data->GetMapping(),
672 persistent_isolate_data->GetSize());
673}
674
679
684
691
699
707
709 Dart_Handle supportedLocalesHandle) {
711 std::vector<std::string> supportedLocales =
713 supportedLocalesHandle);
714
715 std::vector<std::string> results =
718 ->client()
719 ->ComputePlatformResolvedLocale(supportedLocales);
720
721 return tonic::DartConverter<std::vector<std::string>>::ToDart(results);
722}
723
731
733 UIDartState* dart_state = UIDartState::Current();
734 FML_DCHECK(dart_state);
735 return dart_state->GetRootIsolateToken();
736}
737
739 int64_t root_isolate_token) {
740 UIDartState* dart_state = UIDartState::Current();
741 FML_DCHECK(dart_state && !dart_state->IsRootIsolate());
742 auto platform_message_handler =
743 (*static_cast<std::shared_ptr<PlatformMessageHandlerStorage>*>(
744 Dart_CurrentIsolateGroupData()));
745 FML_DCHECK(platform_message_handler);
746 auto weak_platform_message_handler =
747 platform_message_handler->GetPlatformMessageHandler(root_isolate_token);
748 dart_state->SetPlatformMessageHandler(weak_platform_message_handler);
749}
750
752 bool listening) {
754 name, listening);
755}
756
758 double unscaled_font_size,
759 int configuration_id) {
761 return UIDartState::Current()
763 ->client()
764 ->GetScaledFontSize(unscaled_font_size, configuration_id);
765}
766} // namespace flutter
GLenum type
A client interface that the RuntimeController uses to define handlers for PlatformConfiguration reque...
virtual void RequestViewFocusChange(const ViewFocusChangeRequest &request)=0
Notifies the client that the Flutter view focus state has changed and the platform view should be upd...
virtual std::shared_ptr< const fml::Mapping > GetPersistentIsolateData()=0
The embedder can specify data that the isolate can request synchronously on launch....
virtual void EndWarmUpFrame()=0
Called when a warm up frame has ended.
virtual void SetApplicationLocale(std::string locale)=0
Framework sets the application locale.
virtual void SetNeedsReportTimings(bool value)=0
Notifies this client that the application has an opinion about whether its frame timings need to be r...
virtual void SetSemanticsTreeEnabled(bool enabled)=0
Notifies whether Framework starts generating semantics tree.
virtual std::string DefaultRouteName()=0
The route or path that the embedder requested when the application was launched.
virtual void ScheduleFrame()=0
Requests that, at the next appropriate opportunity, a new frame be scheduled for rendering.
virtual double GetScaledFontSize(double unscaled_font_size, int configuration_id) const =0
Synchronously invokes platform-specific APIs to apply the system text scaling on the given unscaled f...
virtual std::unique_ptr< std::vector< std::string > > ComputePlatformResolvedLocale(const std::vector< std::string > &supported_locale_data)=0
Directly invokes platform-specific APIs to compute the locale the platform would have natively resolv...
virtual void UpdateSemantics(int64_t viewId, SemanticsUpdate *update)=0
Receives an updated semantics tree from the Framework.
virtual void Render(int64_t view_id, Scene *scene, double width, double height)=0
Updates the client's rendering on the GPU with the newly provided Scene.
virtual void SendChannelUpdate(std::string name, bool listening)=0
Invoked when a listener is registered on a platform channel.
void UpdateAccessibilityFeatures(int32_t flags)
Forward the preference of accessibility features that must be enabled in the semantics tree to the fr...
bool SetEngineId(int64_t engine_id)
Sets the opaque identifier of the engine.
void DidCreateIsolate()
Called by the RuntimeController once it has created the root isolate, so that the PlatformController ...
void DispatchPointerDataPacket(const PointerDataPacket &packet)
Notifies the PlatformConfiguration that the client has sent it pointer events. This call originates i...
void CompletePlatformMessageResponse(int response_id, std::vector< uint8_t > data)
Responds to a previous platform message to the engine from the framework.
void DispatchSemanticsAction(int64_t view_id, int32_t node_id, SemanticsAction action, fml::MallocMapping args)
Notifies the framework that the embedder encountered an accessibility related action on the specified...
void DispatchPlatformMessage(std::unique_ptr< PlatformMessage > message)
Notifies the PlatformConfiguration that the client has sent it a message. This call originates in the...
bool SendFocusEvent(const ViewFocusEvent &event)
Notify the isolate that the focus state of a native view has changed.
PlatformConfiguration(PlatformConfigurationClient *client)
Creates a new PlatformConfiguration, typically created by the RuntimeController.
void UpdateSemanticsEnabled(bool enabled)
Notifies the PlatformConfiguration that the embedder has expressed an opinion about whether the acces...
void ReportTimings(std::vector< int64_t > timings)
Dart code cannot fully measure the time it takes for a specific frame to be rendered....
bool AddView(int64_t view_id, const ViewportMetrics &view_metrics)
Notify the framework that a new view is available.
void UpdateInitialLifecycleState(const std::string &data)
Updates the lifecycle state data in the framework.
void UpdateDisplays(const std::vector< DisplayData > &displays)
Update the specified display data in the framework.
void UpdateLocales(const std::vector< std::string > &locales)
Update the specified locale data in the framework.
bool RemoveView(int64_t view_id)
Notify the framework that a view is no longer available.
void BeginFrame(fml::TimePoint frame_time, uint64_t frame_number)
Notifies the framework that it is time to begin working on a new frame previously scheduled via a cal...
void CompletePlatformMessageEmptyResponse(int response_id)
Responds to a previous platform message to the engine from the framework with an empty response.
const ViewportMetrics * GetMetrics(int view_id)
Retrieves the viewport metrics with the given ID managed by the PlatformConfiguration.
bool UpdateViewMetrics(int64_t view_id, const ViewportMetrics &metrics)
Update the view metrics for the specified view.
PlatformConfigurationClient * client() const
Access to the platform configuration client (which typically is implemented by the RuntimeController)...
void UpdateUserSettingsData(const std::string &data)
Update the user settings data in the framework.
static void UpdateSemantics(int64_t viewId, SemanticsUpdate *update)
static void SendChannelUpdate(const std::string &name, bool listening)
static void Render(int64_t view_id, Scene *scene, double width, double height)
static Dart_Handle SendPortPlatformMessage(const std::string &name, Dart_Handle identifier, Dart_Handle send_port, Dart_Handle data_handle)
static void SetApplicationLocale(std::string locale)
static double GetScaledFontSize(double unscaled_font_size, int configuration_id)
static void RequestViewFocusChange(int64_t view_id, int64_t state, int64_t direction)
static int RequestDartPerformanceMode(int mode)
Requests the Dart VM to adjusts the GC heuristics based on the requested performance_mode....
static Dart_PerformanceMode GetDartPerformanceMode()
Returns the current performance mode of the Dart VM. Defaults to Dart_PerformanceMode_Default if no p...
static Dart_Handle ComputePlatformResolvedLocale(Dart_Handle supportedLocalesHandle)
static void RegisterBackgroundIsolate(int64_t root_isolate_token)
static Dart_Handle SendPlatformMessage(const std::string &name, Dart_Handle callback, Dart_Handle data_handle)
static void RespondToPlatformMessage(int response_id, const tonic::DartByteData &data)
static void SetIsolateDebugName(const std::string &name)
const std::vector< uint8_t > & data() const
fml::RefPtr< fml::TaskRunner > GetUITaskRunner() const
PlatformConfiguration * platform_configuration() const
bool IsRootIsolate() const
const TaskRunners & GetTaskRunners() const
void SetDebugName(const std::string &name)
int64_t GetRootIsolateToken() const
void SetPlatformMessageHandler(std::weak_ptr< PlatformMessageHandler > handler)
static UIDartState * Current()
static void ThrowIfUIOperationsProhibited()
Dart_Handle HandlePlatformMessage(std::unique_ptr< PlatformMessage > message)
A Mapping like NonOwnedMapping, but uses Free as its release proc.
Definition mapping.h:144
static MallocMapping Copy(const T *begin, const T *end)
Definition mapping.h:162
constexpr int64_t ToMicroseconds() const
Definition time_delta.h:62
constexpr TimeDelta ToEpochDelta() const
Definition time_point.h:52
static Dart_Handle Create(const void *data, size_t length)
void Set(DartState *dart_state, Dart_Handle value)
const std::weak_ptr< DartState > & dart_state() const
static DartState * Current()
Definition dart_state.cc:56
int32_t value
const char * message
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
G_BEGIN_DECLS FlutterViewId view_id
FlutterDesktopBinaryReply callback
#define FML_DLOG(severity)
Definition logging.h:121
#define FML_LOG(severity)
Definition logging.h:101
#define FML_CHECK(condition)
Definition logging.h:104
#define FML_DCHECK(condition)
Definition logging.h:122
constexpr int64_t kFlutterImplicitViewId
Definition constants.h:35
DEF_SWITCHES_START aot vmservice shared library name
Definition switch_defs.h:27
ViewFocusDirection
Definition view_focus.h:22
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switch_defs.h:36
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set profile Make the profiler discard new samples once the profiler sample buffer is full When this flag is not the profiler sample buffer is used as a ring buffer
Definition switch_defs.h:98
Dart_Handle ToDart(const T &object)
Dart_Handle DartInvoke(Dart_Handle closure, std::initializer_list< Dart_Handle > args)
Dart_Handle DartInvokeVoid(Dart_Handle closure)
bool CheckAndHandleError(Dart_Handle handle)
Definition dart_error.cc:33
std::vector< FlutterEngineDisplay > * displays
int32_t height
int32_t width