• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_EMBEDDER_H_
6 #define FLUTTER_EMBEDDER_H_
7 
8 #include <stdbool.h>
9 #include <stddef.h>
10 #include <stdint.h>
11 
12 #if defined(__cplusplus)
13 #include <functional>
14 extern "C" {
15 #endif
16 
17 #ifndef FLUTTER_EXPORT
18 #define FLUTTER_EXPORT
19 #endif  // FLUTTER_EXPORT
20 
21 #ifdef FLUTTER_API_SYMBOL_PREFIX
22 #define FLUTTER_EMBEDDING_CONCAT(a, b) a##b
23 #define FLUTTER_EMBEDDING_ADD_PREFIX(symbol, prefix) \
24   FLUTTER_EMBEDDING_CONCAT(prefix, symbol)
25 #define FLUTTER_API_SYMBOL(symbol) \
26   FLUTTER_EMBEDDING_ADD_PREFIX(symbol, FLUTTER_API_SYMBOL_PREFIX)
27 #else
28 #define FLUTTER_API_SYMBOL(symbol) symbol
29 #endif
30 
31 #define FLUTTER_ENGINE_VERSION 1
32 
33 typedef enum {
34   kSuccess = 0,
35   kInvalidLibraryVersion,
36   kInvalidArguments,
37   kInternalInconsistency,
38 } FlutterEngineResult;
39 
40 typedef enum {
41   kOpenGL,
42   kSoftware,
43 } FlutterRendererType;
44 
45 typedef enum {
46   // Text has unknown text direction.
47   kFlutterTextDirectionUnknown = 0,
48   // Text is read from right to left.
49   kFlutterTextDirectionRTL = 1,
50   // Text is read from left to right.
51   kFlutterTextDirectionLTR = 2,
52 } FlutterTextDirection;
53 
54 typedef struct _FlutterEngine* FLUTTER_API_SYMBOL(FlutterEngine);
55 
56 typedef struct {
57   // horizontal scale factor
58   double scaleX;
59   // horizontal skew factor
60   double skewX;
61   // horizontal translation
62   double transX;
63   // vertical skew factor
64   double skewY;
65   // vertical scale factor
66   double scaleY;
67   // vertical translation
68   double transY;
69   // input x-axis perspective factor
70   double pers0;
71   // input y-axis perspective factor
72   double pers1;
73   // perspective scale factor
74   double pers2;
75 } FlutterTransformation;
76 
77 typedef void (*VoidCallback)(void* /* user data */);
78 
79 typedef enum {
80   // Specifies an OpenGL texture target type. Textures are specified using
81   // the FlutterOpenGLTexture struct.
82   kFlutterOpenGLTargetTypeTexture,
83   // Specifies an OpenGL frame-buffer target type. Framebuffers are specified
84   // using the FlutterOpenGLFramebuffer struct.
85   kFlutterOpenGLTargetTypeFramebuffer,
86 } FlutterOpenGLTargetType;
87 
88 typedef struct {
89   // Target texture of the active texture unit (example GL_TEXTURE_2D).
90   uint32_t target;
91   // The name of the texture.
92   uint32_t name;
93   // The texture format (example GL_RGBA8).
94   uint32_t format;
95   // User data to be returned on the invocation of the destruction callback.
96   void* user_data;
97   // Callback invoked (on an engine managed thread) that asks the embedder to
98   // collect the texture.
99   VoidCallback destruction_callback;
100 } FlutterOpenGLTexture;
101 
102 typedef struct {
103   // The target of the color attachment of the frame-buffer. For example,
104   // GL_TEXTURE_2D or GL_RENDERBUFFER. In case of ambiguity when dealing with
105   // Window bound frame-buffers, 0 may be used.
106   uint32_t target;
107 
108   // The name of the framebuffer.
109   uint32_t name;
110 
111   // User data to be returned on the invocation of the destruction callback.
112   void* user_data;
113 
114   // Callback invoked (on an engine managed thread) that asks the embedder to
115   // collect the framebuffer.
116   VoidCallback destruction_callback;
117 } FlutterOpenGLFramebuffer;
118 
119 // ACE PC preivew
120 using IdleCallback = std::function<void(int64_t)>;
121 typedef bool (*UserBoolCallback)(const void*, const size_t, const int32_t, const int32_t);
122 #ifdef USE_GLFW_WINDOW
123 namespace flutter {
124   class PointerDataPacket;
125 }
126 
127 using HandleTouchEventCallback =
128     std::function<bool(std::unique_ptr<flutter::PointerDataPacket>&)>;
129 #endif
130 
131 typedef bool (*BoolCallback)(void* /* user data */);
132 typedef FlutterTransformation (*TransformationCallback)(void* /* user data */);
133 typedef uint32_t (*UIntCallback)(void* /* user data */);
134 typedef bool (*SoftwareSurfacePresentCallback)(void* /* user data */,
135                                                const void* /* allocation */,
136                                                size_t /* row bytes */,
137                                                size_t /* height */);
138 typedef void* (*ProcResolver)(void* /* user data */, const char* /* name */);
139 typedef bool (*TextureFrameCallback)(void* /* user data */,
140                                      int64_t /* texture identifier */,
141                                      size_t /* width */,
142                                      size_t /* height */,
143                                      FlutterOpenGLTexture* /* texture out */);
144 typedef void (*VsyncCallback)(void* /* user data */, intptr_t /* baton */);
145 
146 typedef struct {
147   // The size of this struct. Must be sizeof(FlutterOpenGLRendererConfig).
148   size_t struct_size;
149   BoolCallback make_current;
150   BoolCallback clear_current;
151   BoolCallback present;
152   UserBoolCallback send_current_surface; // for ACE PC preivew
153   UIntCallback fbo_callback;
154   // This is an optional callback. Flutter will ask the emebdder to create a GL
155   // context current on a background thread. If the embedder is able to do so,
156   // Flutter will assume that this context is in the same sharegroup as the main
157   // rendering context and use this context for asynchronous texture uploads.
158   // Though optional, it is recommended that all embedders set this callback as
159   // it will lead to better performance in texture handling.
160   BoolCallback make_resource_current;
161   // By default, the renderer config assumes that the FBO does not change for
162   // the duration of the engine run. If this argument is true, the
163   // engine will ask the embedder for an updated FBO target (via an fbo_callback
164   // invocation) after a present call.
165   bool fbo_reset_after_present;
166   // The transformation to apply to the render target before any rendering
167   // operations. This callback is optional.
168   TransformationCallback surface_transformation;
169   ProcResolver gl_proc_resolver;
170   // When the embedder specifies that a texture has a frame available, the
171   // engine will call this method (on an internal engine managed thread) so that
172   // external texture details can be supplied to the engine for subsequent
173   // composition.
174   TextureFrameCallback gl_external_texture_frame_callback;
175 } FlutterOpenGLRendererConfig;
176 
177 typedef struct {
178   // The size of this struct. Must be sizeof(FlutterSoftwareRendererConfig).
179   size_t struct_size;
180   // The callback presented to the embedder to present a fully populated buffer
181   // to the user. The pixel format of the buffer is the native 32-bit RGBA
182   // format. The buffer is owned by the Flutter engine and must be copied in
183   // this callback if needed.
184   SoftwareSurfacePresentCallback surface_present_callback;
185 } FlutterSoftwareRendererConfig;
186 
187 typedef struct {
188   FlutterRendererType type;
189   union {
190     FlutterOpenGLRendererConfig open_gl;
191     FlutterSoftwareRendererConfig software;
192   };
193 } FlutterRendererConfig;
194 
195 typedef struct {
196   // The size of this struct. Must be sizeof(FlutterWindowMetricsEvent).
197   size_t struct_size;
198   // Physical width of the window.
199   size_t width;
200   // Physical height of the window.
201   size_t height;
202   // Scale factor for the physical screen.
203   double pixel_ratio;
204 } FlutterWindowMetricsEvent;
205 
206 // The phase of the pointer event.
207 typedef enum {
208   kCancel,
209   // The pointer, which must have been down (see kDown), is now up.
210   //
211   // For touch, this means that the pointer is no longer in contact with the
212   // screen. For a mouse, it means the last button was released. Note that if
213   // any other buttons are still pressed when one button is released, that
214   // should be sent as a kMove rather than a kUp.
215   kUp,
216   // The pointer, which must have been been up, is now down.
217   //
218   // For touch, this means that the pointer has come into contact with the
219   // screen. For a mouse, it means a button is now pressed. Note that if any
220   // other buttons are already pressed when a new button is pressed, that should
221   // be sent as a kMove rather than a kDown.
222   kDown,
223   // The pointer moved while down.
224   //
225   // This is also used for changes in button state that don't cause a kDown or
226   // kUp, such as releasing one of two pressed buttons.
227   kMove,
228   // The pointer is now sending input to Flutter. For instance, a mouse has
229   // entered the area where the Flutter content is displayed.
230   //
231   // A pointer should always be added before sending any other events.
232   kAdd,
233   // The pointer is no longer sending input to Flutter. For instance, a mouse
234   // has left the area where the Flutter content is displayed.
235   //
236   // A removed pointer should no longer send events until sending a new kAdd.
237   kRemove,
238   // The pointer moved while up.
239   kHover,
240 } FlutterPointerPhase;
241 
242 // The device type that created a pointer event.
243 typedef enum {
244   kFlutterPointerDeviceKindMouse = 1,
245   kFlutterPointerDeviceKindTouch,
246 } FlutterPointerDeviceKind;
247 
248 // Flags for the |buttons| field of |FlutterPointerEvent| when |device_kind|
249 // is |kFlutterPointerDeviceKindMouse|.
250 typedef enum {
251   kFlutterPointerButtonMousePrimary = 1 << 0,
252   kFlutterPointerButtonMouseSecondary = 1 << 1,
253   kFlutterPointerButtonMouseMiddle = 1 << 2,
254   kFlutterPointerButtonMouseBack = 1 << 3,
255   kFlutterPointerButtonMouseForward = 1 << 4,
256   // If a mouse has more than five buttons, send higher bit shifted values
257   // corresponding to the button number: 1 << 5 for the 6th, etc.
258 } FlutterPointerMouseButtons;
259 
260 // The type of a pointer signal.
261 typedef enum {
262   kFlutterPointerSignalKindNone,
263   kFlutterPointerSignalKindScroll,
264 } FlutterPointerSignalKind;
265 
266 typedef struct {
267   // The size of this struct. Must be sizeof(FlutterPointerEvent).
268   size_t struct_size;
269   FlutterPointerPhase phase;
270   size_t timestamp;  // in microseconds.
271   double x;
272   double y;
273   // An optional device identifier. If this is not specified, it is assumed that
274   // the embedder has no multi-touch capability.
275   int32_t device;
276   FlutterPointerSignalKind signal_kind;
277   double scroll_delta_x;
278   double scroll_delta_y;
279   // The type of the device generating this event.
280   // Backwards compatibility note: If this is not set, the device will be
281   // treated as a mouse, with the primary button set for |kDown| and |kMove|.
282   // If set explicitly to |kFlutterPointerDeviceKindMouse|, you must set the
283   // correct buttons.
284   FlutterPointerDeviceKind device_kind;
285   // The buttons currently pressed, if any.
286   int64_t buttons;
287 } FlutterPointerEvent;
288 
289 struct _FlutterPlatformMessageResponseHandle;
290 typedef struct _FlutterPlatformMessageResponseHandle
291     FlutterPlatformMessageResponseHandle;
292 
293 typedef struct {
294   // The size of this struct. Must be sizeof(FlutterPlatformMessage).
295   size_t struct_size;
296   const char* channel;
297   const uint8_t* message;
298   size_t message_size;
299   // The response handle on which to invoke
300   // |FlutterEngineSendPlatformMessageResponse| when the response is ready.
301   // |FlutterEngineSendPlatformMessageResponse| must be called for all messages
302   // received by the embedder. Failure to call
303   // |FlutterEngineSendPlatformMessageResponse| will cause a memory leak. It is
304   // not safe to send multiple responses on a single response object.
305   const FlutterPlatformMessageResponseHandle* response_handle;
306 } FlutterPlatformMessage;
307 
308 typedef void (*FlutterPlatformMessageCallback)(
309     const FlutterPlatformMessage* /* message*/,
310     void* /* user data */);
311 
312 typedef void (*FlutterDataCallback)(const uint8_t* /* data */,
313                                     size_t /* size */,
314                                     void* /* user data */);
315 
316 typedef struct {
317   double left;
318   double top;
319   double right;
320   double bottom;
321 } FlutterRect;
322 
323 typedef struct _FlutterTaskRunner* FlutterTaskRunner;
324 
325 typedef struct {
326   FlutterTaskRunner runner;
327   uint64_t task;
328 } FlutterTask;
329 
330 typedef void (*FlutterTaskRunnerPostTaskCallback)(
331     FlutterTask /* task */,
332     uint64_t /* target time nanos */,
333     void* /* user data */);
334 
335 // An interface used by the Flutter engine to execute tasks at the target time
336 // on a specified thread. There should be a 1-1 relationship between a thread
337 // and a task runner. It is undefined behavior to run a task on a thread that is
338 // not associated with its task runner.
339 typedef struct {
340   // The size of this struct. Must be sizeof(FlutterTaskRunnerDescription).
341   size_t struct_size;
342   void* user_data;
343   // May be called from any thread. Should return true if tasks posted on the
344   // calling thread will be run on that same thread.
345   //
346   // This field is required.
347   BoolCallback runs_task_on_current_thread_callback;
348   // May be called from any thread. The given task should be executed by the
349   // embedder on the thread associated with that task runner by calling
350   // |FlutterEngineRunTask| at the given target time. The system monotonic clock
351   // should be used for the target time. The target time is the absolute time
352   // from epoch (NOT a delta) at which the task must be returned back to the
353   // engine on the correct thread. If the embedder needs to calculate a delta,
354   // |FlutterEngineGetCurrentTime| may be called and the difference used as the
355   // delta.
356   //
357   // This field is required.
358   FlutterTaskRunnerPostTaskCallback post_task_callback;
359 } FlutterTaskRunnerDescription;
360 
361 typedef struct {
362   // The size of this struct. Must be sizeof(FlutterCustomTaskRunners).
363   size_t struct_size;
364   // Specify the task runner for the thread on which the |FlutterEngineRun| call
365   // is made.
366   const FlutterTaskRunnerDescription* platform_task_runner;
367 } FlutterCustomTaskRunners;
368 
369 typedef struct {
370   // The type of the OpenGL backing store. Currently, it can either be a texture
371   // or a framebuffer.
372   FlutterOpenGLTargetType type;
373   union {
374     // A texture for Flutter to render into.
375     FlutterOpenGLTexture texture;
376     // A framebuffer for Flutter to render into. The embedder must ensure that
377     // the framebuffer is complete.
378     FlutterOpenGLFramebuffer framebuffer;
379   };
380 } FlutterOpenGLBackingStore;
381 
382 typedef struct {
383   // A pointer to the raw bytes of the allocation described by this software
384   // backing store.
385   const void* allocation;
386   // The number of bytes in a single row of the allocation.
387   size_t row_bytes;
388   // The number of rows in the allocation.
389   size_t height;
390   // A baton that is not interpreted by the engine in any way. It will be given
391   // back to the embedder in the destruction callback below. Embedder resources
392   // may be associated with this baton.
393   void* user_data;
394   // The callback invoked by the engine when it no longer needs this backing
395   // store.
396   VoidCallback destruction_callback;
397 } FlutterSoftwareBackingStore;
398 
399 // The identifier of the platform view. This identifier is specified by the
400 // application when a platform view is added to the scene via the
401 // `SceneBuilder.addPlatformView` call.
402 typedef int64_t FlutterPlatformViewIdentifier;
403 
404 typedef struct {
405   // The size of this struct. Must be sizeof(FlutterPlatformView).
406   size_t struct_size;
407   // The identifier of this platform view. This identifier is specified by the
408   // application when a platform view is added to the scene via the
409   // `SceneBuilder.addPlatformView` call.
410   FlutterPlatformViewIdentifier identifier;
411 } FlutterPlatformView;
412 
413 typedef enum {
414   // Specifies an OpenGL backing store. Can either be an OpenGL texture or
415   // framebuffer.
416   kFlutterBackingStoreTypeOpenGL,
417   // Specified an software allocation for Flutter to render into using the CPU.
418   kFlutterBackingStoreTypeSoftware,
419 } FlutterBackingStoreType;
420 
421 typedef struct {
422   // The size of this struct. Must be sizeof(FlutterBackingStore).
423   size_t struct_size;
424   // A baton that is not interpreted by the engine in any way. The embedder may
425   // use this to associate resources that are tied to the lifecycle of the
426   // |FlutterBackingStore|.
427   void* user_data;
428   // Specifies the type of backing store.
429   FlutterBackingStoreType type;
430   // Indicates if this backing store was updated since the last time it was
431   // associated with a presented layer.
432   bool did_update;
433   union {
434     // The description of the OpenGL backing store.
435     FlutterOpenGLBackingStore open_gl;
436     // The description of the software backing store.
437     FlutterSoftwareBackingStore software;
438   };
439 } FlutterBackingStore;
440 
441 typedef struct {
442   double x;
443   double y;
444 } FlutterPoint;
445 
446 typedef struct {
447   double width;
448   double height;
449 } FlutterSize;
450 
451 typedef struct {
452   // The size of this struct. Must be sizeof(FlutterBackingStoreConfig).
453   size_t struct_size;
454   // The size of the render target the engine expects to render into.
455   FlutterSize size;
456 } FlutterBackingStoreConfig;
457 
458 typedef enum {
459   // Indicates that the contents of this layer are rendered by Flutter into a
460   // backing store.
461   kFlutterLayerContentTypeBackingStore,
462   // Indicates that the contents of this layer are determined by the embedder.
463   kFlutterLayerContentTypePlatformView,
464 } FlutterLayerContentType;
465 
466 typedef struct {
467   // This size of this struct. Must be sizeof(FlutterLayer).
468   size_t struct_size;
469   // Each layer displays contents in one way or another. The type indicates
470   // whether those contents are specified by Flutter or the embedder.
471   FlutterLayerContentType type;
472   union {
473     // Indicates that the contents of this layer are rendered by Flutter into a
474     // backing store.
475     const FlutterBackingStore* backing_store;
476     // Indicates that the contents of this layer are determined by the embedder.
477     const FlutterPlatformView* platform_view;
478   };
479   // The offset of this layer (in physical pixels) relative to the top left of
480   // the root surface used by the engine.
481   FlutterPoint offset;
482   // The size of the layer (in physical pixels).
483   FlutterSize size;
484 } FlutterLayer;
485 
486 typedef bool (*FlutterBackingStoreCreateCallback)(
487     const FlutterBackingStoreConfig* config,
488     FlutterBackingStore* backing_store_out,
489     void* user_data);
490 
491 typedef bool (*FlutterBackingStoreCollectCallback)(
492     const FlutterBackingStore* renderer,
493     void* user_data);
494 
495 typedef bool (*FlutterLayersPresentCallback)(const FlutterLayer** layers,
496                                              size_t layers_count,
497                                              void* user_data);
498 
499 typedef struct {
500   // This size of this struct. Must be sizeof(FlutterCompositor).
501   size_t struct_size;
502   // A baton that in not interpreted by the engine in any way. If it passed back
503   // to the embedder in  |FlutterCompositor.create_backing_store_callback|,
504   // |FlutterCompositor.collect_backing_store_callback| and
505   // |FlutterCompositor.present_layers_callback|
506   void* user_data;
507   // A callback invoked by the engine to obtain a backing store for a specific
508   // |FlutterLayer|.
509   //
510   // On ABI stability: Callers must take care to restrict access within
511   // |FlutterBackingStore::struct_size| when specifying a new backing store to
512   // the engine. This only matters if the embedder expects to be used with
513   // engines older than the version whose headers it used during compilation.
514   FlutterBackingStoreCreateCallback create_backing_store_callback;
515   // A callback invoked by the engine to release the backing store. The embedder
516   // may collect any resources associated with the backing store.
517   FlutterBackingStoreCollectCallback collect_backing_store_callback;
518   // Callback invoked by the engine to composite the contents of each layer onto
519   // the screen.
520   FlutterLayersPresentCallback present_layers_callback;
521 } FlutterCompositor;
522 
523 typedef struct {
524   // The size of this struct. Must be sizeof(FlutterProjectArgs).
525   size_t struct_size;
526 
527   // A callback that gets invoked by the engine when it attempts to wait for a
528   // platform vsync event. The engine will give the platform a baton that needs
529   // to be returned back to the engine via |FlutterEngineOnVsync|. All batons
530   // must be retured to the engine before initializing a
531   // |FlutterEngineShutdown|. Not doing the same will result in a memory leak.
532   // While the call to |FlutterEngineOnVsync| must occur on the thread that made
533   // the call to |FlutterEngineRun|, the engine will make this callback on an
534   // internal engine-managed thread. If the components accessed on the embedder
535   // are not thread safe, the appropriate re-threading must be done.
536   VsyncCallback vsync_callback;
537 
538   // Typically the Flutter engine create and manages its internal threads. This
539   // optional argument allows for the specification of task runner interfaces to
540   // event loops managed by the embedder on threads it creates.
541   const FlutterCustomTaskRunners* custom_task_runners;
542 
543   // Typically, Flutter renders the layer hierarchy into a single root surface.
544   // However, when embedders need to interleave their own contents within the
545   // Flutter layer hierarchy, their applications can push platform views within
546   // the Flutter scene. This is done using the `SceneBuilder.addPlatformView`
547   // call. When this happens, the Flutter rasterizer divides the effective view
548   // hierarchy into multiple layers. Each layer gets its own backing store and
549   // Flutter renders into the same. Once the layers contents have been
550   // fulfilled, the embedder is asked to composite these layers on-screen. At
551   // this point, it can interleave its own contents within the effective
552   // hierarchy. The interface for the specification of these layer backing
553   // stores and the hooks to listen for the composition of layers on-screen can
554   // be controlled using this field. This field is completely optional. In its
555   // absence, platforms views in the scene are ignored and Flutter renders to
556   // the root surface as normal.
557   const FlutterCompositor* compositor;
558 } FlutterProjectArgs;
559 
560 FLUTTER_EXPORT
561 FlutterEngineResult FlutterEngineRun(const FlutterRendererConfig* config,
562                                      const FlutterProjectArgs* args,
563                                      void* user_data,
564                                      FLUTTER_API_SYMBOL(FlutterEngine) *
565                                          engine_out);
566 
567 FLUTTER_EXPORT
568 FlutterEngineResult FlutterEngineShutdown(FLUTTER_API_SYMBOL(FlutterEngine)
569                                               engine);
570 
571 FLUTTER_EXPORT
572 FlutterEngineResult FlutterEngineSetIdleNotificationCallback(
573     FLUTTER_API_SYMBOL(FlutterEngine) engine,
574     const IdleCallback& idle_notification_callback);
575 
576 FLUTTER_EXPORT
577 FlutterEngineResult FlutterEngineSendWindowMetricsEvent(
578     FLUTTER_API_SYMBOL(FlutterEngine) engine,
579     const FlutterWindowMetricsEvent* event);
580 
581 FLUTTER_EXPORT
582 FlutterEngineResult FlutterEngineSendPointerEvent(
583     FLUTTER_API_SYMBOL(FlutterEngine) engine,
584     const FlutterPointerEvent* events,
585     size_t events_count);
586 
587 FLUTTER_EXPORT
588 FlutterEngineResult FlutterEngineSendPlatformMessage(
589     FLUTTER_API_SYMBOL(FlutterEngine) engine,
590     const FlutterPlatformMessage* message);
591 
592 // Creates a platform message response handle that allows the embedder to set a
593 // native callback for a response to a message. This handle may be set on the
594 // |response_handle| field of any |FlutterPlatformMessage| sent to the engine.
595 //
596 // The handle must be collected via a call to
597 // |FlutterPlatformMessageReleaseResponseHandle|. This may be done immediately
598 // after a call to |FlutterEngineSendPlatformMessage| with a platform message
599 // whose response handle contains the handle created using this call. In case a
600 // handle is created but never sent in a message, the release call must still be
601 // made. Not calling release on the handle results in a small memory leak.
602 //
603 // The user data baton passed to the data callback is the one specified in this
604 // call as the third argument.
605 FLUTTER_EXPORT
606 FlutterEngineResult FlutterPlatformMessageCreateResponseHandle(
607     FLUTTER_API_SYMBOL(FlutterEngine) engine,
608     FlutterDataCallback data_callback,
609     void* user_data,
610     FlutterPlatformMessageResponseHandle** response_out);
611 
612 // Collects the handle created using
613 // |FlutterPlatformMessageCreateResponseHandle|.
614 FLUTTER_EXPORT
615 FlutterEngineResult FlutterPlatformMessageReleaseResponseHandle(
616     FLUTTER_API_SYMBOL(FlutterEngine) engine,
617     FlutterPlatformMessageResponseHandle* response);
618 
619 FLUTTER_EXPORT
620 FlutterEngineResult FlutterEngineSendPlatformMessageResponse(
621     FLUTTER_API_SYMBOL(FlutterEngine) engine,
622     const FlutterPlatformMessageResponseHandle* handle,
623     const uint8_t* data,
624     size_t data_length);
625 
626 // This API is only meant to be used by platforms that need to flush tasks on a
627 // message loop not controlled by the Flutter engine. This API will be
628 // deprecated soon.
629 FLUTTER_EXPORT
630 FlutterEngineResult __FlutterEngineFlushPendingTasksNow();
631 
632 // Register an external texture with a unique (per engine) identifier. Only
633 // rendering backends that support external textures accept external texture
634 // registrations. After the external texture is registered, the application can
635 // mark that a frame is available by calling
636 // |FlutterEngineMarkExternalTextureFrameAvailable|.
637 FLUTTER_EXPORT
638 FlutterEngineResult FlutterEngineRegisterExternalTexture(
639     FLUTTER_API_SYMBOL(FlutterEngine) engine,
640     int64_t texture_identifier);
641 
642 // Unregister a previous texture registration.
643 FLUTTER_EXPORT
644 FlutterEngineResult FlutterEngineUnregisterExternalTexture(
645     FLUTTER_API_SYMBOL(FlutterEngine) engine,
646     int64_t texture_identifier);
647 
648 // Mark that a new texture frame is available for a given texture identifier.
649 FLUTTER_EXPORT
650 FlutterEngineResult FlutterEngineMarkExternalTextureFrameAvailable(
651     FLUTTER_API_SYMBOL(FlutterEngine) engine,
652     int64_t texture_identifier);
653 
654 // Notify the engine that a vsync event occurred. A baton passed to the
655 // platform via the vsync callback must be returned. This call must be made on
656 // the thread on which the call to |FlutterEngineRun| was made.
657 //
658 // |frame_start_time_nanos| is the point at which the vsync event occurred or
659 // will occur. If the time point is in the future, the engine will wait till
660 // that point to begin its frame workload. The system monotonic clock is used as
661 // the timebase.
662 //
663 // |frame_target_time_nanos| is the point at which the embedder anticipates the
664 // next vsync to occur. This is a hint the engine uses to schedule Dart VM
665 // garbage collection in periods in which the various threads are most likely to
666 // be idle. For example, for a 60Hz display, embedders should add 16.6 * 1e6 to
667 // the frame time field. The system monotonic clock is used as the timebase.
668 //
669 // That frame timepoints are in nanoseconds.
670 FLUTTER_EXPORT
671 FlutterEngineResult FlutterEngineOnVsync(FLUTTER_API_SYMBOL(FlutterEngine)
672                                              engine,
673                                          intptr_t baton,
674                                          uint64_t frame_start_time_nanos,
675                                          uint64_t frame_target_time_nanos);
676 
677 // A profiling utility. Logs a trace duration begin event to the timeline. If
678 // the timeline is unavailable or disabled, this has no effect. Must be
679 // balanced with an duration end event (via
680 // |FlutterEngineTraceEventDurationEnd|) with the same name on the same thread.
681 // Can be called on any thread. Strings passed into the function will NOT be
682 // copied when added to the timeline. Only string literals may be passed in.
683 FLUTTER_EXPORT
684 void FlutterEngineTraceEventDurationBegin(const char* name);
685 
686 // A profiling utility. Logs a trace duration end event to the timeline. If the
687 // timeline is unavailable or disabled, this has no effect. This call must be
688 // preceded by a trace duration begin call (via
689 // |FlutterEngineTraceEventDurationBegin|) with the same name on the same
690 // thread. Can be called on any thread. Strings passed into the function will
691 // NOT be copied when added to the timeline. Only string literals may be passed
692 // in.
693 FLUTTER_EXPORT
694 void FlutterEngineTraceEventDurationEnd(const char* name);
695 
696 // A profiling utility. Logs a trace duration instant event to the timeline. If
697 // the timeline is unavailable or disabled, this has no effect. Can be called
698 // on any thread. Strings passed into the function will NOT be copied when added
699 // to the timeline. Only string literals may be passed in.
700 FLUTTER_EXPORT
701 void FlutterEngineTraceEventInstant(const char* name);
702 
703 // Posts a task onto the Flutter render thread. Typically, this may be called
704 // from any thread as long as a |FlutterEngineShutdown| on the specific engine
705 // has not already been initiated.
706 FLUTTER_EXPORT
707 FlutterEngineResult FlutterEnginePostRenderThreadTask(
708     FLUTTER_API_SYMBOL(FlutterEngine) engine,
709     VoidCallback callback,
710     void* callback_data);
711 
712 // Get the current time in nanoseconds from the clock used by the flutter
713 // engine. This is the system monotonic clock.
714 FLUTTER_EXPORT
715 uint64_t FlutterEngineGetCurrentTime();
716 
717 // Inform the engine to run the specified task. This task has been given to
718 // the engine via the |FlutterTaskRunnerDescription.post_task_callback|. This
719 // call must only be made at the target time specified in that callback. Running
720 // the task before that time is undefined behavior.
721 FLUTTER_EXPORT
722 FlutterEngineResult FlutterEngineRunTask(FLUTTER_API_SYMBOL(FlutterEngine)
723                                              engine,
724                                          const FlutterTask* task);
725 
726 #ifdef USE_GLFW_WINDOW
727 FLUTTER_EXPORT
728 void FlutterEngineRegisterHandleTouchEventCallback(HandleTouchEventCallback&& callback);
729 #endif
730 
731 #if defined(__cplusplus)
732 }  // extern "C"
733 #endif
734 
735 #endif  // FLUTTER_EMBEDDER_H_
736