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