embedder.h 47.4 KB
Newer Older
M
Michael Goderbauer 已提交
1
// Copyright 2013 The Flutter Authors. All rights reserved.
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef FLUTTER_EMBEDDER_H_
#define FLUTTER_EMBEDDER_H_

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

#if defined(__cplusplus)
extern "C" {
#endif

#ifndef FLUTTER_EXPORT
#define FLUTTER_EXPORT
#endif  // FLUTTER_EXPORT

20 21 22 23 24 25 26 27 28 29
#ifdef FLUTTER_API_SYMBOL_PREFIX
#define FLUTTER_EMBEDDING_CONCAT(a, b) a##b
#define FLUTTER_EMBEDDING_ADD_PREFIX(symbol, prefix) \
  FLUTTER_EMBEDDING_CONCAT(prefix, symbol)
#define FLUTTER_API_SYMBOL(symbol) \
  FLUTTER_EMBEDDING_ADD_PREFIX(symbol, FLUTTER_API_SYMBOL_PREFIX)
#else
#define FLUTTER_API_SYMBOL(symbol) symbol
#endif

30 31 32 33 34 35
#define FLUTTER_ENGINE_VERSION 1

typedef enum {
  kSuccess = 0,
  kInvalidLibraryVersion,
  kInvalidArguments,
36
  kInternalInconsistency,
37
} FlutterEngineResult;
38 39 40

typedef enum {
  kOpenGL,
41
  kSoftware,
42 43
} FlutterRendererType;

44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
// Additional accessibility features that may be enabled by the platform.
//
// Must match the |AccessibilityFeatures| enum in window.dart.
typedef enum {
  // Indicate there is a running accessibility service which is changing the
  // interaction model of the device.
  kFlutterAccessibilityFeatureAccessibleNavigation = 1 << 0,
  // Indicate the platform is inverting the colors of the application.
  kFlutterAccessibilityFeatureInvertColors = 1 << 1,
  // Request that animations be disabled or simplified.
  kFlutterAccessibilityFeatureDisableAnimations = 1 << 2,
  // Request that text be rendered at a bold font weight.
  kFlutterAccessibilityFeatureBoldText = 1 << 3,
  // Request that certain animations be simplified and parallax effects
  // removed.
  kFlutterAccessibilityFeatureReduceMotion = 1 << 4,
} FlutterAccessibilityFeature;

// The set of possible actions that can be conveyed to a semantics node.
//
// Must match the |SemanticsAction| enum in semantics.dart.
typedef enum {
  // The equivalent of a user briefly tapping the screen with the finger without
  // moving it.
  kFlutterSemanticsActionTap = 1 << 0,
  // The equivalent of a user pressing and holding the screen with the finger
  // for a few seconds without moving it.
  kFlutterSemanticsActionLongPress = 1 << 1,
  // The equivalent of a user moving their finger across the screen from right
  // to left.
  kFlutterSemanticsActionScrollLeft = 1 << 2,
  // The equivalent of a user moving their finger across the screen from left to
  // right.
  kFlutterSemanticsActionScrollRight = 1 << 3,
  // The equivalent of a user moving their finger across the screen from bottom
  // to top.
  kFlutterSemanticsActionScrollUp = 1 << 4,
  // The equivalent of a user moving their finger across the screen from top to
  // bottom.
  kFlutterSemanticsActionScrollDown = 1 << 5,
  // Increase the value represented by the semantics node.
  kFlutterSemanticsActionIncrease = 1 << 6,
  // Decrease the value represented by the semantics node.
  kFlutterSemanticsActionDecrease = 1 << 7,
  // A request to fully show the semantics node on screen.
  kFlutterSemanticsActionShowOnScreen = 1 << 8,
  // Move the cursor forward by one character.
  kFlutterSemanticsActionMoveCursorForwardByCharacter = 1 << 9,
  // Move the cursor backward by one character.
  kFlutterSemanticsActionMoveCursorBackwardByCharacter = 1 << 10,
  // Set the text selection to the given range.
  kFlutterSemanticsActionSetSelection = 1 << 11,
  // Copy the current selection to the clipboard.
  kFlutterSemanticsActionCopy = 1 << 12,
  // Cut the current selection and place it in the clipboard.
  kFlutterSemanticsActionCut = 1 << 13,
  // Paste the current content of the clipboard.
  kFlutterSemanticsActionPaste = 1 << 14,
  // Indicate that the node has gained accessibility focus.
  kFlutterSemanticsActionDidGainAccessibilityFocus = 1 << 15,
  // Indicate that the node has lost accessibility focus.
  kFlutterSemanticsActionDidLoseAccessibilityFocus = 1 << 16,
  // Indicate that the user has invoked a custom accessibility action.
  kFlutterSemanticsActionCustomAction = 1 << 17,
  // A request that the node should be dismissed.
  kFlutterSemanticsActionDismiss = 1 << 18,
110
  // Move the cursor forward by one word.
111
  kFlutterSemanticsActionMoveCursorForwardByWord = 1 << 19,
112
  // Move the cursor backward by one word.
113
  kFlutterSemanticsActionMoveCursorBackwardByWord = 1 << 20,
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
} FlutterSemanticsAction;

// The set of properties that may be associated with a semantics node.
//
// Must match the |SemanticsFlag| enum in semantics.dart.
typedef enum {
  // The semantics node has the quality of either being "checked" or
  // "unchecked".
  kFlutterSemanticsFlagHasCheckedState = 1 << 0,
  // Whether a semantics node is checked.
  kFlutterSemanticsFlagIsChecked = 1 << 1,
  // Whether a semantics node is selected.
  kFlutterSemanticsFlagIsSelected = 1 << 2,
  // Whether the semantic node represents a button.
  kFlutterSemanticsFlagIsButton = 1 << 3,
  // Whether the semantic node represents a text field.
  kFlutterSemanticsFlagIsTextField = 1 << 4,
  // Whether the semantic node currently holds the user's focus.
  kFlutterSemanticsFlagIsFocused = 1 << 5,
  // The semantics node has the quality of either being "enabled" or "disabled".
  kFlutterSemanticsFlagHasEnabledState = 1 << 6,
  // Whether a semantic node that hasEnabledState is currently enabled.
  kFlutterSemanticsFlagIsEnabled = 1 << 7,
  // Whether a semantic node is in a mutually exclusive group.
  kFlutterSemanticsFlagIsInMutuallyExclusiveGroup = 1 << 8,
  // Whether a semantic node is a header that divides content into sections.
  kFlutterSemanticsFlagIsHeader = 1 << 9,
  // Whether the value of the semantics node is obscured.
  kFlutterSemanticsFlagIsObscured = 1 << 10,
  // Whether the semantics node is the root of a subtree for which a route name
  // should be announced.
  kFlutterSemanticsFlagScopesRoute = 1 << 11,
  // Whether the semantics node label is the name of a visually distinct route.
  kFlutterSemanticsFlagNamesRoute = 1 << 12,
  // Whether the semantics node is considered hidden.
  kFlutterSemanticsFlagIsHidden = 1 << 13,
  // Whether the semantics node represents an image.
  kFlutterSemanticsFlagIsImage = 1 << 14,
  // Whether the semantics node is a live region.
  kFlutterSemanticsFlagIsLiveRegion = 1 << 15,
  // The semantics node has the quality of either being "on" or "off".
  kFlutterSemanticsFlagHasToggledState = 1 << 16,
  // If true, the semantics node is "on". If false, the semantics node is "off".
  kFlutterSemanticsFlagIsToggled = 1 << 17,
158 159 160 161 162 163 164 165
  // 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.
  kFlutterSemanticsFlagHasImplicitScrolling = 1 << 18,
166 167 168 169
  // Whether the semantic node is read only.
  //
  // Only applicable when kFlutterSemanticsFlagIsTextField flag is on.
  kFlutterSemanticsFlagIsReadOnly = 1 << 20,
170 171 172 173 174 175 176 177 178 179 180
} FlutterSemanticsFlag;

typedef enum {
  // Text has unknown text direction.
  kFlutterTextDirectionUnknown = 0,
  // Text is read from right to left.
  kFlutterTextDirectionRTL = 1,
  // Text is read from left to right.
  kFlutterTextDirectionLTR = 2,
} FlutterTextDirection;

181
typedef struct _FlutterEngine* FLUTTER_API_SYMBOL(FlutterEngine);
182

183
typedef struct {
184
  // horizontal scale factor
185
  double scaleX;
186
  // horizontal skew factor
187
  double skewX;
188
  // horizontal translation
189
  double transX;
190
  // vertical skew factor
191
  double skewY;
192
  // vertical scale factor
193
  double scaleY;
194
  // vertical translation
195
  double transY;
196
  // input x-axis perspective factor
197
  double pers0;
198
  // input y-axis perspective factor
199
  double pers1;
200
  // perspective scale factor
201 202 203
  double pers2;
} FlutterTransformation;

204 205
typedef void (*VoidCallback)(void* /* user data */);

206 207 208 209 210 211 212 213 214
typedef enum {
  // Specifies an OpenGL texture target type. Textures are specified using
  // the FlutterOpenGLTexture struct.
  kFlutterOpenGLTargetTypeTexture,
  // Specifies an OpenGL frame-buffer target type. Framebuffers are specified
  // using the FlutterOpenGLFramebuffer struct.
  kFlutterOpenGLTargetTypeFramebuffer,
} FlutterOpenGLTargetType;

215
typedef struct {
216
  // Target texture of the active texture unit (example GL_TEXTURE_2D).
217
  uint32_t target;
218
  // The name of the texture.
219
  uint32_t name;
220
  // The texture format (example GL_RGBA8).
221
  uint32_t format;
222
  // User data to be returned on the invocation of the destruction callback.
223
  void* user_data;
224 225
  // Callback invoked (on an engine managed thread) that asks the embedder to
  // collect the texture.
226 227 228
  VoidCallback destruction_callback;
} FlutterOpenGLTexture;

229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
typedef struct {
  // The target of the color attachment of the frame-buffer. For example,
  // GL_TEXTURE_2D or GL_RENDERBUFFER. In case of ambiguity when dealing with
  // Window bound frame-buffers, 0 may be used.
  uint32_t target;

  // The name of the framebuffer.
  uint32_t name;

  // User data to be returned on the invocation of the destruction callback.
  void* user_data;

  // Callback invoked (on an engine managed thread) that asks the embedder to
  // collect the framebuffer.
  VoidCallback destruction_callback;
} FlutterOpenGLFramebuffer;

246
typedef bool (*BoolCallback)(void* /* user data */);
247
typedef FlutterTransformation (*TransformationCallback)(void* /* user data */);
248
typedef uint32_t (*UIntCallback)(void* /* user data */);
249 250 251 252
typedef bool (*SoftwareSurfacePresentCallback)(void* /* user data */,
                                               const void* /* allocation */,
                                               size_t /* row bytes */,
                                               size_t /* height */);
253
typedef void* (*ProcResolver)(void* /* user data */, const char* /* name */);
254 255 256 257 258
typedef bool (*TextureFrameCallback)(void* /* user data */,
                                     int64_t /* texture identifier */,
                                     size_t /* width */,
                                     size_t /* height */,
                                     FlutterOpenGLTexture* /* texture out */);
259
typedef void (*VsyncCallback)(void* /* user data */, intptr_t /* baton */);
260 261 262 263 264 265 266 267

typedef struct {
  // The size of this struct. Must be sizeof(FlutterOpenGLRendererConfig).
  size_t struct_size;
  BoolCallback make_current;
  BoolCallback clear_current;
  BoolCallback present;
  UIntCallback fbo_callback;
268 269 270 271 272 273
  // This is an optional callback. Flutter will ask the emebdder to create a GL
  // context current on a background thread. If the embedder is able to do so,
  // Flutter will assume that this context is in the same sharegroup as the main
  // rendering context and use this context for asynchronous texture uploads.
  // Though optional, it is recommended that all embedders set this callback as
  // it will lead to better performance in texture handling.
274
  BoolCallback make_resource_current;
275 276 277 278 279
  // By default, the renderer config assumes that the FBO does not change for
  // the duration of the engine run. If this argument is true, the
  // engine will ask the embedder for an updated FBO target (via an fbo_callback
  // invocation) after a present call.
  bool fbo_reset_after_present;
280 281 282
  // The transformation to apply to the render target before any rendering
  // operations. This callback is optional.
  TransformationCallback surface_transformation;
283
  ProcResolver gl_proc_resolver;
284 285
  // When the embedder specifies that a texture has a frame available, the
  // engine will call this method (on an internal engine managed thread) so that
286
  // external texture details can be supplied to the engine for subsequent
287 288
  // composition.
  TextureFrameCallback gl_external_texture_frame_callback;
289 290
} FlutterOpenGLRendererConfig;

291 292 293 294 295 296 297 298 299 300
typedef struct {
  // The size of this struct. Must be sizeof(FlutterSoftwareRendererConfig).
  size_t struct_size;
  // The callback presented to the embedder to present a fully populated buffer
  // to the user. The pixel format of the buffer is the native 32-bit RGBA
  // format. The buffer is owned by the Flutter engine and must be copied in
  // this callback if needed.
  SoftwareSurfacePresentCallback surface_present_callback;
} FlutterSoftwareRendererConfig;

301 302 303 304
typedef struct {
  FlutterRendererType type;
  union {
    FlutterOpenGLRendererConfig open_gl;
305
    FlutterSoftwareRendererConfig software;
306 307 308 309 310 311 312 313 314 315 316 317 318 319
  };
} FlutterRendererConfig;

typedef struct {
  // The size of this struct. Must be sizeof(FlutterWindowMetricsEvent).
  size_t struct_size;
  // Physical width of the window.
  size_t width;
  // Physical height of the window.
  size_t height;
  // Scale factor for the physical screen.
  double pixel_ratio;
} FlutterWindowMetricsEvent;

320
// The phase of the pointer event.
321 322
typedef enum {
  kCancel,
323 324 325 326 327 328
  // 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.
329
  kUp,
330 331 332 333 334 335
  // 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.
336
  kDown,
337 338 339 340
  // 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.
341
  kMove,
342 343 344 345
  // 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.
346
  kAdd,
347 348 349 350
  // 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.
351
  kRemove,
352
  // The pointer moved while up.
353
  kHover,
354 355
} FlutterPointerPhase;

356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373
// The device type that created a pointer event.
typedef enum {
  kFlutterPointerDeviceKindMouse = 1,
  kFlutterPointerDeviceKindTouch,
} FlutterPointerDeviceKind;

// Flags for the |buttons| field of |FlutterPointerEvent| when |device_kind|
// is |kFlutterPointerDeviceKindMouse|.
typedef enum {
  kFlutterPointerButtonMousePrimary = 1 << 0,
  kFlutterPointerButtonMouseSecondary = 1 << 1,
  kFlutterPointerButtonMouseMiddle = 1 << 2,
  kFlutterPointerButtonMouseBack = 1 << 3,
  kFlutterPointerButtonMouseForward = 1 << 4,
  // If a mouse has more than five buttons, send higher bit shifted values
  // corresponding to the button number: 1 << 5 for the 6th, etc.
} FlutterPointerMouseButtons;

374 375 376 377 378 379
// The type of a pointer signal.
typedef enum {
  kFlutterPointerSignalKindNone,
  kFlutterPointerSignalKindScroll,
} FlutterPointerSignalKind;

380 381 382 383 384 385 386
typedef struct {
  // The size of this struct. Must be sizeof(FlutterPointerEvent).
  size_t struct_size;
  FlutterPointerPhase phase;
  size_t timestamp;  // in microseconds.
  double x;
  double y;
387
  // An optional device identifier. If this is not specified, it is assumed that
388
  // the embedder has no multi-touch capability.
389
  int32_t device;
390 391 392
  FlutterPointerSignalKind signal_kind;
  double scroll_delta_x;
  double scroll_delta_y;
393 394 395 396 397 398 399 400
  // The type of the device generating this event.
  // Backwards compatibility note: If this is not set, the device will be
  // treated as a mouse, with the primary button set for |kDown| and |kMove|.
  // If set explicitly to |kFlutterPointerDeviceKindMouse|, you must set the
  // correct buttons.
  FlutterPointerDeviceKind device_kind;
  // The buttons currently pressed, if any.
  int64_t buttons;
401 402
} FlutterPointerEvent;

403 404 405 406
struct _FlutterPlatformMessageResponseHandle;
typedef struct _FlutterPlatformMessageResponseHandle
    FlutterPlatformMessageResponseHandle;

407 408 409 410 411
typedef struct {
  // The size of this struct. Must be sizeof(FlutterPlatformMessage).
  size_t struct_size;
  const char* channel;
  const uint8_t* message;
412
  size_t message_size;
413
  // The response handle on which to invoke
414 415 416
  // |FlutterEngineSendPlatformMessageResponse| when the response is ready.
  // |FlutterEngineSendPlatformMessageResponse| must be called for all messages
  // received by the embedder. Failure to call
417 418
  // |FlutterEngineSendPlatformMessageResponse| will cause a memory leak. It is
  // not safe to send multiple responses on a single response object.
419
  const FlutterPlatformMessageResponseHandle* response_handle;
420 421
} FlutterPlatformMessage;

422 423 424 425
typedef void (*FlutterPlatformMessageCallback)(
    const FlutterPlatformMessage* /* message*/,
    void* /* user data */);

426 427 428 429
typedef void (*FlutterDataCallback)(const uint8_t* /* data */,
                                    size_t /* size */,
                                    void* /* user data */);

430 431 432 433 434 435 436
typedef struct {
  double left;
  double top;
  double right;
  double bottom;
} FlutterRect;

437 438
// |FlutterSemanticsNode| ID used as a sentinel to signal the end of a batch of
// semantics node updates.
439
FLUTTER_EXPORT
440
extern const int32_t kFlutterSemanticsNodeIdBatchEnd;
441

442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457
// A node that represents some semantic data.
//
// The semantics tree is maintained during the semantics phase of the pipeline
// (i.e., during PipelineOwner.flushSemantics), which happens after
// compositing. Updates are then pushed to embedders via the registered
// |FlutterUpdateSemanticsNodeCallback|.
typedef struct {
  // The size of this struct. Must be sizeof(FlutterSemanticsNode).
  size_t struct_size;
  // The unique identifier for this node.
  int32_t id;
  // The set of semantics flags associated with this node.
  FlutterSemanticsFlag flags;
  // The set of semantics actions applicable to this node.
  FlutterSemanticsAction actions;
  // The position at which the text selection originates.
458
  int32_t text_selection_base;
459
  // The position at which the text selection terminates.
460
  int32_t text_selection_extent;
461
  // The total number of scrollable children that contribute to semantics.
462
  int32_t scroll_child_count;
463
  // The index of the first visible semantic child of a scroll node.
464
  int32_t scroll_index;
465
  // The current scrolling position in logical pixels if the node is scrollable.
466
  double scroll_position;
467
  // The maximum in-range value for |scrollPosition| if the node is scrollable.
468
  double scroll_extent_max;
469
  // The minimum in-range value for |scrollPosition| if the node is scrollable.
470
  double scroll_extent_min;
471 472 473 474 475 476 477 478 479 480 481 482 483
  // The elevation along the z-axis at which the rect of this semantics node is
  // located above its parent.
  double elevation;
  // Describes how much space the semantics node takes up along the z-axis.
  double thickness;
  // A textual description of the node.
  const char* label;
  // A brief description of the result of performing an action on the node.
  const char* hint;
  // A textual description of the current value of the node.
  const char* value;
  // A value that |value| will have after a kFlutterSemanticsActionIncrease|
  // action has been performed.
484
  const char* increased_value;
485 486
  // A value that |value| will have after a kFlutterSemanticsActionDecrease|
  // action has been performed.
487
  const char* decreased_value;
488 489
  // The reading direction for |label|, |value|, |hint|, |increasedValue|, and
  // |decreasedValue|.
490
  FlutterTextDirection text_direction;
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508
  // The bounding box for this node in its coordinate system.
  FlutterRect rect;
  // The transform from this node's coordinate system to its parent's coordinate
  // system.
  FlutterTransformation transform;
  // The number of children this node has.
  size_t child_count;
  // Array of child node IDs in traversal order. Has length |child_count|.
  const int32_t* children_in_traversal_order;
  // Array of child node IDs in hit test order. Has length |child_count|.
  const int32_t* children_in_hit_test_order;
  // The number of custom accessibility action associated with this node.
  size_t custom_accessibility_actions_count;
  // Array of |FlutterSemanticsCustomAction| IDs associated with this node.
  // Has length |custom_accessibility_actions_count|.
  const int32_t* custom_accessibility_actions;
} FlutterSemanticsNode;

509 510
// |FlutterSemanticsCustomAction| ID used as a sentinel to signal the end of a
// batch of semantics custom action updates.
511
FLUTTER_EXPORT
512
extern const int32_t kFlutterSemanticsCustomActionIdBatchEnd;
513

514 515 516 517 518 519 520 521 522 523 524 525 526 527
// A custom semantics action, or action override.
//
// Custom actions can be registered by applications in order to provide
// semantic actions other than the standard actions available through the
// |FlutterSemanticsAction| enum.
//
// Action overrides are custom actions that the application developer requests
// to be used in place of the standard actions in the |FlutterSemanticsAction|
// enum.
typedef struct {
  // The size of the struct. Must be sizeof(FlutterSemanticsCustomAction).
  size_t struct_size;
  // The unique custom action or action override ID.
  int32_t id;
528
  // For overridden standard actions, corresponds to the
529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544
  // |FlutterSemanticsAction| to override.
  FlutterSemanticsAction override_action;
  // The user-readable name of this custom semantics action.
  const char* label;
  // The hint description of this custom semantics action.
  const char* hint;
} FlutterSemanticsCustomAction;

typedef void (*FlutterUpdateSemanticsNodeCallback)(
    const FlutterSemanticsNode* /* semantics node */,
    void* /* user data */);

typedef void (*FlutterUpdateSemanticsCustomActionCallback)(
    const FlutterSemanticsCustomAction* /* semantics custom action */,
    void* /* user data */);

545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590
typedef struct _FlutterTaskRunner* FlutterTaskRunner;

typedef struct {
  FlutterTaskRunner runner;
  uint64_t task;
} FlutterTask;

typedef void (*FlutterTaskRunnerPostTaskCallback)(
    FlutterTask /* task */,
    uint64_t /* target time nanos */,
    void* /* user data */);

// An interface used by the Flutter engine to execute tasks at the target time
// on a specified thread. There should be a 1-1 relationship between a thread
// and a task runner. It is undefined behavior to run a task on a thread that is
// not associated with its task runner.
typedef struct {
  // The size of this struct. Must be sizeof(FlutterTaskRunnerDescription).
  size_t struct_size;
  void* user_data;
  // May be called from any thread. Should return true if tasks posted on the
  // calling thread will be run on that same thread.
  //
  // This field is required.
  BoolCallback runs_task_on_current_thread_callback;
  // May be called from any thread. The given task should be executed by the
  // embedder on the thread associated with that task runner by calling
  // |FlutterEngineRunTask| at the given target time. The system monotonic clock
  // should be used for the target time. The target time is the absolute time
  // from epoch (NOT a delta) at which the task must be returned back to the
  // engine on the correct thread. If the embedder needs to calculate a delta,
  // |FlutterEngineGetCurrentTime| may be called and the difference used as the
  // delta.
  //
  // This field is required.
  FlutterTaskRunnerPostTaskCallback post_task_callback;
} FlutterTaskRunnerDescription;

typedef struct {
  // The size of this struct. Must be sizeof(FlutterCustomTaskRunners).
  size_t struct_size;
  // Specify the task runner for the thread on which the |FlutterEngineRun| call
  // is made.
  const FlutterTaskRunnerDescription* platform_task_runner;
} FlutterCustomTaskRunners;

591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744
typedef struct {
  // The type of the OpenGL backing store. Currently, it can either be a texture
  // or a framebuffer.
  FlutterOpenGLTargetType type;
  union {
    // A texture for Flutter to render into.
    FlutterOpenGLTexture texture;
    // A framebuffer for Flutter to render into. The embedder must ensure that
    // the framebuffer is complete.
    FlutterOpenGLFramebuffer framebuffer;
  };
} FlutterOpenGLBackingStore;

typedef struct {
  // A pointer to the raw bytes of the allocation described by this software
  // backing store.
  const void* allocation;
  // The number of bytes in a single row of the allocation.
  size_t row_bytes;
  // The number of rows in the allocation.
  size_t height;
  // A baton that is not interpreted by the engine in any way. It will be given
  // back to the embedder in the destruction callback below. Embedder resources
  // may be associated with this baton.
  void* user_data;
  // The callback invoked by the engine when it no longer needs this backing
  // store.
  VoidCallback destruction_callback;
} FlutterSoftwareBackingStore;

// 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.
typedef int64_t FlutterPlatformViewIdentifier;

typedef struct {
  // The size of this struct. Must be sizeof(FlutterPlatformView).
  size_t struct_size;
  // The identifier of this platform view. This identifier is specified by the
  // application when a platform view is added to the scene via the
  // `SceneBuilder.addPlatformView` call.
  FlutterPlatformViewIdentifier identifier;
} FlutterPlatformView;

typedef enum {
  // Specifies an OpenGL backing store. Can either be an OpenGL texture or
  // framebuffer.
  kFlutterBackingStoreTypeOpenGL,
  // Specified an software allocation for Flutter to render into using the CPU.
  kFlutterBackingStoreTypeSoftware,
} FlutterBackingStoreType;

typedef struct {
  // The size of this struct. Must be sizeof(FlutterBackingStore).
  size_t struct_size;
  // A baton that is not interpreted by the engine in any way. The embedder may
  // use this to associate resources that are tied to the lifecycle of the
  // |FlutterBackingStore|.
  void* user_data;
  // Specifies the type of backing store.
  FlutterBackingStoreType type;
  // Indicates if this backing store was updated since the last time it was
  // associated with a presented layer.
  bool did_update;
  union {
    // The description of the OpenGL backing store.
    FlutterOpenGLBackingStore open_gl;
    // The description of the software backing store.
    FlutterSoftwareBackingStore software;
  };
} FlutterBackingStore;

typedef struct {
  double x;
  double y;
} FlutterPoint;

typedef struct {
  double width;
  double height;
} FlutterSize;

typedef struct {
  // The size of this struct. Must be sizeof(FlutterBackingStoreConfig).
  size_t struct_size;
  // The size of the render target the engine expects to render into.
  FlutterSize size;
} FlutterBackingStoreConfig;

typedef enum {
  // Indicates that the contents of this layer are rendered by Flutter into a
  // backing store.
  kFlutterLayerContentTypeBackingStore,
  // Indicates that the contents of this layer are determined by the embedder.
  kFlutterLayerContentTypePlatformView,
} FlutterLayerContentType;

typedef struct {
  // This size of this struct. Must be sizeof(FlutterLayer).
  size_t struct_size;
  // Each layer displays contents in one way or another. The type indicates
  // whether those contents are specified by Flutter or the embedder.
  FlutterLayerContentType type;
  union {
    // Indicates that the contents of this layer are rendered by Flutter into a
    // backing store.
    const FlutterBackingStore* backing_store;
    // Indicates that the contents of this layer are determined by the embedder.
    const FlutterPlatformView* platform_view;
  };
  // The offset of this layer (in physical pixels) relative to the top left of
  // the root surface used by the engine.
  FlutterPoint offset;
  // The size of the layer (in physical pixels).
  FlutterSize size;
} FlutterLayer;

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 struct {
  // This size of this struct. Must be sizeof(FlutterCompositor).
  size_t struct_size;
  // A baton that in not interpreted by the engine in any way. If it passed back
  // to the embedder in  |FlutterCompositor.create_backing_store_callback|,
  // |FlutterCompositor.collect_backing_store_callback| and
  // |FlutterCompositor.present_layers_callback|
  void* user_data;
  // A callback invoked by the engine to obtain a backing store for a specific
  // |FlutterLayer|.
  //
  // On ABI stability: Callers must take care to restrict access within
  // |FlutterBackingStore::struct_size| when specifying a new backing store to
  // the engine. This only matters if the embedder expects to be used with
  // engines older than the version whose headers it used during compilation.
  FlutterBackingStoreCreateCallback create_backing_store_callback;
  // A callback invoked by the engine to release the backing store. The embedder
  // may collect any resources associated with the backing store.
  FlutterBackingStoreCollectCallback collect_backing_store_callback;
  // Callback invoked by the engine to composite the contents of each layer onto
  // the screen.
  FlutterLayersPresentCallback present_layers_callback;
} FlutterCompositor;

745 746 747
typedef struct {
  // The size of this struct. Must be sizeof(FlutterProjectArgs).
  size_t struct_size;
748 749 750
  // The path to the Flutter assets directory containing project assets. The
  // string can be collected after the call to |FlutterEngineRun| returns. The
  // string must be NULL terminated.
751
  const char* assets_path;
752 753 754 755 756 757 758 759 760
  // The path to the Dart file containing the |main| entry point.
  // The string can be collected after the call to |FlutterEngineRun| returns.
  // The string must be NULL terminated.
  //
  // \deprecated As of Dart 2, running from Dart source is no longer supported.
  // Dart code should now be compiled to kernel form and will be loaded by from
  // |kernel_blob.bin| in the assets directory. This struct member is retained
  // for ABI stability.
  const char* main_path__unused__;
761 762 763
  // The path to the |.packages| for the project. The string can be collected
  // after the call to |FlutterEngineRun| returns. The string must be NULL
  // terminated.
764 765 766 767 768 769
  //
  // \deprecated As of Dart 2, running from Dart source is no longer supported.
  // Dart code should now be compiled to kernel form and will be loaded by from
  // |kernel_blob.bin| in the assets directory. This struct member is retained
  // for ABI stability.
  const char* packages_path__unused__;
770 771 772 773
  // The path to the icudtl.dat file for the project. The string can be
  // collected after the call to |FlutterEngineRun| returns. The string must
  // be NULL terminated.
  const char* icu_data_path;
774
  // The command line argument count used to initialize the project.
775 776 777 778
  int command_line_argc;
  // The command line arguments used to initialize the project. The strings can
  // be collected after the call to |FlutterEngineRun| returns. The strings must
  // be NULL terminated.
779 780 781 782 783 784 785 786
  // Note: The first item in the command line (if specificed at all) is
  // interpreted as the executable name. So if an engine flag needs to be passed
  // into the same, it needs to not be the very first item in the list. The set
  // of engine flags are only meant to control unstable features in the engine.
  // Deployed applications should not pass any command line arguments at all as
  // they may affect engine stability at runtime in the presence of unsanitized
  // input. The list of currently recognized engine flags and their descriptions
  // can be retrieved from the |switches.h| engine source file.
787 788 789 790 791
  const char* const* command_line_argv;
  // The callback invoked by the engine in order to give the embedder the chance
  // to respond to platform messages from the Dart application. The callback
  // will be invoked on the thread on which the |FlutterEngineRun| call is made.
  FlutterPlatformMessageCallback platform_message_callback;
792 793 794 795 796
  // The VM snapshot data buffer used in AOT operation. This buffer must be
  // mapped in as read-only. For more information refer to the documentation on
  // the Wiki at
  // https://github.com/flutter/flutter/wiki/Flutter-engine-operation-in-AOT-Mode
  const uint8_t* vm_snapshot_data;
797 798
  // The size of the VM snapshot data buffer.  If vm_snapshot_data is a symbol
  // reference, 0 may be passed here.
799 800 801 802 803 804
  size_t vm_snapshot_data_size;
  // The VM snapshot instructions buffer used in AOT operation. This buffer must
  // be mapped in as read-execute. For more information refer to the
  // documentation on the Wiki at
  // https://github.com/flutter/flutter/wiki/Flutter-engine-operation-in-AOT-Mode
  const uint8_t* vm_snapshot_instructions;
805 806
  // The size of the VM snapshot instructions buffer. If
  // vm_snapshot_instructions is a symbol reference, 0 may be passed here.
807 808 809 810 811 812
  size_t vm_snapshot_instructions_size;
  // The isolate snapshot data buffer used in AOT operation. This buffer must be
  // mapped in as read-only. For more information refer to the documentation on
  // the Wiki at
  // https://github.com/flutter/flutter/wiki/Flutter-engine-operation-in-AOT-Mode
  const uint8_t* isolate_snapshot_data;
813 814
  // The size of the isolate snapshot data buffer.  If isolate_snapshot_data is
  // a symbol reference, 0 may be passed here.
815 816 817 818 819 820
  size_t isolate_snapshot_data_size;
  // The isolate snapshot instructions buffer used in AOT operation. This buffer
  // must be mapped in as read-execute. For more information refer to the
  // documentation on the Wiki at
  // https://github.com/flutter/flutter/wiki/Flutter-engine-operation-in-AOT-Mode
  const uint8_t* isolate_snapshot_instructions;
821 822
  // The size of the isolate snapshot instructions buffer. If
  // isolate_snapshot_instructions is a symbol reference, 0 may be passed here.
823
  size_t isolate_snapshot_instructions_size;
824 825 826
  // The callback invoked by the engine in root isolate scope. Called
  // immediately after the root isolate has been created and marked runnable.
  VoidCallback root_isolate_create_callback;
827
  // The callback invoked by the engine in order to give the embedder the
828 829 830 831 832 833
  // chance to respond to semantics node updates from the Dart application.
  // Semantics node updates are sent in batches terminated by a 'batch end'
  // callback that is passed a sentinel |FlutterSemanticsNode| whose |id| field
  // has the value |kFlutterSemanticsNodeIdBatchEnd|.
  //
  // The callback will be invoked on the thread on which the |FlutterEngineRun|
834 835 836 837
  // call is made.
  FlutterUpdateSemanticsNodeCallback update_semantics_node_callback;
  // The callback invoked by the engine in order to give the embedder the
  // chance to respond to updates to semantics custom actions from the Dart
838 839 840 841 842 843 844
  // application.  Custom action updates are sent in batches terminated by a
  // 'batch end' callback that is passed a sentinel
  // |FlutterSemanticsCustomAction| whose |id| field has the value
  // |kFlutterSemanticsCustomActionIdBatchEnd|.
  //
  // The callback will be invoked on the thread on which the |FlutterEngineRun|
  // call is made.
845 846
  FlutterUpdateSemanticsCustomActionCallback
      update_semantics_custom_action_callback;
847 848 849
  // Path to a directory used to store data that is cached across runs of a
  // Flutter application (such as compiled shader programs used by Skia).
  // This is optional.  The string must be NULL terminated.
850 851 852
  //
  // This is different from the cache-path-dir argument defined in switches.h,
  // which is used in |flutter::Settings| as |temp_directory_path|.
853
  const char* persistent_cache_path;
854 855 856 857

  // If true, we'll only read the existing cache, but not write new ones.
  bool is_persistent_cache_read_only;

858 859 860 861 862 863 864 865 866
  // A callback that gets invoked by the engine when it attempts to wait for a
  // platform vsync event. The engine will give the platform a baton that needs
  // to be returned back to the engine via |FlutterEngineOnVsync|. All batons
  // must be retured to the engine before initializing a
  // |FlutterEngineShutdown|. Not doing the same will result in a memory leak.
  // While the call to |FlutterEngineOnVsync| must occur on the thread that made
  // the call to |FlutterEngineRun|, the engine will make this callback on an
  // internal engine-managed thread. If the components accessed on the embedder
  // are not thread safe, the appropriate re-threading must be done.
867
  VsyncCallback vsync_callback;
868 869 870 871 872 873 874 875 876

  // The name of a custom Dart entrypoint. This is optional and specifying a
  // null or empty entrypoint makes the engine look for a method named "main" in
  // the root library of the application.
  //
  // Care must be taken to ensure that the custom entrypoint is not tree-shaken
  // away. Usually, this is done using the `@pragma('vm:entry-point')`
  // decoration.
  const char* custom_dart_entrypoint;
877 878 879 880 881

  // Typically the Flutter engine create and manages its internal threads. This
  // optional argument allows for the specification of task runner interfaces to
  // event loops managed by the embedder on threads it creates.
  const FlutterCustomTaskRunners* custom_task_runners;
882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900

  // All `FlutterEngine` instances in the process share the same Dart VM. When
  // the first engine is launched, it starts the Dart VM as well. It used to be
  // the case that it was not possible to shutdown the Dart VM cleanly and start
  // it back up in the process in a safe manner. This issue has since been
  // patched. Unfortunately, applications already began to make use of the fact
  // that shutting down the Flutter engine instance left a running VM in the
  // process. Since a Flutter engine could be launched on any thread,
  // applications would "warm up" the VM on another thread by launching
  // an engine with no isolates and then shutting it down immediately. The main
  // Flutter application could then be started on the main thread without having
  // to incur the Dart VM startup costs at that time. With the new behavior,
  // this "optimization" immediately becomes massive performance pessimization
  // as the VM would be started up in the "warm up" phase, shut down there and
  // then started again on the main thread. Changing this behavior was deemed to
  // be an unacceptable breaking change. Embedders that wish to shutdown the
  // Dart VM when the last engine is terminated in the process should opt into
  // this behavior by setting this flag to true.
  bool shutdown_dart_vm_when_done;
901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916

  // Typically, Flutter renders the layer hierarchy into a single root surface.
  // However, when embedders need to interleave their own contents within the
  // Flutter layer hierarchy, their applications can push platform views within
  // the Flutter scene. This is done using the `SceneBuilder.addPlatformView`
  // call. When this happens, the Flutter rasterizer divides the effective view
  // hierarchy into multiple layers. Each layer gets its own backing store and
  // Flutter renders into the same. Once the layers contents have been
  // fulfilled, the embedder is asked to composite these layers on-screen. At
  // this point, it can interleave its own contents within the effective
  // hierarchy. The interface for the specification of these layer backing
  // stores and the hooks to listen for the composition of layers on-screen can
  // be controlled using this field. This field is completely optional. In its
  // absence, platforms views in the scene are ignored and Flutter renders to
  // the root surface as normal.
  const FlutterCompositor* compositor;
917 918
} FlutterProjectArgs;

919
FLUTTER_EXPORT
920 921 922 923
FlutterEngineResult FlutterEngineRun(size_t version,
                                     const FlutterRendererConfig* config,
                                     const FlutterProjectArgs* args,
                                     void* user_data,
924 925
                                     FLUTTER_API_SYMBOL(FlutterEngine) *
                                         engine_out);
926 927

FLUTTER_EXPORT
928 929
FlutterEngineResult FlutterEngineShutdown(FLUTTER_API_SYMBOL(FlutterEngine)
                                              engine);
930 931

FLUTTER_EXPORT
932
FlutterEngineResult FlutterEngineSendWindowMetricsEvent(
933
    FLUTTER_API_SYMBOL(FlutterEngine) engine,
934 935 936
    const FlutterWindowMetricsEvent* event);

FLUTTER_EXPORT
937
FlutterEngineResult FlutterEngineSendPointerEvent(
938
    FLUTTER_API_SYMBOL(FlutterEngine) engine,
939 940
    const FlutterPointerEvent* events,
    size_t events_count);
941

942
FLUTTER_EXPORT
943
FlutterEngineResult FlutterEngineSendPlatformMessage(
944
    FLUTTER_API_SYMBOL(FlutterEngine) engine,
945 946
    const FlutterPlatformMessage* message);

947 948 949 950 951 952 953 954 955 956 957 958 959 960 961
// 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.
FLUTTER_EXPORT
FlutterEngineResult FlutterPlatformMessageCreateResponseHandle(
962
    FLUTTER_API_SYMBOL(FlutterEngine) engine,
963 964 965 966 967 968 969 970
    FlutterDataCallback data_callback,
    void* user_data,
    FlutterPlatformMessageResponseHandle** response_out);

// Collects the handle created using
// |FlutterPlatformMessageCreateResponseHandle|.
FLUTTER_EXPORT
FlutterEngineResult FlutterPlatformMessageReleaseResponseHandle(
971
    FLUTTER_API_SYMBOL(FlutterEngine) engine,
972 973
    FlutterPlatformMessageResponseHandle* response);

974
FLUTTER_EXPORT
975
FlutterEngineResult FlutterEngineSendPlatformMessageResponse(
976
    FLUTTER_API_SYMBOL(FlutterEngine) engine,
977 978 979 980
    const FlutterPlatformMessageResponseHandle* handle,
    const uint8_t* data,
    size_t data_length);

981 982 983 984
// 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. This API will be
// deprecated soon.
FLUTTER_EXPORT
985
FlutterEngineResult __FlutterEngineFlushPendingTasksNow();
986

987 988 989 990 991 992
// 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|.
FLUTTER_EXPORT
993
FlutterEngineResult FlutterEngineRegisterExternalTexture(
994
    FLUTTER_API_SYMBOL(FlutterEngine) engine,
995
    int64_t texture_identifier);
996 997 998

// Unregister a previous texture registration.
FLUTTER_EXPORT
999
FlutterEngineResult FlutterEngineUnregisterExternalTexture(
1000
    FLUTTER_API_SYMBOL(FlutterEngine) engine,
1001 1002 1003 1004
    int64_t texture_identifier);

// Mark that a new texture frame is available for a given texture identifier.
FLUTTER_EXPORT
1005
FlutterEngineResult FlutterEngineMarkExternalTextureFrameAvailable(
1006
    FLUTTER_API_SYMBOL(FlutterEngine) engine,
1007 1008
    int64_t texture_identifier);

1009 1010 1011 1012 1013 1014
// Enable or disable accessibility semantics.
//
// When enabled, changes to the semantic contents of the window are sent via
// the |FlutterUpdateSemanticsNodeCallback| registered to
// |update_semantics_node_callback| in |FlutterProjectArgs|;
FLUTTER_EXPORT
1015 1016 1017
FlutterEngineResult FlutterEngineUpdateSemanticsEnabled(
    FLUTTER_API_SYMBOL(FlutterEngine) engine,
    bool enabled);
1018 1019 1020 1021

// Sets additional accessibility features.
FLUTTER_EXPORT
FlutterEngineResult FlutterEngineUpdateAccessibilityFeatures(
1022
    FLUTTER_API_SYMBOL(FlutterEngine) engine,
1023 1024 1025 1026 1027
    FlutterAccessibilityFeature features);

// Dispatch a semantics action to the specified semantics node.
FLUTTER_EXPORT
FlutterEngineResult FlutterEngineDispatchSemanticsAction(
1028
    FLUTTER_API_SYMBOL(FlutterEngine) engine,
1029 1030 1031 1032 1033
    uint64_t id,
    FlutterSemanticsAction action,
    const uint8_t* data,
    size_t data_length);

1034
// Notify the engine that a vsync event occurred. A baton passed to the
1035 1036 1037
// platform via the vsync callback must be returned. This call must be made on
// the thread on which the call to |FlutterEngineRun| was made.
//
1038 1039 1040 1041 1042
// |frame_start_time_nanos| is the point at which the vsync event occurred or
// will occur. If the time point is in the future, the engine will wait till
// that point to begin its frame workload. The system monotonic clock is used as
// the timebase.
//
1043 1044 1045 1046
// |frame_target_time_nanos| is the point at which the embedder anticipates the
// next vsync to occur. This is a hint the engine uses to schedule Dart VM
// garbage collection in periods in which the various threads are most likely to
// be idle. For example, for a 60Hz display, embedders should add 16.6 * 1e6 to
1047
// the frame time field. The system monotonic clock is used as the timebase.
1048 1049
//
// That frame timepoints are in nanoseconds.
1050
FLUTTER_EXPORT
1051 1052
FlutterEngineResult FlutterEngineOnVsync(FLUTTER_API_SYMBOL(FlutterEngine)
                                             engine,
1053 1054 1055 1056
                                         intptr_t baton,
                                         uint64_t frame_start_time_nanos,
                                         uint64_t frame_target_time_nanos);

1057 1058 1059 1060
// 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.
1061 1062
// 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.
1063 1064 1065
FLUTTER_EXPORT
void FlutterEngineTraceEventDurationBegin(const char* name);

1066 1067 1068
// 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
1069
// |FlutterEngineTraceEventDurationBegin|) with the same name on the same
1070 1071 1072
// 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.
1073 1074 1075 1076 1077
FLUTTER_EXPORT
void FlutterEngineTraceEventDurationEnd(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
1078 1079
// on any thread. Strings passed into the function will NOT be copied when added
// to the timeline. Only string literals may be passed in.
1080 1081 1082
FLUTTER_EXPORT
void FlutterEngineTraceEventInstant(const char* name);

1083 1084 1085 1086
// 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.
FLUTTER_EXPORT
1087 1088 1089 1090
FlutterEngineResult FlutterEnginePostRenderThreadTask(
    FLUTTER_API_SYMBOL(FlutterEngine) engine,
    VoidCallback callback,
    void* callback_data);
1091

1092 1093 1094 1095 1096 1097 1098 1099 1100 1101
// Get the current time in nanoseconds from the clock used by the flutter
// engine. This is the system monotonic clock.
FLUTTER_EXPORT
uint64_t FlutterEngineGetCurrentTime();

// 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.
FLUTTER_EXPORT
1102 1103
FlutterEngineResult FlutterEngineRunTask(FLUTTER_API_SYMBOL(FlutterEngine)
                                             engine,
1104 1105
                                         const FlutterTask* task);

1106 1107 1108 1109 1110
#if defined(__cplusplus)
}  // extern "C"
#endif

#endif  // FLUTTER_EMBEDDER_H_