Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
platform_configuration.h
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
5#ifndef FLUTTER_LIB_UI_WINDOW_PLATFORM_CONFIGURATION_H_
6#define FLUTTER_LIB_UI_WINDOW_PLATFORM_CONFIGURATION_H_
7
8#include <functional>
9#include <memory>
10#include <string>
11#include <unordered_map>
12#include <vector>
13
24#include "fml/macros.h"
27
28namespace flutter {
29class FontCollection;
30class PlatformMessage;
32class PlatformIsolateManager;
33class Scene;
34
35// Forward declaration of friendly tests.
36namespace testing {
38}
39
40//--------------------------------------------------------------------------
41/// @brief An enum for defining the different kinds of accessibility features
42/// that can be enabled by the platform.
43///
44/// Must match the `AccessibilityFeatures` class in framework.
45enum class AccessibilityFeatureFlag : int32_t {
46 kAccessibleNavigation = 1 << 0,
47 kInvertColors = 1 << 1,
48 kDisableAnimations = 1 << 2,
49 kBoldText = 1 << 3,
50 kReduceMotion = 1 << 4,
51 kHighContrast = 1 << 5,
52 kOnOffSwitchLabels = 1 << 6,
53 kNoAnnounce = 1 << 7,
55 kNoAutoPlayVideos = 1 << 9,
56 kDeterministicCursor = 1 << 10,
57};
58
59//--------------------------------------------------------------------------
60/// @brief A client interface that the `RuntimeController` uses to define
61/// handlers for `PlatformConfiguration` requests.
62///
63/// @see `PlatformConfiguration`
64///
66 public:
67 //--------------------------------------------------------------------------
68 /// @brief The route or path that the embedder requested when the
69 /// application was launched.
70 ///
71 /// This will be the string "`/`" if no particular route was
72 /// requested.
73 ///
74 virtual std::string DefaultRouteName() = 0;
75
76 //--------------------------------------------------------------------------
77 /// @brief Requests that, at the next appropriate opportunity, a new
78 /// frame be scheduled for rendering.
79 ///
80 virtual void ScheduleFrame() = 0;
81
82 //--------------------------------------------------------------------------
83 /// @brief Called when a warm up frame has ended.
84 ///
85 /// For more introduction, see `Animator::EndWarmUpFrame`.
86 ///
87 virtual void EndWarmUpFrame() = 0;
88
89 //--------------------------------------------------------------------------
90 /// @brief Updates the client's rendering on the GPU with the newly
91 /// provided Scene.
92 ///
93 virtual void Render(int64_t view_id,
94 Scene* scene,
95 double width,
96 double height) = 0;
97
98 //--------------------------------------------------------------------------
99 /// @brief Receives an updated semantics tree from the Framework.
100 ///
101 /// @param[in] viewId The identifier of the view to update.
102 /// @param[in] update The updated semantic tree to apply.
103 ///
104 virtual void UpdateSemantics(int64_t viewId, SemanticsUpdate* update) = 0;
105
106 //--------------------------------------------------------------------------
107 /// @brief Framework sets the application locale
108 ///
109 /// @param[in] locale The application locale in BCP 47 format.
110 ///
111 virtual void SetApplicationLocale(std::string locale) = 0;
112
113 //--------------------------------------------------------------------------
114 /// @brief Notifies whether Framework starts generating semantics tree.
115 ///
116 /// @param[in] enabled True if Framework starts generating semantics tree.
117 ///
118 virtual void SetSemanticsTreeEnabled(bool enabled) = 0;
119
120 //--------------------------------------------------------------------------
121 /// @brief When the Flutter application has a message to send to the
122 /// underlying platform, the message needs to be forwarded to
123 /// the platform on the appropriate thread (via the platform
124 /// task runner). The PlatformConfiguration delegates this task
125 /// to the engine via this method.
126 ///
127 /// @see `PlatformView::HandlePlatformMessage`
128 ///
129 /// @param[in] message The message from the Flutter application to send to
130 /// the underlying platform.
131 ///
133 std::unique_ptr<PlatformMessage> message) = 0;
134
135 //--------------------------------------------------------------------------
136 /// @brief Returns the current collection of fonts available on the
137 /// platform.
138 ///
139 /// This function reads an XML file and makes font families and
140 /// collections of them. MinikinFontForTest is used for FontFamily
141 /// creation.
143
144 //--------------------------------------------------------------------------
145 /// @brief Returns the current collection of assets available on the
146 /// platform.
147 virtual std::shared_ptr<AssetManager> GetAssetManager() = 0;
148
149 //--------------------------------------------------------------------------
150 /// @brief Notifies this client of the name of the root isolate and its
151 /// port when that isolate is launched, restarted (in the
152 /// cold-restart scenario) or the application itself updates the
153 /// name of the root isolate (via `Window.setIsolateDebugName`
154 /// in `window.dart`). The name of the isolate is meaningless to
155 /// the engine but is used in instrumentation and tooling.
156 /// Currently, this information is to update the service
157 /// protocol list of available root isolates running in the VM
158 /// and their names so that the appropriate isolate can be
159 /// selected in the tools for debugging and instrumentation.
160 ///
161 /// @param[in] isolate_name The isolate name
162 /// @param[in] isolate_port The isolate port
163 ///
164 virtual void UpdateIsolateDescription(const std::string isolate_name,
165 int64_t isolate_port) = 0;
166
167 //--------------------------------------------------------------------------
168 /// @brief Notifies this client that the application has an opinion about
169 /// whether its frame timings need to be reported backed to it.
170 /// Due to the asynchronous nature of rendering in Flutter, it is
171 /// not possible for the application to determine the total time
172 /// it took to render a specific frame. While the layer-tree is
173 /// constructed on the UI thread, it needs to be rendering on the
174 /// raster thread. Dart code cannot execute on this thread. So any
175 /// instrumentation about the frame times gathered on this thread
176 /// needs to be aggregated and sent back to the UI thread for
177 /// processing in Dart.
178 ///
179 /// When the application indicates that frame times need to be
180 /// reported, it collects this information till a specified number
181 /// of data points are gathered. Then this information is sent
182 /// back to Dart code via `Engine::ReportTimings`.
183 ///
184 /// This option is engine counterpart of the
185 /// `Window._setNeedsReportTimings` in `window.dart`.
186 ///
187 /// @param[in] needs_reporting If reporting information should be collected
188 /// and send back to Dart.
189 ///
190 virtual void SetNeedsReportTimings(bool value) = 0;
191
192 //--------------------------------------------------------------------------
193 /// @brief The embedder can specify data that the isolate can request
194 /// synchronously on launch. This accessor fetches that data.
195 ///
196 /// This data is persistent for the duration of the Flutter
197 /// application and is available even after isolate restarts.
198 /// Because of this lifecycle, the size of this data must be kept
199 /// to a minimum.
200 ///
201 /// For asynchronous communication between the embedder and
202 /// isolate, a platform channel may be used.
203 ///
204 /// @return A map of the isolate data that the framework can request upon
205 /// launch.
206 ///
207 virtual std::shared_ptr<const fml::Mapping> GetPersistentIsolateData() = 0;
208
209 //--------------------------------------------------------------------------
210 /// @brief Directly invokes platform-specific APIs to compute the
211 /// locale the platform would have natively resolved to.
212 ///
213 /// @param[in] supported_locale_data The vector of strings that represents
214 /// the locales supported by the app.
215 /// Each locale consists of three
216 /// strings: languageCode, countryCode,
217 /// and scriptCode in that order.
218 ///
219 /// @return A vector of 3 strings languageCode, countryCode, and
220 /// scriptCode that represents the locale selected by the
221 /// platform. Empty strings mean the value was unassigned. Empty
222 /// vector represents a null locale.
223 ///
224 virtual std::unique_ptr<std::vector<std::string>>
226 const std::vector<std::string>& supported_locale_data) = 0;
227
228 //--------------------------------------------------------------------------
229 /// @brief Invoked when the Dart VM requests that a deferred library
230 /// be loaded. Notifies the engine that the deferred library
231 /// identified by the specified loading unit id should be
232 /// downloaded and loaded into the Dart VM via
233 /// `LoadDartDeferredLibrary`
234 ///
235 /// Upon encountering errors or otherwise failing to load a
236 /// loading unit with the specified id, the failure should be
237 /// directly reported to dart by calling
238 /// `LoadDartDeferredLibraryFailure` to ensure the waiting dart
239 /// future completes with an error.
240 ///
241 /// @param[in] loading_unit_id The unique id of the deferred library's
242 /// loading unit. This id is to be passed
243 /// back into LoadDartDeferredLibrary
244 /// in order to identify which deferred
245 /// library to load.
246 ///
247 virtual void RequestDartDeferredLibrary(intptr_t loading_unit_id) = 0;
248
249 //--------------------------------------------------------------------------
250 /// @brief Invoked when a listener is registered on a platform channel.
251 ///
252 /// @param[in] name The name of the platform channel to which a
253 /// listener has been registered or cleared.
254 ///
255 /// @param[in] listening Whether the listener has been set (true) or
256 /// cleared (false).
257 ///
258 virtual void SendChannelUpdate(std::string name, bool listening) = 0;
259
260 //--------------------------------------------------------------------------
261 /// @brief Synchronously invokes platform-specific APIs to apply the
262 /// system text scaling on the given unscaled font size.
263 ///
264 /// Platforms that support this feature (currently it's only
265 /// implemented for Android SDK level 34+) will send a valid
266 /// configuration_id to potential callers, before this method can
267 /// be called.
268 ///
269 /// @param[in] unscaled_font_size The unscaled font size specified by the
270 /// app developer. The value is in logical
271 /// pixels, and is guaranteed to be finite and
272 /// non-negative.
273 /// @param[in] configuration_id The unique id of the configuration to use
274 /// for computing the scaled font size.
275 ///
276 /// @return The scaled font size in logical pixels, or -1 if the given
277 /// configuration_id did not match a valid configuration.
278 ///
279 virtual double GetScaledFontSize(double unscaled_font_size,
280 int configuration_id) const = 0;
281
282 //--------------------------------------------------------------------------
283 /// @brief Notifies the client that the Flutter view focus state has
284 /// changed and the platform view should be updated.
285 ///
286 /// @param[in] request The request to change the focus state of the view.
288 const ViewFocusChangeRequest& request) = 0;
289
290 virtual std::shared_ptr<PlatformIsolateManager>
292
293 protected:
295};
296
297//----------------------------------------------------------------------------
298/// @brief A class for holding and distributing platform-level information
299/// to and from the Dart code in Flutter's framework.
300///
301/// It handles communication between the engine and the framework.
302///
303/// It communicates with the RuntimeController through the use of a
304/// PlatformConfigurationClient interface, which the
305/// RuntimeController defines.
306///
308 public:
309 //----------------------------------------------------------------------------
310 /// @brief Creates a new PlatformConfiguration, typically created by the
311 /// RuntimeController.
312 ///
313 /// @param[in] client The `PlatformConfigurationClient` to be injected into
314 /// the PlatformConfiguration. This client is used to
315 /// forward requests to the RuntimeController.
316 ///
318
319 // PlatformConfiguration is not copyable.
322
324
325 //----------------------------------------------------------------------------
326 /// @brief Access to the platform configuration client (which typically
327 /// is implemented by the RuntimeController).
328 ///
329 /// @return Returns the client used to construct this
330 /// PlatformConfiguration.
331 ///
332 PlatformConfigurationClient* client() const { return client_; }
333
334 //----------------------------------------------------------------------------
335 /// @brief Called by the RuntimeController once it has created the root
336 /// isolate, so that the PlatformController can get a handle to
337 /// the 'dart:ui' library.
338 ///
339 /// It uses the handle to call the hooks in hooks.dart.
340 ///
341 void DidCreateIsolate();
342
343 //----------------------------------------------------------------------------
344 /// @brief Notify the framework that a new view is available.
345 ///
346 /// A view must be added before other methods can refer to it,
347 /// including the implicit view. Adding a view that already exists
348 /// triggers an assertion.
349 ///
350 /// @param[in] view_id The ID of the new view.
351 /// @param[in] viewport_metrics The initial viewport metrics for the view.
352 ///
353 /// @return Whether the view was added.
354 ///
355 bool AddView(int64_t view_id, const ViewportMetrics& view_metrics);
356
357 //----------------------------------------------------------------------------
358 /// @brief Notify the framework that a view is no longer available.
359 ///
360 /// Removing a view that does not exist triggers an assertion.
361 ///
362 /// The implicit view (kFlutterImplicitViewId) should never be
363 /// removed. Doing so triggers an assertion.
364 ///
365 /// @param[in] view_id The ID of the view.
366 ///
367 /// @return Whether the view was removed.
368 ///
369 bool RemoveView(int64_t view_id);
370
371 //----------------------------------------------------------------------------
372 /// @brief Notify the isolate that the focus state of a native view has
373 /// changed.
374 ///
375 /// @param[in] event The focus event describing the change.
376 ///
377 /// @return Whether the focus event was sent.
378 bool SendFocusEvent(const ViewFocusEvent& event);
379
380 /// @brief Sets the opaque identifier of the engine.
381 ///
382 /// The identifier can be passed from Dart to native code to
383 /// retrieve the engine instance.
384 ///
385 /// @return Whether the identifier was set.
386 bool SetEngineId(int64_t engine_id);
387
388 //----------------------------------------------------------------------------
389 /// @brief Update the view metrics for the specified view.
390 ///
391 /// If the view is not found, silently return false.
392 ///
393 /// @param[in] view_id The ID of the view.
394 /// @param[in] metrics The new metrics of the view.
395 ///
396 /// @return Whether the view is found.
397 ///
398 bool UpdateViewMetrics(int64_t view_id, const ViewportMetrics& metrics);
399
400 //----------------------------------------------------------------------------
401 /// @brief Update the specified display data in the framework.
402 ///
403 /// @param[in] displays The display data to send to Dart.
404 ///
405 void UpdateDisplays(const std::vector<DisplayData>& displays);
406
407 //----------------------------------------------------------------------------
408 /// @brief Update the specified locale data in the framework.
409 ///
410 /// @param[in] locale_data The locale data. This should consist of groups of
411 /// 4 strings, each group representing a single locale.
412 ///
413 void UpdateLocales(const std::vector<std::string>& locales);
414
415 //----------------------------------------------------------------------------
416 /// @brief Update the user settings data in the framework.
417 ///
418 /// @param[in] data The user settings data.
419 ///
420 void UpdateUserSettingsData(const std::string& data);
421
422 //----------------------------------------------------------------------------
423 /// @brief Updates the lifecycle state data in the framework.
424 ///
425 /// @param[in] data The lifecycle state data.
426 ///
427 void UpdateInitialLifecycleState(const std::string& data);
428
429 //----------------------------------------------------------------------------
430 /// @brief Notifies the PlatformConfiguration that the embedder has
431 /// expressed an opinion about whether the accessibility tree
432 /// should be generated or not. This call originates in the
433 /// platform view and is forwarded to the PlatformConfiguration
434 /// here by the engine.
435 ///
436 /// @param[in] enabled Whether the accessibility tree is enabled or
437 /// disabled.
438 ///
439 void UpdateSemanticsEnabled(bool enabled);
440
441 //----------------------------------------------------------------------------
442 /// @brief Forward the preference of accessibility features that must be
443 /// enabled in the semantics tree to the framwork.
444 ///
445 /// @param[in] flags The accessibility features that must be generated in
446 /// the semantics tree.
447 ///
448 void UpdateAccessibilityFeatures(int32_t flags);
449
450 //----------------------------------------------------------------------------
451 /// @brief Notifies the PlatformConfiguration that the client has sent
452 /// it a message. This call originates in the platform view and
453 /// has been forwarded through the engine to here.
454 ///
455 /// @param[in] message The message sent from the embedder to the Dart
456 /// application.
457 ///
458 void DispatchPlatformMessage(std::unique_ptr<PlatformMessage> message);
459
460 //----------------------------------------------------------------------------
461 /// @brief Notifies the PlatformConfiguration that the client has sent
462 /// it pointer events. This call originates in the platform view
463 /// and has been forwarded through the engine to here.
464 ///
465 /// @param[in] packet The pointer event(s) serialized into a packet.
466 ///
468
469 //----------------------------------------------------------------------------
470 /// @brief Requests to perform framework hit test from the engine.
471 ///
472 /// @param[in] view_id The identifier of the flutter view that
473 /// should be hit tested.
474 /// @param[in] offset The position in the view that should be hit tested.
475 ///
476 /// @return The hit test response.
477 ///
478 HitTestResponse HitTest(int64_t view_id, const flutter::PointData offset);
479
480 //----------------------------------------------------------------------------
481 /// @brief Notifies the framework that the embedder encountered an
482 /// accessibility related action on the specified node. This call
483 /// originates on the platform view and has been forwarded to the
484 /// platform configuration here by the engine.
485 ///
486 /// @param[in] view_id The identifier of the view.
487 /// @param[in] node_id The identifier of the accessibility node.
488 /// @param[in] action The accessibility related action performed on the
489 /// node of the specified ID.
490 /// @param[in] args Optional data that applies to the specified action.
491 ///
492 void DispatchSemanticsAction(int64_t view_id,
493 int32_t node_id,
496
497 //----------------------------------------------------------------------------
498 /// @brief Notifies the framework that it is time to begin working on a
499 /// new frame previously scheduled via a call to
500 /// `PlatformConfigurationClient::ScheduleFrame`. This call
501 /// originates in the animator.
502 ///
503 /// The frame time given as the argument indicates the point at
504 /// which the current frame interval began. It is very slightly
505 /// (because of scheduling overhead) in the past. If a new layer
506 /// tree is not produced and given to the raster task runner
507 /// within one frame interval from this point, the Flutter
508 /// application will jank.
509 ///
510 /// This method calls the `::_beginFrame` method in `hooks.dart`.
511 ///
512 /// @param[in] frame_time The point at which the current frame interval
513 /// began. May be used by animation interpolators,
514 /// physics simulations, etc..
515 ///
516 /// @param[in] frame_number The frame number recorded by the animator. Used
517 /// by the framework to associate frame specific
518 /// debug information with frame timings and timeline
519 /// events.
520 ///
521 void BeginFrame(fml::TimePoint frame_time, uint64_t frame_number);
522
523 //----------------------------------------------------------------------------
524 /// @brief Dart code cannot fully measure the time it takes for a
525 /// specific frame to be rendered. This is because Dart code only
526 /// runs on the UI task runner. That is only a small part of the
527 /// overall frame workload. The raster task runner frame workload
528 /// is executed on a thread where Dart code cannot run (and hence
529 /// instrument). Besides, due to the pipelined nature of rendering
530 /// in Flutter, there may be multiple frame workloads being
531 /// processed at any given time. However, for non-Timeline based
532 /// profiling, it is useful for trace collection and processing to
533 /// happen in Dart. To do this, the raster task runner frame
534 /// workloads need to be instrumented separately. After a set
535 /// number of these profiles have been gathered, they need to be
536 /// reported back to Dart code. The engine reports this extra
537 /// instrumentation information back to the framework by invoking
538 /// this method at predefined intervals.
539 ///
540 /// @see `FrameTiming`
541 ///
542 /// @param[in] timings Collection of `FrameTiming::kStatisticsCount` * 'n'
543 /// values for `n` frames whose timings have not been
544 /// reported yet. Many of the values are timestamps, but
545 /// a collection of integers is reported here for easier
546 /// conversions to Dart objects. The timestamps are
547 /// measured against the system monotonic clock measured
548 /// in microseconds.
549 ///
550 void ReportTimings(std::vector<int64_t> timings);
551
552 //----------------------------------------------------------------------------
553 /// @brief Retrieves the viewport metrics with the given ID managed by
554 /// the `PlatformConfiguration`.
555 ///
556 /// @param[in] view_id The id of the view's viewport metrics to return.
557 ///
558 /// @return a pointer to the ViewportMetrics. Returns nullptr if the ID is
559 /// not found.
560 ///
562
563 //----------------------------------------------------------------------------
564 /// @brief Responds to a previous platform message to the engine from the
565 /// framework.
566 ///
567 /// @param[in] response_id The unique id that identifies the original platform
568 /// message to respond to.
569 /// @param[in] data The data to send back in the response.
570 ///
571 void CompletePlatformMessageResponse(int response_id,
572 std::vector<uint8_t> data);
573
574 //----------------------------------------------------------------------------
575 /// @brief Responds to a previous platform message to the engine from the
576 /// framework with an empty response.
577 ///
578 /// @param[in] response_id The unique id that identifies the original platform
579 /// message to respond to.
580 ///
581 void CompletePlatformMessageEmptyResponse(int response_id);
582
583 Dart_Handle on_error() { return on_error_.Get(); }
584
585 private:
587
591 tonic::DartPersistentValue remove_view_;
592 tonic::DartPersistentValue send_view_focus_event_;
593 tonic::DartPersistentValue set_engine_id_;
594 tonic::DartPersistentValue update_window_metrics_;
595 tonic::DartPersistentValue update_displays_;
596 tonic::DartPersistentValue update_locales_;
597 tonic::DartPersistentValue update_user_settings_data_;
598 tonic::DartPersistentValue update_initial_lifecycle_state_;
599 tonic::DartPersistentValue update_semantics_enabled_;
600 tonic::DartPersistentValue update_accessibility_features_;
601 tonic::DartPersistentValue dispatch_platform_message_;
602 tonic::DartPersistentValue dispatch_pointer_data_packet_;
604 tonic::DartPersistentValue dispatch_semantics_action_;
605 tonic::DartPersistentValue begin_frame_;
606 tonic::DartPersistentValue draw_frame_;
607 tonic::DartPersistentValue report_timings_;
608
609 uint64_t last_frame_number_ = 0;
610 int64_t last_microseconds_ = 0;
611
612 // All current views' view metrics mapped from view IDs.
613 std::unordered_map<int64_t, ViewportMetrics> metrics_;
614
615 // ID starts at 1 because an ID of 0 indicates that no response is expected.
616 int next_response_id_ = 1;
617 std::unordered_map<int, fml::RefPtr<PlatformMessageResponse>>
618 pending_responses_;
619};
620
621//----------------------------------------------------------------------------
622/// An inteface that the result of `Dart_CurrentIsolateGroupData` should
623/// implement for registering background isolates to work.
625 public:
628 int64_t root_isolate_token,
629 std::weak_ptr<PlatformMessageHandler> handler) = 0;
630
631 virtual std::weak_ptr<PlatformMessageHandler> GetPlatformMessageHandler(
632 int64_t root_isolate_token) const = 0;
633};
634
635//----------------------------------------------------------------------------
636// API exposed as FFI calls in Dart.
637//
638// These are probably not supposed to be called directly, and should instead
639// be called through their sibling API in `PlatformConfiguration` or
640// `PlatformConfigurationClient`.
641//
642// These are intentionally undocumented. Refer instead to the sibling methods
643// above.
644//----------------------------------------------------------------------------
646 public:
647 static std::string DefaultRouteName();
648
649 static void ScheduleFrame();
650
651 static void EndWarmUpFrame();
652
653 static void Render(int64_t view_id,
654 Scene* scene,
655 double width,
656 double height);
657
658 static void UpdateSemantics(int64_t viewId, SemanticsUpdate* update);
659
660 static void SetApplicationLocale(std::string locale);
661
662 static void SetSemanticsTreeEnabled(bool enabled);
663
664 static void SetNeedsReportTimings(bool value);
665
666 static Dart_Handle GetPersistentIsolateData();
667
668 static Dart_Handle ComputePlatformResolvedLocale(
669 Dart_Handle supportedLocalesHandle);
670
671 static void SetIsolateDebugName(const std::string& name);
672
673 static Dart_Handle SendPlatformMessage(const std::string& name,
674 Dart_Handle callback,
675 Dart_Handle data_handle);
676
677 static Dart_Handle SendPortPlatformMessage(const std::string& name,
678 Dart_Handle identifier,
679 Dart_Handle send_port,
680 Dart_Handle data_handle);
681
682 static void RespondToPlatformMessage(int response_id,
684
685 static void SendChannelUpdate(const std::string& name, bool listening);
686
687 static void RequestViewFocusChange(int64_t view_id,
688 int64_t state,
689 int64_t direction);
690
691 //--------------------------------------------------------------------------
692 /// @brief Requests the Dart VM to adjusts the GC heuristics based on
693 /// the requested `performance_mode`. Returns the old performance
694 /// mode.
695 ///
696 /// Requesting a performance mode doesn't guarantee any
697 /// performance characteristics. This is best effort, and should
698 /// be used after careful consideration of the various GC
699 /// trade-offs.
700 ///
701 /// @param[in] performance_mode The requested performance mode. Please refer
702 /// to documentation of `Dart_PerformanceMode`
703 /// for more details about what each performance
704 /// mode does.
705 ///
706 static int RequestDartPerformanceMode(int mode);
707
708 //--------------------------------------------------------------------------
709 /// @brief Returns the current performance mode of the Dart VM. Defaults
710 /// to `Dart_PerformanceMode_Default` if no prior requests to change the
711 /// performance mode have been made.
712 static Dart_PerformanceMode GetDartPerformanceMode();
713
714 static int64_t GetRootIsolateToken();
715
716 static void RegisterBackgroundIsolate(int64_t root_isolate_token);
717
718 static double GetScaledFontSize(double unscaled_font_size,
719 int configuration_id);
720
721 private:
722 static Dart_PerformanceMode current_performance_mode_;
723};
724
725} // namespace flutter
726
727#endif // FLUTTER_LIB_UI_WINDOW_PLATFORM_CONFIGURATION_H_
A client interface that the RuntimeController uses to define handlers for PlatformConfiguration reque...
virtual FontCollection & GetFontCollection()=0
Returns the current collection of fonts available on the platform.
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 std::shared_ptr< PlatformIsolateManager > GetPlatformIsolateManager()=0
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 std::shared_ptr< AssetManager > GetAssetManager()=0
Returns the current collection of assets available on the platform.
virtual void UpdateIsolateDescription(const std::string isolate_name, int64_t isolate_port)=0
Notifies this client of the name of the root isolate and its port when that isolate is launched,...
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 HandlePlatformMessage(std::unique_ptr< PlatformMessage > message)=0
When the Flutter application has a message to send to the underlying platform, the message needs to b...
virtual void RequestDartDeferredLibrary(intptr_t loading_unit_id)=0
Invoked when the Dart VM requests that a deferred library be loaded. Notifies the engine that the def...
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.
A class for holding and distributing platform-level information to and from the Dart code in Flutter'...
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...
PlatformConfiguration & operator=(const PlatformConfiguration &)=delete
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.
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.
HitTestResponse HitTest(int64_t view_id, const flutter::PointData offset)
Requests to perform framework hit test from the engine.
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.
PlatformConfiguration(const PlatformConfiguration &)=delete
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)
virtual void SetPlatformMessageHandler(int64_t root_isolate_token, std::weak_ptr< PlatformMessageHandler > handler)=0
virtual std::weak_ptr< PlatformMessageHandler > GetPlatformMessageHandler(int64_t root_isolate_token) const =0
virtual ~PlatformMessageHandlerStorage()=default
A Mapping like NonOwnedMapping, but uses Free as its release proc.
Definition mapping.h:144
int32_t value
const char * message
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
const gchar FlBinaryMessengerMessageHandler handler
G_BEGIN_DECLS FlutterViewId view_id
FlutterDesktopBinaryReply callback
#define FML_FRIEND_TEST(test_case_name, test_name)
Definition macros.h:47
#define FML_TEST_CLASS(test_case_name, test_name)
Definition macros.h:44
DEF_SWITCHES_START aot vmservice shared library name
Definition switch_defs.h:27
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
AccessibilityFeatureFlag
An enum for defining the different kinds of accessibility features that can be enabled by the platfor...
std::vector< FlutterEngineDisplay > * displays
int32_t height
int32_t width