Flutter Engine
The Flutter Engine
|
#include <cstring>
#include <iostream>
#include <memory>
#include <set>
#include <string>
#include <vector>
#include "flutter/fml/build_config.h"
#include "flutter/fml/closure.h"
#include "flutter/fml/make_copyable.h"
#include "flutter/fml/native_library.h"
#include "flutter/fml/thread.h"
#include "third_party/dart/runtime/bin/elf_loader.h"
#include "third_party/dart/runtime/include/dart_native_api.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/gpu/GpuTypes.h"
#include "third_party/skia/include/gpu/GrBackendSurface.h"
#include "third_party/skia/include/gpu/ganesh/SkSurfaceGanesh.h"
#include "flutter/assets/directory_asset_bundle.h"
#include "flutter/common/graphics/persistent_cache.h"
#include "flutter/common/task_runners.h"
#include "flutter/fml/command_line.h"
#include "flutter/fml/file.h"
#include "flutter/fml/message_loop.h"
#include "flutter/fml/paths.h"
#include "flutter/fml/trace_event.h"
#include "flutter/shell/common/rasterizer.h"
#include "flutter/shell/common/switches.h"
#include "flutter/shell/platform/embedder/embedder.h"
#include "flutter/shell/platform/embedder/embedder_engine.h"
#include "flutter/shell/platform/embedder/embedder_external_texture_resolver.h"
#include "flutter/shell/platform/embedder/embedder_platform_message_response.h"
#include "flutter/shell/platform/embedder/embedder_render_target.h"
#include "flutter/shell/platform/embedder/embedder_render_target_skia.h"
#include "flutter/shell/platform/embedder/embedder_semantics_update.h"
#include "flutter/shell/platform/embedder/embedder_struct_macros.h"
#include "flutter/shell/platform/embedder/embedder_task_runner.h"
#include "flutter/shell/platform/embedder/embedder_thread_host.h"
#include "flutter/shell/platform/embedder/pixel_formats.h"
#include "flutter/shell/platform/embedder/platform_view_embedder.h"
#include "rapidjson/rapidjson.h"
#include "rapidjson/writer.h"
Go to the source code of this file.
Classes | |
struct | _FlutterPlatformMessageResponseHandle |
struct | LoadedElfDeleter |
struct | _FlutterEngineAOTData |
Macros | |
#define | FML_USED_ON_EMBEDDER |
#define | RAPIDJSON_HAS_STDSTRING 1 |
#define | FLUTTER_EXPORT __attribute__((visibility("default"))) |
#define | LOG_EMBEDDER_ERROR(code, reason) LogEmbedderError(code, reason, #code, __FUNCTION__, __FILE__, __LINE__) |
#define | SET_PROC(member, function) |
Typedefs | |
using | UniqueLoadedElf = std::unique_ptr< Dart_LoadedElf, LoadedElfDeleter > |
Functions | |
static FlutterEngineResult | LogEmbedderError (FlutterEngineResult code, const char *reason, const char *code_name, const char *function, const char *file, int line) |
static bool | IsOpenGLRendererConfigValid (const FlutterRendererConfig *config) |
static bool | IsSoftwareRendererConfigValid (const FlutterRendererConfig *config) |
static bool | IsMetalRendererConfigValid (const FlutterRendererConfig *config) |
static bool | IsVulkanRendererConfigValid (const FlutterRendererConfig *config) |
static bool | IsRendererValid (const FlutterRendererConfig *config) |
static flutter::Shell::CreateCallback< flutter::PlatformView > | InferOpenGLPlatformViewCreationCallback (const FlutterRendererConfig *config, void *user_data, const flutter::PlatformViewEmbedder::PlatformDispatchTable &platform_dispatch_table, std::unique_ptr< flutter::EmbedderExternalViewEmbedder > external_view_embedder, bool enable_impeller) |
static flutter::Shell::CreateCallback< flutter::PlatformView > | InferMetalPlatformViewCreationCallback (const FlutterRendererConfig *config, void *user_data, const flutter::PlatformViewEmbedder::PlatformDispatchTable &platform_dispatch_table, std::unique_ptr< flutter::EmbedderExternalViewEmbedder > external_view_embedder, bool enable_impeller) |
static flutter::Shell::CreateCallback< flutter::PlatformView > | InferVulkanPlatformViewCreationCallback (const FlutterRendererConfig *config, void *user_data, const flutter::PlatformViewEmbedder::PlatformDispatchTable &platform_dispatch_table, std::unique_ptr< flutter::EmbedderExternalViewEmbedder > external_view_embedder) |
static flutter::Shell::CreateCallback< flutter::PlatformView > | InferSoftwarePlatformViewCreationCallback (const FlutterRendererConfig *config, void *user_data, const flutter::PlatformViewEmbedder::PlatformDispatchTable &platform_dispatch_table, std::unique_ptr< flutter::EmbedderExternalViewEmbedder > external_view_embedder) |
static flutter::Shell::CreateCallback< flutter::PlatformView > | InferPlatformViewCreationCallback (const FlutterRendererConfig *config, void *user_data, const flutter::PlatformViewEmbedder::PlatformDispatchTable &platform_dispatch_table, std::unique_ptr< flutter::EmbedderExternalViewEmbedder > external_view_embedder, bool enable_impeller) |
static sk_sp< SkSurface > | MakeSkSurfaceFromBackingStore (GrDirectContext *context, const FlutterBackingStoreConfig &config, const FlutterOpenGLTexture *texture) |
static sk_sp< SkSurface > | MakeSkSurfaceFromBackingStore (GrDirectContext *context, const FlutterBackingStoreConfig &config, const FlutterOpenGLFramebuffer *framebuffer) |
static sk_sp< SkSurface > | MakeSkSurfaceFromBackingStore (GrDirectContext *context, const FlutterBackingStoreConfig &config, const FlutterSoftwareBackingStore *software) |
static sk_sp< SkSurface > | MakeSkSurfaceFromBackingStore (GrDirectContext *context, const FlutterBackingStoreConfig &config, const FlutterSoftwareBackingStore2 *software) |
static sk_sp< SkSurface > | MakeSkSurfaceFromBackingStore (GrDirectContext *context, const FlutterBackingStoreConfig &config, const FlutterMetalBackingStore *metal) |
static std::unique_ptr< flutter::EmbedderRenderTarget > | MakeRenderTargetFromBackingStoreImpeller (FlutterBackingStore backing_store, const fml::closure &on_release, const std::shared_ptr< impeller::AiksContext > &aiks_context, const FlutterBackingStoreConfig &config, const FlutterOpenGLFramebuffer *framebuffer) |
static std::unique_ptr< flutter::EmbedderRenderTarget > | MakeRenderTargetFromBackingStoreImpeller (FlutterBackingStore backing_store, const fml::closure &on_release, const std::shared_ptr< impeller::AiksContext > &aiks_context, const FlutterBackingStoreConfig &config, const FlutterMetalBackingStore *metal) |
static sk_sp< SkSurface > | MakeSkSurfaceFromBackingStore (GrDirectContext *context, const FlutterBackingStoreConfig &config, const FlutterVulkanBackingStore *vulkan) |
static std::unique_ptr< flutter::EmbedderRenderTarget > | MakeRenderTargetFromSkSurface (FlutterBackingStore backing_store, sk_sp< SkSurface > skia_surface, fml::closure on_release) |
static std::unique_ptr< flutter::EmbedderRenderTarget > | CreateEmbedderRenderTarget (const FlutterCompositor *compositor, const FlutterBackingStoreConfig &config, GrDirectContext *context, const std::shared_ptr< impeller::AiksContext > &aiks_context, bool enable_impeller) |
static std::pair< std::unique_ptr< flutter::EmbedderExternalViewEmbedder >, bool > | InferExternalViewEmbedderFromArgs (const FlutterCompositor *compositor, bool enable_impeller) |
static std::variant< flutter::ViewportMetrics, std::string > | MakeViewportMetricsFromWindowMetrics (const FlutterWindowMetricsEvent *flutter_metrics) |
FlutterEngineResult | FlutterEngineCreateAOTData (const FlutterEngineAOTDataSource *source, FlutterEngineAOTData *data_out) |
Creates the necessary data structures to launch a Flutter Dart application in AOT mode. The data may only be collected after all FlutterEngine instances launched using this data have been terminated. More... | |
FlutterEngineResult | FlutterEngineCollectAOTData (FlutterEngineAOTData data) |
Collects the AOT data. More... | |
void | PopulateJITSnapshotMappingCallbacks (const FlutterProjectArgs *args, flutter::Settings &settings) |
void | PopulateAOTSnapshotMappingCallbacks (const FlutterProjectArgs *args, flutter::Settings &settings) |
flutter::PlatformViewEmbedder::UpdateSemanticsCallback | CreateEmbedderSemanticsUpdateCallbackV1 (FlutterUpdateSemanticsNodeCallback update_semantics_node_callback, FlutterUpdateSemanticsCustomActionCallback update_semantics_custom_action_callback, void *user_data) |
flutter::PlatformViewEmbedder::UpdateSemanticsCallback | CreateEmbedderSemanticsUpdateCallbackV2 (FlutterUpdateSemanticsCallback update_semantics_callback, void *user_data) |
flutter::PlatformViewEmbedder::UpdateSemanticsCallback | CreateEmbedderSemanticsUpdateCallbackV3 (FlutterUpdateSemanticsCallback2 update_semantics_callback, void *user_data) |
flutter::PlatformViewEmbedder::UpdateSemanticsCallback | CreateEmbedderSemanticsUpdateCallback (const FlutterProjectArgs *args, void *user_data) |
FlutterEngineResult | FlutterEngineRun (size_t version, const FlutterRendererConfig *config, const FlutterProjectArgs *args, void *user_data, FLUTTER_API_SYMBOL(FlutterEngine) *engine_out) |
Initialize and run a Flutter engine instance and return a handle to it. This is a convenience method for the pair of calls to FlutterEngineInitialize and FlutterEngineRunInitialized . More... | |
FlutterEngineResult | FlutterEngineInitialize (size_t version, const FlutterRendererConfig *config, const FlutterProjectArgs *args, void *user_data, FLUTTER_API_SYMBOL(FlutterEngine) *engine_out) |
Initialize a Flutter engine instance. This does not run the Flutter application code till the FlutterEngineRunInitialized call is made. Besides Flutter application code, no tasks are scheduled on embedder managed task runners either. This allows embedders providing custom task runners to the Flutter engine to obtain a handle to the Flutter engine before the engine can post tasks on these task runners. More... | |
FlutterEngineResult | FlutterEngineRunInitialized (FLUTTER_API_SYMBOL(FlutterEngine) engine) |
Runs an initialized engine instance. An engine can be initialized via FlutterEngineInitialize . An initialized instance can only be run once. During and after this call, custom task runners supplied by the embedder are expected to start servicing tasks. More... | |
FLUTTER_EXPORT FlutterEngineResult | FlutterEngineAddView (FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterAddViewInfo *info) |
Adds a view. More... | |
FLUTTER_EXPORT FlutterEngineResult | FlutterEngineRemoveView (FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterRemoveViewInfo *info) |
Removes a view. More... | |
FLUTTER_EXPORT FlutterEngineResult | FlutterEngineDeinitialize (FLUTTER_API_SYMBOL(FlutterEngine) engine) |
Stops running the Flutter engine instance. After this call, the embedder is also guaranteed that no more calls to post tasks onto custom task runners specified by the embedder are made. The Flutter engine handle still needs to be collected via a call to FlutterEngineShutdown . More... | |
FlutterEngineResult | FlutterEngineShutdown (FLUTTER_API_SYMBOL(FlutterEngine) engine) |
Shuts down a Flutter engine instance. The engine handle is no longer valid for any calls in the embedder API after this point. Making additional calls with this handle is undefined behavior. More... | |
FlutterEngineResult | FlutterEngineSendWindowMetricsEvent (FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterWindowMetricsEvent *flutter_metrics) |
flutter::PointerData::Change | ToPointerDataChange (FlutterPointerPhase phase) |
flutter::PointerData::DeviceKind | ToPointerDataKind (FlutterPointerDeviceKind device_kind) |
flutter::PointerData::SignalKind | ToPointerDataSignalKind (FlutterPointerSignalKind kind) |
int64_t | PointerDataButtonsForLegacyEvent (flutter::PointerData::Change change) |
FlutterEngineResult | FlutterEngineSendPointerEvent (FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterPointerEvent *pointers, size_t events_count) |
static flutter::KeyEventType | MapKeyEventType (FlutterKeyEventType event_kind) |
static flutter::KeyEventDeviceType | MapKeyEventDeviceType (FlutterKeyEventDeviceType event_kind) |
static FlutterEngineResult | InternalSendPlatformMessage (FLUTTER_API_SYMBOL(FlutterEngine) engine, const char *channel, const uint8_t *data, size_t size, FlutterDataCallback data_callback, void *user_data) |
FlutterEngineResult | FlutterEngineSendKeyEvent (FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterKeyEvent *event, FlutterKeyEventCallback callback, void *user_data) |
Sends a key event to the engine. The framework will decide whether to handle this event in a synchronous fashion, although due to technical limitation, the result is always reported asynchronously. The callback is guaranteed to be called exactly once. More... | |
FlutterEngineResult | FlutterEngineSendPlatformMessage (FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterPlatformMessage *flutter_message) |
FlutterEngineResult | FlutterPlatformMessageCreateResponseHandle (FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterDataCallback data_callback, void *user_data, FlutterPlatformMessageResponseHandle **response_out) |
Creates a platform message response handle that allows the embedder to set a native callback for a response to a message. This handle may be set on the response_handle field of any FlutterPlatformMessage sent to the engine. More... | |
FlutterEngineResult | FlutterPlatformMessageReleaseResponseHandle (FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterPlatformMessageResponseHandle *response) |
Collects the handle created using FlutterPlatformMessageCreateResponseHandle . More... | |
FlutterEngineResult | FlutterEngineSendPlatformMessageResponse (FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterPlatformMessageResponseHandle *handle, const uint8_t *data, size_t data_length) |
Send a response from the native side to a platform message from the Dart Flutter application. More... | |
FlutterEngineResult | __FlutterEngineFlushPendingTasksNow () |
This API is only meant to be used by platforms that need to flush tasks on a message loop not controlled by the Flutter engine. More... | |
FlutterEngineResult | FlutterEngineRegisterExternalTexture (FLUTTER_API_SYMBOL(FlutterEngine) engine, int64_t texture_identifier) |
Register an external texture with a unique (per engine) identifier. Only rendering backends that support external textures accept external texture registrations. After the external texture is registered, the application can mark that a frame is available by calling FlutterEngineMarkExternalTextureFrameAvailable . More... | |
FlutterEngineResult | FlutterEngineUnregisterExternalTexture (FLUTTER_API_SYMBOL(FlutterEngine) engine, int64_t texture_identifier) |
Unregister a previous texture registration. More... | |
FlutterEngineResult | FlutterEngineMarkExternalTextureFrameAvailable (FLUTTER_API_SYMBOL(FlutterEngine) engine, int64_t texture_identifier) |
Mark that a new texture frame is available for a given texture identifier. More... | |
FlutterEngineResult | FlutterEngineUpdateSemanticsEnabled (FLUTTER_API_SYMBOL(FlutterEngine) engine, bool enabled) |
Enable or disable accessibility semantics. More... | |
FlutterEngineResult | FlutterEngineUpdateAccessibilityFeatures (FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterAccessibilityFeature flags) |
Sets additional accessibility features. More... | |
FlutterEngineResult | FlutterEngineDispatchSemanticsAction (FLUTTER_API_SYMBOL(FlutterEngine) engine, uint64_t node_id, FlutterSemanticsAction action, const uint8_t *data, size_t data_length) |
Dispatch a semantics action to the specified semantics node. More... | |
FlutterEngineResult | FlutterEngineOnVsync (FLUTTER_API_SYMBOL(FlutterEngine) engine, intptr_t baton, uint64_t frame_start_time_nanos, uint64_t frame_target_time_nanos) |
Notify the engine that a vsync event occurred. A baton passed to the platform via the vsync callback must be returned. This call must be made on the thread on which the call to FlutterEngineRun was made. More... | |
FlutterEngineResult | FlutterEngineReloadSystemFonts (FLUTTER_API_SYMBOL(FlutterEngine) engine) |
Reloads the system fonts in engine. More... | |
void | FlutterEngineTraceEventDurationBegin (const char *name) |
A profiling utility. Logs a trace duration begin event to the timeline. If the timeline is unavailable or disabled, this has no effect. Must be balanced with an duration end event (via FlutterEngineTraceEventDurationEnd ) with the same name on the same thread. Can be called on any thread. Strings passed into the function will NOT be copied when added to the timeline. Only string literals may be passed in. More... | |
void | FlutterEngineTraceEventDurationEnd (const char *name) |
A profiling utility. Logs a trace duration end event to the timeline. If the timeline is unavailable or disabled, this has no effect. This call must be preceded by a trace duration begin call (via FlutterEngineTraceEventDurationBegin ) with the same name on the same thread. Can be called on any thread. Strings passed into the function will NOT be copied when added to the timeline. Only string literals may be passed in. More... | |
void | FlutterEngineTraceEventInstant (const char *name) |
A profiling utility. Logs a trace duration instant event to the timeline. If the timeline is unavailable or disabled, this has no effect. Can be called on any thread. Strings passed into the function will NOT be copied when added to the timeline. Only string literals may be passed in. More... | |
FlutterEngineResult | FlutterEnginePostRenderThreadTask (FLUTTER_API_SYMBOL(FlutterEngine) engine, VoidCallback callback, void *baton) |
Posts a task onto the Flutter render thread. Typically, this may be called from any thread as long as a FlutterEngineShutdown on the specific engine has not already been initiated. More... | |
uint64_t | FlutterEngineGetCurrentTime () |
Get the current time in nanoseconds from the clock used by the flutter engine. This is the system monotonic clock. More... | |
FlutterEngineResult | FlutterEngineRunTask (FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterTask *task) |
Inform the engine to run the specified task. This task has been given to the engine via the FlutterTaskRunnerDescription.post_task_callback . This call must only be made at the target time specified in that callback. Running the task before that time is undefined behavior. More... | |
static bool | DispatchJSONPlatformMessage (FLUTTER_API_SYMBOL(FlutterEngine) engine, const rapidjson::Document &document, const std::string &channel_name) |
FlutterEngineResult | FlutterEngineUpdateLocales (FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterLocale **locales, size_t locales_count) |
Notify a running engine instance that the locale has been updated. The preferred locale must be the first item in the list of locales supplied. The other entries will be used as a fallback. More... | |
bool | FlutterEngineRunsAOTCompiledDartCode (void) |
Returns if the Flutter engine instance will run AOT compiled Dart code. This call has no threading restrictions. More... | |
FlutterEngineResult | FlutterEnginePostDartObject (FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterEngineDartPort port, const FlutterEngineDartObject *object) |
Posts a Dart object to specified send port. The corresponding receive port for send port can be in any isolate running in the VM. This isolate can also be the root isolate for an unrelated engine. The engine parameter is necessary only to ensure the call is not made when no engine (and hence no VM) is running. More... | |
FlutterEngineResult | FlutterEngineNotifyLowMemoryWarning (FLUTTER_API_SYMBOL(FlutterEngine) raw_engine) |
Posts a low memory notification to a running engine instance. The engine will do its best to release non-critical resources in response. It is not guaranteed that the resource would have been collected by the time this call returns however. The notification is posted to engine subsystems that may be operating on other threads. More... | |
FlutterEngineResult | FlutterEnginePostCallbackOnAllNativeThreads (FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterNativeThreadCallback callback, void *user_data) |
Schedule a callback to be run on all engine managed threads. The engine will attempt to service this callback the next time the message loop for each managed thread is idle. Since the engine manages the entire lifecycle of multiple threads, there is no opportunity for the embedders to finely tune the priorities of threads directly, or, perform other thread specific configuration (for example, setting thread names for tracing). This callback gives embedders a chance to affect such tuning. More... | |
FlutterEngineResult | FlutterEngineNotifyDisplayUpdate (FLUTTER_API_SYMBOL(FlutterEngine) raw_engine, const FlutterEngineDisplaysUpdateType update_type, const FlutterEngineDisplay *embedder_displays, size_t display_count) |
Posts updates corresponding to display changes to a running engine instance. More... | |
FlutterEngineResult | FlutterEngineScheduleFrame (FLUTTER_API_SYMBOL(FlutterEngine) engine) |
Schedule a new frame to redraw the content. More... | |
FlutterEngineResult | FlutterEngineSetNextFrameCallback (FLUTTER_API_SYMBOL(FlutterEngine) engine, VoidCallback callback, void *user_data) |
Schedule a callback to be called after the next frame is drawn. This must be called from the platform thread. The callback is executed only once from the raster thread; embedders must re-thread if necessary. Performing blocking calls in this callback may introduce application jank. More... | |
FlutterEngineResult | FlutterEngineGetProcAddresses (FlutterEngineProcTable *table) |
Gets the table of engine function pointers. More... | |
Variables | |
const uint8_t | kPlatformStrongDill [] |
const intptr_t | kPlatformStrongDillSize |
const int32_t | kFlutterSemanticsNodeIdBatchEnd = -1 |
const int32_t | kFlutterSemanticsCustomActionIdBatchEnd = -1 |
static constexpr FlutterViewId | kFlutterImplicitViewId = 0 |
const char * | kFlutterKeyDataChannel = "flutter/keydata" |
#define FLUTTER_EXPORT __attribute__((visibility("default"))) |
Definition at line 31 of file embedder.cc.
#define FML_USED_ON_EMBEDDER |
Definition at line 5 of file embedder.cc.
#define LOG_EMBEDDER_ERROR | ( | code, | |
reason | |||
) | LogEmbedderError(code, reason, #code, __FUNCTION__, __FILE__, __LINE__) |
Definition at line 153 of file embedder.cc.
#define RAPIDJSON_HAS_STDSTRING 1 |
Definition at line 6 of file embedder.cc.
using UniqueLoadedElf = std::unique_ptr<Dart_LoadedElf, LoadedElfDeleter> |
Definition at line 1416 of file embedder.cc.
FlutterEngineResult __FlutterEngineFlushPendingTasksNow | ( | ) |
This API is only meant to be used by platforms that need to flush tasks on a message loop not controlled by the Flutter engine.
FlutterProjectArgs::custom_task_runners
interface. This will yield better performance and the interface is stable.Definition at line 2764 of file embedder.cc.
|
static |
Definition at line 1167 of file embedder.cc.
flutter::PlatformViewEmbedder::UpdateSemanticsCallback CreateEmbedderSemanticsUpdateCallback | ( | const FlutterProjectArgs * | args, |
void * | user_data | ||
) |
Definition at line 1669 of file embedder.cc.
flutter::PlatformViewEmbedder::UpdateSemanticsCallback CreateEmbedderSemanticsUpdateCallbackV1 | ( | FlutterUpdateSemanticsNodeCallback | update_semantics_node_callback, |
FlutterUpdateSemanticsCustomActionCallback | update_semantics_custom_action_callback, | ||
void * | user_data | ||
) |
Definition at line 1589 of file embedder.cc.
flutter::PlatformViewEmbedder::UpdateSemanticsCallback CreateEmbedderSemanticsUpdateCallbackV2 | ( | FlutterUpdateSemanticsCallback | update_semantics_callback, |
void * | user_data | ||
) |
Definition at line 1638 of file embedder.cc.
flutter::PlatformViewEmbedder::UpdateSemanticsCallback CreateEmbedderSemanticsUpdateCallbackV3 | ( | FlutterUpdateSemanticsCallback2 | update_semantics_callback, |
void * | user_data | ||
) |
Definition at line 1653 of file embedder.cc.
|
static |
Definition at line 2972 of file embedder.cc.
FLUTTER_EXPORT FlutterEngineResult FlutterEngineAddView | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine, |
const FlutterAddViewInfo * | info | ||
) |
Adds a view.
This is an asynchronous operation. The view should not be used until the |info.add_view_callback| is invoked with an |added| value of true. The embedder should prepare resources in advance but be ready to clean up on failure. A frame is scheduled if the operation succeeds. The callback is invoked on a thread managed by the engine. The embedder should re-thread if needed. Attempting to add the implicit view will fail and will return kInvalidArguments. Attempting to add a view with an already existing view ID will fail, and |info.add_view_callback| will be invoked with an |added| value of false.
[in] | engine | A running engine instance. |
[in] | info | The add view arguments. This can be deallocated once |FlutterEngineAddView| returns, before |add_view_callback| is invoked. |
kSuccess
, the |add_view_callback| will be invoked. Definition at line 2193 of file embedder.cc.
FlutterEngineResult FlutterEngineCollectAOTData | ( | FlutterEngineAOTData | data | ) |
Collects the AOT data.
[in] | data | The data to collect. |
Definition at line 1480 of file embedder.cc.
FlutterEngineResult FlutterEngineCreateAOTData | ( | const FlutterEngineAOTDataSource * | source, |
FlutterEngineAOTData * | data_out | ||
) |
Creates the necessary data structures to launch a Flutter Dart application in AOT mode. The data may only be collected after all FlutterEngine instances launched using this data have been terminated.
[in] | source | The source of the AOT data. |
[out] | data_out | The AOT data on success. Unchanged on failure. |
Definition at line 1426 of file embedder.cc.
FLUTTER_EXPORT FlutterEngineResult FlutterEngineDeinitialize | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine | ) |
Stops running the Flutter engine instance. After this call, the embedder is also guaranteed that no more calls to post tasks onto custom task runners specified by the embedder are made. The Flutter engine handle still needs to be collected via a call to FlutterEngineShutdown
.
[in] | engine | The running engine instance to de-initialize. |
Definition at line 2297 of file embedder.cc.
FlutterEngineResult FlutterEngineDispatchSemanticsAction | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine, |
uint64_t | node_id, | ||
FlutterSemanticsAction | action, | ||
const uint8_t * | data, | ||
size_t | data_length | ||
) |
Dispatch a semantics action to the specified semantics node.
[in] | engine | A running engine instance. |
[in] | node_id | The semantics node identifier. |
[in] | action | The semantics action. |
[in] | data | Data associated with the action. |
[in] | data_length | The data length. |
Definition at line 2855 of file embedder.cc.
uint64_t FlutterEngineGetCurrentTime | ( | ) |
Get the current time in nanoseconds from the clock used by the flutter engine. This is the system monotonic clock.
Definition at line 2955 of file embedder.cc.
FlutterEngineResult FlutterEngineGetProcAddresses | ( | FlutterEngineProcTable * | table | ) |
Gets the table of engine function pointers.
[out] | table | The table to fill with pointers. This should be zero-initialized, except for struct_size. |
Definition at line 3335 of file embedder.cc.
FlutterEngineResult FlutterEngineInitialize | ( | size_t | version, |
const FlutterRendererConfig * | config, | ||
const FlutterProjectArgs * | args, | ||
void * | user_data, | ||
FLUTTER_API_SYMBOL(FlutterEngine) * | engine_out | ||
) |
Initialize a Flutter engine instance. This does not run the Flutter application code till the FlutterEngineRunInitialized
call is made. Besides Flutter application code, no tasks are scheduled on embedder managed task runners either. This allows embedders providing custom task runners to the Flutter engine to obtain a handle to the Flutter engine before the engine can post tasks on these task runners.
[in] | version | The Flutter embedder API version. Must be FLUTTER_ENGINE_VERSION. |
[in] | config | The renderer configuration. |
[in] | args | The Flutter project arguments. |
user_data | A user data baton passed back to embedders in callbacks. | |
[out] | engine_out | The engine handle on successful engine creation. |
Definition at line 1731 of file embedder.cc.
FlutterEngineResult FlutterEngineMarkExternalTextureFrameAvailable | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine, |
int64_t | texture_identifier | ||
) |
Mark that a new texture frame is available for a given texture identifier.
[in] | engine | A running engine instance. |
[in] | texture_identifier | The identifier of the texture whose frame has been updated. |
Definition at line 2809 of file embedder.cc.
FlutterEngineResult FlutterEngineNotifyDisplayUpdate | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine, |
FlutterEngineDisplaysUpdateType | update_type, | ||
const FlutterEngineDisplay * | displays, | ||
size_t | display_count | ||
) |
Posts updates corresponding to display changes to a running engine instance.
[in] | update_type | The type of update pushed to the engine. |
[in] | displays | The displays affected by this update. |
[in] | display_count | Size of the displays array, must be at least 1. |
Definition at line 3252 of file embedder.cc.
FlutterEngineResult FlutterEngineNotifyLowMemoryWarning | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine | ) |
Posts a low memory notification to a running engine instance. The engine will do its best to release non-critical resources in response. It is not guaranteed that the resource would have been collected by the time this call returns however. The notification is posted to engine subsystems that may be operating on other threads.
Flutter applications can respond to these notifications by setting WidgetsBindingObserver.didHaveMemoryPressure
observers.
[in] | engine | A running engine instance. |
Definition at line 3191 of file embedder.cc.
FlutterEngineResult FlutterEngineOnVsync | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine, |
intptr_t | baton, | ||
uint64_t | frame_start_time_nanos, | ||
uint64_t | frame_target_time_nanos | ||
) |
Notify the engine that a vsync event occurred. A baton passed to the platform via the vsync callback must be returned. This call must be made on the thread on which the call to FlutterEngineRun
was made.
[in] | engine. | A running engine instance. |
[in] | baton | The baton supplied by the engine. |
[in] | frame_start_time_nanos | The point at which the vsync event occurred or will occur. If the time point is in the future, the engine will wait till that point to begin its frame workload. |
[in] | frame_target_time_nanos | The point at which the embedder anticipates the next vsync to occur. This is a hint the engine uses to schedule Dart VM garbage collection in periods in which the various threads are most likely to be idle. For example, for a 60Hz display, embedders should add 16.6 * 1e6 to the frame time field. |
Definition at line 2875 of file embedder.cc.
FlutterEngineResult FlutterEnginePostCallbackOnAllNativeThreads | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine, |
FlutterNativeThreadCallback | callback, | ||
void * | user_data | ||
) |
Schedule a callback to be run on all engine managed threads. The engine will attempt to service this callback the next time the message loop for each managed thread is idle. Since the engine manages the entire lifecycle of multiple threads, there is no opportunity for the embedders to finely tune the priorities of threads directly, or, perform other thread specific configuration (for example, setting thread names for tracing). This callback gives embedders a chance to affect such tuning.
[in] | engine | A running engine instance. |
[in] | callback | The callback that will get called multiple times on each engine managed thread. |
[in] | user_data | A baton passed by the engine to the callback. This baton is not interpreted by the engine in any way. |
Definition at line 3213 of file embedder.cc.
FlutterEngineResult FlutterEnginePostDartObject | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine, |
FlutterEngineDartPort | port, | ||
const FlutterEngineDartObject * | object | ||
) |
Posts a Dart object to specified send port. The corresponding receive port for send port can be in any isolate running in the VM. This isolate can also be the root isolate for an unrelated engine. The engine parameter is necessary only to ensure the call is not made when no engine (and hence no VM) is running.
Unlike the platform messages mechanism, there are no threading restrictions when using this API. Message can be posted on any thread and they will be made available to isolate on which the corresponding send port is listening.
However, it is the embedders responsibility to ensure that the call is not made during an ongoing call the FlutterEngineDeinitialize
or FlutterEngineShutdown
on another thread.
[in] | engine | A running engine instance. |
[in] | port | The send port to send the object to. |
[in] | object | The object to send to the isolate with the corresponding receive port. |
Definition at line 3067 of file embedder.cc.
FlutterEngineResult FlutterEnginePostRenderThreadTask | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine, |
VoidCallback | callback, | ||
void * | callback_data | ||
) |
Posts a task onto the Flutter render thread. Typically, this may be called from any thread as long as a FlutterEngineShutdown
on the specific engine has not already been initiated.
[in] | engine | A running engine instance. |
[in] | callback | The callback to execute on the render thread. |
callback_data | The callback context. |
Definition at line 2933 of file embedder.cc.
FlutterEngineResult FlutterEngineRegisterExternalTexture | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine, |
int64_t | texture_identifier | ||
) |
Register an external texture with a unique (per engine) identifier. Only rendering backends that support external textures accept external texture registrations. After the external texture is registered, the application can mark that a frame is available by calling FlutterEngineMarkExternalTextureFrameAvailable
.
[in] | engine | A running engine instance. |
[in] | texture_identifier | The identifier of the texture to register with the engine. The embedder may supply new frames to this texture using the same identifier. |
Definition at line 2769 of file embedder.cc.
FlutterEngineResult FlutterEngineReloadSystemFonts | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine | ) |
Reloads the system fonts in engine.
[in] | engine. | A running engine instance. |
Definition at line 2902 of file embedder.cc.
FLUTTER_EXPORT FlutterEngineResult FlutterEngineRemoveView | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine, |
const FlutterRemoveViewInfo * | info | ||
) |
Removes a view.
This is an asynchronous operation. The view's resources must not be cleaned up until |info.remove_view_callback| is invoked with a |removed| value of true. The callback is invoked on a thread managed by the engine. The embedder should re-thread if needed. Attempting to remove the implicit view will fail and will return kInvalidArguments. Attempting to remove a view with a non-existent view ID will fail, and |info.remove_view_callback| will be invoked with a |removed| value of false.
[in] | engine | A running engine instance. |
[in] | info | The remove view arguments. This can be deallocated once |FlutterEngineRemoveView| returns, before |remove_view_callback| is invoked. |
kSuccess
, the |remove_view_callback| will be invoked. Definition at line 2254 of file embedder.cc.
FlutterEngineResult FlutterEngineRun | ( | size_t | version, |
const FlutterRendererConfig * | config, | ||
const FlutterProjectArgs * | args, | ||
void * | user_data, | ||
FLUTTER_API_SYMBOL(FlutterEngine) * | engine_out | ||
) |
Initialize and run a Flutter engine instance and return a handle to it. This is a convenience method for the pair of calls to FlutterEngineInitialize
and FlutterEngineRunInitialized
.
FlutterProjectArgs::custom_task_runners
. In such cases, the engine may need the embedder to post tasks back to it before FlutterEngineRun
has returned. Embedders can only post tasks to the engine if they have a handle to the engine. In such cases, embedders are advised to get the engine handle via the FlutterInitializeCall
. Then they can call FlutterEngineRunInitialized
knowing that they will be able to service custom tasks on other threads with the engine handle.[in] | version | The Flutter embedder API version. Must be FLUTTER_ENGINE_VERSION. |
[in] | config | The renderer configuration. |
[in] | args | The Flutter project arguments. |
user_data | A user data baton passed back to embedders in callbacks. | |
[out] | engine_out | The engine handle on successful engine creation. |
Definition at line 1715 of file embedder.cc.
FlutterEngineResult FlutterEngineRunInitialized | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine | ) |
Runs an initialized engine instance. An engine can be initialized via FlutterEngineInitialize
. An initialized instance can only be run once. During and after this call, custom task runners supplied by the embedder are expected to start servicing tasks.
[in] | engine | An initialized engine instance that has not previously been run. |
Definition at line 2154 of file embedder.cc.
bool FlutterEngineRunsAOTCompiledDartCode | ( | void | ) |
Returns if the Flutter engine instance will run AOT compiled Dart code. This call has no threading restrictions.
For embedder code that is configured for both AOT and JIT mode Dart execution based on the Flutter engine being linked to, this runtime check may be used to appropriately configure the FlutterProjectArgs
. In JIT mode execution, the kernel snapshots must be present in the Flutter assets directory specified in the FlutterProjectArgs
. For AOT execution, the fields vm_snapshot_data
, vm_snapshot_instructions
, isolate_snapshot_data
and isolate_snapshot_instructions
(along with their size fields) must be specified in FlutterProjectArgs
.
Definition at line 3063 of file embedder.cc.
FlutterEngineResult FlutterEngineRunTask | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine, |
const FlutterTask * | task | ||
) |
Inform the engine to run the specified task. This task has been given to the engine via the FlutterTaskRunnerDescription.post_task_callback
. This call must only be made at the target time specified in that callback. Running the task before that time is undefined behavior.
[in] | engine | A running engine instance. |
[in] | task | the task handle. |
Definition at line 2959 of file embedder.cc.
FlutterEngineResult FlutterEngineScheduleFrame | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine | ) |
Schedule a new frame to redraw the content.
[in] | engine | A running engine instance. |
Definition at line 3293 of file embedder.cc.
FlutterEngineResult FlutterEngineSendKeyEvent | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine, |
const FlutterKeyEvent * | event, | ||
FlutterKeyEventCallback | callback, | ||
void * | user_data | ||
) |
Sends a key event to the engine. The framework will decide whether to handle this event in a synchronous fashion, although due to technical limitation, the result is always reported asynchronously. The callback
is guaranteed to be called exactly once.
[in] | engine | A running engine instance. |
[in] | event | The event data to be sent. This function will no longer access event after returning. |
[in] | callback | The callback invoked by the engine when the Flutter application has decided whether it handles this event. Accepts nullptr. |
[in] | user_data | The context associated with the callback. The exact same value will used to invoke callback . Accepts nullptr. |
Definition at line 2581 of file embedder.cc.
FlutterEngineResult FlutterEngineSendPlatformMessage | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine, |
const FlutterPlatformMessage * | flutter_message | ||
) |
Definition at line 2636 of file embedder.cc.
FlutterEngineResult FlutterEngineSendPlatformMessageResponse | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine, |
const FlutterPlatformMessageResponseHandle * | handle, | ||
const uint8_t * | data, | ||
size_t | data_length | ||
) |
Send a response from the native side to a platform message from the Dart Flutter application.
[in] | engine | The running engine instance. |
[in] | handle | The platform message response handle. |
[in] | data | The data to associate with the platform message response. |
[in] | data_length | The length of the platform message response data. |
Definition at line 2737 of file embedder.cc.
FlutterEngineResult FlutterEngineSendPointerEvent | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine, |
const FlutterPointerEvent * | pointers, | ||
size_t | events_count | ||
) |
Definition at line 2429 of file embedder.cc.
FlutterEngineResult FlutterEngineSendWindowMetricsEvent | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine, |
const FlutterWindowMetricsEvent * | flutter_metrics | ||
) |
Definition at line 2320 of file embedder.cc.
FlutterEngineResult FlutterEngineSetNextFrameCallback | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine, |
VoidCallback | callback, | ||
void * | user_data | ||
) |
Schedule a callback to be called after the next frame is drawn. This must be called from the platform thread. The callback is executed only once from the raster thread; embedders must re-thread if necessary. Performing blocking calls in this callback may introduce application jank.
[in] | engine | A running engine instance. |
[in] | callback | The callback to execute. |
[in] | user_data | A baton passed by the engine to the callback. This baton is not interpreted by the engine in any way. |
Definition at line 3305 of file embedder.cc.
FlutterEngineResult FlutterEngineShutdown | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine | ) |
Shuts down a Flutter engine instance. The engine handle is no longer valid for any calls in the embedder API after this point. Making additional calls with this handle is undefined behavior.
FlutterEngineDeinitialize
) if necessary.[in] | engine | The Flutter engine instance to collect. |
Definition at line 2309 of file embedder.cc.
void FlutterEngineTraceEventDurationBegin | ( | const char * | name | ) |
A profiling utility. Logs a trace duration begin event to the timeline. If the timeline is unavailable or disabled, this has no effect. Must be balanced with an duration end event (via FlutterEngineTraceEventDurationEnd
) with the same name on the same thread. Can be called on any thread. Strings passed into the function will NOT be copied when added to the timeline. Only string literals may be passed in.
[in] | name | The name of the trace event. |
Definition at line 2919 of file embedder.cc.
void FlutterEngineTraceEventDurationEnd | ( | const char * | name | ) |
A profiling utility. Logs a trace duration end event to the timeline. If the timeline is unavailable or disabled, this has no effect. This call must be preceded by a trace duration begin call (via FlutterEngineTraceEventDurationBegin
) with the same name on the same thread. Can be called on any thread. Strings passed into the function will NOT be copied when added to the timeline. Only string literals may be passed in.
[in] | name | The name of the trace event. |
Definition at line 2924 of file embedder.cc.
void FlutterEngineTraceEventInstant | ( | const char * | name | ) |
A profiling utility. Logs a trace duration instant event to the timeline. If the timeline is unavailable or disabled, this has no effect. Can be called on any thread. Strings passed into the function will NOT be copied when added to the timeline. Only string literals may be passed in.
[in] | name | The name of the trace event. |
Definition at line 2928 of file embedder.cc.
FlutterEngineResult FlutterEngineUnregisterExternalTexture | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine, |
int64_t | texture_identifier | ||
) |
Unregister a previous texture registration.
[in] | engine | A running engine instance. |
[in] | texture_identifier | The identifier of the texture for which new frame will not be available. |
Definition at line 2788 of file embedder.cc.
FlutterEngineResult FlutterEngineUpdateAccessibilityFeatures | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine, |
FlutterAccessibilityFeature | features | ||
) |
Sets additional accessibility features.
[in] | engine | A running engine instance |
[in] | features | The accessibility features to set. |
Definition at line 2841 of file embedder.cc.
FlutterEngineResult FlutterEngineUpdateLocales | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine, |
const FlutterLocale ** | locales, | ||
size_t | locales_count | ||
) |
Notify a running engine instance that the locale has been updated. The preferred locale must be the first item in the list of locales supplied. The other entries will be used as a fallback.
[in] | engine | A running engine instance. |
[in] | locales | The updated locales in the order of preference. |
[in] | locales_count | The count of locales supplied. |
Definition at line 3004 of file embedder.cc.
FlutterEngineResult FlutterEngineUpdateSemanticsEnabled | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine, |
bool | enabled | ||
) |
Enable or disable accessibility semantics.
[in] | engine | A running engine instance. |
[in] | enabled | When enabled, changes to the semantic contents of the window are sent via the FlutterUpdateSemanticsCallback2 registered to update_semantics_callback2 in FlutterProjectArgs . |
Definition at line 2827 of file embedder.cc.
FlutterEngineResult FlutterPlatformMessageCreateResponseHandle | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine, |
FlutterDataCallback | data_callback, | ||
void * | user_data, | ||
FlutterPlatformMessageResponseHandle ** | response_out | ||
) |
Creates a platform message response handle that allows the embedder to set a native callback for a response to a message. This handle may be set on the response_handle
field of any FlutterPlatformMessage
sent to the engine.
The handle must be collected via a call to FlutterPlatformMessageReleaseResponseHandle
. This may be done immediately after a call to FlutterEngineSendPlatformMessage
with a platform message whose response handle contains the handle created using this call. In case a handle is created but never sent in a message, the release call must still be made. Not calling release on the handle results in a small memory leak.
The user data baton passed to the data callback is the one specified in this call as the third argument.
[in] | engine | A running engine instance. |
[in] | data_callback | The callback invoked by the engine when the Flutter application send a response on the handle. |
[in] | user_data | The user data associated with the data callback. |
[out] | response_out | The response handle created when this call is successful. |
Definition at line 2687 of file embedder.cc.
FlutterEngineResult FlutterPlatformMessageReleaseResponseHandle | ( | FLUTTER_API_SYMBOL(FlutterEngine) | engine, |
FlutterPlatformMessageResponseHandle * | response | ||
) |
Collects the handle created using FlutterPlatformMessageCreateResponseHandle
.
[in] | engine | A running engine instance. |
[in] | response | The platform message response handle to collect. These handles are created using FlutterPlatformMessageCreateResponseHandle() . |
Definition at line 2722 of file embedder.cc.
|
static |
Definition at line 1283 of file embedder.cc.
|
static |
Definition at line 496 of file embedder.cc.
|
inlinestatic |
Definition at line 284 of file embedder.cc.
|
static |
Definition at line 713 of file embedder.cc.
|
static |
Definition at line 676 of file embedder.cc.
|
static |
Definition at line 589 of file embedder.cc.
|
static |
Definition at line 2545 of file embedder.cc.
|
static |
Definition at line 189 of file embedder.cc.
|
static |
Definition at line 156 of file embedder.cc.
|
static |
Definition at line 227 of file embedder.cc.
|
static |
Definition at line 174 of file embedder.cc.
|
static |
Definition at line 207 of file embedder.cc.
|
static |
Definition at line 132 of file embedder.cc.
|
static |
Definition at line 1037 of file embedder.cc.
|
static |
Definition at line 965 of file embedder.cc.
|
static |
Definition at line 1156 of file embedder.cc.
|
static |
Definition at line 918 of file embedder.cc.
|
static |
Definition at line 788 of file embedder.cc.
|
static |
Definition at line 748 of file embedder.cc.
|
static |
Definition at line 829 of file embedder.cc.
|
static |
Definition at line 873 of file embedder.cc.
|
static |
Definition at line 1104 of file embedder.cc.
|
static |
Definition at line 1361 of file embedder.cc.
|
inlinestatic |
Definition at line 2525 of file embedder.cc.
|
inlinestatic |
Definition at line 2512 of file embedder.cc.
|
inline |
Definition at line 2408 of file embedder.cc.
void PopulateAOTSnapshotMappingCallbacks | ( | const FlutterProjectArgs * | args, |
flutter::Settings & | settings | ||
) |
Definition at line 1536 of file embedder.cc.
void PopulateJITSnapshotMappingCallbacks | ( | const FlutterProjectArgs * | args, |
flutter::Settings & | settings | ||
) |
Definition at line 1493 of file embedder.cc.
|
inline |
Definition at line 2345 of file embedder.cc.
|
inline |
Definition at line 2374 of file embedder.cc.
|
inline |
Definition at line 2391 of file embedder.cc.
|
staticconstexpr |
Definition at line 108 of file embedder.cc.
const char* kFlutterKeyDataChannel = "flutter/keydata" |
Definition at line 130 of file embedder.cc.
const int32_t kFlutterSemanticsCustomActionIdBatchEnd = -1 |
FlutterSemanticsCustomAction
ID used as a sentinel to signal the end of a batch of semantics custom action updates. This is unused if using FlutterUpdateSemanticsCallback2
.
Definition at line 106 of file embedder.cc.
const int32_t kFlutterSemanticsNodeIdBatchEnd = -1 |
FlutterSemanticsNode
ID used as a sentinel to signal the end of a batch of semantics node updates. This is unused if using FlutterUpdateSemanticsCallback2
.
Definition at line 105 of file embedder.cc.
|
extern |
|
extern |