Skip to content

Commit 9743862

Browse files
embedder: merge embedder.h from flutter/engine (#416)
Merged from https://github.com/flutter/engine/commits/3.22.0/shell/platform/embedder/embedder.h Signed-off-by: Hidenori Matsubayashi <Hidenori.Matsubayashi@gmail.com>
1 parent f296db8 commit 9743862

File tree

1 file changed

+113
-3
lines changed

1 file changed

+113
-3
lines changed

src/flutter/shell/platform/embedder/embedder.h

Lines changed: 113 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,53 @@ typedef struct {
831831
};
832832
} FlutterRendererConfig;
833833

834+
typedef struct {
835+
/// The size of this struct.
836+
/// Must be sizeof(FlutterRemoveViewResult).
837+
size_t struct_size;
838+
839+
/// True if the remove view operation succeeded.
840+
bool removed;
841+
842+
/// The |FlutterRemoveViewInfo.user_data|.
843+
void* user_data;
844+
} FlutterRemoveViewResult;
845+
846+
/// The callback invoked by the engine when the engine has attempted to remove
847+
/// a view.
848+
///
849+
/// The |FlutterRemoveViewResult| will be deallocated once the callback returns.
850+
typedef void (*FlutterRemoveViewCallback)(
851+
const FlutterRemoveViewResult* /* result */);
852+
853+
typedef struct {
854+
/// The size of this struct.
855+
/// Must be sizeof(FlutterRemoveViewInfo).
856+
size_t struct_size;
857+
858+
/// The identifier for the view to remove.
859+
///
860+
/// The implicit view cannot be removed if it is enabled.
861+
FlutterViewId view_id;
862+
863+
/// A baton that is not interpreted by the engine in any way.
864+
/// It will be given back to the embedder in |remove_view_callback|.
865+
/// Embedder resources may be associated with this baton.
866+
void* user_data;
867+
868+
/// Called once the engine has attempted to remove the view.
869+
/// This callback is required.
870+
///
871+
/// The embedder must not destroy the underlying surface until the callback is
872+
/// invoked with a `removed` value of `true`.
873+
///
874+
/// This callback is invoked on an internal engine managed thread.
875+
/// Embedders must re-thread if necessary.
876+
///
877+
/// The |result| argument will be deallocated when the callback returns.
878+
FlutterRemoveViewCallback remove_view_callback;
879+
} FlutterRemoveViewInfo;
880+
834881
/// Display refers to a graphics hardware system consisting of a framebuffer,
835882
/// typically a monitor or a screen. This ID is unique per display and is
836883
/// stable until the Flutter application restarts.
@@ -859,6 +906,8 @@ typedef struct {
859906
double physical_view_inset_left;
860907
/// The identifier of the display the view is rendering on.
861908
FlutterEngineDisplayId display_id;
909+
/// The view that this event is describing.
910+
int64_t view_id;
862911
} FlutterWindowMetricsEvent;
863912

864913
/// The phase of the pointer event.
@@ -1736,8 +1785,30 @@ typedef struct {
17361785
/// Extra information for the backing store that the embedder may
17371786
/// use during presentation.
17381787
FlutterBackingStorePresentInfo* backing_store_present_info;
1788+
1789+
// Time in nanoseconds at which this frame is scheduled to be presented. 0 if
1790+
// not known. See FlutterEngineGetCurrentTime().
1791+
uint64_t presentation_time;
17391792
} FlutterLayer;
17401793

1794+
typedef struct {
1795+
/// The size of this struct.
1796+
/// Must be sizeof(FlutterPresentViewInfo).
1797+
size_t struct_size;
1798+
1799+
/// The identifier of the target view.
1800+
FlutterViewId view_id;
1801+
1802+
/// The layers that should be composited onto the view.
1803+
const FlutterLayer** layers;
1804+
1805+
/// The count of layers.
1806+
size_t layers_count;
1807+
1808+
/// The |FlutterCompositor.user_data|.
1809+
void* user_data;
1810+
} FlutterPresentViewInfo;
1811+
17411812
typedef bool (*FlutterBackingStoreCreateCallback)(
17421813
const FlutterBackingStoreConfig* config,
17431814
FlutterBackingStore* backing_store_out,
@@ -1751,13 +1822,20 @@ typedef bool (*FlutterLayersPresentCallback)(const FlutterLayer** layers,
17511822
size_t layers_count,
17521823
void* user_data);
17531824

1825+
/// The callback invoked when the embedder should present to a view.
1826+
///
1827+
/// The |FlutterPresentViewInfo| will be deallocated once the callback returns.
1828+
typedef bool (*FlutterPresentViewCallback)(
1829+
const FlutterPresentViewInfo* /* present info */);
1830+
17541831
typedef struct {
17551832
/// This size of this struct. Must be sizeof(FlutterCompositor).
17561833
size_t struct_size;
17571834
/// A baton that in not interpreted by the engine in any way. If it passed
17581835
/// back to the embedder in `FlutterCompositor.create_backing_store_callback`,
1759-
/// `FlutterCompositor.collect_backing_store_callback` and
1760-
/// `FlutterCompositor.present_layers_callback`
1836+
/// `FlutterCompositor.collect_backing_store_callback`,
1837+
/// `FlutterCompositor.present_layers_callback`, and
1838+
/// `FlutterCompositor.present_view_callback`.
17611839
void* user_data;
17621840
/// A callback invoked by the engine to obtain a backing store for a specific
17631841
/// `FlutterLayer`.
@@ -1771,10 +1849,23 @@ typedef struct {
17711849
/// embedder may collect any resources associated with the backing store.
17721850
FlutterBackingStoreCollectCallback collect_backing_store_callback;
17731851
/// Callback invoked by the engine to composite the contents of each layer
1774-
/// onto the screen.
1852+
/// onto the implicit view.
1853+
///
1854+
/// DEPRECATED: Use |present_view_callback| to support multiple views.
1855+
///
1856+
/// Only one of `present_layers_callback` and `present_view_callback` may be
1857+
/// provided. Providing both is an error and engine initialization will
1858+
/// terminate.
17751859
FlutterLayersPresentCallback present_layers_callback;
17761860
/// Avoid caching backing stores provided by this compositor.
17771861
bool avoid_backing_store_cache;
1862+
/// Callback invoked by the engine to composite the contents of each layer
1863+
/// onto the specified view.
1864+
///
1865+
/// Only one of `present_layers_callback` and `present_view_callback` may be
1866+
/// provided. Providing both is an error and engine initialization will
1867+
/// terminate.
1868+
FlutterPresentViewCallback present_view_callback;
17781869
} FlutterCompositor;
17791870

17801871
typedef struct {
@@ -2414,6 +2505,25 @@ FLUTTER_EXPORT
24142505
FlutterEngineResult FlutterEngineRunInitialized(
24152506
FLUTTER_API_SYMBOL(FlutterEngine) engine);
24162507

2508+
//------------------------------------------------------------------------------
2509+
/// @brief Removes a view.
2510+
///
2511+
/// This is an asynchronous operation. The view's resources must not
2512+
/// be cleaned up until the |remove_view_callback| is invoked with
2513+
/// a |removed| value of `true`.
2514+
///
2515+
/// @param[in] engine A running engine instance.
2516+
/// @param[in] info The remove view arguments. This can be deallocated
2517+
/// once |FlutterEngineRemoveView| returns, before
2518+
/// |remove_view_callback| is invoked.
2519+
///
2520+
/// @return The result of *starting* the asynchronous operation. If
2521+
/// `kSuccess`, the |remove_view_callback| will be invoked.
2522+
FLUTTER_EXPORT
2523+
FlutterEngineResult FlutterEngineRemoveView(FLUTTER_API_SYMBOL(FlutterEngine)
2524+
engine,
2525+
const FlutterRemoveViewInfo* info);
2526+
24172527
FLUTTER_EXPORT
24182528
FlutterEngineResult FlutterEngineSendWindowMetricsEvent(
24192529
FLUTTER_API_SYMBOL(FlutterEngine) engine,

0 commit comments

Comments
 (0)