Skip to content

Commit b0fd447

Browse files
authored
[engine] Sync Flutter 3.24.1 source code (#71)
1 parent ee1afba commit b0fd447

File tree

3 files changed

+175
-60
lines changed

3 files changed

+175
-60
lines changed

DEPS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ deps = {
66
'src/third_party/rapidjson': 'https://fuchsia.googlesource.com/third_party/rapidjson@ef3564c5c8824989393b87df25355baf35ff544b',
77
'src/third_party/libcxx': 'https://llvm.googlesource.com/llvm-project/libcxx@44079a4cc04cdeffb9cfe8067bfb3c276fb2bab0',
88
'src/third_party/libcxxabi': 'https://llvm.googlesource.com/llvm-project/libcxxabi@2ce528fb5e0f92e57c97ec3ff53b75359d33af12',
9-
'src/third_party/googletest': 'https://github.com/google/googletest@054a986a8513149e8374fc669a5fe40117ca6b41',
10-
'src/third_party/dart': 'https://dart.googlesource.com/sdk.git@1618a775995ef6f862b9f05be61a6a8fc23f2e4d',
9+
'src/third_party/googletest': 'https://github.com/google/googletest@7f036c5563af7d0329f20e8bb42effb04629f0c0',
10+
'src/third_party/dart': 'https://dart.googlesource.com/sdk.git@b9479eb440de7af2c9946931a1ecaabf457b31af',
1111
'src/third_party/clang': {
1212
'packages': [
1313
{

build/secondary/third_party/googletest/BUILD.gn

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,25 @@ static_library("gtest") {
1616
public = [
1717
"googletest/include/gtest/gtest-spi.h",
1818
"googletest/include/gtest/gtest.h",
19+
"googletest/include/gtest/gtest_prod.h",
1920
]
20-
sources = [
21-
"googletest/src/gtest-all.cc",
22-
"googletest/src/gtest-death-test.cc",
23-
"googletest/src/gtest-filepath.cc",
24-
"googletest/src/gtest-internal-inl.h",
25-
"googletest/src/gtest-matchers.cc",
26-
"googletest/src/gtest-port.cc",
27-
"googletest/src/gtest-printers.cc",
28-
"googletest/src/gtest-test-part.cc",
29-
"googletest/src/gtest-typed-test.cc",
30-
"googletest/src/gtest.cc",
31-
]
32-
sources -= [ "googletest/src/gtest-all.cc" ]
21+
22+
# Only add the "*-all.cc" files (and no headers) to improve maintainability
23+
# from upstream refactoring. The "*-all.cc" files include the respective
24+
# source files.
25+
sources = [ "googletest/src/gtest-all.cc" ]
26+
3327
public_configs = [ ":gtest_config" ]
3428
configs += [ ":gtest_private_config" ]
3529
}
3630

31+
# Library that defines the FRIEND_TEST macro.
32+
source_set("gtest_prod") {
33+
testonly = false
34+
public = [ "googletest/include/gtest/gtest_prod.h" ]
35+
public_configs = [ ":gtest_config" ]
36+
}
37+
3738
static_library("gtest_main") {
3839
testonly = true
3940
sources = [ "googletest/src/gtest_main.cc" ]
@@ -61,15 +62,7 @@ config("gmock_config") {
6162
static_library("gmock") {
6263
testonly = true
6364
public = [ "googlemock/include/gmock/gmock.h" ]
64-
sources = [
65-
"googlemock/src/gmock-all.cc",
66-
"googlemock/src/gmock-cardinalities.cc",
67-
"googlemock/src/gmock-internal-utils.cc",
68-
"googlemock/src/gmock-matchers.cc",
69-
"googlemock/src/gmock-spec-builders.cc",
70-
"googlemock/src/gmock.cc",
71-
]
72-
sources -= [ "googlemock/src/gmock-all.cc" ]
65+
sources = [ "googlemock/src/gmock-all.cc" ]
7366
public_configs = [ ":gmock_config" ]
7467
configs += [ ":gmock_private_config" ]
7568
deps = [ ":gtest" ]

flutter/shell/platform/embedder/embedder.h

Lines changed: 158 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ typedef enum {
162162
kFlutterSemanticsActionMoveCursorBackwardByWord = 1 << 20,
163163
/// Replace the current text in the text field.
164164
kFlutterSemanticsActionSetText = 1 << 21,
165+
/// Request that the respective focusable widget gain input focus.
166+
kFlutterSemanticsActionFocus = 1 << 22,
165167
} FlutterSemanticsAction;
166168

167169
/// The set of properties that may be associated with a semantics node.
@@ -844,6 +846,86 @@ typedef struct {
844846
};
845847
} FlutterRendererConfig;
846848

849+
/// Display refers to a graphics hardware system consisting of a framebuffer,
850+
/// typically a monitor or a screen. This ID is unique per display and is
851+
/// stable until the Flutter application restarts.
852+
typedef uint64_t FlutterEngineDisplayId;
853+
854+
typedef struct {
855+
/// The size of this struct. Must be sizeof(FlutterWindowMetricsEvent).
856+
size_t struct_size;
857+
/// Physical width of the window.
858+
size_t width;
859+
/// Physical height of the window.
860+
size_t height;
861+
/// Scale factor for the physical screen.
862+
double pixel_ratio;
863+
/// Horizontal physical location of the left side of the window on the screen.
864+
size_t left;
865+
/// Vertical physical location of the top of the window on the screen.
866+
size_t top;
867+
/// Top inset of window.
868+
double physical_view_inset_top;
869+
/// Right inset of window.
870+
double physical_view_inset_right;
871+
/// Bottom inset of window.
872+
double physical_view_inset_bottom;
873+
/// Left inset of window.
874+
double physical_view_inset_left;
875+
/// The identifier of the display the view is rendering on.
876+
FlutterEngineDisplayId display_id;
877+
/// The view that this event is describing.
878+
int64_t view_id;
879+
} FlutterWindowMetricsEvent;
880+
881+
typedef struct {
882+
/// The size of this struct.
883+
/// Must be sizeof(FlutterAddViewResult).
884+
size_t struct_size;
885+
886+
/// True if the add view operation succeeded.
887+
bool added;
888+
889+
/// The |FlutterAddViewInfo.user_data|.
890+
void* user_data;
891+
} FlutterAddViewResult;
892+
893+
/// The callback invoked by the engine when the engine has attempted to add a
894+
/// view.
895+
///
896+
/// The |FlutterAddViewResult| is only guaranteed to be valid during this
897+
/// callback.
898+
typedef void (*FlutterAddViewCallback)(const FlutterAddViewResult* result);
899+
900+
typedef struct {
901+
/// The size of this struct.
902+
/// Must be sizeof(FlutterAddViewInfo).
903+
size_t struct_size;
904+
905+
/// The identifier for the view to add. This must be unique.
906+
FlutterViewId view_id;
907+
908+
/// The view's properties.
909+
///
910+
/// The metric's |view_id| must match this struct's |view_id|.
911+
const FlutterWindowMetricsEvent* view_metrics;
912+
913+
/// A baton that is not interpreted by the engine in any way. It will be given
914+
/// back to the embedder in |add_view_callback|. Embedder resources may be
915+
/// associated with this baton.
916+
void* user_data;
917+
918+
/// Called once the engine has attempted to add the view. This callback is
919+
/// required.
920+
///
921+
/// The embedder/app must not use the view until the callback is invoked with
922+
/// an `added` value of `true`.
923+
///
924+
/// This callback is invoked on an internal engine managed thread. Embedders
925+
/// must re-thread if necessary.
926+
FlutterAddViewCallback add_view_callback;
927+
} FlutterAddViewInfo;
928+
847929
typedef struct {
848930
/// The size of this struct.
849931
/// Must be sizeof(FlutterRemoveViewResult).
@@ -859,7 +941,8 @@ typedef struct {
859941
/// The callback invoked by the engine when the engine has attempted to remove
860942
/// a view.
861943
///
862-
/// The |FlutterRemoveViewResult| will be deallocated once the callback returns.
944+
/// The |FlutterRemoveViewResult| is only guaranteed to be valid during this
945+
/// callback.
863946
typedef void (*FlutterRemoveViewCallback)(
864947
const FlutterRemoveViewResult* /* result */);
865948

@@ -891,38 +974,6 @@ typedef struct {
891974
FlutterRemoveViewCallback remove_view_callback;
892975
} FlutterRemoveViewInfo;
893976

894-
/// Display refers to a graphics hardware system consisting of a framebuffer,
895-
/// typically a monitor or a screen. This ID is unique per display and is
896-
/// stable until the Flutter application restarts.
897-
typedef uint64_t FlutterEngineDisplayId;
898-
899-
typedef struct {
900-
/// The size of this struct. Must be sizeof(FlutterWindowMetricsEvent).
901-
size_t struct_size;
902-
/// Physical width of the window.
903-
size_t width;
904-
/// Physical height of the window.
905-
size_t height;
906-
/// Scale factor for the physical screen.
907-
double pixel_ratio;
908-
/// Horizontal physical location of the left side of the window on the screen.
909-
size_t left;
910-
/// Vertical physical location of the top of the window on the screen.
911-
size_t top;
912-
/// Top inset of window.
913-
double physical_view_inset_top;
914-
/// Right inset of window.
915-
double physical_view_inset_right;
916-
/// Bottom inset of window.
917-
double physical_view_inset_bottom;
918-
/// Left inset of window.
919-
double physical_view_inset_left;
920-
/// The identifier of the display the view is rendering on.
921-
FlutterEngineDisplayId display_id;
922-
/// The view that this event is describing.
923-
int64_t view_id;
924-
} FlutterWindowMetricsEvent;
925-
926977
/// The phase of the pointer event.
927978
typedef enum {
928979
kCancel,
@@ -1744,6 +1795,9 @@ typedef struct {
17441795
size_t struct_size;
17451796
/// The size of the render target the engine expects to render into.
17461797
FlutterSize size;
1798+
/// The identifier for the view that the engine will use this backing store to
1799+
/// render into.
1800+
FlutterViewId view_id;
17471801
} FlutterBackingStoreConfig;
17481802

17491803
typedef enum {
@@ -1857,18 +1911,26 @@ typedef struct {
18571911
/// `FlutterBackingStore::struct_size` when specifying a new backing store to
18581912
/// the engine. This only matters if the embedder expects to be used with
18591913
/// engines older than the version whose headers it used during compilation.
1914+
///
1915+
/// The callback should return true if the operation was successful.
18601916
FlutterBackingStoreCreateCallback create_backing_store_callback;
18611917
/// A callback invoked by the engine to release the backing store. The
18621918
/// embedder may collect any resources associated with the backing store.
1919+
///
1920+
/// The callback should return true if the operation was successful.
18631921
FlutterBackingStoreCollectCallback collect_backing_store_callback;
18641922
/// Callback invoked by the engine to composite the contents of each layer
18651923
/// onto the implicit view.
18661924
///
1867-
/// DEPRECATED: Use |present_view_callback| to support multiple views.
1925+
/// DEPRECATED: Use `present_view_callback` to support multiple views.
1926+
/// If this callback is provided, `FlutterEngineAddView` and
1927+
/// `FlutterEngineRemoveView` should not be used.
18681928
///
18691929
/// Only one of `present_layers_callback` and `present_view_callback` may be
18701930
/// provided. Providing both is an error and engine initialization will
18711931
/// terminate.
1932+
///
1933+
/// The callback should return true if the operation was successful.
18721934
FlutterLayersPresentCallback present_layers_callback;
18731935
/// Avoid caching backing stores provided by this compositor.
18741936
bool avoid_backing_store_cache;
@@ -1878,6 +1940,8 @@ typedef struct {
18781940
/// Only one of `present_layers_callback` and `present_view_callback` may be
18791941
/// provided. Providing both is an error and engine initialization will
18801942
/// terminate.
1943+
///
1944+
/// The callback should return true if the operation was successful.
18811945
FlutterPresentViewCallback present_view_callback;
18821946
} FlutterCompositor;
18831947

@@ -2188,6 +2252,10 @@ typedef struct {
21882252
/// `update_semantics_callback`, and
21892253
/// `update_semantics_callback2` may be provided; the others
21902254
/// should be set to null.
2255+
///
2256+
/// This callback is incompatible with multiple views. If this
2257+
/// callback is provided, `FlutterEngineAddView` and
2258+
/// `FlutterEngineRemoveView` should not be used.
21912259
FlutterUpdateSemanticsNodeCallback update_semantics_node_callback;
21922260
/// The legacy callback invoked by the engine in order to give the embedder
21932261
/// the chance to respond to updates to semantics custom actions from the Dart
@@ -2204,6 +2272,10 @@ typedef struct {
22042272
/// `update_semantics_callback`, and
22052273
/// `update_semantics_callback2` may be provided; the others
22062274
/// should be set to null.
2275+
///
2276+
/// This callback is incompatible with multiple views. If this
2277+
/// callback is provided, `FlutterEngineAddView` and
2278+
/// `FlutterEngineRemoveView` should not be used.
22072279
FlutterUpdateSemanticsCustomActionCallback
22082280
update_semantics_custom_action_callback;
22092281
/// Path to a directory used to store data that is cached across runs of a
@@ -2353,6 +2425,10 @@ typedef struct {
23532425
/// `update_semantics_callback`, and
23542426
/// `update_semantics_callback2` may be provided; the others
23552427
/// must be set to null.
2428+
///
2429+
/// This callback is incompatible with multiple views. If this
2430+
/// callback is provided, `FlutterEngineAddView` and
2431+
/// `FlutterEngineRemoveView` should not be used.
23562432
FlutterUpdateSemanticsCallback update_semantics_callback;
23572433

23582434
/// The callback invoked by the engine in order to give the embedder the
@@ -2518,12 +2594,50 @@ FLUTTER_EXPORT
25182594
FlutterEngineResult FlutterEngineRunInitialized(
25192595
FLUTTER_API_SYMBOL(FlutterEngine) engine);
25202596

2597+
//------------------------------------------------------------------------------
2598+
/// @brief Adds a view.
2599+
///
2600+
/// This is an asynchronous operation. The view should not be used
2601+
/// until the |info.add_view_callback| is invoked with an |added|
2602+
/// value of true. The embedder should prepare resources in advance
2603+
/// but be ready to clean up on failure.
2604+
///
2605+
/// A frame is scheduled if the operation succeeds.
2606+
///
2607+
/// The callback is invoked on a thread managed by the engine. The
2608+
/// embedder should re-thread if needed.
2609+
///
2610+
/// Attempting to add the implicit view will fail and will return
2611+
/// kInvalidArguments. Attempting to add a view with an already
2612+
/// existing view ID will fail, and |info.add_view_callback| will be
2613+
/// invoked with an |added| value of false.
2614+
///
2615+
/// @param[in] engine A running engine instance.
2616+
/// @param[in] info The add view arguments. This can be deallocated
2617+
/// once |FlutterEngineAddView| returns, before
2618+
/// |add_view_callback| is invoked.
2619+
///
2620+
/// @return The result of *starting* the asynchronous operation. If
2621+
/// `kSuccess`, the |add_view_callback| will be invoked.
2622+
FLUTTER_EXPORT
2623+
FlutterEngineResult FlutterEngineAddView(FLUTTER_API_SYMBOL(FlutterEngine)
2624+
engine,
2625+
const FlutterAddViewInfo* info);
2626+
25212627
//------------------------------------------------------------------------------
25222628
/// @brief Removes a view.
25232629
///
25242630
/// This is an asynchronous operation. The view's resources must not
2525-
/// be cleaned up until the |remove_view_callback| is invoked with
2526-
/// a |removed| value of `true`.
2631+
/// be cleaned up until |info.remove_view_callback| is invoked with
2632+
/// a |removed| value of true.
2633+
///
2634+
/// The callback is invoked on a thread managed by the engine. The
2635+
/// embedder should re-thread if needed.
2636+
///
2637+
/// Attempting to remove the implicit view will fail and will return
2638+
/// kInvalidArguments. Attempting to remove a view with a
2639+
/// non-existent view ID will fail, and |info.remove_view_callback|
2640+
/// will be invoked with a |removed| value of false.
25272641
///
25282642
/// @param[in] engine A running engine instance.
25292643
/// @param[in] info The remove view arguments. This can be deallocated
@@ -3207,6 +3321,12 @@ typedef FlutterEngineResult (*FlutterEngineSetNextFrameCallbackFnPtr)(
32073321
FLUTTER_API_SYMBOL(FlutterEngine) engine,
32083322
VoidCallback callback,
32093323
void* user_data);
3324+
typedef FlutterEngineResult (*FlutterEngineAddViewFnPtr)(
3325+
FLUTTER_API_SYMBOL(FlutterEngine) engine,
3326+
const FlutterAddViewInfo* info);
3327+
typedef FlutterEngineResult (*FlutterEngineRemoveViewFnPtr)(
3328+
FLUTTER_API_SYMBOL(FlutterEngine) engine,
3329+
const FlutterRemoveViewInfo* info);
32103330

32113331
/// Function-pointer-based versions of the APIs above.
32123332
typedef struct {
@@ -3253,6 +3373,8 @@ typedef struct {
32533373
FlutterEngineNotifyDisplayUpdateFnPtr NotifyDisplayUpdate;
32543374
FlutterEngineScheduleFrameFnPtr ScheduleFrame;
32553375
FlutterEngineSetNextFrameCallbackFnPtr SetNextFrameCallback;
3376+
FlutterEngineAddViewFnPtr AddView;
3377+
FlutterEngineRemoveViewFnPtr RemoveView;
32563378
} FlutterEngineProcTable;
32573379

32583380
//------------------------------------------------------------------------------

0 commit comments

Comments
 (0)