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