Flutter Engine
embedder.h File Reference
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Classes

struct  FlutterTransformation
 
struct  FlutterOpenGLTexture
 
struct  FlutterOpenGLFramebuffer
 
struct  FlutterSize
 A structure to represent the width and height. More...
 
struct  FlutterUIntSize
 
struct  FlutterRect
 A structure to represent a rectangle. More...
 
struct  FlutterPoint
 A structure to represent a 2D point. More...
 
struct  FlutterRoundedRect
 A structure to represent a rounded rectangle. More...
 
struct  FlutterFrameInfo
 
struct  FlutterPresentInfo
 
struct  FlutterOpenGLRendererConfig
 
struct  FlutterMetalExternalTexture
 
struct  FlutterMetalTexture
 
struct  FlutterMetalRendererConfig
 
struct  FlutterSoftwareRendererConfig
 
struct  FlutterRendererConfig
 
struct  FlutterWindowMetricsEvent
 
struct  FlutterPointerEvent
 
struct  FlutterKeyEvent
 
struct  FlutterPlatformMessage
 
struct  FlutterSemanticsNode
 
struct  FlutterSemanticsCustomAction
 
struct  FlutterTask
 
struct  FlutterTaskRunnerDescription
 
struct  FlutterCustomTaskRunners
 
struct  FlutterOpenGLBackingStore
 
struct  FlutterSoftwareBackingStore
 
struct  FlutterMetalBackingStore
 
struct  FlutterPlatformViewMutation
 
struct  FlutterPlatformView
 
struct  FlutterBackingStore
 
struct  FlutterBackingStoreConfig
 
struct  FlutterLayer
 
struct  FlutterCompositor
 
struct  FlutterLocale
 
struct  FlutterEngineDisplay
 
struct  FlutterEngineDartBuffer
 
struct  FlutterEngineDartObject
 
struct  FlutterEngineAOTDataSource
 
struct  FlutterProjectArgs
 
struct  FlutterEngineProcTable
 Function-pointer-based versions of the APIs above. More...
 

Macros

#define FLUTTER_EXPORT
 
#define FLUTTER_API_SYMBOL(symbol)   symbol
 
#define FLUTTER_ENGINE_VERSION   1
 

Typedefs

typedef struct _FlutterEngineFLUTTER_API_SYMBOL(FlutterEngine)
 
typedef void(* VoidCallback) (void *)
 
typedef bool(* BoolCallback) (void *)
 
typedef FlutterTransformation(* TransformationCallback) (void *)
 
typedef uint32_t(* UIntCallback) (void *)
 
typedef bool(* SoftwareSurfacePresentCallback) (void *, const void *, size_t, size_t)
 
typedef void *(* ProcResolver) (void *, const char *)
 
typedef bool(* TextureFrameCallback) (void *, int64_t, size_t, size_t, FlutterOpenGLTexture *)
 
typedef void(* VsyncCallback) (void *, intptr_t)
 
typedef void(* OnPreEngineRestartCallback) (void *)
 
typedef uint32_t(* UIntFrameInfoCallback) (void *, const FlutterFrameInfo *)
 Callback for when a frame buffer object is requested. More...
 
typedef bool(* BoolPresentInfoCallback) (void *, const FlutterPresentInfo *)
 Callback for when a surface is presented. More...
 
typedef const void * FlutterMetalDeviceHandle
 Alias for id<MTLDevice>. More...
 
typedef const void * FlutterMetalCommandQueueHandle
 Alias for id<MTLCommandQueue>. More...
 
typedef const void * FlutterMetalTextureHandle
 Alias for id<MTLTexture>. More...
 
typedef bool(* FlutterMetalTextureFrameCallback) (void *, int64_t, size_t, size_t, FlutterMetalExternalTexture *)
 
typedef FlutterMetalTexture(* FlutterMetalTextureCallback) (void *, const FlutterFrameInfo *)
 Callback for when a metal texture is requested. More...
 
typedef bool(* FlutterMetalPresentCallback) (void *, const FlutterMetalTexture *)
 
typedef void(* FlutterKeyEventCallback) (bool, void *)
 
typedef struct _FlutterPlatformMessageResponseHandle FlutterPlatformMessageResponseHandle
 
typedef void(* FlutterPlatformMessageCallback) (const FlutterPlatformMessage *, void *)
 
typedef void(* FlutterDataCallback) (const uint8_t *, size_t, void *)
 
typedef int64_t FlutterPlatformViewIdentifier
 
typedef void(* FlutterUpdateSemanticsNodeCallback) (const FlutterSemanticsNode *, void *)
 
typedef void(* FlutterUpdateSemanticsCustomActionCallback) (const FlutterSemanticsCustomAction *, void *)
 
typedef struct _FlutterTaskRunnerFlutterTaskRunner
 
typedef void(* FlutterTaskRunnerPostTaskCallback) (FlutterTask, uint64_t, void *)
 
typedef bool(* FlutterBackingStoreCreateCallback) (const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out, void *user_data)
 
typedef bool(* FlutterBackingStoreCollectCallback) (const FlutterBackingStore *renderer, void *user_data)
 
typedef bool(* FlutterLayersPresentCallback) (const FlutterLayer **layers, size_t layers_count, void *user_data)
 
typedef const FlutterLocale *(* FlutterComputePlatformResolvedLocaleCallback) (const FlutterLocale **, size_t)
 
typedef uint64_t FlutterEngineDisplayId
 
typedef int64_t FlutterEngineDartPort
 
typedef void(* FlutterNativeThreadCallback) (FlutterNativeThreadType type, void *user_data)
 
typedef void(* FlutterLogMessageCallback) (const char *, const char *, void *)
 
typedef struct _FlutterEngineAOTDataFlutterEngineAOTData
 
typedef FlutterEngineResult(* FlutterEngineCreateAOTDataFnPtr) (const FlutterEngineAOTDataSource *source, FlutterEngineAOTData *data_out)
 
typedef FlutterEngineResult(* FlutterEngineCollectAOTDataFnPtr) (FlutterEngineAOTData data)
 
typedef FlutterEngineResult(* FlutterEngineRunFnPtr) (size_t version, const FlutterRendererConfig *config, const FlutterProjectArgs *args, void *user_data, FLUTTER_API_SYMBOL(FlutterEngine) *engine_out)
 
typedef FlutterEngineResult(* FlutterEngineShutdownFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine)
 
typedef FlutterEngineResult(* FlutterEngineInitializeFnPtr) (size_t version, const FlutterRendererConfig *config, const FlutterProjectArgs *args, void *user_data, FLUTTER_API_SYMBOL(FlutterEngine) *engine_out)
 
typedef FlutterEngineResult(* FlutterEngineDeinitializeFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine)
 
typedef FlutterEngineResult(* FlutterEngineRunInitializedFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine)
 
typedef FlutterEngineResult(* FlutterEngineSendWindowMetricsEventFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterWindowMetricsEvent *event)
 
typedef FlutterEngineResult(* FlutterEngineSendPointerEventFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterPointerEvent *events, size_t events_count)
 
typedef FlutterEngineResult(* FlutterEngineSendKeyEventFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterKeyEvent *event, FlutterKeyEventCallback callback, void *user_data)
 
typedef FlutterEngineResult(* FlutterEngineSendPlatformMessageFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterPlatformMessage *message)
 
typedef FlutterEngineResult(* FlutterEnginePlatformMessageCreateResponseHandleFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterDataCallback data_callback, void *user_data, FlutterPlatformMessageResponseHandle **response_out)
 
typedef FlutterEngineResult(* FlutterEnginePlatformMessageReleaseResponseHandleFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterPlatformMessageResponseHandle *response)
 
typedef FlutterEngineResult(* FlutterEngineSendPlatformMessageResponseFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterPlatformMessageResponseHandle *handle, const uint8_t *data, size_t data_length)
 
typedef FlutterEngineResult(* FlutterEngineRegisterExternalTextureFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, int64_t texture_identifier)
 
typedef FlutterEngineResult(* FlutterEngineUnregisterExternalTextureFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, int64_t texture_identifier)
 
typedef FlutterEngineResult(* FlutterEngineMarkExternalTextureFrameAvailableFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, int64_t texture_identifier)
 
typedef FlutterEngineResult(* FlutterEngineUpdateSemanticsEnabledFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, bool enabled)
 
typedef FlutterEngineResult(* FlutterEngineUpdateAccessibilityFeaturesFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterAccessibilityFeature features)
 
typedef FlutterEngineResult(* FlutterEngineDispatchSemanticsActionFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, uint64_t id, FlutterSemanticsAction action, const uint8_t *data, size_t data_length)
 
typedef FlutterEngineResult(* FlutterEngineOnVsyncFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, intptr_t baton, uint64_t frame_start_time_nanos, uint64_t frame_target_time_nanos)
 
typedef FlutterEngineResult(* FlutterEngineReloadSystemFontsFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine)
 
typedef void(* FlutterEngineTraceEventDurationBeginFnPtr) (const char *name)
 
typedef void(* FlutterEngineTraceEventDurationEndFnPtr) (const char *name)
 
typedef void(* FlutterEngineTraceEventInstantFnPtr) (const char *name)
 
typedef FlutterEngineResult(* FlutterEnginePostRenderThreadTaskFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, VoidCallback callback, void *callback_data)
 
typedef uint64_t(* FlutterEngineGetCurrentTimeFnPtr) ()
 
typedef FlutterEngineResult(* FlutterEngineRunTaskFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterTask *task)
 
typedef FlutterEngineResult(* FlutterEngineUpdateLocalesFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterLocale **locales, size_t locales_count)
 
typedef bool(* FlutterEngineRunsAOTCompiledDartCodeFnPtr) (void)
 
typedef FlutterEngineResult(* FlutterEnginePostDartObjectFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterEngineDartPort port, const FlutterEngineDartObject *object)
 
typedef FlutterEngineResult(* FlutterEngineNotifyLowMemoryWarningFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine)
 
typedef FlutterEngineResult(* FlutterEnginePostCallbackOnAllNativeThreadsFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterNativeThreadCallback callback, void *user_data)
 
typedef FlutterEngineResult(* FlutterEngineNotifyDisplayUpdateFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterEngineDisplaysUpdateType update_type, const FlutterEngineDisplay *displays, size_t display_count)
 

Enumerations

enum  FlutterEngineResult {
  kSuccess = 0,
  kInvalidLibraryVersion,
  kInvalidArguments,
  kInternalInconsistency
}
 
enum  FlutterRendererType {
  kOpenGL,
  kSoftware,
  kMetal
}
 
enum  FlutterAccessibilityFeature {
  kFlutterAccessibilityFeatureAccessibleNavigation = 1 << 0,
  kFlutterAccessibilityFeatureInvertColors = 1 << 1,
  kFlutterAccessibilityFeatureDisableAnimations = 1 << 2,
  kFlutterAccessibilityFeatureBoldText = 1 << 3,
  kFlutterAccessibilityFeatureReduceMotion = 1 << 4
}
 
enum  FlutterSemanticsAction {
  kFlutterSemanticsActionTap = 1 << 0,
  kFlutterSemanticsActionLongPress = 1 << 1,
  kFlutterSemanticsActionScrollLeft = 1 << 2,
  kFlutterSemanticsActionScrollRight = 1 << 3,
  kFlutterSemanticsActionScrollUp = 1 << 4,
  kFlutterSemanticsActionScrollDown = 1 << 5,
  kFlutterSemanticsActionIncrease = 1 << 6,
  kFlutterSemanticsActionDecrease = 1 << 7,
  kFlutterSemanticsActionShowOnScreen = 1 << 8,
  kFlutterSemanticsActionMoveCursorForwardByCharacter = 1 << 9,
  kFlutterSemanticsActionMoveCursorBackwardByCharacter = 1 << 10,
  kFlutterSemanticsActionSetSelection = 1 << 11,
  kFlutterSemanticsActionCopy = 1 << 12,
  kFlutterSemanticsActionCut = 1 << 13,
  kFlutterSemanticsActionPaste = 1 << 14,
  kFlutterSemanticsActionDidGainAccessibilityFocus = 1 << 15,
  kFlutterSemanticsActionDidLoseAccessibilityFocus = 1 << 16,
  kFlutterSemanticsActionCustomAction = 1 << 17,
  kFlutterSemanticsActionDismiss = 1 << 18,
  kFlutterSemanticsActionMoveCursorForwardByWord = 1 << 19,
  kFlutterSemanticsActionMoveCursorBackwardByWord = 1 << 20
}
 
enum  FlutterSemanticsFlag {
  kFlutterSemanticsFlagHasCheckedState = 1 << 0,
  kFlutterSemanticsFlagIsChecked = 1 << 1,
  kFlutterSemanticsFlagIsSelected = 1 << 2,
  kFlutterSemanticsFlagIsButton = 1 << 3,
  kFlutterSemanticsFlagIsTextField = 1 << 4,
  kFlutterSemanticsFlagIsFocused = 1 << 5,
  kFlutterSemanticsFlagHasEnabledState = 1 << 6,
  kFlutterSemanticsFlagIsEnabled = 1 << 7,
  kFlutterSemanticsFlagIsInMutuallyExclusiveGroup = 1 << 8,
  kFlutterSemanticsFlagIsHeader = 1 << 9,
  kFlutterSemanticsFlagIsObscured = 1 << 10,
  kFlutterSemanticsFlagScopesRoute = 1 << 11,
  kFlutterSemanticsFlagNamesRoute = 1 << 12,
  kFlutterSemanticsFlagIsHidden = 1 << 13,
  kFlutterSemanticsFlagIsImage = 1 << 14,
  kFlutterSemanticsFlagIsLiveRegion = 1 << 15,
  kFlutterSemanticsFlagHasToggledState = 1 << 16,
  kFlutterSemanticsFlagIsToggled = 1 << 17,
  kFlutterSemanticsFlagHasImplicitScrolling = 1 << 18,
  kFlutterSemanticsFlagIsReadOnly = 1 << 20,
  kFlutterSemanticsFlagIsFocusable = 1 << 21,
  kFlutterSemanticsFlagIsLink = 1 << 22,
  kFlutterSemanticsFlagIsSlider = 1 << 23,
  kFlutterSemanticsFlagIsKeyboardKey = 1 << 24
}
 
enum  FlutterTextDirection {
  kFlutterTextDirectionUnknown = 0,
  kFlutterTextDirectionRTL = 1,
  kFlutterTextDirectionLTR = 2
}
 
enum  FlutterOpenGLTargetType {
  kFlutterOpenGLTargetTypeTexture,
  kFlutterOpenGLTargetTypeFramebuffer
}
 
enum  FlutterMetalExternalTexturePixelFormat {
  kYUVA,
  kRGBA
}
 Pixel format for the external texture. More...
 
enum  FlutterPointerPhase {
  kCancel,
  kUp,
  kDown,
  kMove,
  kAdd,
  kRemove,
  kHover
}
 The phase of the pointer event. More...
 
enum  FlutterPointerDeviceKind {
  kFlutterPointerDeviceKindMouse = 1,
  kFlutterPointerDeviceKindTouch,
  kFlutterPointerDeviceKindStylus
}
 The device type that created a pointer event. More...
 
enum  FlutterPointerMouseButtons {
  kFlutterPointerButtonMousePrimary = 1 << 0,
  kFlutterPointerButtonMouseSecondary = 1 << 1,
  kFlutterPointerButtonMouseMiddle = 1 << 2,
  kFlutterPointerButtonMouseBack = 1 << 3,
  kFlutterPointerButtonMouseForward = 1 << 4
}
 
enum  FlutterPointerSignalKind {
  kFlutterPointerSignalKindNone,
  kFlutterPointerSignalKindScroll
}
 The type of a pointer signal. More...
 
enum  FlutterKeyEventType {
  kFlutterKeyEventTypeUp = 1,
  kFlutterKeyEventTypeDown,
  kFlutterKeyEventTypeRepeat
}
 
enum  FlutterPlatformViewMutationType {
  kFlutterPlatformViewMutationTypeOpacity,
  kFlutterPlatformViewMutationTypeClipRect,
  kFlutterPlatformViewMutationTypeClipRoundedRect,
  kFlutterPlatformViewMutationTypeTransformation
}
 
enum  FlutterBackingStoreType {
  kFlutterBackingStoreTypeOpenGL,
  kFlutterBackingStoreTypeSoftware,
  kFlutterBackingStoreTypeMetal
}
 
enum  FlutterLayerContentType {
  kFlutterLayerContentTypeBackingStore,
  kFlutterLayerContentTypePlatformView
}
 
enum  FlutterEngineDisplaysUpdateType {
  kFlutterEngineDisplaysUpdateTypeStartup,
  kFlutterEngineDisplaysUpdateTypeCount
}
 
enum  FlutterEngineDartObjectType {
  kFlutterEngineDartObjectTypeNull,
  kFlutterEngineDartObjectTypeBool,
  kFlutterEngineDartObjectTypeInt32,
  kFlutterEngineDartObjectTypeInt64,
  kFlutterEngineDartObjectTypeDouble,
  kFlutterEngineDartObjectTypeString,
  kFlutterEngineDartObjectTypeBuffer
}
 
enum  FlutterNativeThreadType {
  kFlutterNativeThreadTypePlatform,
  kFlutterNativeThreadTypeRender,
  kFlutterNativeThreadTypeUI,
  kFlutterNativeThreadTypeWorker
}
 
enum  FlutterEngineAOTDataSourceType { kFlutterEngineAOTDataSourceTypeElfPath }
 AOT data source type. More...
 

Functions

FLUTTER_EXPORT 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...
 
FLUTTER_EXPORT FlutterEngineResult FlutterEngineCollectAOTData (FlutterEngineAOTData data)
 Collects the AOT data. More...
 
FLUTTER_EXPORT 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...
 
FLUTTER_EXPORT 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...
 
FLUTTER_EXPORT 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...
 
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...
 
FLUTTER_EXPORT 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 FlutterEngineSendWindowMetricsEvent (FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterWindowMetricsEvent *event)
 
FLUTTER_EXPORT FlutterEngineResult FlutterEngineSendPointerEvent (FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterPointerEvent *events, size_t events_count)
 
FLUTTER_EXPORT 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...
 
FLUTTER_EXPORT FlutterEngineResult FlutterEngineSendPlatformMessage (FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterPlatformMessage *message)
 
FLUTTER_EXPORT 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...
 
FLUTTER_EXPORT FlutterEngineResult FlutterPlatformMessageReleaseResponseHandle (FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterPlatformMessageResponseHandle *response)
 Collects the handle created using FlutterPlatformMessageCreateResponseHandle. More...
 
FLUTTER_EXPORT 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...
 
FLUTTER_EXPORT 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...
 
FLUTTER_EXPORT 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...
 
FLUTTER_EXPORT FlutterEngineResult FlutterEngineUnregisterExternalTexture (FLUTTER_API_SYMBOL(FlutterEngine) engine, int64_t texture_identifier)
 Unregister a previous texture registration. More...
 
FLUTTER_EXPORT 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...
 
FLUTTER_EXPORT FlutterEngineResult FlutterEngineUpdateSemanticsEnabled (FLUTTER_API_SYMBOL(FlutterEngine) engine, bool enabled)
 Enable or disable accessibility semantics. More...
 
FLUTTER_EXPORT FlutterEngineResult FlutterEngineUpdateAccessibilityFeatures (FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterAccessibilityFeature features)
 Sets additional accessibility features. More...
 
FLUTTER_EXPORT FlutterEngineResult FlutterEngineDispatchSemanticsAction (FLUTTER_API_SYMBOL(FlutterEngine) engine, uint64_t id, FlutterSemanticsAction action, const uint8_t *data, size_t data_length)
 Dispatch a semantics action to the specified semantics node. More...
 
FLUTTER_EXPORT 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...
 
FLUTTER_EXPORT FlutterEngineResult FlutterEngineReloadSystemFonts (FLUTTER_API_SYMBOL(FlutterEngine) engine)
 Reloads the system fonts in engine. More...
 
FLUTTER_EXPORT 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...
 
FLUTTER_EXPORT 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...
 
FLUTTER_EXPORT 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...
 
FLUTTER_EXPORT 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. More...
 
FLUTTER_EXPORT uint64_t FlutterEngineGetCurrentTime ()
 Get the current time in nanoseconds from the clock used by the flutter engine. This is the system monotonic clock. More...
 
FLUTTER_EXPORT 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...
 
FLUTTER_EXPORT 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...
 
FLUTTER_EXPORT bool FlutterEngineRunsAOTCompiledDartCode (void)
 Returns if the Flutter engine instance will run AOT compiled Dart code. This call has no threading restrictions. More...
 
FLUTTER_EXPORT 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...
 
FLUTTER_EXPORT 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. More...
 
FLUTTER_EXPORT 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...
 
FLUTTER_EXPORT 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. More...
 
FLUTTER_EXPORT FlutterEngineResult FlutterEngineGetProcAddresses (FlutterEngineProcTable *table)
 Gets the table of engine function pointers. More...
 

Variables

FLUTTER_EXPORT const int32_t kFlutterSemanticsNodeIdBatchEnd
 
FLUTTER_EXPORT const int32_t kFlutterSemanticsCustomActionIdBatchEnd
 

Macro Definition Documentation

◆ FLUTTER_API_SYMBOL

#define FLUTTER_API_SYMBOL (   symbol)    symbol

Definition at line 60 of file embedder.h.

◆ FLUTTER_ENGINE_VERSION

◆ FLUTTER_EXPORT

#define FLUTTER_EXPORT

Definition at line 50 of file embedder.h.

Typedef Documentation

◆ BoolCallback

typedef bool(* BoolCallback) (void *)

Definition at line 302 of file embedder.h.

◆ BoolPresentInfoCallback

typedef bool(* BoolPresentInfoCallback) (void *, const FlutterPresentInfo *)

Callback for when a surface is presented.

Definition at line 382 of file embedder.h.

◆ FLUTTER_API_SYMBOL

typedef struct _FlutterEngine* FLUTTER_API_SYMBOL(FlutterEngine)

Definition at line 228 of file embedder.h.

◆ FlutterBackingStoreCollectCallback

typedef bool(* FlutterBackingStoreCollectCallback) (const FlutterBackingStore *renderer, void *user_data)

Definition at line 1116 of file embedder.h.

◆ FlutterBackingStoreCreateCallback

typedef bool(* FlutterBackingStoreCreateCallback) (const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out, void *user_data)

Definition at line 1111 of file embedder.h.

◆ FlutterComputePlatformResolvedLocaleCallback

typedef const FlutterLocale*(* FlutterComputePlatformResolvedLocaleCallback) (const FlutterLocale **, size_t)

Callback that returns the system locale.

Embedders that implement this callback should return the FlutterLocale from the supported_locales list that most closely matches the user/device's preferred locale.

This callback does not currently provide the user_data baton. https://github.com/flutter/flutter/issues/79826

Definition at line 1182 of file embedder.h.

◆ FlutterDataCallback

typedef void(* FlutterDataCallback) (const uint8_t *, size_t, void *)

Definition at line 774 of file embedder.h.

◆ FlutterEngineAOTData

An opaque object that describes the AOT data that can be used to launch a FlutterEngine instance in AOT mode.

Definition at line 1346 of file embedder.h.

◆ FlutterEngineCollectAOTDataFnPtr

typedef FlutterEngineResult(* FlutterEngineCollectAOTDataFnPtr) (FlutterEngineAOTData data)

Definition at line 2260 of file embedder.h.

◆ FlutterEngineCreateAOTDataFnPtr

typedef FlutterEngineResult(* FlutterEngineCreateAOTDataFnPtr) (const FlutterEngineAOTDataSource *source, FlutterEngineAOTData *data_out)

Definition at line 2257 of file embedder.h.

◆ FlutterEngineDartPort

typedef int64_t FlutterEngineDartPort

Definition at line 1220 of file embedder.h.

◆ FlutterEngineDeinitializeFnPtr

typedef FlutterEngineResult(* FlutterEngineDeinitializeFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine)

Definition at line 2276 of file embedder.h.

◆ FlutterEngineDispatchSemanticsActionFnPtr

typedef FlutterEngineResult(* FlutterEngineDispatchSemanticsActionFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, uint64_t id, FlutterSemanticsAction action, const uint8_t *data, size_t data_length)

Definition at line 2326 of file embedder.h.

◆ FlutterEngineDisplayId

typedef uint64_t FlutterEngineDisplayId

Display refers to a graphics hardware system consisting of a framebuffer, typically a monitor or a screen. This ID is unique per display and is stable until the Flutter application restarts.

Definition at line 1189 of file embedder.h.

◆ FlutterEngineGetCurrentTimeFnPtr

typedef uint64_t(* FlutterEngineGetCurrentTimeFnPtr) ()

Definition at line 2346 of file embedder.h.

◆ FlutterEngineInitializeFnPtr

typedef FlutterEngineResult(* FlutterEngineInitializeFnPtr) (size_t version, const FlutterRendererConfig *config, const FlutterProjectArgs *args, void *user_data, FLUTTER_API_SYMBOL(FlutterEngine) *engine_out)

Definition at line 2270 of file embedder.h.

◆ FlutterEngineMarkExternalTextureFrameAvailableFnPtr

typedef FlutterEngineResult( * FlutterEngineMarkExternalTextureFrameAvailableFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, int64_t texture_identifier)

Definition at line 2317 of file embedder.h.

◆ FlutterEngineNotifyDisplayUpdateFnPtr

typedef FlutterEngineResult(* FlutterEngineNotifyDisplayUpdateFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterEngineDisplaysUpdateType update_type, const FlutterEngineDisplay *displays, size_t display_count)

Definition at line 2365 of file embedder.h.

◆ FlutterEngineNotifyLowMemoryWarningFnPtr

typedef FlutterEngineResult(* FlutterEngineNotifyLowMemoryWarningFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine)

Definition at line 2359 of file embedder.h.

◆ FlutterEngineOnVsyncFnPtr

typedef FlutterEngineResult(* FlutterEngineOnVsyncFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, intptr_t baton, uint64_t frame_start_time_nanos, uint64_t frame_target_time_nanos)

Definition at line 2332 of file embedder.h.

◆ FlutterEnginePlatformMessageCreateResponseHandleFnPtr

typedef FlutterEngineResult( * FlutterEnginePlatformMessageCreateResponseHandleFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterDataCallback data_callback, void *user_data, FlutterPlatformMessageResponseHandle **response_out)

Definition at line 2296 of file embedder.h.

◆ FlutterEnginePlatformMessageReleaseResponseHandleFnPtr

typedef FlutterEngineResult( * FlutterEnginePlatformMessageReleaseResponseHandleFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterPlatformMessageResponseHandle *response)

Definition at line 2302 of file embedder.h.

◆ FlutterEnginePostCallbackOnAllNativeThreadsFnPtr

typedef FlutterEngineResult(* FlutterEnginePostCallbackOnAllNativeThreadsFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterNativeThreadCallback callback, void *user_data)

Definition at line 2361 of file embedder.h.

◆ FlutterEnginePostDartObjectFnPtr

typedef FlutterEngineResult(* FlutterEnginePostDartObjectFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterEngineDartPort port, const FlutterEngineDartObject *object)

Definition at line 2355 of file embedder.h.

◆ FlutterEnginePostRenderThreadTaskFnPtr

typedef FlutterEngineResult(* FlutterEnginePostRenderThreadTaskFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, VoidCallback callback, void *callback_data)

Definition at line 2342 of file embedder.h.

◆ FlutterEngineRegisterExternalTextureFnPtr

typedef FlutterEngineResult(* FlutterEngineRegisterExternalTextureFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, int64_t texture_identifier)

Definition at line 2310 of file embedder.h.

◆ FlutterEngineReloadSystemFontsFnPtr

typedef FlutterEngineResult(* FlutterEngineReloadSystemFontsFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine)

Definition at line 2337 of file embedder.h.

◆ FlutterEngineRunFnPtr

typedef FlutterEngineResult(* FlutterEngineRunFnPtr) (size_t version, const FlutterRendererConfig *config, const FlutterProjectArgs *args, void *user_data, FLUTTER_API_SYMBOL(FlutterEngine) *engine_out)

Definition at line 2262 of file embedder.h.

◆ FlutterEngineRunInitializedFnPtr

typedef FlutterEngineResult(* FlutterEngineRunInitializedFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine)

Definition at line 2278 of file embedder.h.

◆ FlutterEngineRunsAOTCompiledDartCodeFnPtr

typedef bool(* FlutterEngineRunsAOTCompiledDartCodeFnPtr) (void)

Definition at line 2354 of file embedder.h.

◆ FlutterEngineRunTaskFnPtr

typedef FlutterEngineResult(* FlutterEngineRunTaskFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterTask *task)

Definition at line 2347 of file embedder.h.

◆ FlutterEngineSendKeyEventFnPtr

Definition at line 2287 of file embedder.h.

◆ FlutterEngineSendPlatformMessageFnPtr

typedef FlutterEngineResult(* FlutterEngineSendPlatformMessageFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterPlatformMessage *message)

Definition at line 2292 of file embedder.h.

◆ FlutterEngineSendPlatformMessageResponseFnPtr

typedef FlutterEngineResult(* FlutterEngineSendPlatformMessageResponseFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterPlatformMessageResponseHandle *handle, const uint8_t *data, size_t data_length)

Definition at line 2305 of file embedder.h.

◆ FlutterEngineSendPointerEventFnPtr

typedef FlutterEngineResult(* FlutterEngineSendPointerEventFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterPointerEvent *events, size_t events_count)

Definition at line 2283 of file embedder.h.

◆ FlutterEngineSendWindowMetricsEventFnPtr

typedef FlutterEngineResult(* FlutterEngineSendWindowMetricsEventFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterWindowMetricsEvent *event)

Definition at line 2280 of file embedder.h.

◆ FlutterEngineShutdownFnPtr

typedef FlutterEngineResult(* FlutterEngineShutdownFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine)

Definition at line 2268 of file embedder.h.

◆ FlutterEngineTraceEventDurationBeginFnPtr

typedef void(* FlutterEngineTraceEventDurationBeginFnPtr) (const char *name)

Definition at line 2339 of file embedder.h.

◆ FlutterEngineTraceEventDurationEndFnPtr

typedef void(* FlutterEngineTraceEventDurationEndFnPtr) (const char *name)

Definition at line 2340 of file embedder.h.

◆ FlutterEngineTraceEventInstantFnPtr

typedef void(* FlutterEngineTraceEventInstantFnPtr) (const char *name)

Definition at line 2341 of file embedder.h.

◆ FlutterEngineUnregisterExternalTextureFnPtr

typedef FlutterEngineResult(* FlutterEngineUnregisterExternalTextureFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, int64_t texture_identifier)

Definition at line 2313 of file embedder.h.

◆ FlutterEngineUpdateAccessibilityFeaturesFnPtr

typedef FlutterEngineResult(* FlutterEngineUpdateAccessibilityFeaturesFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterAccessibilityFeature features)

Definition at line 2323 of file embedder.h.

◆ FlutterEngineUpdateLocalesFnPtr

typedef FlutterEngineResult(* FlutterEngineUpdateLocalesFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterLocale **locales, size_t locales_count)

Definition at line 2350 of file embedder.h.

◆ FlutterEngineUpdateSemanticsEnabledFnPtr

typedef FlutterEngineResult(* FlutterEngineUpdateSemanticsEnabledFnPtr) (FLUTTER_API_SYMBOL(FlutterEngine) engine, bool enabled)

Definition at line 2320 of file embedder.h.

◆ FlutterKeyEventCallback

typedef void(* FlutterKeyEventCallback) (bool, void *)

Definition at line 748 of file embedder.h.

◆ FlutterLayersPresentCallback

typedef bool(* FlutterLayersPresentCallback) (const FlutterLayer **layers, size_t layers_count, void *user_data)

Definition at line 1120 of file embedder.h.

◆ FlutterLogMessageCallback

typedef void(* FlutterLogMessageCallback) (const char *, const char *, void *)

Definition at line 1340 of file embedder.h.

◆ FlutterMetalCommandQueueHandle

typedef const void* FlutterMetalCommandQueueHandle

Alias for id<MTLCommandQueue>.

Definition at line 450 of file embedder.h.

◆ FlutterMetalDeviceHandle

typedef const void* FlutterMetalDeviceHandle

Alias for id<MTLDevice>.

Definition at line 447 of file embedder.h.

◆ FlutterMetalPresentCallback

typedef bool(* FlutterMetalPresentCallback) (void *, const FlutterMetalTexture *)

Callback for when a metal texture is presented. The texture_id here corresponds to the texture_id provided by the embedder in the FlutterMetalTextureCallback callback.

Definition at line 520 of file embedder.h.

◆ FlutterMetalTextureCallback

typedef FlutterMetalTexture(* FlutterMetalTextureCallback) (void *, const FlutterFrameInfo *)

Callback for when a metal texture is requested.

Definition at line 513 of file embedder.h.

◆ FlutterMetalTextureFrameCallback

typedef bool(* FlutterMetalTextureFrameCallback) (void *, int64_t, size_t, size_t, FlutterMetalExternalTexture *)

Callback to provide an external texture for a given texture_id. See: external_texture_frame_callback.

Definition at line 485 of file embedder.h.

◆ FlutterMetalTextureHandle

typedef const void* FlutterMetalTextureHandle

Alias for id<MTLTexture>.

Definition at line 453 of file embedder.h.

◆ FlutterNativeThreadCallback

typedef void(* FlutterNativeThreadCallback) (FlutterNativeThreadType type, void *user_data)

A callback made by the engine in response to FlutterEnginePostCallbackOnAllNativeThreads on all internal thread.

Definition at line 1315 of file embedder.h.

◆ FlutterPlatformMessageCallback

typedef void(* FlutterPlatformMessageCallback) (const FlutterPlatformMessage *, void *)

Definition at line 770 of file embedder.h.

◆ FlutterPlatformMessageResponseHandle

◆ FlutterPlatformViewIdentifier

The identifier of the platform view. This identifier is specified by the application when a platform view is added to the scene via the SceneBuilder.addPlatformView call.

Definition at line 781 of file embedder.h.

◆ FlutterTaskRunner

Definition at line 895 of file embedder.h.

◆ FlutterTaskRunnerPostTaskCallback

typedef void(* FlutterTaskRunnerPostTaskCallback) (FlutterTask, uint64_t, void *)

Definition at line 902 of file embedder.h.

◆ FlutterUpdateSemanticsCustomActionCallback

typedef void(* FlutterUpdateSemanticsCustomActionCallback) (const FlutterSemanticsCustomAction *, void *)

Definition at line 891 of file embedder.h.

◆ FlutterUpdateSemanticsNodeCallback

typedef void(* FlutterUpdateSemanticsNodeCallback) (const FlutterSemanticsNode *, void *)

Definition at line 887 of file embedder.h.

◆ OnPreEngineRestartCallback

typedef void(* OnPreEngineRestartCallback) (void *)

Definition at line 316 of file embedder.h.

◆ ProcResolver

typedef void*(* ProcResolver) (void *, const char *)

Definition at line 309 of file embedder.h.

◆ SoftwareSurfacePresentCallback

typedef bool(* SoftwareSurfacePresentCallback) (void *, const void *, size_t, size_t)

Definition at line 305 of file embedder.h.

◆ TextureFrameCallback

typedef bool(* TextureFrameCallback) (void *, int64_t, size_t, size_t, FlutterOpenGLTexture *)

Definition at line 310 of file embedder.h.

◆ TransformationCallback

typedef FlutterTransformation(* TransformationCallback) (void *)

Definition at line 303 of file embedder.h.

◆ UIntCallback

typedef uint32_t(* UIntCallback) (void *)

Definition at line 304 of file embedder.h.

◆ UIntFrameInfoCallback

typedef uint32_t(* UIntFrameInfoCallback) (void *, const FlutterFrameInfo *)

Callback for when a frame buffer object is requested.

Definition at line 367 of file embedder.h.

◆ VoidCallback

typedef void(* VoidCallback) (void *)

Definition at line 251 of file embedder.h.

◆ VsyncCallback

typedef void(* VsyncCallback) (void *, intptr_t)

Definition at line 315 of file embedder.h.

Enumeration Type Documentation

◆ FlutterAccessibilityFeature

Additional accessibility features that may be enabled by the platform. Must match the AccessibilityFeatures enum in window.dart.

Enumerator
kFlutterAccessibilityFeatureAccessibleNavigation 

Indicate there is a running accessibility service which is changing the interaction model of the device.

kFlutterAccessibilityFeatureInvertColors 

Indicate the platform is inverting the colors of the application.

kFlutterAccessibilityFeatureDisableAnimations 

Request that animations be disabled or simplified.

kFlutterAccessibilityFeatureBoldText 

Request that text be rendered at a bold font weight.

kFlutterAccessibilityFeatureReduceMotion 

Request that certain animations be simplified and parallax effects.

Definition at line 83 of file embedder.h.

83  {
84  /// Indicate there is a running accessibility service which is changing the
85  /// interaction model of the device.
87  /// Indicate the platform is inverting the colors of the application.
89  /// Request that animations be disabled or simplified.
91  /// Request that text be rendered at a bold font weight.
93  /// Request that certain animations be simplified and parallax effects
94  // removed.
FlutterAccessibilityFeature
Definition: embedder.h:83
Request that text be rendered at a bold font weight.
Definition: embedder.h:92
Indicate the platform is inverting the colors of the application.
Definition: embedder.h:88
Request that animations be disabled or simplified.
Definition: embedder.h:90
Request that certain animations be simplified and parallax effects.
Definition: embedder.h:95

◆ FlutterBackingStoreType

Enumerator
kFlutterBackingStoreTypeOpenGL 

Specifies an OpenGL backing store. Can either be an OpenGL texture or framebuffer.

kFlutterBackingStoreTypeSoftware 

Specified an software allocation for Flutter to render into using the CPU.

kFlutterBackingStoreTypeMetal 

Specifies a Metal backing store. This is backed by a Metal texture.

Definition at line 1043 of file embedder.h.

1043  {
1044  /// Specifies an OpenGL backing store. Can either be an OpenGL texture or
1045  /// framebuffer.
1047  /// Specified an software allocation for Flutter to render into using the CPU.
1049  /// Specifies a Metal backing store. This is backed by a Metal texture.
Specified an software allocation for Flutter to render into using the CPU.
Definition: embedder.h:1048
Specifies a Metal backing store. This is backed by a Metal texture.
Definition: embedder.h:1050
FlutterBackingStoreType
Definition: embedder.h:1043

◆ FlutterEngineAOTDataSourceType

AOT data source type.

Enumerator
kFlutterEngineAOTDataSourceTypeElfPath 

Definition at line 1319 of file embedder.h.

◆ FlutterEngineDartObjectType

Enumerator
kFlutterEngineDartObjectTypeNull 
kFlutterEngineDartObjectTypeBool 
kFlutterEngineDartObjectTypeInt32 
kFlutterEngineDartObjectTypeInt64 
kFlutterEngineDartObjectTypeDouble 
kFlutterEngineDartObjectTypeString 
kFlutterEngineDartObjectTypeBuffer 

The object will be made available to Dart code as an instance of Uint8List.

Definition at line 1222 of file embedder.h.

◆ FlutterEngineDisplaysUpdateType

The update type parameter that is passed to FlutterEngineNotifyDisplayUpdate.

Enumerator
kFlutterEngineDisplaysUpdateTypeStartup 

FlutterEngineDisplays that were active during start-up. A display is considered active if:

  1. The frame buffer hardware is connected.
  2. The display is drawable, e.g. it isn't being mirrored from another connected display or sleeping.
kFlutterEngineDisplaysUpdateTypeCount 

Definition at line 1210 of file embedder.h.

1210  {
1211  /// `FlutterEngineDisplay`s that were active during start-up. A display is
1212  /// considered active if:
1213  /// 1. The frame buffer hardware is connected.
1214  /// 2. The display is drawable, e.g. it isn't being mirrored from another
1215  /// connected display or sleeping.
FlutterEngineDisplaysUpdateType
Definition: embedder.h:1210

◆ FlutterEngineResult

Enumerator
kSuccess 
kInvalidLibraryVersion 
kInvalidArguments 
kInternalInconsistency 

Definition at line 65 of file embedder.h.

◆ FlutterKeyEventType

Enumerator
kFlutterKeyEventTypeUp 
kFlutterKeyEventTypeDown 
kFlutterKeyEventTypeRepeat 

Definition at line 677 of file embedder.h.

◆ FlutterLayerContentType

Enumerator
kFlutterLayerContentTypeBackingStore 

Indicates that the contents of this layer are rendered by Flutter into a backing store.

kFlutterLayerContentTypePlatformView 

Indicates that the contents of this layer are determined by the embedder.

Definition at line 1082 of file embedder.h.

1082  {
1083  /// Indicates that the contents of this layer are rendered by Flutter into a
1084  /// backing store.
1086  /// Indicates that the contents of this layer are determined by the embedder.
FlutterLayerContentType
Definition: embedder.h:1082
Indicates that the contents of this layer are determined by the embedder.
Definition: embedder.h:1087

◆ FlutterMetalExternalTexturePixelFormat

Pixel format for the external texture.

Enumerator
kYUVA 
kRGBA 

Definition at line 456 of file embedder.h.

456  {
457  kYUVA,
458  kRGBA,
FlutterMetalExternalTexturePixelFormat
Pixel format for the external texture.
Definition: embedder.h:456

◆ FlutterNativeThreadType

This enum allows embedders to determine the type of the engine thread in the FlutterNativeThreadCallback. Based on the thread type, the embedder may be able to tweak the thread priorities for optimum performance.

Enumerator
kFlutterNativeThreadTypePlatform 

The Flutter Engine considers the thread on which the FlutterEngineRun call is made to be the platform thread. There is only one such thread per engine instance.

kFlutterNativeThreadTypeRender 

This is the thread the Flutter Engine uses to execute rendering commands based on the selected client rendering API. There is only one such thread per engine instance.

kFlutterNativeThreadTypeUI 

This is a dedicated thread on which the root Dart isolate is serviced. There is only one such thread per engine instance.

kFlutterNativeThreadTypeWorker 

Multiple threads are used by the Flutter engine to perform long running background tasks.

Definition at line 1296 of file embedder.h.

1296  {
1297  /// The Flutter Engine considers the thread on which the FlutterEngineRun call
1298  /// is made to be the platform thread. There is only one such thread per
1299  /// engine instance.
1301  /// This is the thread the Flutter Engine uses to execute rendering commands
1302  /// based on the selected client rendering API. There is only one such thread
1303  /// per engine instance.
1305  /// This is a dedicated thread on which the root Dart isolate is serviced.
1306  /// There is only one such thread per engine instance.
1308  /// Multiple threads are used by the Flutter engine to perform long running
1309  /// background tasks.
FlutterNativeThreadType
Definition: embedder.h:1296

◆ FlutterOpenGLTargetType

Enumerator
kFlutterOpenGLTargetTypeTexture 

Specifies an OpenGL texture target type. Textures are specified using the FlutterOpenGLTexture struct.

kFlutterOpenGLTargetTypeFramebuffer 

Specifies an OpenGL frame-buffer target type. Framebuffers are specified using the FlutterOpenGLFramebuffer struct.

Definition at line 253 of file embedder.h.

253  {
254  /// Specifies an OpenGL texture target type. Textures are specified using
255  /// the FlutterOpenGLTexture struct.
257  /// Specifies an OpenGL frame-buffer target type. Framebuffers are specified
258  /// using the FlutterOpenGLFramebuffer struct.
FlutterOpenGLTargetType
Definition: embedder.h:253

◆ FlutterPlatformViewMutationType

Enumerator
kFlutterPlatformViewMutationTypeOpacity 

Indicates that the Flutter application requested that an opacity be applied to the platform view.

kFlutterPlatformViewMutationTypeClipRect 

Indicates that the Flutter application requested that the platform view be clipped using a rectangle.

kFlutterPlatformViewMutationTypeClipRoundedRect 

Indicates that the Flutter application requested that the platform view be clipped using a rounded rectangle.

kFlutterPlatformViewMutationTypeTransformation 

Indicates that the Flutter application requested that the platform view be transformed before composition.

Definition at line 992 of file embedder.h.

992  {
993  /// Indicates that the Flutter application requested that an opacity be
994  /// applied to the platform view.
996  /// Indicates that the Flutter application requested that the platform view be
997  /// clipped using a rectangle.
999  /// Indicates that the Flutter application requested that the platform view be
1000  /// clipped using a rounded rectangle.
1002  /// Indicates that the Flutter application requested that the platform view be
1003  /// transformed before composition.
FlutterPlatformViewMutationType
Definition: embedder.h:992

◆ FlutterPointerDeviceKind

The device type that created a pointer event.

Enumerator
kFlutterPointerDeviceKindMouse 
kFlutterPointerDeviceKindTouch 
kFlutterPointerDeviceKindStylus 

Definition at line 623 of file embedder.h.

◆ FlutterPointerMouseButtons

Flags for the buttons field of FlutterPointerEvent when device_kind is kFlutterPointerDeviceKindMouse.

Enumerator
kFlutterPointerButtonMousePrimary 
kFlutterPointerButtonMouseSecondary 
kFlutterPointerButtonMouseMiddle 
kFlutterPointerButtonMouseBack 
kFlutterPointerButtonMouseForward 

Definition at line 631 of file embedder.h.

631  {
637  /// If a mouse has more than five buttons, send higher bit shifted values
638  /// corresponding to the button number: 1 << 5 for the 6th, etc.
FlutterPointerMouseButtons
Definition: embedder.h:631

◆ FlutterPointerPhase

The phase of the pointer event.

Enumerator
kCancel 
kUp 

The pointer, which must have been down (see kDown), is now up.

For touch, this means that the pointer is no longer in contact with the screen. For a mouse, it means the last button was released. Note that if any other buttons are still pressed when one button is released, that should be sent as a kMove rather than a kUp.

kDown 

The pointer, which must have been been up, is now down.

For touch, this means that the pointer has come into contact with the screen. For a mouse, it means a button is now pressed. Note that if any other buttons are already pressed when a new button is pressed, that should be sent as a kMove rather than a kDown.

kMove 

The pointer moved while down.

This is also used for changes in button state that don't cause a kDown or kUp, such as releasing one of two pressed buttons.

kAdd 

The pointer is now sending input to Flutter. For instance, a mouse has entered the area where the Flutter content is displayed.

A pointer should always be added before sending any other events.

kRemove 

The pointer is no longer sending input to Flutter. For instance, a mouse has left the area where the Flutter content is displayed.

A removed pointer should no longer send events until sending a new kAdd.

kHover 

The pointer moved while up.

Definition at line 587 of file embedder.h.

587  {
588  kCancel,
589  /// The pointer, which must have been down (see kDown), is now up.
590  ///
591  /// For touch, this means that the pointer is no longer in contact with the
592  /// screen. For a mouse, it means the last button was released. Note that if
593  /// any other buttons are still pressed when one button is released, that
594  /// should be sent as a kMove rather than a kUp.
595  kUp,
596  /// The pointer, which must have been been up, is now down.
597  ///
598  /// For touch, this means that the pointer has come into contact with the
599  /// screen. For a mouse, it means a button is now pressed. Note that if any
600  /// other buttons are already pressed when a new button is pressed, that
601  /// should be sent as a kMove rather than a kDown.
602  kDown,
603  /// The pointer moved while down.
604  ///
605  /// This is also used for changes in button state that don't cause a kDown or
606  /// kUp, such as releasing one of two pressed buttons.
607  kMove,
608  /// The pointer is now sending input to Flutter. For instance, a mouse has
609  /// entered the area where the Flutter content is displayed.
610  ///
611  /// A pointer should always be added before sending any other events.
612  kAdd,
613  /// The pointer is no longer sending input to Flutter. For instance, a mouse
614  /// has left the area where the Flutter content is displayed.
615  ///
616  /// A removed pointer should no longer send events until sending a new kAdd.
617  kRemove,
618  /// The pointer moved while up.
619  kHover,
Definition: embedder.h:595
FlutterPointerPhase
The phase of the pointer event.
Definition: embedder.h:587
The pointer moved while up.
Definition: embedder.h:619
Definition: embedder.h:612

◆ FlutterPointerSignalKind

The type of a pointer signal.

Enumerator
kFlutterPointerSignalKindNone 
kFlutterPointerSignalKindScroll 

Definition at line 642 of file embedder.h.

◆ FlutterRendererType

Enumerator
kOpenGL 
kSoftware 
kMetal 

Metal is only supported on Darwin platforms (macOS / iOS). iOS version >= 10.0 (device), 13.0 (simulator) macOS version >= 10.14

Definition at line 72 of file embedder.h.

72  {
73  kOpenGL,
74  kSoftware,
75  /// Metal is only supported on Darwin platforms (macOS / iOS).
76  /// iOS version >= 10.0 (device), 13.0 (simulator)
77  /// macOS version >= 10.14
78  kMetal,
FlutterRendererType
Definition: embedder.h:72

◆ FlutterSemanticsAction

The set of possible actions that can be conveyed to a semantics node.

Must match the SemanticsAction enum in semantics.dart.

Enumerator
kFlutterSemanticsActionTap 

The equivalent of a user briefly tapping the screen with the finger without moving it.

kFlutterSemanticsActionLongPress 

The equivalent of a user pressing and holding the screen with the finger for a few seconds without moving it.

kFlutterSemanticsActionScrollLeft 

The equivalent of a user moving their finger across the screen from right to left.

kFlutterSemanticsActionScrollRight 

The equivalent of a user moving their finger across the screen from left to right.

kFlutterSemanticsActionScrollUp 

The equivalent of a user moving their finger across the screen from bottom to top.

kFlutterSemanticsActionScrollDown 

The equivalent of a user moving their finger across the screen from top to bottom.

kFlutterSemanticsActionIncrease 

Increase the value represented by the semantics node.

kFlutterSemanticsActionDecrease 

Decrease the value represented by the semantics node.

kFlutterSemanticsActionShowOnScreen 

A request to fully show the semantics node on screen.

kFlutterSemanticsActionMoveCursorForwardByCharacter 

Move the cursor forward by one character.

kFlutterSemanticsActionMoveCursorBackwardByCharacter 

Move the cursor backward by one character.

kFlutterSemanticsActionSetSelection 

Set the text selection to the given range.

kFlutterSemanticsActionCopy 

Copy the current selection to the clipboard.

kFlutterSemanticsActionCut 

Cut the current selection and place it in the clipboard.

kFlutterSemanticsActionPaste 

Paste the current content of the clipboard.

kFlutterSemanticsActionDidGainAccessibilityFocus 

Indicate that the node has gained accessibility focus.

kFlutterSemanticsActionDidLoseAccessibilityFocus 

Indicate that the node has lost accessibility focus.

kFlutterSemanticsActionCustomAction 

Indicate that the user has invoked a custom accessibility action.

kFlutterSemanticsActionDismiss 

A request that the node should be dismissed.

kFlutterSemanticsActionMoveCursorForwardByWord 

Move the cursor forward by one word.

kFlutterSemanticsActionMoveCursorBackwardByWord 

Move the cursor backward by one word.

Definition at line 101 of file embedder.h.

101  {
102  /// The equivalent of a user briefly tapping the screen with the finger
103  /// without moving it.
105  /// The equivalent of a user pressing and holding the screen with the finger
106  /// for a few seconds without moving it.
108  /// The equivalent of a user moving their finger across the screen from right
109  /// to left.
111  /// The equivalent of a user moving their finger across the screen from left
112  /// to
113  /// right.
115  /// The equivalent of a user moving their finger across the screen from bottom
116  /// to top.
118  /// The equivalent of a user moving their finger across the screen from top to
119  /// bottom.
121  /// Increase the value represented by the semantics node.
123  /// Decrease the value represented by the semantics node.
125  /// A request to fully show the semantics node on screen.
127  /// Move the cursor forward by one character.
129  /// Move the cursor backward by one character.
131  /// Set the text selection to the given range.
133  /// Copy the current selection to the clipboard.
134  kFlutterSemanticsActionCopy = 1 << 12,
135  /// Cut the current selection and place it in the clipboard.
136  kFlutterSemanticsActionCut = 1 << 13,
137  /// Paste the current content of the clipboard.
139  /// Indicate that the node has gained accessibility focus.
141  /// Indicate that the node has lost accessibility focus.
143  /// Indicate that the user has invoked a custom accessibility action.
145  /// A request that the node should be dismissed.
147  /// Move the cursor forward by one word.
149  /// Move the cursor backward by one word.
A request to fully show the semantics node on screen.
Definition: embedder.h:126
Indicate that the user has invoked a custom accessibility action.
Definition: embedder.h:144
Move the cursor backward by one character.
Definition: embedder.h:130
Cut the current selection and place it in the clipboard.
Definition: embedder.h:136
Move the cursor forward by one word.
Definition: embedder.h:148
Set the text selection to the given range.
Definition: embedder.h:132
Copy the current selection to the clipboard.
Definition: embedder.h:134
FlutterSemanticsAction
Definition: embedder.h:101
Decrease the value represented by the semantics node.
Definition: embedder.h:124
Indicate that the node has lost accessibility focus.
Definition: embedder.h:142
Move the cursor backward by one word.
Definition: embedder.h:150
Indicate that the node has gained accessibility focus.
Definition: embedder.h:140
Paste the current content of the clipboard.
Definition: embedder.h:138
Move the cursor forward by one character.
Definition: embedder.h:128
A request that the node should be dismissed.
Definition: embedder.h:146
Increase the value represented by the semantics node.
Definition: embedder.h:122

◆ FlutterSemanticsFlag

The set of properties that may be associated with a semantics node.

Must match the SemanticsFlag enum in semantics.dart.

Enumerator
kFlutterSemanticsFlagHasCheckedState 

The semantics node has the quality of either being "checked" or "unchecked".

kFlutterSemanticsFlagIsChecked 

Whether a semantics node is checked.

kFlutterSemanticsFlagIsSelected 

Whether a semantics node is selected.

kFlutterSemanticsFlagIsButton 

Whether the semantic node represents a button.

kFlutterSemanticsFlagIsTextField 

Whether the semantic node represents a text field.

kFlutterSemanticsFlagIsFocused 

Whether the semantic node currently holds the user's focus.

kFlutterSemanticsFlagHasEnabledState 

The semantics node has the quality of either being "enabled" or "disabled".

kFlutterSemanticsFlagIsEnabled 

Whether a semantic node that hasEnabledState is currently enabled.

kFlutterSemanticsFlagIsInMutuallyExclusiveGroup 

Whether a semantic node is in a mutually exclusive group.

kFlutterSemanticsFlagIsHeader 

Whether a semantic node is a header that divides content into sections.

kFlutterSemanticsFlagIsObscured 

Whether the value of the semantics node is obscured.

kFlutterSemanticsFlagScopesRoute 

Whether the semantics node is the root of a subtree for which a route name should be announced.

kFlutterSemanticsFlagNamesRoute 

Whether the semantics node label is the name of a visually distinct route.

kFlutterSemanticsFlagIsHidden 

Whether the semantics node is considered hidden.

kFlutterSemanticsFlagIsImage 

Whether the semantics node represents an image.

kFlutterSemanticsFlagIsLiveRegion 

Whether the semantics node is a live region.

kFlutterSemanticsFlagHasToggledState 

The semantics node has the quality of either being "on" or "off".

kFlutterSemanticsFlagIsToggled 

If true, the semantics node is "on". If false, the semantics node is "off".

kFlutterSemanticsFlagHasImplicitScrolling 

Whether the platform can scroll the semantics node when the user attempts to move the accessibility focus to an offscreen child.

For example, a ListView widget has implicit scrolling so that users can easily move the accessibility focus to the next set of children. A PageView widget does not have implicit scrolling, so that users don't navigate to the next page when reaching the end of the current one.

kFlutterSemanticsFlagIsReadOnly 

Whether the semantic node is read only.

Only applicable when kFlutterSemanticsFlagIsTextField flag is on.

kFlutterSemanticsFlagIsFocusable 

Whether the semantic node can hold the user's focus.

kFlutterSemanticsFlagIsLink 

Whether the semantics node represents a link.

kFlutterSemanticsFlagIsSlider 

Whether the semantics node represents a slider.

kFlutterSemanticsFlagIsKeyboardKey 

Whether the semantics node represents a keyboard key.

Definition at line 156 of file embedder.h.

156  {
157  /// The semantics node has the quality of either being "checked" or
158  /// "unchecked".
160  /// Whether a semantics node is checked.
162  /// Whether a semantics node is selected.
164  /// Whether the semantic node represents a button.
166  /// Whether the semantic node represents a text field.
168  /// Whether the semantic node currently holds the user's focus.
170  /// The semantics node has the quality of either being "enabled" or
171  /// "disabled".
173  /// Whether a semantic node that hasEnabledState is currently enabled.
175  /// Whether a semantic node is in a mutually exclusive group.
177  /// Whether a semantic node is a header that divides content into sections.
179  /// Whether the value of the semantics node is obscured.
181  /// Whether the semantics node is the root of a subtree for which a route name
182  /// should be announced.
184  /// Whether the semantics node label is the name of a visually distinct route.
186  /// Whether the semantics node is considered hidden.
188  /// Whether the semantics node represents an image.
190  /// Whether the semantics node is a live region.
192  /// The semantics node has the quality of either being "on" or "off".
194  /// If true, the semantics node is "on". If false, the semantics node is
195  /// "off".
197  /// Whether the platform can scroll the semantics node when the user attempts
198  /// to move the accessibility focus to an offscreen child.
199  ///
200  /// For example, a `ListView` widget has implicit scrolling so that users can
201  /// easily move the accessibility focus to the next set of children. A
202  /// `PageView` widget does not have implicit scrolling, so that users don't
203  /// navigate to the next page when reaching the end of the current one.
205  /// Whether the semantic node is read only.
206  ///
207  /// Only applicable when kFlutterSemanticsFlagIsTextField flag is on.
209  /// Whether the semantic node can hold the user's focus.
211  /// Whether the semantics node represents a link.
212  kFlutterSemanticsFlagIsLink = 1 << 22,
213  /// Whether the semantics node represents a slider.
215  /// Whether the semantics node represents a keyboard key.
Whether the semantics node is considered hidden.
Definition: embedder.h:187
Whether a semantics node is selected.
Definition: embedder.h:163
Whether the semantics node label is the name of a visually distinct route.
Definition: embedder.h:185
Whether the semantics node represents an image.
Definition: embedder.h:189
Whether the semantic node can hold the user&#39;s focus.
Definition: embedder.h:210
Whether the semantics node represents a slider.
Definition: embedder.h:214
Whether a semantic node is in a mutually exclusive group.
Definition: embedder.h:176
Whether a semantic node is a header that divides content into sections.
Definition: embedder.h:178
Whether the semantics node represents a keyboard key.
Definition: embedder.h:216
Whether the semantic node represents a button.
Definition: embedder.h:165
The semantics node has the quality of either being "on" or "off".
Definition: embedder.h:193
Whether the semantic node currently holds the user&#39;s focus.
Definition: embedder.h:169
Whether the semantic node represents a text field.
Definition: embedder.h:167
Whether the semantics node represents a link.
Definition: embedder.h:212
Whether a semantics node is checked.
Definition: embedder.h:161
Whether the value of the semantics node is obscured.
Definition: embedder.h:180
Whether a semantic node that hasEnabledState is currently enabled.
Definition: embedder.h:174
FlutterSemanticsFlag
Definition: embedder.h:156
Whether the semantics node is a live region.
Definition: embedder.h:191

◆ FlutterTextDirection

Enumerator
kFlutterTextDirectionUnknown 

Text has unknown text direction.

kFlutterTextDirectionRTL 

Text is read from right to left.

kFlutterTextDirectionLTR 

Text is read from left to right.

Definition at line 219 of file embedder.h.

219  {
220  /// Text has unknown text direction.
222  /// Text is read from right to left.
224  /// Text is read from left to right.
Text is read from left to right.
Definition: embedder.h:225
Text is read from right to left.
Definition: embedder.h:223
FlutterTextDirection
Definition: embedder.h:219
Text has unknown text direction.
Definition: embedder.h:221

Function Documentation

◆ __FlutterEngineFlushPendingTasksNow()

FLUTTER_EXPORT 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.

Returns
The result of the call.

Definition at line 1763 of file embedder.cc.

References fml::MessageLoop::GetCurrent(), kSuccess, and fml::MessageLoop::RunExpiredTasksNow().

1763  {
1765  return kSuccess;
1766 }
static FML_EMBEDDER_ONLY MessageLoop & GetCurrent()
Definition: message_loop.cc:19
void RunExpiredTasksNow()
Definition: message_loop.cc:72

◆ FlutterEngineCollectAOTData()

FLUTTER_EXPORT FlutterEngineResult FlutterEngineCollectAOTData ( FlutterEngineAOTData  data)

Collects the AOT data.

Warning
The embedder must ensure that this call is made only after all FlutterEngine instances launched using this data have been terminated, and that all of those instances were launched with the FlutterProjectArgs::shutdown_dart_vm_when_done flag set to true.
Parameters
[in]dataThe data to collect.
Returns
Returns if the AOT data was successfully collected.

Definition at line 802 of file embedder.cc.

References kSuccess.

Referenced by FlutterEngineGetProcAddresses(), flutter::testing::AOTDataDeleter::operator()(), AOTDataDeleter::operator()(), flutter::testing::TEST_F(), and _FlutterTaskRunner::~_FlutterTaskRunner().

802  {
803  if (!data) {
804  // Deleting a null object should be a no-op.
805  return kSuccess;
806  }
807 
808  // Created in a unique pointer in `FlutterEngineCreateAOTData`.
809  delete data;
810  return kSuccess;
811 }

◆ FlutterEngineCreateAOTData()

FLUTTER_EXPORT 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.

Parameters
[in]sourceThe source of the AOT data.
[out]data_outThe AOT data on success. Unchanged on failure.
Returns
Returns if the AOT data could be successfully resolved.

Definition at line 748 of file embedder.cc.

References FlutterEngineAOTDataSource::elf_path, error, fml::IsFile(), flutter::DartVM::IsRunningPrecompiledCode(), kFlutterEngineAOTDataSourceTypeElfPath, kInvalidArguments, kSuccess, LOG_EMBEDDER_ERROR, and FlutterEngineAOTDataSource::type.

Referenced by FlutterEngineGetProcAddresses(), LoadAotData(), flutter::testing::EmbedderTestContext::SetupAOTDataIfNecessary(), flutter::testing::TEST_F(), and _FlutterTaskRunner::~_FlutterTaskRunner().

750  {
753  "AOT data can only be created in AOT mode.");
754  } else if (!source) {
755  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Null source specified.");
756  } else if (!data_out) {
757  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Null data_out specified.");
758  }
759 
760  switch (source->type) {
762  if (!source->elf_path || !fml::IsFile(source->elf_path)) {
764  "Invalid ELF path specified.");
765  }
766 
767  auto aot_data = std::make_unique<_FlutterEngineAOTData>();
768  const char* error = nullptr;
769 
770 #if OS_FUCHSIA
771  // TODO(gw280): https://github.com/flutter/flutter/issues/50285
772  // Dart doesn't implement Dart_LoadELF on Fuchsia
773  Dart_LoadedElf* loaded_elf = nullptr;
774 #else
775  Dart_LoadedElf* loaded_elf = Dart_LoadELF(
776  source->elf_path, // file path
777  0, // file offset
778  &error, // error (out)
779  &aot_data->vm_snapshot_data, // vm snapshot data (out)
780  &aot_data->vm_snapshot_instrs, // vm snapshot instr (out)
781  &aot_data->vm_isolate_data, // vm isolate data (out)
782  &aot_data->vm_isolate_instrs // vm isolate instr (out)
783  );
784 #endif
785 
786  if (loaded_elf == nullptr) {
787  return LOG_EMBEDDER_ERROR(kInvalidArguments, error);
788  }
789 
790  aot_data->loaded_elf.reset(loaded_elf);
791 
792  *data_out = aot_data.release();
793  return kSuccess;
794  }
795  }
796 
797  return LOG_EMBEDDER_ERROR(
799  "Invalid FlutterEngineAOTDataSourceType type specified.");
800 }
const uint8_t uint32_t uint32_t GError ** error
#define LOG_EMBEDDER_ERROR(code, reason)
Definition: embedder.cc:93
static bool IsRunningPrecompiledCode()
Checks if VM instances in the process can run precompiled code. This call can be made at any time and...
Definition: dart_vm.cc:202
bool IsFile(const std::string &path)
Definition: file_posix.cc:145
FlutterEngineAOTDataSourceType type
Definition: embedder.h:1326
const char * elf_path
Absolute path to an ELF library file.
Definition: embedder.h:1329

◆ FlutterEngineDeinitialize()

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.

Parameters
[in]engineThe running engine instance to de-initialize.
Returns
The result of the call to de-initialize the Flutter engine.

Definition at line 1365 of file embedder.cc.

References engine, kInvalidArguments, kSuccess, LOG_EMBEDDER_ERROR, and flutter::EmbedderEngine::NotifyDestroyed().

Referenced by FlutterEngineGetProcAddresses(), FlutterEngineShutdown(), flutter::testing::TEST_F(), and _FlutterTaskRunner::~_FlutterTaskRunner().

1366  {
1367  if (engine == nullptr) {
1368  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Engine handle was invalid.");
1369  }
1370 
1371  auto embedder_engine = reinterpret_cast<flutter::EmbedderEngine*>(engine);
1372  embedder_engine->NotifyDestroyed();
1373  embedder_engine->CollectShell();
1374  return kSuccess;
1375 }
#define LOG_EMBEDDER_ERROR(code, reason)
Definition: embedder.cc:93

◆ FlutterEngineDispatchSemanticsAction()

FLUTTER_EXPORT FlutterEngineResult FlutterEngineDispatchSemanticsAction ( FLUTTER_API_SYMBOL(FlutterEngine engine,
uint64_t  id,
FlutterSemanticsAction  action,
const uint8_t *  data,
size_t  data_length 
)

Dispatch a semantics action to the specified semantics node.

Parameters
[in]engineA running engine instance.
[in]identifierThe semantics action identifier.
[in]actionThe semantics action.
[in]dataData associated with the action.
[in]data_lengthThe data length.
Returns
The result of the call.

Definition at line 1854 of file embedder.cc.

References action, fml::MallocMapping::Copy(), kInternalInconsistency, kInvalidArguments, kSuccess, and LOG_EMBEDDER_ERROR.

Referenced by FlutterEngineGetProcAddresses(), flutter::testing::TEST_F(), and _FlutterTaskRunner::~_FlutterTaskRunner().

1859  {
1860  if (engine == nullptr) {
1861  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Invalid engine handle.");
1862  }
1863  auto engine_action = static_cast<flutter::SemanticsAction>(action);
1864  if (!reinterpret_cast<flutter::EmbedderEngine*>(engine)
1865  ->DispatchSemanticsAction(
1866  id, engine_action,
1867  fml::MallocMapping::Copy(data, data_length))) {
1869  "Could not dispatch semantics action.");
1870  }
1871  return kSuccess;
1872 }
#define LOG_EMBEDDER_ERROR(code, reason)
Definition: embedder.cc:93
SemanticsAction action
static MallocMapping Copy(const T *begin, const T *end)
Definition: mapping.h:147

◆ FlutterEngineGetCurrentTime()

FLUTTER_EXPORT uint64_t FlutterEngineGetCurrentTime ( )

Get the current time in nanoseconds from the clock used by the flutter engine. This is the system monotonic clock.

Returns
The current time in nanoseconds.

Definition at line 1952 of file embedder.cc.

References fml::TimePoint::Now(), fml::TimePoint::ToEpochDelta(), and fml::TimeDelta::ToNanoseconds().

Referenced by FlutterEngineGetProcAddresses(), flutter::testing::TEST(), and flutter::EventLoop::TimePointFromFlutterTime().

1952  {
1954 }
TimeDelta ToEpochDelta() const
Definition: time_point.h:47
constexpr int64_t ToNanoseconds() const
Definition: time_delta.h:61
static TimePoint Now()
Definition: time_point.cc:39

◆ FlutterEngineGetProcAddresses()

FLUTTER_EXPORT FlutterEngineResult FlutterEngineGetProcAddresses ( FlutterEngineProcTable table)

Gets the table of engine function pointers.

Parameters
[out]tableThe table to fill with pointers. This should be zero-initialized, except for struct_size.
Returns
Returns whether the table was successfully populated.

Definition at line 2291 of file embedder.cc.

References FlutterEngineProcTable::CollectAOTData, FlutterEngineProcTable::CreateAOTData, FlutterEngineProcTable::Deinitialize, flutter::DispatchSemanticsAction(), FlutterEngineProcTable::DispatchSemanticsAction, FlutterEngineCollectAOTData(), FlutterEngineCreateAOTData(), FlutterEngineDeinitialize(), FlutterEngineDispatchSemanticsAction(), FlutterEngineGetCurrentTime(), FlutterEngineInitialize(), FlutterEngineMarkExternalTextureFrameAvailable(), FlutterEngineNotifyDisplayUpdate(), FlutterEngineNotifyLowMemoryWarning(), FlutterEngineOnVsync(), FlutterEnginePostCallbackOnAllNativeThreads(), FlutterEnginePostDartObject(), FlutterEnginePostRenderThreadTask(), FlutterEngineRegisterExternalTexture(), FlutterEngineReloadSystemFonts(), FlutterEngineRun(), FlutterEngineRunInitialized(), FlutterEngineRunsAOTCompiledDartCode(), FlutterEngineRunTask(), FlutterEngineSendKeyEvent(), FlutterEngineSendPlatformMessage(), FlutterEngineSendPlatformMessageResponse(), FlutterEngineSendPointerEvent(), FlutterEngineSendWindowMetricsEvent(), FlutterEngineShutdown(), FlutterEngineTraceEventDurationBegin(), FlutterEngineTraceEventDurationEnd(), FlutterEngineTraceEventInstant(), FlutterEngineUnregisterExternalTexture(), FlutterEngineUpdateAccessibilityFeatures(), FlutterEngineUpdateLocales(), FlutterEngineUpdateSemanticsEnabled(), FlutterPlatformMessageCreateResponseHandle(), FlutterPlatformMessageReleaseResponseHandle(), GetCurrentTime, fuchsia::dart::Initialize(), FlutterEngineProcTable::Initialize, kInvalidArguments, kSuccess, LOG_EMBEDDER_ERROR, FlutterEngineProcTable::MarkExternalTextureFrameAvailable, flutter::NotifyLowMemoryWarning(), FlutterEngineProcTable::PlatformMessageCreateResponseHandle, FlutterEngineProcTable::PlatformMessageReleaseResponseHandle, FlutterEngineProcTable::RegisterExternalTexture, FlutterEngineProcTable::Run, FlutterEngineProcTable::RunInitialized, FlutterEngineProcTable::RunsAOTCompiledDartCode, FlutterEngineProcTable::RunTask, FlutterEngineProcTable::SendKeyEvent, FlutterEngineProcTable::SendPlatformMessage, FlutterEngineProcTable::SendPlatformMessageResponse, FlutterEngineProcTable::SendPointerEvent, FlutterEngineProcTable::SendWindowMetricsEvent, SET_PROC, FlutterEngineProcTable::Shutdown, FlutterEngineProcTable::UnregisterExternalTexture, FlutterEngineProcTable::UpdateLocales, and FlutterEngineProcTable::UpdateSemanticsEnabled.

Referenced by fl_engine_init(), flutter::FlutterWindowsEngine::FlutterWindowsEngine(), and flutter::testing::TEST().

2292  {
2293  if (!table) {
2294  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Null table specified.");
2295  }
2296 #define SET_PROC(member, function) \
2297  if (STRUCT_HAS_MEMBER(table, member)) { \
2298  table->member = &function; \
2299  }
2300 
2301  SET_PROC(CreateAOTData, FlutterEngineCreateAOTData);
2302  SET_PROC(CollectAOTData, FlutterEngineCollectAOTData);
2303  SET_PROC(Run, FlutterEngineRun);
2304  SET_PROC(Shutdown, FlutterEngineShutdown);
2306  SET_PROC(Deinitialize, FlutterEngineDeinitialize);
2307  SET_PROC(RunInitialized, FlutterEngineRunInitialized);
2308  SET_PROC(SendWindowMetricsEvent, FlutterEngineSendWindowMetricsEvent);
2309  SET_PROC(SendPointerEvent, FlutterEngineSendPointerEvent);
2310  SET_PROC(SendKeyEvent, FlutterEngineSendKeyEvent);
2311  SET_PROC(SendPlatformMessage, FlutterEngineSendPlatformMessage);
2312  SET_PROC(PlatformMessageCreateResponseHandle,
2314  SET_PROC(PlatformMessageReleaseResponseHandle,
2316  SET_PROC(SendPlatformMessageResponse,
2318  SET_PROC(RegisterExternalTexture, FlutterEngineRegisterExternalTexture);
2319  SET_PROC(UnregisterExternalTexture, FlutterEngineUnregisterExternalTexture);
2320  SET_PROC(MarkExternalTextureFrameAvailable,
2322  SET_PROC(UpdateSemanticsEnabled, FlutterEngineUpdateSemanticsEnabled);
2323  SET_PROC(UpdateAccessibilityFeatures,
2326  SET_PROC(OnVsync, FlutterEngineOnVsync);
2327  SET_PROC(ReloadSystemFonts, FlutterEngineReloadSystemFonts);
2328  SET_PROC(TraceEventDurationBegin, FlutterEngineTraceEventDurationBegin);
2329  SET_PROC(TraceEventDurationEnd, FlutterEngineTraceEventDurationEnd);
2330  SET_PROC(TraceEventInstant, FlutterEngineTraceEventInstant);
2331  SET_PROC(PostRenderThreadTask, FlutterEnginePostRenderThreadTask);
2333  SET_PROC(RunTask, FlutterEngineRunTask);
2334  SET_PROC(UpdateLocales, FlutterEngineUpdateLocales);
2335  SET_PROC(RunsAOTCompiledDartCode, FlutterEngineRunsAOTCompiledDartCode);
2336  SET_PROC(PostDartObject, FlutterEnginePostDartObject);
2338  SET_PROC(PostCallbackOnAllNativeThreads,
2340  SET_PROC(NotifyDisplayUpdate, FlutterEngineNotifyDisplayUpdate);
2341 #undef SET_PROC
2342 
2343  return kSuccess;
2344 }
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.
Definition: embedder.cc:2251
static void DispatchSemanticsAction(JNIEnv *env, jobject jcaller, jlong shell_holder, jint id, jint action, jobject args, jint args_position)
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 m...
Definition: embedder.cc:1365
FlutterEngineResult FlutterPlatformMessageReleaseResponseHandle(FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterPlatformMessageResponseHandle *response)
Collects the handle created using FlutterPlatformMessageCreateResponseHandle.
Definition: embedder.cc:1722
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 FlutterTa...
Definition: embedder.cc:1956
void FlutterEngineTraceEventDurationEnd(const char *name)
A profiling utility. Logs a trace duration end event to the timeline. If the timeline is unavailable ...
Definition: embedder.cc:1922
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...
Definition: embedder.cc:1930
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.
Definition: embedder.cc:1736
FlutterEngineResult FlutterEngineDispatchSemanticsAction(FLUTTER_API_SYMBOL(FlutterEngine) engine, uint64_t id, FlutterSemanticsAction action, const uint8_t *data, size_t data_length)
Dispatch a semantics action to the specified semantics node.
Definition: embedder.cc:1854
#define LOG_EMBEDDER_ERROR(code, reason)
Definition: embedder.cc:93
FlutterEngineResult FlutterEngineUpdateAccessibilityFeatures(FLUTTER_API_SYMBOL(FlutterEngine) engine, FlutterAccessibilityFeature flags)
Sets additional accessibility features.
Definition: embedder.cc:1840
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 embed...
Definition: embedder.cc:1377
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 an...
Definition: embedder.cc:2065
FlutterEngineResult FlutterEngineMarkExternalTextureFrameAvailable(FLUTTER_API_SYMBOL(FlutterEngine) engine, int64_t texture_identifier)
Mark that a new texture frame is available for a given texture identifier.
Definition: embedder.cc:1808
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 ...
Definition: embedder.cc:2189
void FlutterEngineTraceEventDurationBegin(const char *name)
A profiling utility. Logs a trace duration begin event to the timeline. If the timeline is unavailabl...
Definition: embedder.cc:1918
FlutterEngineResult FlutterEngineReloadSystemFonts(FLUTTER_API_SYMBOL(FlutterEngine) engine)
Reloads the system fonts in engine.
Definition: embedder.cc:1901
void FlutterEngineTraceEventInstant(const char *name)
A profiling utility. Logs a trace duration instant event to the timeline. If the timeline is unavaila...
Definition: embedder.cc:1926
static void NotifyLowMemoryWarning(JNIEnv *env, jobject obj, jlong shell_holder)
FlutterEngineResult FlutterEngineUpdateSemanticsEnabled(FLUTTER_API_SYMBOL(FlutterEngine) engine, bool enabled)
Enable or disable accessibility semantics.
Definition: embedder.cc:1826
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 ...
Definition: embedder.cc:869
FlutterEngineResult FlutterEngineCollectAOTData(FlutterEngineAOTData data)
Collects the AOT data.
Definition: embedder.cc:802
void Initialize(fidl::InterfaceHandle< fuchsia::sys::Environment > environment, zx::channel directory_request, std::optional< zx::eventpair > view_ref)
Initializes Dart bindings for the Fuchsia application model.
Definition: fuchsia.cc:103
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 f...
Definition: embedder.cc:2001
#define SET_PROC(member, function)
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 synchron...
Definition: embedder.cc:1596
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 supp...
Definition: embedder.cc:1768
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 ...
Definition: embedder.cc:2212
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 Flutter...
Definition: embedder.cc:885
FlutterEngineResult FlutterEngineUnregisterExternalTexture(FLUTTER_API_SYMBOL(FlutterEngine) engine, int64_t texture_identifier)
Unregister a previous texture registration.
Definition: embedder.cc:1787
#define GetCurrentTime()
FlutterEngineResult FlutterEngineSendPointerEvent(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterPointerEvent *pointers, size_t events_count)
Definition: embedder.cc:1510
FlutterEngineResult FlutterEngineSendWindowMetricsEvent(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterWindowMetricsEvent *flutter_metrics)
Definition: embedder.cc:1388
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 ...
Definition: embedder.cc:1874
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.
Definition: embedder.cc:1326
bool FlutterEngineRunsAOTCompiledDartCode(void)
Returns if the Flutter engine instance will run AOT compiled Dart code. This call has no threading re...
Definition: embedder.cc:2061
uint64_t FlutterEngineGetCurrentTime()
Get the current time in nanoseconds from the clock used by the flutter engine. This is the system mon...
Definition: embedder.cc:1952
FlutterEngineResult FlutterEngineSendPlatformMessage(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterPlatformMessage *flutter_message)
Definition: embedder.cc:1636
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 re...
Definition: embedder.cc:1687
FlutterEngineResult FlutterEngineCreateAOTData(const FlutterEngineAOTDataSource *source, FlutterEngineAOTData *data_out)
Creates the necessary data structures to launch a Flutter Dart application in AOT mode...
Definition: embedder.cc:748

◆ FlutterEngineInitialize()

FLUTTER_EXPORT 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.

Parameters
[in]versionThe Flutter embedder API version. Must be FLUTTER_ENGINE_VERSION.
[in]configThe renderer configuration.
[in]argsThe Flutter project arguments.
user_dataA user data baton passed back to embedders in callbacks.
[out]engine_outThe engine handle on successful engine creation.
Returns
The result of the call to initialize the Flutter engine.

Definition at line 885 of file embedder.cc.

References action, FlutterSemanticsNode::actions, fml::MessageLoop::AddTaskObserver(), flutter::Settings::application_kernel_asset, flutter::Settings::assets_path, FlutterProjectArgs::assets_path, callback, FlutterPlatformMessage::channel, fml::CommandLineFromArgcArgv(), FlutterProjectArgs::compute_platform_resolved_locale_callback, flutter::EmbedderThreadHost::CreateEmbedderOrEngineManagedThreadHost(), FlutterProjectArgs::custom_dart_entrypoint, FlutterProjectArgs::dart_entrypoint_argc, flutter::Settings::dart_entrypoint_args, FlutterProjectArgs::dart_entrypoint_argv, FlutterSemanticsNode::elevation, FlutterMetalRendererConfig::external_texture_frame_callback, FlutterSemanticsNode::flags, FLUTTER_ENGINE_VERSION, FML_LOG, fml::MessageLoop::GetCurrent(), flutter::PersistentCache::gIsReadOnly, FlutterOpenGLRendererConfig::gl_external_texture_frame_callback, height, FlutterSemanticsNode::hint, flutter::Settings::icu_data_path, FlutterSemanticsNode::id, InferExternalViewEmbedderFromArgs(), flutter::RunConfiguration::InferFromSettings(), InferPlatformViewCreationCallback(), fml::IsFile(), IsRendererValid(), flutter::DartVM::IsRunningPrecompiledCode(), fml::paths::JoinPaths(), kApplicationKernelSnapshotFileName, key, kFlutterSemanticsCustomActionIdBatchEnd, kFlutterSemanticsNodeIdBatchEnd, kInternalInconsistency, kInvalidArguments, kInvalidLibraryVersion, kMetal, kOpenGL, kSuccess, FlutterSemanticsNode::label, flutter::Settings::leak_vm, LOG_EMBEDDER_ERROR, flutter::Settings::log_message_callback, flutter::Settings::log_tag, FlutterRendererConfig::metal, node, flutter::Settings::old_gen_heap_size, FlutterProjectArgs::on_pre_engine_restart_callback, FlutterRendererConfig::open_gl, FlutterProjectArgs::platform_message_callback, PopulateSnapshotMappingCallbacks(), FlutterSemanticsNode::rect, fml::MessageLoop::RemoveTaskObserver(), result, flutter::Settings::root_isolate_create_callback, SAFE_ACCESS, flutter::PersistentCache::SetCacheDirectoryPath(), flutter::SettingsFromCommandLine(), flutter::Settings::task_observer_add, flutter::Settings::task_observer_remove, texture, FlutterSemanticsNode::thickness, flutter::transform, FlutterSemanticsNode::transform, FlutterRendererConfig::type, FlutterProjectArgs::update_semantics_custom_action_callback, FlutterProjectArgs::update_semantics_node_callback, user_data, value, FlutterSemanticsNode::value, FlutterProjectArgs::vsync_callback, and width.

Referenced by FlutterEngineGetProcAddresses(), FlutterEngineRun(), flutter::testing::EmbedderConfigBuilder::InitializeEngine(), and _FlutterTaskRunner::~_FlutterTaskRunner().

890  {
891  // Step 0: Figure out arguments for shell creation.
892  if (version != FLUTTER_ENGINE_VERSION) {
893  return LOG_EMBEDDER_ERROR(
895  "Flutter embedder version mismatch. There has been a breaking change. "
896  "Please consult the changelog and update the embedder.");
897  }
898 
899  if (engine_out == nullptr) {
901  "The engine out parameter was missing.");
902  }
903 
904  if (args == nullptr) {
906  "The Flutter project arguments were missing.");
907  }
908 
909  if (SAFE_ACCESS(args, assets_path, nullptr) == nullptr) {
910  return LOG_EMBEDDER_ERROR(
912  "The assets path in the Flutter project arguments was missing.");
913  }
914 
915  if (SAFE_ACCESS(args, main_path__unused__, nullptr) != nullptr) {
916  FML_LOG(WARNING)
917  << "FlutterProjectArgs.main_path is deprecated and should be set null.";
918  }
919 
920  if (SAFE_ACCESS(args, packages_path__unused__, nullptr) != nullptr) {
921  FML_LOG(WARNING) << "FlutterProjectArgs.packages_path is deprecated and "
922  "should be set null.";
923  }
924 
925  if (!IsRendererValid(config)) {
927  "The renderer configuration was invalid.");
928  }
929 
930  std::string icu_data_path;
931  if (SAFE_ACCESS(args, icu_data_path, nullptr) != nullptr) {
932  icu_data_path = SAFE_ACCESS(args, icu_data_path, nullptr);
933  }
934 
935  if (SAFE_ACCESS(args, persistent_cache_path, nullptr) != nullptr) {
936  std::string persistent_cache_path =
937  SAFE_ACCESS(args, persistent_cache_path, nullptr);
939  }
940 
941  if (SAFE_ACCESS(args, is_persistent_cache_read_only, false)) {
943  }
944 
945  fml::CommandLine command_line;
946  if (SAFE_ACCESS(args, command_line_argc, 0) != 0 &&
947  SAFE_ACCESS(args, command_line_argv, nullptr) != nullptr) {
948  command_line = fml::CommandLineFromArgcArgv(
949  SAFE_ACCESS(args, command_line_argc, 0),
950  SAFE_ACCESS(args, command_line_argv, nullptr));
951  }
952 
953  flutter::Settings settings = flutter::SettingsFromCommandLine(command_line);
954 
955  if (SAFE_ACCESS(args, aot_data, nullptr)) {
956  if (SAFE_ACCESS(args, vm_snapshot_data, nullptr) ||
957  SAFE_ACCESS(args, vm_snapshot_instructions, nullptr) ||
958  SAFE_ACCESS(args, isolate_snapshot_data, nullptr) ||
959  SAFE_ACCESS(args, isolate_snapshot_instructions, nullptr)) {
960  return LOG_EMBEDDER_ERROR(
962  "Multiple AOT sources specified. Embedders should provide either "
963  "*_snapshot_* buffers or aot_data, not both.");
964  }
965  }
966 
967  PopulateSnapshotMappingCallbacks(args, settings);
968 
969  settings.icu_data_path = icu_data_path;
970  settings.assets_path = args->assets_path;
971  settings.leak_vm = !SAFE_ACCESS(args, shutdown_dart_vm_when_done, false);
972  settings.old_gen_heap_size = SAFE_ACCESS(args, dart_old_gen_heap_size, -1);
973 
975  // Verify the assets path contains Dart 2 kernel assets.
976  const std::string kApplicationKernelSnapshotFileName = "kernel_blob.bin";
977  std::string application_kernel_path = fml::paths::JoinPaths(
978  {settings.assets_path, kApplicationKernelSnapshotFileName});
979  if (!fml::IsFile(application_kernel_path)) {
980  return LOG_EMBEDDER_ERROR(
982  "Not running in AOT mode but could not resolve the kernel binary.");
983  }
985  }
986 
987  settings.task_observer_add = [](intptr_t key, fml::closure callback) {
989  };
990  settings.task_observer_remove = [](intptr_t key) {
992  };
993  if (SAFE_ACCESS(args, root_isolate_create_callback, nullptr) != nullptr) {
995  SAFE_ACCESS(args, root_isolate_create_callback, nullptr);
997  [callback, user_data](const auto& isolate) { callback(user_data); };
998  }
999  if (SAFE_ACCESS(args, log_message_callback, nullptr) != nullptr) {
1001  SAFE_ACCESS(args, log_message_callback, nullptr);
1002  settings.log_message_callback = [callback, user_data](
1003  const std::string& tag,
1004  const std::string& message) {
1005  callback(tag.c_str(), message.c_str(), user_data);
1006  };
1007  }
1008  if (SAFE_ACCESS(args, log_tag, nullptr) != nullptr) {
1009  settings.log_tag = SAFE_ACCESS(args, log_tag, nullptr);
1010  }
1011 
1013  update_semantics_nodes_callback = nullptr;
1014  if (SAFE_ACCESS(args, update_semantics_node_callback, nullptr) != nullptr) {
1015  update_semantics_nodes_callback =
1016  [ptr = args->update_semantics_node_callback,
1018  for (const auto& value : update) {
1019  const auto& node = value.second;
1020  SkMatrix transform = node.transform.asM33();
1021  FlutterTransformation flutter_transform{
1022  transform.get(SkMatrix::kMScaleX),
1023  transform.get(SkMatrix::kMSkewX),
1024  transform.get(SkMatrix::kMTransX),
1025  transform.get(SkMatrix::kMSkewY),
1026  transform.get(SkMatrix::kMScaleY),
1027  transform.get(SkMatrix::kMTransY),
1028  transform.get(SkMatrix::kMPersp0),
1029  transform.get(SkMatrix::kMPersp1),
1030  transform.get(SkMatrix::kMPersp2)};
1031  const FlutterSemanticsNode embedder_node{
1032  sizeof(FlutterSemanticsNode),
1033  node.id,
1034  static_cast<FlutterSemanticsFlag>(node.flags),
1035  static_cast<FlutterSemanticsAction>(node.actions),
1036  node.textSelectionBase,
1037  node.textSelectionExtent,
1038  node.scrollChildren,
1039  node.scrollIndex,
1040  node.scrollPosition,
1041  node.scrollExtentMax,
1042  node.scrollExtentMin,
1043  node.elevation,
1044  node.thickness,
1045  node.label.c_str(),
1046  node.hint.c_str(),
1047  node.value.c_str(),
1048  node.increasedValue.c_str(),
1049  node.decreasedValue.c_str(),
1050  static_cast<FlutterTextDirection>(node.textDirection),
1051  FlutterRect{node.rect.fLeft, node.rect.fTop, node.rect.fRight,
1052  node.rect.fBottom},
1053  flutter_transform,
1054  node.childrenInTraversalOrder.size(),
1055  &node.childrenInTraversalOrder[0],
1056  &node.childrenInHitTestOrder[0],
1057  node.customAccessibilityActions.size(),
1058  &node.customAccessibilityActions[0],
1059  node.platformViewId,
1060  };
1061  ptr(&embedder_node, user_data);
1062  }
1063  const FlutterSemanticsNode batch_end_sentinel = {
1064  sizeof(FlutterSemanticsNode),
1066  };
1067  ptr(&batch_end_sentinel, user_data);
1068  };
1069  }
1070 
1072  update_semantics_custom_actions_callback = nullptr;
1073  if (SAFE_ACCESS(args, update_semantics_custom_action_callback, nullptr) !=
1074  nullptr) {
1075  update_semantics_custom_actions_callback =
1078  for (const auto& value : actions) {
1079  const auto& action = value.second;
1080  const FlutterSemanticsCustomAction embedder_action = {
1082  action.id,
1083  static_cast<FlutterSemanticsAction>(action.overrideId),
1084  action.label.c_str(),
1085  action.hint.c_str(),
1086  };
1087  ptr(&embedder_action, user_data);
1088  }
1089  const FlutterSemanticsCustomAction batch_end_sentinel = {
1092  };
1093  ptr(&batch_end_sentinel, user_data);
1094  };
1095  }
1096 
1098  platform_message_response_callback = nullptr;
1099  if (SAFE_ACCESS(args, platform_message_callback, nullptr) != nullptr) {
1100  platform_message_response_callback =
1101  [ptr = args->platform_message_callback,
1102  user_data](std::unique_ptr<flutter::PlatformMessage> message) {
1103  auto handle = new FlutterPlatformMessageResponseHandle();
1104  const FlutterPlatformMessage incoming_message = {
1105  sizeof(FlutterPlatformMessage), // struct_size
1106  message->channel().c_str(), // channel
1107  message->data().GetMapping(), // message
1108  message->data().GetSize(), // message_size
1109  handle, // response_handle
1110  };
1111  handle->message = std::move(message);
1112  return ptr(&incoming_message, user_data);
1113  };
1114  }
1115 
1116  flutter::VsyncWaiterEmbedder::VsyncCallback vsync_callback = nullptr;
1117  if (SAFE_ACCESS(args, vsync_callback, nullptr) != nullptr) {
1118  vsync_callback = [ptr = args->vsync_callback, user_data](intptr_t baton) {
1119  return ptr(user_data, baton);
1120  };
1121  }
1122 
1124  compute_platform_resolved_locale_callback = nullptr;
1125  if (SAFE_ACCESS(args, compute_platform_resolved_locale_callback, nullptr) !=
1126  nullptr) {
1127  compute_platform_resolved_locale_callback =
1129  const std::vector<std::string>& supported_locales_data) {
1130  const size_t number_of_strings_per_locale = 3;
1131  size_t locale_count =
1132  supported_locales_data.size() / number_of_strings_per_locale;
1133  std::vector<FlutterLocale> supported_locales;
1134  std::vector<const FlutterLocale*> supported_locales_ptr;
1135  for (size_t i = 0; i < locale_count; ++i) {
1136  supported_locales.push_back(
1137  {.struct_size = sizeof(FlutterLocale),
1138  .language_code =
1139  supported_locales_data[i * number_of_strings_per_locale +
1140  0]
1141  .c_str(),
1142  .country_code =
1143  supported_locales_data[i * number_of_strings_per_locale +
1144  1]
1145  .c_str(),
1146  .script_code =
1147  supported_locales_data[i * number_of_strings_per_locale +
1148  2]
1149  .c_str(),
1150  .variant_code = nullptr});
1151  supported_locales_ptr.push_back(&supported_locales[i]);
1152  }
1153 
1154  const FlutterLocale* result =
1155  ptr(supported_locales_ptr.data(), locale_count);
1156 
1157  std::unique_ptr<std::vector<std::string>> out =
1158  std::make_unique<std::vector<std::string>>();
1159  if (result) {
1160  std::string language_code(SAFE_ACCESS(result, language_code, ""));
1161  if (language_code != "") {
1162  out->push_back(language_code);
1163  out->emplace_back(SAFE_ACCESS(result, country_code, ""));
1164  out->emplace_back(SAFE_ACCESS(result, script_code, ""));
1165  }
1166  }
1167  return out;
1168  };
1169  }
1170 
1172  on_pre_engine_restart_callback = nullptr;
1173  if (SAFE_ACCESS(args, on_pre_engine_restart_callback, nullptr) != nullptr) {
1174  on_pre_engine_restart_callback = [ptr =
1176  user_data]() { return ptr(user_data); };
1177  }
1178 
1179  auto external_view_embedder_result =
1180  InferExternalViewEmbedderFromArgs(SAFE_ACCESS(args, compositor, nullptr));
1181  if (external_view_embedder_result.second) {
1183  "Compositor arguments were invalid.");
1184  }
1185 
1187  {
1188  update_semantics_nodes_callback, //
1189  update_semantics_custom_actions_callback, //
1190  platform_message_response_callback, //
1191  vsync_callback, //
1192  compute_platform_resolved_locale_callback, //
1193  on_pre_engine_restart_callback, //
1194  };
1195 
1196  auto on_create_platform_view = InferPlatformViewCreationCallback(
1197  config, user_data, platform_dispatch_table,
1198  std::move(external_view_embedder_result.first));
1199 
1200  if (!on_create_platform_view) {
1201  return LOG_EMBEDDER_ERROR(
1203  "Could not infer platform view creation callback.");
1204  }
1205 
1207  [](flutter::Shell& shell) {
1208  return std::make_unique<flutter::Rasterizer>(shell);
1209  };
1210 
1211  using ExternalTextureResolver = flutter::EmbedderExternalTextureResolver;
1212  std::unique_ptr<ExternalTextureResolver> external_texture_resolver;
1213  external_texture_resolver = std::make_unique<ExternalTextureResolver>();
1214 
1215 #ifdef SHELL_ENABLE_GL
1217  external_texture_callback;
1218  if (config->type == kOpenGL) {
1219  const FlutterOpenGLRendererConfig* open_gl_config = &config->open_gl;
1220  if (SAFE_ACCESS(open_gl_config, gl_external_texture_frame_callback,
1221  nullptr) != nullptr) {
1222  external_texture_callback =
1223  [ptr = open_gl_config->gl_external_texture_frame_callback, user_data](
1224  int64_t texture_identifier, size_t width,
1225  size_t height) -> std::unique_ptr<FlutterOpenGLTexture> {
1226  std::unique_ptr<FlutterOpenGLTexture> texture =
1227  std::make_unique<FlutterOpenGLTexture>();
1228  if (!ptr(user_data, texture_identifier, width, height, texture.get())) {
1229  return nullptr;
1230  }
1231  return texture;
1232  };
1233  external_texture_resolver =
1234  std::make_unique<ExternalTextureResolver>(external_texture_callback);
1235  }
1236  }
1237 #endif
1238 #ifdef SHELL_ENABLE_METAL
1240  external_texture_metal_callback;
1241  if (config->type == kMetal) {
1242  const FlutterMetalRendererConfig* metal_config = &config->metal;
1243  if (SAFE_ACCESS(metal_config, external_texture_frame_callback, nullptr)) {
1244  external_texture_metal_callback =
1245  [ptr = metal_config->external_texture_frame_callback, user_data](
1246  int64_t texture_identifier, size_t width,
1247  size_t height) -> std::unique_ptr<FlutterMetalExternalTexture> {
1248  std::unique_ptr<FlutterMetalExternalTexture> texture =
1249  std::make_unique<FlutterMetalExternalTexture>();
1250  texture->struct_size = sizeof(FlutterMetalExternalTexture);
1251  if (!ptr(user_data, texture_identifier, width, height, texture.get())) {
1252  return nullptr;
1253  }
1254  return texture;
1255  };
1256  external_texture_resolver = std::make_unique<ExternalTextureResolver>(
1257  external_texture_metal_callback);
1258  }
1259  }
1260 #endif
1261 
1262  auto thread_host =
1264  SAFE_ACCESS(args, custom_task_runners, nullptr));
1265 
1266  if (!thread_host || !thread_host->IsValid()) {
1268  "Could not set up or infer thread configuration "
1269  "to run the Flutter engine on.");
1270  }
1271 
1272  auto task_runners = thread_host->GetTaskRunners();
1273 
1274  if (!task_runners.IsValid()) {
1276  "Task runner configuration was invalid.");
1277  }
1278 
1279  auto run_configuration =
1281 
1282  if (SAFE_ACCESS(args, custom_dart_entrypoint, nullptr) != nullptr) {
1283  auto dart_entrypoint = std::string{args->custom_dart_entrypoint};
1284  if (dart_entrypoint.size() != 0) {
1285  run_configuration.SetEntrypoint(std::move(dart_entrypoint));
1286  }
1287  }
1288 
1289  if (SAFE_ACCESS(args, dart_entrypoint_argc, 0) > 0) {
1290  if (SAFE_ACCESS(args, dart_entrypoint_argv, nullptr) == nullptr) {
1292  "Could not determine Dart entrypoint arguments "
1293  "as dart_entrypoint_argc "
1294  "was set, but dart_entrypoint_argv was null.");
1295  }
1296  std::vector<std::string> arguments(args->dart_entrypoint_argc);
1297  for (int i = 0; i < args->dart_entrypoint_argc; ++i) {
1298  arguments[i] = std::string{args->dart_entrypoint_argv[i]};
1299  }
1300  settings.dart_entrypoint_args = std::move(arguments);
1301  }
1302 
1303  if (!run_configuration.IsValid()) {
1304  return LOG_EMBEDDER_ERROR(
1306  "Could not infer the Flutter project to run from given arguments.");
1307  }
1308 
1309  // Create the engine but don't launch the shell or run the root isolate.
1310  auto embedder_engine = std::make_unique<flutter::EmbedderEngine>(
1311  std::move(thread_host), //
1312  std::move(task_runners), //
1313  std::move(settings), //
1314  std::move(run_configuration), //
1315  on_create_platform_view, //
1316  on_create_rasterizer, //
1317  std::move(external_texture_resolver) //
1318  );
1319 
1320  // Release the ownership of the embedder engine to the caller.
1321  *engine_out = reinterpret_cast<FLUTTER_API_SYMBOL(FlutterEngine)>(
1322  embedder_engine.release());
1323  return kSuccess;
1324 }
std::function< void()> OnPreEngineRestartCallback
std::function< std::unique_ptr< FlutterMetalExternalTexture >(int64_t, size_t, size_t)> ExternalTextureCallback
const char * channel
Definition: embedder.h:758
struct _FlutterEngine * FLUTTER_API_SYMBOL(FlutterEngine)
Definition: embedder.h:228
LogMessageCallback log_message_callback
Definition: settings.h:247
G_BEGIN_DECLS FlTexture * texture
std::function< std::unique_ptr< T >(Shell &)> CreateCallback
Definition: shell.h:114
FlutterComputePlatformResolvedLocaleCallback compute_platform_resolved_locale_callback
Definition: embedder.h:1554
FlutterMetalTextureFrameCallback external_texture_frame_callback
Definition: embedder.h:541
std::vector< std::string > dart_entrypoint_args
Definition: settings.h:126
std::function< void(const DartIsolate &)> root_isolate_create_callback
Definition: settings.h:216
std::string application_kernel_asset
Definition: settings.h:119
void AddTaskObserver(intptr_t key, const fml::closure &callback)
Definition: message_loop.cc:64
CommandLine CommandLineFromArgcArgv(int argc, const char *const *argv)
Definition: command_line.h:222
FlutterRect rect
The bounding box for this node in its coordinate system.
Definition: embedder.h:839
OnPreEngineRestartCallback on_pre_engine_restart_callback
Definition: embedder.h:1591
#define LOG_EMBEDDER_ERROR(code, reason)
Definition: embedder.cc:93
int64_t old_gen_heap_size
Definition: settings.h:283
void(* FlutterLogMessageCallback)(const char *, const char *, void *)
Definition: embedder.h:1340
void * user_data
static bool IsRendererValid(const FlutterRendererConfig *config)
Definition: embedder.cc:147
static FML_EMBEDDER_ONLY MessageLoop & GetCurrent()
Definition: message_loop.cc:19
std::unordered_map< int32_t, SemanticsNode > SemanticsNodeUpdates
GAsyncResult * result
Settings SettingsFromCommandLine(const fml::CommandLine &command_line)
Definition: switches.cc:228
#define FML_LOG(severity)
Definition: logging.h:65
FlutterPlatformMessageCallback platform_message_callback
Definition: embedder.h:1402
A structure to represent a rectangle.
Definition: embedder.h:333
FlKeyEvent FlKeyResponderAsyncCallback callback
static const char * kApplicationKernelSnapshotFileName
#define SAFE_ACCESS(pointer, member, default_value)
FlutterSemanticsAction
Definition: embedder.h:101
const char *const * dart_entrypoint_argv
Definition: embedder.h:1566
VsyncCallback vsync_callback
Definition: embedder.h:1479
std::function< void()> closure
Definition: closure.h:14
std::string JoinPaths(std::initializer_list< std::string > components)
Definition: paths.cc:14
FlutterSemanticsFlag flags
The set of semantics flags associated with this node.
Definition: embedder.h:800
static RunConfiguration InferFromSettings(const Settings &settings, fml::RefPtr< fml::TaskRunner > io_worker=nullptr)
Attempts to infer a run configuration from the settings object. This tries to create a run configurat...
#define FLUTTER_ENGINE_VERSION
Definition: embedder.h:63
FlutterRendererType type
Definition: embedder.h:555
uint8_t value
static void SetCacheDirectoryPath(std::string path)
double thickness
Describes how much space the semantics node takes up along the z-axis.
Definition: embedder.h:822
const FlutterSemanticsNode * node
Definition: fl_view.cc:83
FlutterUpdateSemanticsNodeCallback update_semantics_node_callback
Definition: embedder.h:1446
std::function< void(flutter::CustomAccessibilityActionUpdates actions)> UpdateSemanticsCustomActionsCallback
SemanticsAction action
int32_t id
The unique identifier for this node.
Definition: embedder.h:798
FlutterUpdateSemanticsCustomActionCallback update_semantics_custom_action_callback
Definition: embedder.h:1457
FlutterTransformation transform
Definition: embedder.h:842
static bool IsRunningPrecompiledCode()
Checks if VM instances in the process can run precompiled code. This call can be made at any time and...
Definition: dart_vm.cc:202
TextureFrameCallback gl_external_texture_frame_callback
Definition: embedder.h:429
const char * hint
A brief description of the result of performing an action on the node.
Definition: embedder.h:826
int32_t width
static std::pair< std::unique_ptr< flutter::EmbedderExternalViewEmbedder >, bool > InferExternalViewEmbedderFromArgs(const FlutterCompositor *compositor)
Definition: embedder.cc:682
TaskObserverAdd task_observer_add
Definition: settings.h:212
void PopulateSnapshotMappingCallbacks(const FlutterProjectArgs *args, flutter::Settings &settings)
Definition: embedder.cc:813
static std::unique_ptr< EmbedderThreadHost > CreateEmbedderOrEngineManagedThreadHost(const FlutterCustomTaskRunners *custom_task_runners)
std::string icu_data_path
Definition: settings.h:258
int32_t height
const char * custom_dart_entrypoint
Definition: embedder.h:1488
const char * assets_path
Definition: embedder.h:1354
FlutterOpenGLRendererConfig open_gl
Definition: embedder.h:557
std::function< void(std::unique_ptr< PlatformMessage >)> PlatformMessageResponseCallback
const int32_t kFlutterSemanticsNodeIdBatchEnd
Definition: embedder.cc:69
const char * value
A textual description of the current value of the node.
Definition: embedder.h:828
bool IsFile(const std::string &path)
Definition: file_posix.cc:145
std::function< void(flutter::SemanticsNodeUpdates update)> UpdateSemanticsNodesCallback
const char * label
A textual description of the node.
Definition: embedder.h:824
void RemoveTaskObserver(intptr_t key)
Definition: message_loop.cc:68
std::function< void(intptr_t)> VsyncCallback
FlutterSemanticsAction actions
The set of semantics actions applicable to this node.
Definition: embedder.h:802
void(* VoidCallback)(void *)
Definition: embedder.h:251
struct _FlutterPlatformMessageResponseHandle FlutterPlatformMessageResponseHandle
Definition: embedder.h:752
FlutterMetalRendererConfig metal
Definition: embedder.h:559
std::function< std::unique_ptr< FlutterOpenGLTexture >(int64_t, size_t, size_t)> ExternalTextureCallback
FlutterTextDirection
Definition: embedder.h:219
std::unordered_map< int32_t, CustomAccessibilityAction > CustomAccessibilityActionUpdates
TaskObserverRemove task_observer_remove
Definition: settings.h:213
std::string assets_path
Definition: settings.h:264
std::string log_tag
Definition: settings.h:251
const int32_t kFlutterSemanticsCustomActionIdBatchEnd
Definition: embedder.cc:70
static flutter::Shell::CreateCallback< flutter::PlatformView > InferPlatformViewCreationCallback(const FlutterRendererConfig *config, void *user_data, flutter::PlatformViewEmbedder::PlatformDispatchTable platform_dispatch_table, std::unique_ptr< flutter::EmbedderExternalViewEmbedder > external_view_embedder)
Definition: embedder.cc:409
std::function< std::unique_ptr< std::vector< std::string > >(const std::vector< std::string > &supported_locale_data)> ComputePlatformResolvedLocaleCallback

◆ FlutterEngineMarkExternalTextureFrameAvailable()

FLUTTER_EXPORT FlutterEngineResult FlutterEngineMarkExternalTextureFrameAvailable ( FLUTTER_API_SYMBOL(FlutterEngine engine,
int64_t  texture_identifier 
)

Mark that a new texture frame is available for a given texture identifier.

See also
FlutterEngineRegisterExternalTexture()
FlutterEngineUnregisterExternalTexture()
Parameters
[in]engineA running engine instance.
[in]texture_identifierThe identifier of the texture whose frame has been updated.
Returns
The result of the call.

Definition at line 1808 of file embedder.cc.

References kInternalInconsistency, kInvalidArguments, kSuccess, LOG_EMBEDDER_ERROR, and flutter::MarkTextureFrameAvailable().

Referenced by FlutterEngineGetProcAddresses(), and _FlutterTaskRunner::~_FlutterTaskRunner().

1810  {
1811  if (engine == nullptr) {
1812  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Invalid engine handle.");
1813  }
1814  if (texture_identifier == 0) {
1815  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Invalid texture identifier.");
1816  }
1817  if (!reinterpret_cast<flutter::EmbedderEngine*>(engine)
1818  ->MarkTextureFrameAvailable(texture_identifier)) {
1819  return LOG_EMBEDDER_ERROR(
1821  "Could not mark the texture frame as being available.");
1822  }
1823  return kSuccess;
1824 }
#define LOG_EMBEDDER_ERROR(code, reason)
Definition: embedder.cc:93
static void MarkTextureFrameAvailable(JNIEnv *env, jobject jcaller, jlong shell_holder, jlong texture_id)

◆ FlutterEngineNotifyDisplayUpdate()

FLUTTER_EXPORT 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.

Parameters
[in]update_typeThe type of update pushed to the engine.
[in]displaysThe displays affected by this update.
[in]display_countSize of the displays array, must be at least 1.
Returns
the result of the call made to the engine.

Definition at line 2251 of file embedder.cc.

References engine, kFlutterEngineDisplaysUpdateTypeStartup, kInvalidArguments, flutter::kStartup, kSuccess, and LOG_EMBEDDER_ERROR.

Referenced by FlutterEngineGetProcAddresses(), and flutter::testing::TEST_F().

2255  {
2256  if (raw_engine == nullptr) {
2257  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Invalid engine handle.");
2258  }
2259 
2260  if (!ValidDisplayConfiguration(embedder_displays, display_count)) {
2261  return LOG_EMBEDDER_ERROR(
2263  "Invalid FlutterEngineDisplay configuration specified.");
2264  }
2265 
2266  auto engine = reinterpret_cast<flutter::EmbedderEngine*>(raw_engine);
2267 
2268  switch (update_type) {
2270  std::vector<flutter::Display> displays;
2271  for (size_t i = 0; i < display_count; i++) {
2272  flutter::Display display =
2273  flutter::Display(embedder_displays[i].refresh_rate);
2274  if (!embedder_displays[i].single_display) {
2275  display = flutter::Display(embedder_displays[i].display_id,
2276  embedder_displays[i].refresh_rate);
2277  }
2278  displays.push_back(display);
2279  }
2280  engine->GetShell().OnDisplayUpdates(flutter::DisplayUpdateType::kStartup,
2281  displays);
2282  return kSuccess;
2283  }
2284  default:
2285  return LOG_EMBEDDER_ERROR(
2287  "Invalid FlutterEngineDisplaysUpdateType type specified.");
2288  }
2289 }
#define LOG_EMBEDDER_ERROR(code, reason)
Definition: embedder.cc:93

◆ FlutterEngineNotifyLowMemoryWarning()

FLUTTER_EXPORT 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.

Parameters
[in]engineA running engine instance.
Returns
If the low memory notification was sent to the running engine instance.

Definition at line 2189 of file embedder.cc.

References DispatchJSONPlatformMessage(), engine, kInternalInconsistency, kInvalidArguments, kSuccess, and LOG_EMBEDDER_ERROR.

Referenced by FlutterEngineGetProcAddresses(), and flutter::testing::TEST_F().

2190  {
2191  auto engine = reinterpret_cast<flutter::EmbedderEngine*>(raw_engine);
2192  if (engine == nullptr || !engine->IsValid()) {
2193  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Engine was invalid.");
2194  }
2195 
2196  engine->GetShell().NotifyLowMemoryWarning();
2197 
2198  rapidjson::Document document;
2199  auto& allocator = document.GetAllocator();
2200 
2201  document.SetObject();
2202  document.AddMember("type", "memoryPressure", allocator);
2203 
2204  return DispatchJSONPlatformMessage(raw_engine, std::move(document),
2205  "flutter/system")
2206  ? kSuccess
2209  "Could not dispatch the low memory notification message.");
2210 }
static bool DispatchJSONPlatformMessage(FLUTTER_API_SYMBOL(FlutterEngine) engine, rapidjson::Document document, const std::string &channel_name)
Definition: embedder.cc:1969
#define LOG_EMBEDDER_ERROR(code, reason)
Definition: embedder.cc:93

◆ FlutterEngineOnVsync()

FLUTTER_EXPORT 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.

See also
FlutterEngineGetCurrentTime()
Attention
That frame timepoints are in nanoseconds.
The system monotonic clock is used as the timebase.
Parameters
[in]engine.A running engine instance.
[in]batonThe baton supplied by the engine.
[in]frame_start_time_nanosThe 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_nanosThe 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.
Returns
The result of the call.

Definition at line 1874 of file embedder.cc.

References fml::TimePoint::FromEpochDelta(), fml::TimeDelta::FromNanoseconds(), kInternalInconsistency, kInvalidArguments, kSuccess, LOG_EMBEDDER_ERROR, and TRACE_EVENT0.

Referenced by FlutterEngineGetProcAddresses().

1878  {
1879  if (engine == nullptr) {
1880  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Invalid engine handle.");
1881  }
1882 
1883  TRACE_EVENT0("flutter", "FlutterEngineOnVsync");
1884 
1885  auto start_time = fml::TimePoint::FromEpochDelta(
1886  fml::TimeDelta::FromNanoseconds(frame_start_time_nanos));
1887 
1888  auto target_time = fml::TimePoint::FromEpochDelta(
1889  fml::TimeDelta::FromNanoseconds(frame_target_time_nanos));
1890 
1891  if (!reinterpret_cast<flutter::EmbedderEngine*>(engine)->OnVsyncEvent(
1892  baton, start_time, target_time)) {
1893  return LOG_EMBEDDER_ERROR(
1895  "Could not notify the running engine instance of a Vsync event.");
1896  }
1897 
1898  return kSuccess;
1899 }
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:90
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
Definition: time_delta.h:40
#define LOG_EMBEDDER_ERROR(code, reason)
Definition: embedder.cc:93
static constexpr TimePoint FromEpochDelta(TimeDelta ticks)
Definition: time_point.h:38

◆ FlutterEnginePostCallbackOnAllNativeThreads()

FLUTTER_EXPORT 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.

Attention
This call is expensive and must be made as few times as possible. The callback must also return immediately as not doing so may risk performance issues (especially for callbacks of type kFlutterNativeThreadTypeUI and kFlutterNativeThreadTypeRender).
Some callbacks (especially the ones of type kFlutterNativeThreadTypeWorker) may be called after the FlutterEngine instance has shut down. Embedders must be careful in handling the lifecycle of objects associated with the user data baton.
In case there are multiple running Flutter engine instances, their workers are shared.
Parameters
[in]engineA running engine instance.
[in]callbackThe callback that will get called multiple times on each engine managed thread.
[in]user_dataA baton passed by the engine to the callback. This baton is not interpreted by the engine in any way.
Returns
Returns if the callback was successfully posted to all threads.

Definition at line 2212 of file embedder.cc.

References callback, engine, kInvalidArguments, kSuccess, LOG_EMBEDDER_ERROR, and type.

Referenced by FlutterEngineGetProcAddresses(), and flutter::testing::TEST_F().

2215  {
2216  if (engine == nullptr) {
2217  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Invalid engine handle.");
2218  }
2219 
2220  if (callback == nullptr) {
2222  "Invalid native thread callback.");
2223  }
2224 
2225  return reinterpret_cast<flutter::EmbedderEngine*>(engine)
2226  ->PostTaskOnEngineManagedNativeThreads(
2228  callback(type, user_data);
2229  })
2230  ? kSuccess
2232  "Internal error while attempting to post "
2233  "tasks to all threads.");
2234 }
KeyCallType type
#define LOG_EMBEDDER_ERROR(code, reason)
Definition: embedder.cc:93
void * user_data
FlKeyEvent FlKeyResponderAsyncCallback callback
FlutterNativeThreadType
Definition: embedder.h:1296

◆ FlutterEnginePostDartObject()

FLUTTER_EXPORT 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.

Parameters
[in]engineA running engine instance.
[in]portThe send port to send the object to.
[in]objectThe object to send to the isolate with the corresponding receive port.
Returns
If the message was posted to the send port.

Definition at line 2065 of file embedder.cc.

References buffer, FlutterEngineDartObject::buffer_value, callback, flutter::IsValid(), kFlutterEngineDartObjectTypeBool, kFlutterEngineDartObjectTypeBuffer, kFlutterEngineDartObjectTypeDouble, kFlutterEngineDartObjectTypeInt32, kFlutterEngineDartObjectTypeInt64, kFlutterEngineDartObjectTypeNull, kFlutterEngineDartObjectTypeString, kInternalInconsistency, kInvalidArguments, kSuccess, LOG_EMBEDDER_ERROR, fml::ScopedCleanupClosure::Release(), SAFE_ACCESS, fml::ScopedCleanupClosure::SetClosure(), FlutterEngineDartObject::string_value, FlutterEngineDartObject::type, and user_data.

Referenced by FlutterEngineGetProcAddresses(), and flutter::testing::TEST_F().

2068  {
2069  if (engine == nullptr) {
2070  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Invalid engine handle.");
2071  }
2072 
2073  if (!reinterpret_cast<flutter::EmbedderEngine*>(engine)->IsValid()) {
2074  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Engine not running.");
2075  }
2076 
2077  if (port == ILLEGAL_PORT) {
2079  "Attempted to post to an illegal port.");
2080  }
2081 
2082  if (object == nullptr) {
2084  "Invalid Dart object to post.");
2085  }
2086 
2087  Dart_CObject dart_object = {};
2088  fml::ScopedCleanupClosure typed_data_finalizer;
2089 
2090  switch (object->type) {
2092  dart_object.type = Dart_CObject_kNull;
2093  break;
2095  dart_object.type = Dart_CObject_kBool;
2096  dart_object.value.as_bool = object->bool_value;
2097  break;
2099  dart_object.type = Dart_CObject_kInt32;
2100  dart_object.value.as_int32 = object->int32_value;
2101  break;
2103  dart_object.type = Dart_CObject_kInt64;
2104  dart_object.value.as_int64 = object->int64_value;
2105  break;
2107  dart_object.type = Dart_CObject_kDouble;
2108  dart_object.value.as_double = object->double_value;
2109  break;
2111  if (object->string_value == nullptr) {
2113  "kFlutterEngineDartObjectTypeString must be "
2114  "a null terminated string but was null.");
2115  }
2116  dart_object.type = Dart_CObject_kString;
2117  dart_object.value.as_string = const_cast<char*>(object->string_value);
2118  break;
2120  auto* buffer = SAFE_ACCESS(object->buffer_value, buffer, nullptr);
2121  if (buffer == nullptr) {
2123  "kFlutterEngineDartObjectTypeBuffer must "
2124  "specify a buffer but found nullptr.");
2125  }
2126  auto buffer_size = SAFE_ACCESS(object->buffer_value, buffer_size, 0);
2127  auto callback =
2128  SAFE_ACCESS(object->buffer_value, buffer_collect_callback, nullptr);
2129  auto user_data = SAFE_ACCESS(object->buffer_value, user_data, nullptr);
2130 
2131  // The user has provided a callback, let them manage the lifecycle of
2132  // the underlying data. If not, copy it out from the provided buffer.
2133 
2134  if (callback == nullptr) {
2135  dart_object.type = Dart_CObject_kTypedData;
2136  dart_object.value.as_typed_data.type = Dart_TypedData_kUint8;
2137  dart_object.value.as_typed_data.length = buffer_size;
2138  dart_object.value.as_typed_data.values = buffer;
2139  } else {
2140  struct ExternalTypedDataPeer {
2141  void* user_data = nullptr;
2142  VoidCallback trampoline = nullptr;
2143  };
2144  auto peer = new ExternalTypedDataPeer();
2145  peer->user_data = user_data;
2146  peer->trampoline = callback;
2147  // This finalizer is set so that in case of failure of the
2148  // Dart_PostCObject below, we collect the peer. The embedder is still
2149  // responsible for collecting the buffer in case of non-kSuccess
2150  // returns from this method. This finalizer must be released in case
2151  // of kSuccess returns from this method.
2152  typed_data_finalizer.SetClosure([peer]() {
2153  // This is the tiny object we use as the peer to the Dart call so
2154  // that we can attach the a trampoline to the embedder supplied
2155  // callback. In case of error, we need to collect this object lest
2156  // we introduce a tiny leak.
2157  delete peer;
2158  });
2159  dart_object.type = Dart_CObject_kExternalTypedData;
2160  dart_object.value.as_external_typed_data.type = Dart_TypedData_kUint8;
2161  dart_object.value.as_external_typed_data.length = buffer_size;
2162  dart_object.value.as_external_typed_data.data = buffer;
2163  dart_object.value.as_external_typed_data.peer = peer;
2164  dart_object.value.as_external_typed_data.callback =
2165  +[](void* unused_isolate_callback_data, void* peer) {
2166  auto typed_peer = reinterpret_cast<ExternalTypedDataPeer*>(peer);
2167  typed_peer->trampoline(typed_peer->user_data);
2168  delete typed_peer;
2169  };
2170  }
2171  } break;
2172  default:
2173  return LOG_EMBEDDER_ERROR(
2175  "Invalid FlutterEngineDartObjectType type specified.");
2176  }
2177 
2178  if (!Dart_PostCObject(port, &dart_object)) {
2180  "Could not post the object to the Dart VM.");
2181  }
2182 
2183  // On a successful call, the VM takes ownership of and is responsible for
2184  // invoking the finalizer.
2185  typed_data_finalizer.Release();
2186  return kSuccess;
2187 }
#define LOG_EMBEDDER_ERROR(code, reason)
Definition: embedder.cc:93
void * user_data
DEF_SWITCHES_START snapshot asset Path to the directory containing the four files specified by VmSnapshotInstructions and IsolateSnapshotInstructions vm snapshot The VM instructions snapshot that will be memory mapped as read and executable SnapshotAssetPath must be present isolate snapshot The isolate instructions snapshot that will be memory mapped as read and executable SnapshotAssetPath must be present icu symbol Prefix for the symbols representing ICU data linked into the Flutter library dart Flags passed directly to the Dart VM without being interpreted by the Flutter shell observatory port
Definition: switches.h:75
FlKeyEvent FlKeyResponderAsyncCallback callback
#define SAFE_ACCESS(pointer, member, default_value)
const char * string_value
Definition: embedder.h:1288
Wraps a closure that is invoked in the destructor unless released by the caller.
Definition: closure.h:32
static bool IsValid(double value)
fml::closure SetClosure(const fml::closure &closure)
Definition: closure.h:44
fml::closure Release()
Definition: closure.h:50
static const uint8_t buffer[]
void(* VoidCallback)(void *)
Definition: embedder.h:251
const FlutterEngineDartBuffer * buffer_value
Definition: embedder.h:1289
FlutterEngineDartObjectType type
Definition: embedder.h:1279

◆ FlutterEnginePostRenderThreadTask()

FLUTTER_EXPORT 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.

Parameters
[in]engineA running engine instance.
[in]callbackThe callback to execute on the render thread.
callback_dataThe callback context.
Returns
The result of the call.

Definition at line 1930 of file embedder.cc.

References callback, engine, kInternalInconsistency, kInvalidArguments, kSuccess, and LOG_EMBEDDER_ERROR.

Referenced by FlutterEngineGetProcAddresses().

1933  {
1934  if (engine == nullptr) {
1935  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Invalid engine handle.");
1936  }
1937 
1938  if (callback == nullptr) {
1940  "Render thread callback was null.");
1941  }
1942 
1943  auto task = [callback, baton]() { callback(baton); };
1944 
1945  return reinterpret_cast<flutter::EmbedderEngine*>(engine)
1946  ->PostRenderThreadTask(task)
1947  ? kSuccess
1949  "Could not post the render thread task.");
1950 }
#define LOG_EMBEDDER_ERROR(code, reason)
Definition: embedder.cc:93
FlKeyEvent FlKeyResponderAsyncCallback callback

◆ FlutterEngineRegisterExternalTexture()

FLUTTER_EXPORT 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.

See also
FlutterEngineUnregisterExternalTexture()
FlutterEngineMarkExternalTextureFrameAvailable()
Parameters
[in]engineA running engine instance.
[in]texture_identifierThe identifier of the texture to register with the engine. The embedder may supply new frames to this texture using the same identifier.
Returns
The result of the call.

Definition at line 1768 of file embedder.cc.

References kInternalInconsistency, kInvalidArguments, kSuccess, LOG_EMBEDDER_ERROR, and flutter::RegisterTexture().

Referenced by FlutterEngineGetProcAddresses(), flutter::testing::TEST_F(), and _FlutterTaskRunner::~_FlutterTaskRunner().

1770  {
1771  if (engine == nullptr) {
1772  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Engine handle was invalid.");
1773  }
1774 
1775  if (texture_identifier == 0) {
1777  "Texture identifier was invalid.");
1778  }
1779  if (!reinterpret_cast<flutter::EmbedderEngine*>(engine)->RegisterTexture(
1780  texture_identifier)) {
1782  "Could not register the specified texture.");
1783  }
1784  return kSuccess;
1785 }
#define LOG_EMBEDDER_ERROR(code, reason)
Definition: embedder.cc:93
static void RegisterTexture(JNIEnv *env, jobject jcaller, jlong shell_holder, jlong texture_id, jobject surface_texture)

◆ FlutterEngineReloadSystemFonts()

FLUTTER_EXPORT FlutterEngineResult FlutterEngineReloadSystemFonts ( FLUTTER_API_SYMBOL(FlutterEngine engine)

Reloads the system fonts in engine.

Parameters
[in]engine.A running engine instance.
Returns
The result of the call.

Definition at line 1901 of file embedder.cc.

References kInternalInconsistency, kInvalidArguments, kSuccess, LOG_EMBEDDER_ERROR, and TRACE_EVENT0.

Referenced by FlutterEngineGetProcAddresses(), and flutter::testing::TEST_F().

1902  {
1903  if (engine == nullptr) {
1904  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Invalid engine handle.");
1905  }
1906 
1907  TRACE_EVENT0("flutter", "FlutterEngineReloadSystemFonts");
1908 
1909  if (!reinterpret_cast<flutter::EmbedderEngine*>(engine)
1910  ->ReloadSystemFonts()) {
1912  "Could not reload system fonts.");
1913  }
1914 
1915  return kSuccess;
1916 }
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:90
#define LOG_EMBEDDER_ERROR(code, reason)
Definition: embedder.cc:93

◆ FlutterEngineRun()

FLUTTER_EXPORT 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.

Note
This method of running a Flutter engine works well except in cases where the embedder specifies custom task runners via 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.
Parameters
[in]versionThe Flutter embedder API version. Must be FLUTTER_ENGINE_VERSION.
[in]configThe renderer configuration.
[in]argsThe Flutter project arguments.
user_dataA user data baton passed back to embedders in callbacks.
[out]engine_outThe engine handle on successful engine creation.
Returns
The result of the call to run the Flutter engine.

Definition at line 869 of file embedder.cc.

References FlutterEngineInitialize(), FlutterEngineRunInitialized(), kSuccess, and result.

Referenced by FlutterEngineGetProcAddresses(), flutter::testing::EmbedderConfigBuilder::InitializeEngine(), RunFlutter(), RunFlutterEngine(), and _FlutterTaskRunner::~_FlutterTaskRunner().

874  {
875  auto result =
876  FlutterEngineInitialize(version, config, args, user_data, engine_out);
877 
878  if (result != kSuccess) {
879  return result;
880  }
881 
882  return FlutterEngineRunInitialized(*engine_out);
883 }
void * user_data
GAsyncResult * result
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 Flutter...
Definition: embedder.cc:885
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.
Definition: embedder.cc:1326

◆ FlutterEngineRunInitialized()

FLUTTER_EXPORT 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.

Parameters
[in]engineAn initialized engine instance that has not previously been run.
Returns
The result of the call to run the initialized Flutter engine instance.

Definition at line 1326 of file embedder.cc.

References engine, FLUTTER_EXPORT, kInternalInconsistency, kInvalidArguments, kSuccess, and LOG_EMBEDDER_ERROR.

Referenced by FlutterEngineGetProcAddresses(), FlutterEngineRun(), flutter::testing::TEST_F(), and _FlutterTaskRunner::~_FlutterTaskRunner().

1327  {
1328  if (!engine) {
1329  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Engine handle was invalid.");
1330  }
1331 
1332  auto embedder_engine = reinterpret_cast<flutter::EmbedderEngine*>(engine);
1333 
1334  // The engine must not already be running. Initialize may only be called
1335  // once on an engine instance.
1336  if (embedder_engine->IsValid()) {
1337  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Engine handle was invalid.");
1338  }
1339 
1340  // Step 1: Launch the shell.
1341  if (!embedder_engine->LaunchShell()) {
1343  "Could not launch the engine using supplied "
1344  "initialization arguments.");
1345  }
1346 
1347  // Step 2: Tell the platform view to initialize itself.
1348  if (!embedder_engine->NotifyCreated()) {
1350  "Could not create platform view components.");
1351  }
1352 
1353  // Step 3: Launch the root isolate.
1354  if (!embedder_engine->RunRootIsolate()) {
1355  return LOG_EMBEDDER_ERROR(
1357  "Could not run the root isolate of the Flutter application using the "
1358  "project arguments specified.");
1359  }
1360 
1361  return kSuccess;
1362 }
#define LOG_EMBEDDER_ERROR(code, reason)
Definition: embedder.cc:93

◆ FlutterEngineRunsAOTCompiledDartCode()

FLUTTER_EXPORT 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.

Returns
True, if AOT Dart code is run. JIT otherwise.

Definition at line 2061 of file embedder.cc.

References flutter::DartVM::IsRunningPrecompiledCode().

Referenced by FlutterEngineGetProcAddresses(), RunFlutterEngine(), flutter::testing::TEST_F(), and _FlutterTaskRunner::~_FlutterTaskRunner().

2061  {
2063 }
static bool IsRunningPrecompiledCode()
Checks if VM instances in the process can run precompiled code. This call can be made at any time and...
Definition: dart_vm.cc:202

◆ FlutterEngineRunTask()

FLUTTER_EXPORT 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.

Parameters
[in]engineA running engine instance.
[in]taskthe task handle.
Returns
The result of the call.

Definition at line 1956 of file embedder.cc.

References engine, kInvalidArguments, kSuccess, and LOG_EMBEDDER_ERROR.

Referenced by FlutterDesktopCreateWindow(), FlutterDesktopRunEngine(), FlutterEngineGetProcAddresses(), flutter::testing::TEST_F(), and _FlutterTaskRunner::~_FlutterTaskRunner().

1958  {
1959  if (engine == nullptr) {
1960  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Invalid engine handle.");
1961  }
1962 
1963  return reinterpret_cast<flutter::EmbedderEngine*>(engine)->RunTask(task)
1964  ? kSuccess
1966  "Could not run the specified task.");
1967 }
#define LOG_EMBEDDER_ERROR(code, reason)
Definition: embedder.cc:93

◆ FlutterEngineSendKeyEvent()

FLUTTER_EXPORT 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.

Parameters
[in]engineA running engine instance.
[in]eventThe event data to be sent. This function will no longer access event after returning.
[in]callbackThe callback invoked by the engine when the Flutter application has decided whether it handles this event. Accepts nullptr.
[in]user_dataThe context associated with the callback. The exact same value will used to invoke callback. Accepts nullptr.
Returns
The result of the call.

Definition at line 1596 of file embedder.cc.

References callback, character, flutter::KeyData::Clear(), engine, kFlutterKeyEventTypeUp, kInternalInconsistency, kInvalidArguments, kSuccess, LOG_EMBEDDER_ERROR, flutter::KeyData::logical, MapKeyEventType(), flutter::KeyData::physical, SAFE_ACCESS, flutter::KeyData::synthesized, flutter::KeyData::timestamp, flutter::KeyData::type, type, and user_data.

Referenced by FlutterEngineGetProcAddresses(), flutter::testing::TEST_F(), and _FlutterTaskRunner::~_FlutterTaskRunner().

1600  {
1601  if (engine == nullptr) {
1602  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Engine handle was invalid.");
1603  }
1604 
1605  if (event == nullptr) {
1606  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Invalid key event.");
1607  }
1608 
1609  const char* character = SAFE_ACCESS(event, character, nullptr);
1610 
1611  flutter::KeyData key_data;
1612  key_data.Clear();
1613  key_data.timestamp = static_cast<uint64_t>(SAFE_ACCESS(event, timestamp, 0));
1614  key_data.type = MapKeyEventType(
1616  key_data.physical = SAFE_ACCESS(event, physical, 0);
1617  key_data.logical = SAFE_ACCESS(event, logical, 0);
1618  key_data.synthesized = SAFE_ACCESS(event, synthesized, false);
1619 
1620  auto packet = std::make_unique<flutter::KeyDataPacket>(key_data, character);
1621 
1622  auto response = [callback, user_data](bool handled) {
1623  if (callback != nullptr) {
1624  callback(handled, user_data);
1625  }
1626  };
1627 
1628  return reinterpret_cast<flutter::EmbedderEngine*>(engine)
1629  ->DispatchKeyDataPacket(std::move(packet), response)
1630  ? kSuccess
1632  "Could not dispatch the key event to the "
1633  "running Flutter application.");
1634 }
uint64_t timestamp
Definition: key_data.h:33
uint64_t synthesized
Definition: key_data.h:40
KeyCallType type
uint64_t logical
Definition: key_data.h:36
#define LOG_EMBEDDER_ERROR(code, reason)
Definition: embedder.cc:93
void * user_data
char32_t character
FlKeyEvent FlKeyResponderAsyncCallback callback
#define SAFE_ACCESS(pointer, member, default_value)
static flutter::KeyEventType MapKeyEventType(FlutterKeyEventType event_kind)
Definition: embedder.cc:1583
KeyEventType type
Definition: key_data.h:34
uint64_t physical
Definition: key_data.h:35

◆ FlutterEngineSendPlatformMessage()

FLUTTER_EXPORT FlutterEngineResult FlutterEngineSendPlatformMessage ( FLUTTER_API_SYMBOL(FlutterEngine engine,
const FlutterPlatformMessage message 
)

Definition at line 1636 of file embedder.cc.

References FlutterPlatformMessage::channel, fml::MallocMapping::Copy(), engine, kInternalInconsistency, kInvalidArguments, kSuccess, LOG_EMBEDDER_ERROR, _FlutterPlatformMessageResponseHandle::message, and SAFE_ACCESS.

Referenced by FlutterDesktopMessengerSendWithReply(), FlutterEngineGetProcAddresses(), flutter::testing::TEST_F(), and _FlutterTaskRunner::~_FlutterTaskRunner().

1638  {
1639  if (engine == nullptr) {
1640  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Invalid engine handle.");
1641  }
1642 
1643  if (flutter_message == nullptr) {
1644  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Invalid message argument.");
1645  }
1646 
1647  if (SAFE_ACCESS(flutter_message, channel, nullptr) == nullptr) {
1648  return LOG_EMBEDDER_ERROR(
1649  kInvalidArguments, "Message argument did not specify a valid channel.");
1650  }
1651 
1652  size_t message_size = SAFE_ACCESS(flutter_message, message_size, 0);
1653  const uint8_t* message_data = SAFE_ACCESS(flutter_message, message, nullptr);
1654 
1655  if (message_size != 0 && message_data == nullptr) {
1656  return LOG_EMBEDDER_ERROR(
1658  "Message size was non-zero but the message data was nullptr.");
1659  }
1660 
1661  const FlutterPlatformMessageResponseHandle* response_handle =
1662  SAFE_ACCESS(flutter_message, response_handle, nullptr);
1663 
1665  if (response_handle && response_handle->message) {
1666  response = response_handle->message->response();
1667  }
1668 
1669  std::unique_ptr<flutter::PlatformMessage> message;
1670  if (message_size == 0) {
1671  message = std::make_unique<flutter::PlatformMessage>(
1672  flutter_message->channel, response);
1673  } else {
1674  message = std::make_unique<flutter::PlatformMessage>(
1675  flutter_message->channel,
1676  fml::MallocMapping::Copy(message_data, message_size), response);
1677  }
1678 
1679  return reinterpret_cast<flutter::EmbedderEngine*>(engine)
1680  ->SendPlatformMessage(std::move(message))
1681  ? kSuccess
1683  "Could not send a message to the running "
1684  "Flutter application.");
1685 }
#define LOG_EMBEDDER_ERROR(code, reason)
Definition: embedder.cc:93
#define SAFE_ACCESS(pointer, member, default_value)
static MallocMapping Copy(const T *begin, const T *end)
Definition: mapping.h:147
std::unique_ptr< flutter::PlatformMessage > message
Definition: embedder.cc:727

◆ FlutterEngineSendPlatformMessageResponse()

FLUTTER_EXPORT 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.

Parameters
[in]engineThe running engine instance.
[in]handleThe platform message response handle.
[in]dataThe data to associate with the platform message response.
[in]data_lengthThe length of the platform message response data.
Returns
The result of the call.

Definition at line 1736 of file embedder.cc.

References kInvalidArguments, kSuccess, LOG_EMBEDDER_ERROR, and _FlutterPlatformMessageResponseHandle::message.

Referenced by FlutterDesktopMessengerSendResponse(), FlutterEngineGetProcAddresses(), and _FlutterTaskRunner::~_FlutterTaskRunner().

1740  {
1741  if (data_length != 0 && data == nullptr) {
1742  return LOG_EMBEDDER_ERROR(
1744  "Data size was non zero but the pointer to the data was null.");
1745  }
1746 
1747  auto response = handle->message->response();
1748 
1749  if (response) {
1750  if (data_length == 0) {
1751  response->CompleteEmpty();
1752  } else {
1753  response->Complete(std::make_unique<fml::DataMapping>(
1754  std::vector<uint8_t>({data, data + data_length})));
1755  }
1756  }
1757 
1758  delete handle;
1759 
1760  return kSuccess;
1761 }
#define LOG_EMBEDDER_ERROR(code, reason)
Definition: embedder.cc:93
std::unique_ptr< flutter::PlatformMessage > message
Definition: embedder.cc:727

◆ FlutterEngineSendPointerEvent()

FLUTTER_EXPORT FlutterEngineResult FlutterEngineSendPointerEvent ( FLUTTER_API_SYMBOL(FlutterEngine engine,
const FlutterPointerEvent events,
size_t  events_count 
)

Definition at line 1510 of file embedder.cc.

References flutter::PointerData::buttons, flutter::PointerData::change, flutter::PointerData::Clear(), flutter::PointerData::device, flutter::DispatchPointerDataPacket(), flutter::PointerData::embedder_id, engine, kCancel, flutter::PointerData::kDown, kFlutterPointerSignalKindNone, flutter::PointerData::kind, kInternalInconsistency, kInvalidArguments, flutter::PointerData::kMouse, flutter::PointerData::kMove, flutter::kPointerButtonTouchContact, kSuccess, flutter::PointerData::kTouch, LOG_EMBEDDER_ERROR, flutter::PointerData::physical_delta_x, flutter::PointerData::physical_delta_y, flutter::PointerData::physical_x, flutter::PointerData::physical_y, flutter::PointerData::pointer_identifier, PointerDataButtonsForLegacyEvent(), SAFE_ACCESS, flutter::PointerData::scroll_delta_x, flutter::PointerData::scroll_delta_y, flutter::PointerData::signal_kind, flutter::PointerData::time_stamp, ToPointerDataChange(), ToPointerDataKind(), and ToPointerDataSignalKind().

Referenced by FlutterEngineGetProcAddresses(), GLFWcursorPositionCallbackAtPhase(), SendPointerEventWithData(), and _FlutterTaskRunner::~_FlutterTaskRunner().

1513  {
1514  if (engine == nullptr) {
1515  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Engine handle was invalid.");
1516  }
1517 
1518  if (pointers == nullptr || events_count == 0) {
1519  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Invalid pointer events.");
1520  }
1521 
1522  auto packet = std::make_unique<flutter::PointerDataPacket>(events_count);
1523 
1524  const FlutterPointerEvent* current = pointers;
1525 
1526  for (size_t i = 0; i < events_count; ++i) {
1527  flutter::PointerData pointer_data;
1528  pointer_data.Clear();
1529  // this is currely in use only on android embedding.
1530  pointer_data.embedder_id = 0;
1531  pointer_data.time_stamp = SAFE_ACCESS(current, timestamp, 0);
1532  pointer_data.change = ToPointerDataChange(
1533  SAFE_ACCESS(current, phase, FlutterPointerPhase::kCancel));
1534  pointer_data.physical_x = SAFE_ACCESS(current, x, 0.0);
1535  pointer_data.physical_y = SAFE_ACCESS(current, y, 0.0);
1536  // Delta will be generated in pointer_data_packet_converter.cc.
1537  pointer_data.physical_delta_x = 0.0;
1538  pointer_data.physical_delta_y = 0.0;
1539  pointer_data.device = SAFE_ACCESS(current, device, 0);
1540  // Pointer identifier will be generated in
1541  // pointer_data_packet_converter.cc.
1542  pointer_data.pointer_identifier = 0;
1543  pointer_data.signal_kind = ToPointerDataSignalKind(
1544  SAFE_ACCESS(current, signal_kind, kFlutterPointerSignalKindNone));
1545  pointer_data.scroll_delta_x = SAFE_ACCESS(current, scroll_delta_x, 0.0);
1546  pointer_data.scroll_delta_y = SAFE_ACCESS(current, scroll_delta_y, 0.0);
1547  FlutterPointerDeviceKind device_kind = SAFE_ACCESS(current, device_kind, 0);
1548  // For backwards compatibility with embedders written before the device
1549  // kind and buttons were exposed, if the device kind is not set treat it
1550  // as a mouse, with a synthesized primary button state based on the phase.
1551  if (device_kind == 0) {
1553  pointer_data.buttons =
1555 
1556  } else {
1557  pointer_data.kind = ToPointerDataKind(device_kind);
1558  if (pointer_data.kind == flutter::PointerData::DeviceKind::kTouch) {
1559  // For touch events, set the button internally rather than requiring
1560  // it at the API level, since it's a confusing construction to expose.
1561  if (pointer_data.change == flutter::PointerData::Change::kDown ||
1562  pointer_data.change == flutter::PointerData::Change::kMove) {
1564  }
1565  } else {
1566  // Buttons use the same mask values, so pass them through directly.
1567  pointer_data.buttons = SAFE_ACCESS(current, buttons, 0);
1568  }
1569  }
1570  packet->SetPointerData(i, pointer_data);
1571  current = reinterpret_cast<const FlutterPointerEvent*>(
1572  reinterpret_cast<const uint8_t*>(current) + current->struct_size);
1573  }
1574 
1575  return reinterpret_cast<flutter::EmbedderEngine*>(engine)
1576  ->DispatchPointerDataPacket(std::move(packet))
1577  ? kSuccess
1579  "Could not dispatch pointer events to the "
1580  "running Flutter application.");
1581 }
flutter::PointerData::SignalKind ToPointerDataSignalKind(FlutterPointerSignalKind kind)
Definition: embedder.cc:1479
flutter::PointerData::DeviceKind ToPointerDataKind(FlutterPointerDeviceKind device_kind)
Definition: embedder.cc:1464
SignalKind signal_kind
Definition: pointer_data.h:65
int64_t pointer_identifier
Definition: pointer_data.h:67
#define LOG_EMBEDDER_ERROR(code, reason)
Definition: embedder.cc:93
FlutterPointerDeviceKind
The device type that created a pointer event.
Definition: embedder.h:623
#define SAFE_ACCESS(pointer, member, default_value)
flutter::PointerData::Change ToPointerDataChange(FlutterPointerPhase phase)
Definition: embedder.cc:1441
int64_t PointerDataButtonsForLegacyEvent(flutter::PointerData::Change change)
Definition: embedder.cc:1492
static void DispatchPointerDataPacket(JNIEnv *env, jobject jcaller, jlong shell_holder, jobject buffer, jint position)

◆ FlutterEngineSendWindowMetricsEvent()

FLUTTER_EXPORT FlutterEngineResult FlutterEngineSendWindowMetricsEvent ( FLUTTER_API_SYMBOL(FlutterEngine engine,
const FlutterWindowMetricsEvent event 
)

Definition at line 1388 of file embedder.cc.

References flutter::ViewportMetrics::device_pixel_ratio, engine, height, kInvalidArguments, kSuccess, LOG_EMBEDDER_ERROR, flutter::ViewportMetrics::physical_height, flutter::ViewportMetrics::physical_view_inset_bottom, flutter::ViewportMetrics::physical_view_inset_left, flutter::ViewportMetrics::physical_view_inset_right, flutter::ViewportMetrics::physical_view_inset_top, flutter::ViewportMetrics::physical_width, SAFE_ACCESS, flutter::SetViewportMetrics(), and width.

Referenced by FlutterEngineGetProcAddresses(), GLFWwindowSizeCallback(), SendWindowMetrics(), flutter::testing::TEST_F(), and _FlutterTaskRunner::~_FlutterTaskRunner().

1390  {
1391  if (engine == nullptr || flutter_metrics == nullptr) {
1392  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Engine handle was invalid.");
1393  }
1394 
1395  flutter::ViewportMetrics metrics;
1396 
1397  metrics.physical_width = SAFE_ACCESS(flutter_metrics, width, 0.0);
1398  metrics.physical_height = SAFE_ACCESS(flutter_metrics, height, 0.0);
1399  metrics.device_pixel_ratio = SAFE_ACCESS(flutter_metrics, pixel_ratio, 1.0);
1400  metrics.physical_view_inset_top =
1401  SAFE_ACCESS(flutter_metrics, physical_view_inset_top, 0.0);
1402  metrics.physical_view_inset_right =
1403  SAFE_ACCESS(flutter_metrics, physical_view_inset_right, 0.0);
1404  metrics.physical_view_inset_bottom =
1405  SAFE_ACCESS(flutter_metrics, physical_view_inset_bottom, 0.0);
1406  metrics.physical_view_inset_left =
1407  SAFE_ACCESS(flutter_metrics, physical_view_inset_left, 0.0);
1408 
1409  if (metrics.device_pixel_ratio <= 0.0) {
1410  return LOG_EMBEDDER_ERROR(
1412  "Device pixel ratio was invalid. It must be greater than zero.");
1413  }
1414 
1415  if (metrics.physical_view_inset_top < 0 ||
1416  metrics.physical_view_inset_right < 0 ||
1417  metrics.physical_view_inset_bottom < 0 ||
1418  metrics.physical_view_inset_left < 0) {
1419  return LOG_EMBEDDER_ERROR(
1421  "Physical view insets are invalid. They must be non-negative.");
1422  }
1423 
1424  if (metrics.physical_view_inset_top > metrics.physical_height ||
1425  metrics.physical_view_inset_right > metrics.physical_width ||
1426  metrics.physical_view_inset_bottom > metrics.physical_height ||
1427  metrics.physical_view_inset_left > metrics.physical_width) {
1429  "Physical view insets are invalid. They cannot "
1430  "be greater than physical height or width.");
1431  }
1432 
1433  return reinterpret_cast<flutter::EmbedderEngine*>(engine)->SetViewportMetrics(
1434  std::move(metrics))
1435  ? kSuccess
1437  "Viewport metrics were invalid.");
1438 }
#define LOG_EMBEDDER_ERROR(code, reason)
Definition: embedder.cc:93
#define SAFE_ACCESS(pointer, member, default_value)
int32_t width
int32_t height
static void SetViewportMetrics(JNIEnv *env, jobject jcaller, jlong shell_holder, jfloat devicePixelRatio, jint physicalWidth, jint physicalHeight, jint physicalPaddingTop, jint physicalPaddingRight, jint physicalPaddingBottom, jint physicalPaddingLeft, jint physicalViewInsetTop, jint physicalViewInsetRight, jint physicalViewInsetBottom, jint physicalViewInsetLeft, jint systemGestureInsetTop, jint systemGestureInsetRight, jint systemGestureInsetBottom, jint systemGestureInsetLeft, jint physicalTouchSlop)

◆ FlutterEngineShutdown()

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.

Note
This de-initializes the Flutter engine instance (via an implicit call to FlutterEngineDeinitialize) if necessary.
Parameters
[in]engineThe Flutter engine instance to collect.
Returns
The result of the call to shutdown the Flutter engine instance.

Definition at line 1377 of file embedder.cc.

References engine, FlutterEngineDeinitialize(), kSuccess, and result.

Referenced by FlutterDesktopDestroyWindow(), FlutterDesktopShutDownEngine(), FlutterEngineGetProcAddresses(), flutter::testing::UniqueEngineTraits::Free(), flutter::testing::TEST_F(), and _FlutterTaskRunner::~_FlutterTaskRunner().

1378  {
1380  if (result != kSuccess) {
1381  return result;
1382  }
1383  auto embedder_engine = reinterpret_cast<flutter::EmbedderEngine*>(engine);
1384  delete embedder_engine;
1385  return kSuccess;
1386 }
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 m...
Definition: embedder.cc:1365
GAsyncResult * result

◆ FlutterEngineTraceEventDurationBegin()

FLUTTER_EXPORT 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.

Parameters
[in]nameThe name of the trace event.

Definition at line 1918 of file embedder.cc.

References fml::tracing::TraceEvent0().

Referenced by FlutterEngineGetProcAddresses().

1918  {
1919  fml::tracing::TraceEvent0("flutter", name);
1920 }
const char * name
Definition: fuchsia.cc:50
void TraceEvent0(TraceArg category_group, TraceArg name)
Definition: trace_event.cc:317

◆ FlutterEngineTraceEventDurationEnd()

FLUTTER_EXPORT 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.

Parameters
[in]nameThe name of the trace event.

Definition at line 1922 of file embedder.cc.

References fml::tracing::TraceEventEnd().

Referenced by FlutterEngineGetProcAddresses().

1922  {
1924 }
void TraceEventEnd(TraceArg name)
Definition: trace_event.cc:331
const char * name
Definition: fuchsia.cc:50

◆ FlutterEngineTraceEventInstant()

FLUTTER_EXPORT 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.

Parameters
[in]nameThe name of the trace event.

Definition at line 1926 of file embedder.cc.

References fml::tracing::TraceEventInstant0().

Referenced by FlutterEngineGetProcAddresses().

1926  {
1928 }
void TraceEventInstant0(TraceArg category_group, TraceArg name)
Definition: trace_event.cc:358
const char * name
Definition: fuchsia.cc:50

◆ FlutterEngineUnregisterExternalTexture()

FLUTTER_EXPORT FlutterEngineResult FlutterEngineUnregisterExternalTexture ( FLUTTER_API_SYMBOL(FlutterEngine engine,
int64_t  texture_identifier 
)

Unregister a previous texture registration.

See also
FlutterEngineRegisterExternalTexture()
FlutterEngineMarkExternalTextureFrameAvailable()
Parameters
[in]engineA running engine instance.
[in]texture_identifierThe identifier of the texture for which new frame will not be available.
Returns
The result of the call.

Definition at line 1787 of file embedder.cc.

References kInternalInconsistency, kInvalidArguments, kSuccess, LOG_EMBEDDER_ERROR, and flutter::UnregisterTexture().

Referenced by FlutterEngineGetProcAddresses(), and _FlutterTaskRunner::~_FlutterTaskRunner().

1789  {
1790  if (engine == nullptr) {
1791  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Engine handle was invalid.");
1792  }
1793 
1794  if (texture_identifier == 0) {
1796  "Texture identifier was invalid.");
1797  }
1798 
1799  if (!reinterpret_cast<flutter::EmbedderEngine*>(engine)->UnregisterTexture(
1800  texture_identifier)) {
1802  "Could not un-register the specified texture.");
1803  }
1804 
1805  return kSuccess;
1806 }
static void UnregisterTexture(JNIEnv *env, jobject jcaller, jlong shell_holder, jlong texture_id)
#define LOG_EMBEDDER_ERROR(code, reason)
Definition: embedder.cc:93

◆ FlutterEngineUpdateAccessibilityFeatures()

FLUTTER_EXPORT FlutterEngineResult FlutterEngineUpdateAccessibilityFeatures ( FLUTTER_API_SYMBOL(FlutterEngine engine,
FlutterAccessibilityFeature  features 
)

Sets additional accessibility features.

Parameters
[in]engineA running engine instance
[in]featuresThe accessibility features to set.
Returns
The result of the call.

Definition at line 1840 of file embedder.cc.

References kInternalInconsistency, kInvalidArguments, kSuccess, LOG_EMBEDDER_ERROR, and flutter::SetAccessibilityFeatures().

Referenced by FlutterEngineGetProcAddresses(), and flutter::testing::TEST_F().

1842  {
1843  if (engine == nullptr) {
1844  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Invalid engine handle.");
1845  }
1846  if (!reinterpret_cast<flutter::EmbedderEngine*>(engine)
1849  "Could not update accessibility features.");
1850  }
1851  return kSuccess;
1852 }
#define LOG_EMBEDDER_ERROR(code, reason)
Definition: embedder.cc:93
FlutterSemanticsFlag flags
static void SetAccessibilityFeatures(JNIEnv *env, jobject jcaller, jlong shell_holder, jint flags)

◆ FlutterEngineUpdateLocales()

FLUTTER_EXPORT 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.

Parameters
[in]engineA running engine instance.
[in]localesThe updated locales in the order of preference.
[in]locales_countThe count of locales supplied.
Returns
Whether the locale updates were applied.

Definition at line 2001 of file embedder.cc.

References args, DispatchJSONPlatformMessage(), kInternalInconsistency, kInvalidArguments, kSuccess, LOG_EMBEDDER_ERROR, and SAFE_ACCESS.

Referenced by FlutterEngineGetProcAddresses(), SetUpLocales(), flutter::testing::TEST_F(), and _FlutterTaskRunner::~_FlutterTaskRunner().

2004  {
2005  if (engine == nullptr) {
2006  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Invalid engine handle.");
2007  }
2008 
2009  if (locales_count == 0) {
2010  return kSuccess;
2011  }
2012 
2013  if (locales == nullptr) {
2014  return LOG_EMBEDDER_ERROR(kInvalidArguments, "No locales were specified.");
2015  }
2016 
2017  rapidjson::Document document;
2018  auto& allocator = document.GetAllocator();
2019 
2020  document.SetObject();
2021  document.AddMember("method", "setLocale", allocator);
2022 
2023  rapidjson::Value args(rapidjson::kArrayType);
2024  args.Reserve(locales_count * 4, allocator);
2025  for (size_t i = 0; i < locales_count; ++i) {
2026  const FlutterLocale* locale = locales[i];
2027  const char* language_code_str = SAFE_ACCESS(locale, language_code, nullptr);
2028  if (language_code_str == nullptr || ::strlen(language_code_str) == 0) {
2029  return LOG_EMBEDDER_ERROR(
2031  "Language code is required but not present in FlutterLocale.");
2032  }
2033 
2034  const char* country_code_str = SAFE_ACCESS(locale, country_code, "");
2035  const char* script_code_str = SAFE_ACCESS(locale, script_code, "");
2036  const char* variant_code_str = SAFE_ACCESS(locale, variant_code, "");
2037 
2038  rapidjson::Value language_code, country_code, script_code, variant_code;
2039 
2040  language_code.SetString(language_code_str, allocator);
2041  country_code.SetString(country_code_str ? country_code_str : "", allocator);
2042  script_code.SetString(script_code_str ? script_code_str : "", allocator);
2043  variant_code.SetString(variant_code_str ? variant_code_str : "", allocator);
2044 
2045  // Required.
2046  args.PushBack(language_code, allocator);
2047  args.PushBack(country_code, allocator);
2048  args.PushBack(script_code, allocator);
2049  args.PushBack(variant_code, allocator);
2050  }
2051  document.AddMember("args", args, allocator);
2052 
2053  return DispatchJSONPlatformMessage(engine, std::move(document),
2054  "flutter/localization")
2055  ? kSuccess
2057  "Could not send message to update locale of "
2058  "a running Flutter application.");
2059 }
G_BEGIN_DECLS FlValue * args
static bool DispatchJSONPlatformMessage(FLUTTER_API_SYMBOL(FlutterEngine) engine, rapidjson::Document document, const std::string &channel_name)
Definition: embedder.cc:1969
#define LOG_EMBEDDER_ERROR(code, reason)
Definition: embedder.cc:93
#define SAFE_ACCESS(pointer, member, default_value)

◆ FlutterEngineUpdateSemanticsEnabled()

FLUTTER_EXPORT FlutterEngineResult FlutterEngineUpdateSemanticsEnabled ( FLUTTER_API_SYMBOL(FlutterEngine engine,
bool  enabled 
)

Enable or disable accessibility semantics.

Parameters
[in]engineA running engine instance.
[in]enabledWhen enabled, changes to the semantic contents of the window are sent via the FlutterUpdateSemanticsNodeCallback registered to update_semantics_node_callback in FlutterProjectArgs.
Returns
The result of the call.

Definition at line 1826 of file embedder.cc.

References kInternalInconsistency, kInvalidArguments, kSuccess, LOG_EMBEDDER_ERROR, and flutter::SetSemanticsEnabled().

Referenced by FlutterEngineGetProcAddresses(), flutter::testing::TEST_F(), and _FlutterTaskRunner::~_FlutterTaskRunner().

1828  {
1829  if (engine == nullptr) {
1830  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Invalid engine handle.");
1831  }
1832  if (!reinterpret_cast<flutter::EmbedderEngine*>(engine)->SetSemanticsEnabled(
1833  enabled)) {
1835  "Could not update semantics state.");
1836  }
1837  return kSuccess;
1838 }
static void SetSemanticsEnabled(JNIEnv *env, jobject jcaller, jlong shell_holder, jboolean enabled)
#define LOG_EMBEDDER_ERROR(code, reason)
Definition: embedder.cc:93

◆ FlutterPlatformMessageCreateResponseHandle()

FLUTTER_EXPORT 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.

See also
FlutterPlatformMessageReleaseResponseHandle()
Parameters
[in]engineA running engine instance.
[in]data_callbackThe callback invoked by the engine when the Flutter application send a response on the handle.
[in]user_dataThe user data associated with the data callback.
[out]response_outThe response handle created when this call is successful.
Returns
The result of the call.

Definition at line 1687 of file embedder.cc.

References engine, kInvalidArguments, kSuccess, LOG_EMBEDDER_ERROR, fml::size(), and user_data.

Referenced by FlutterDesktopMessengerSendWithReply(), FlutterEngineGetProcAddresses(), flutter::testing::TEST_F(), and _FlutterTaskRunner::~_FlutterTaskRunner().

1691  {
1692  if (engine == nullptr) {
1693  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Engine handle was invalid.");
1694  }
1695 
1696  if (data_callback == nullptr || response_out == nullptr) {
1697  return LOG_EMBEDDER_ERROR(
1698  kInvalidArguments, "Data callback or the response handle was invalid.");
1699  }
1700 
1702  [user_data, data_callback](const uint8_t* data, size_t size) {
1703  data_callback(data, size, user_data);
1704  };
1705 
1706  auto platform_task_runner = reinterpret_cast<flutter::EmbedderEngine*>(engine)
1707  ->GetTaskRunners()
1708  .GetPlatformTaskRunner();
1709 
1710  auto handle = new FlutterPlatformMessageResponseHandle();
1711 
1712  handle->message = std::make_unique<flutter::PlatformMessage>(
1713  "", // The channel is empty and unused as the response handle is going
1714  // to referenced directly in the |FlutterEngineSendPlatformMessage|
1715  // with the container message discarded.
1716  fml::MakeRefCounted<flutter::EmbedderPlatformMessageResponse>(
1717  std::move(platform_task_runner), response_callback));
1718  *response_out = handle;
1719  return kSuccess;
1720 }
#define LOG_EMBEDDER_ERROR(code, reason)
Definition: embedder.cc:93
void * user_data
std::function< void(const uint8_t *data, size_t size)> Callback
constexpr std::size_t size(T(&array)[N])
Definition: size.h:13
struct _FlutterPlatformMessageResponseHandle FlutterPlatformMessageResponseHandle
Definition: embedder.h:752

◆ FlutterPlatformMessageReleaseResponseHandle()

FLUTTER_EXPORT FlutterEngineResult FlutterPlatformMessageReleaseResponseHandle ( FLUTTER_API_SYMBOL(FlutterEngine engine,
FlutterPlatformMessageResponseHandle response 
)

Collects the handle created using FlutterPlatformMessageCreateResponseHandle.

See also
FlutterPlatformMessageCreateResponseHandle()
Parameters
[in]engineA running engine instance.
[in]responseThe platform message response handle to collect. These handles are created using FlutterPlatformMessageCreateResponseHandle().
Returns
The result of the call.

Definition at line 1722 of file embedder.cc.

References kInvalidArguments, kSuccess, and LOG_EMBEDDER_ERROR.

Referenced by FlutterDesktopMessengerSendWithReply(), FlutterEngineGetProcAddresses(), flutter::testing::TEST_F(), and _FlutterTaskRunner::~_FlutterTaskRunner().

1724  {
1725  if (engine == nullptr) {
1726  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Invalid engine handle.");
1727  }
1728 
1729  if (response == nullptr) {
1730  return LOG_EMBEDDER_ERROR(kInvalidArguments, "Invalid response handle.");
1731  }
1732  delete response;
1733  return kSuccess;
1734 }
#define LOG_EMBEDDER_ERROR(code, reason)
Definition: embedder.cc:93

Variable Documentation

◆ kFlutterSemanticsCustomActionIdBatchEnd

FLUTTER_EXPORT const int32_t kFlutterSemanticsCustomActionIdBatchEnd

FlutterSemanticsCustomAction ID used as a sentinel to signal the end of a batch of semantics custom action updates.

Definition at line 70 of file embedder.cc.

Referenced by fl_view_accessible_handle_update_semantics_node(), FlutterEngineInitialize(), and flutter::testing::TEST_F().

◆ kFlutterSemanticsNodeIdBatchEnd

FLUTTER_EXPORT const int32_t kFlutterSemanticsNodeIdBatchEnd

FlutterSemanticsNode ID used as a sentinel to signal the end of a batch of semantics node updates.

Definition at line 69 of file embedder.cc.

Referenced by FlutterEngineInitialize(), FlutterEngine::shutDownEngine, and flutter::testing::TEST_F().