Skip to content

Commit

Permalink
embedder: merge embedder.h from flutter/engine (#416)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
HidenoriMatsubayashi authored May 17, 2024
1 parent f296db8 commit 9743862
Showing 1 changed file with 113 additions and 3 deletions.
116 changes: 113 additions & 3 deletions src/flutter/shell/platform/embedder/embedder.h
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,53 @@ typedef struct {
};
} FlutterRendererConfig;

typedef struct {
/// The size of this struct.
/// Must be sizeof(FlutterRemoveViewResult).
size_t struct_size;

/// True if the remove view operation succeeded.
bool removed;

/// The |FlutterRemoveViewInfo.user_data|.
void* user_data;
} FlutterRemoveViewResult;

/// The callback invoked by the engine when the engine has attempted to remove
/// a view.
///
/// The |FlutterRemoveViewResult| will be deallocated once the callback returns.
typedef void (*FlutterRemoveViewCallback)(
const FlutterRemoveViewResult* /* result */);

typedef struct {
/// The size of this struct.
/// Must be sizeof(FlutterRemoveViewInfo).
size_t struct_size;

/// The identifier for the view to remove.
///
/// The implicit view cannot be removed if it is enabled.
FlutterViewId view_id;

/// A baton that is not interpreted by the engine in any way.
/// It will be given back to the embedder in |remove_view_callback|.
/// Embedder resources may be associated with this baton.
void* user_data;

/// Called once the engine has attempted to remove the view.
/// This callback is required.
///
/// The embedder must not destroy the underlying surface until the callback is
/// invoked with a `removed` value of `true`.
///
/// This callback is invoked on an internal engine managed thread.
/// Embedders must re-thread if necessary.
///
/// The |result| argument will be deallocated when the callback returns.
FlutterRemoveViewCallback remove_view_callback;
} FlutterRemoveViewInfo;

/// Display refers to a graphics hardware system consisting of a framebuffer,
/// typically a monitor or a screen. This ID is unique per display and is
/// stable until the Flutter application restarts.
Expand Down Expand Up @@ -859,6 +906,8 @@ typedef struct {
double physical_view_inset_left;
/// The identifier of the display the view is rendering on.
FlutterEngineDisplayId display_id;
/// The view that this event is describing.
int64_t view_id;
} FlutterWindowMetricsEvent;

/// The phase of the pointer event.
Expand Down Expand Up @@ -1736,8 +1785,30 @@ typedef struct {
/// Extra information for the backing store that the embedder may
/// use during presentation.
FlutterBackingStorePresentInfo* backing_store_present_info;

// Time in nanoseconds at which this frame is scheduled to be presented. 0 if
// not known. See FlutterEngineGetCurrentTime().
uint64_t presentation_time;
} FlutterLayer;

typedef struct {
/// The size of this struct.
/// Must be sizeof(FlutterPresentViewInfo).
size_t struct_size;

/// The identifier of the target view.
FlutterViewId view_id;

/// The layers that should be composited onto the view.
const FlutterLayer** layers;

/// The count of layers.
size_t layers_count;

/// The |FlutterCompositor.user_data|.
void* user_data;
} FlutterPresentViewInfo;

typedef bool (*FlutterBackingStoreCreateCallback)(
const FlutterBackingStoreConfig* config,
FlutterBackingStore* backing_store_out,
Expand All @@ -1751,13 +1822,20 @@ typedef bool (*FlutterLayersPresentCallback)(const FlutterLayer** layers,
size_t layers_count,
void* user_data);

/// The callback invoked when the embedder should present to a view.
///
/// The |FlutterPresentViewInfo| will be deallocated once the callback returns.
typedef bool (*FlutterPresentViewCallback)(
const FlutterPresentViewInfo* /* present info */);

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`
/// `FlutterCompositor.collect_backing_store_callback`,
/// `FlutterCompositor.present_layers_callback`, and
/// `FlutterCompositor.present_view_callback`.
void* user_data;
/// A callback invoked by the engine to obtain a backing store for a specific
/// `FlutterLayer`.
Expand All @@ -1771,10 +1849,23 @@ typedef struct {
/// 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.
/// onto the implicit view.
///
/// DEPRECATED: Use |present_view_callback| to support multiple views.
///
/// Only one of `present_layers_callback` and `present_view_callback` may be
/// provided. Providing both is an error and engine initialization will
/// terminate.
FlutterLayersPresentCallback present_layers_callback;
/// Avoid caching backing stores provided by this compositor.
bool avoid_backing_store_cache;
/// Callback invoked by the engine to composite the contents of each layer
/// onto the specified view.
///
/// Only one of `present_layers_callback` and `present_view_callback` may be
/// provided. Providing both is an error and engine initialization will
/// terminate.
FlutterPresentViewCallback present_view_callback;
} FlutterCompositor;

typedef struct {
Expand Down Expand Up @@ -2414,6 +2505,25 @@ FLUTTER_EXPORT
FlutterEngineResult FlutterEngineRunInitialized(
FLUTTER_API_SYMBOL(FlutterEngine) engine);

//------------------------------------------------------------------------------
/// @brief Removes a view.
///
/// This is an asynchronous operation. The view's resources must not
/// be cleaned up until the |remove_view_callback| is invoked with
/// a |removed| value of `true`.
///
/// @param[in] engine A running engine instance.
/// @param[in] info The remove view arguments. This can be deallocated
/// once |FlutterEngineRemoveView| returns, before
/// |remove_view_callback| is invoked.
///
/// @return The result of *starting* the asynchronous operation. If
/// `kSuccess`, the |remove_view_callback| will be invoked.
FLUTTER_EXPORT
FlutterEngineResult FlutterEngineRemoveView(FLUTTER_API_SYMBOL(FlutterEngine)
engine,
const FlutterRemoveViewInfo* info);

FLUTTER_EXPORT
FlutterEngineResult FlutterEngineSendWindowMetricsEvent(
FLUTTER_API_SYMBOL(FlutterEngine) engine,
Expand Down

0 comments on commit 9743862

Please sign in to comment.