Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 6bc70e4

Browse files
authored
Reland: Migration to PlatformDispatcher and multi-window (#21932)
This re-lands #20496 and #21780 after fixing the semantics-enabling code that was causing the post-submit web_smoke_test to fail. Below is the description from the original PR: This is a PR for converting the dart:ui code in the engine to use a multi-window API. The goal here is to convert from the window singleton to an API that has the concept of multiple windows. Also, I'm matching up the new PlatformDispatcher class to talk directly to the PlatformConfiguration class in the engine. I'm not attempting to actually enable creating multiple windows here, just migrate to an API that has a concept of multiple windows. The multi-window API in this PR currently only ever creates one window. The design doc for this change is here. The major changes in this PR: Move the platfom-specific attributes out of Window, and into the new PlatformDispatcher class that holds all of the platform state, so that the platform code need only update the configuration on this class. Create FlutterView, FlutterWindow, and SingletonFlutterWindow classes to separate out the concepts of a view (of which there may be multiple in a window), a window (of which there may be multiple on a screen, and they host views), and a window where there is only ever expected to be one (this hosts the entire API of the former Window class, and will eventually be the type of the window singleton). Next step after this PR lands: Remove the Window class entirely (it is replaced by SingletonFlutterWindow). Some minor changes in the Framework are needed to switch to using SingletonFlutterWindow directly first. The Window class still exists in this PR, but will be removed as soon as the framework is converted to point to the SingletonFlutterWindow class instead. They share the same API, just have different names (Window is currently a subclass of SingletonFlutterWindow). The intention is that the Window name will be freed up to use as a widget class name in the framework for managing windows. The singleton called window will remain, and keep the same API it has now.
1 parent aed8e01 commit 6bc70e4

File tree

75 files changed

+4400
-2540
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+4400
-2540
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ FILE: ../../../flutter/lib/ui/painting/single_frame_codec.h
371371
FILE: ../../../flutter/lib/ui/painting/vertices.cc
372372
FILE: ../../../flutter/lib/ui/painting/vertices.h
373373
FILE: ../../../flutter/lib/ui/painting/vertices_unittests.cc
374+
FILE: ../../../flutter/lib/ui/platform_dispatcher.dart
374375
FILE: ../../../flutter/lib/ui/plugins.dart
375376
FILE: ../../../flutter/lib/ui/plugins/callback_cache.cc
376377
FILE: ../../../flutter/lib/ui/plugins/callback_cache.h
@@ -500,6 +501,7 @@ FILE: ../../../flutter/lib/web_ui/lib/src/engine/keyboard.dart
500501
FILE: ../../../flutter/lib/web_ui/lib/src/engine/mouse_cursor.dart
501502
FILE: ../../../flutter/lib/web_ui/lib/src/engine/onscreen_logging.dart
502503
FILE: ../../../flutter/lib/web_ui/lib/src/engine/picture.dart
504+
FILE: ../../../flutter/lib/web_ui/lib/src/engine/platform_dispatcher.dart
503505
FILE: ../../../flutter/lib/web_ui/lib/src/engine/platform_views.dart
504506
FILE: ../../../flutter/lib/web_ui/lib/src/engine/plugins.dart
505507
FILE: ../../../flutter/lib/web_ui/lib/src/engine/pointer_binding.dart
@@ -554,6 +556,7 @@ FILE: ../../../flutter/lib/web_ui/lib/src/ui/natives.dart
554556
FILE: ../../../flutter/lib/web_ui/lib/src/ui/painting.dart
555557
FILE: ../../../flutter/lib/web_ui/lib/src/ui/path.dart
556558
FILE: ../../../flutter/lib/web_ui/lib/src/ui/path_metrics.dart
559+
FILE: ../../../flutter/lib/web_ui/lib/src/ui/platform_dispatcher.dart
557560
FILE: ../../../flutter/lib/web_ui/lib/src/ui/pointer.dart
558561
FILE: ../../../flutter/lib/web_ui/lib/src/ui/semantics.dart
559562
FILE: ../../../flutter/lib/web_ui/lib/src/ui/test_embedding.dart

lib/ui/compositing.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ part of dart.ui;
1010
///
1111
/// To create a Scene object, use a [SceneBuilder].
1212
///
13-
/// Scene objects can be displayed on the screen using the
14-
/// [Window.render] method.
13+
/// Scene objects can be displayed on the screen using the [FlutterView.render]
14+
/// method.
1515
@pragma('vm:entry-point')
1616
class Scene extends NativeFieldWrapperClass2 {
1717
/// This class is created by the engine, and should not be instantiated
@@ -186,7 +186,7 @@ class PhysicalShapeEngineLayer extends _EngineLayerWrapper {
186186

187187
/// Builds a [Scene] containing the given visuals.
188188
///
189-
/// A [Scene] can then be rendered using [Window.render].
189+
/// A [Scene] can then be rendered using [FlutterView.render].
190190
///
191191
/// To draw graphical operations onto a [Scene], first create a
192192
/// [Picture] using a [PictureRecorder] and a [Canvas], and then add
@@ -655,13 +655,13 @@ class SceneBuilder extends NativeFieldWrapperClass2 {
655655
/// - 0x08: visualizeEngineStatistics - graph UI thread frame times
656656
/// Set enabledOptions to 0x0F to enable all the currently defined features.
657657
///
658-
/// The "UI thread" is the thread that includes all the execution of
659-
/// the main Dart isolate (the isolate that can call
660-
/// [Window.render]). The UI thread frame time is the total time
661-
/// spent executing the [Window.onBeginFrame] callback. The "raster
662-
/// thread" is the thread (running on the CPU) that subsequently
663-
/// processes the [Scene] provided by the Dart code to turn it into
664-
/// GPU commands and send it to the GPU.
658+
/// The "UI thread" is the thread that includes all the execution of the main
659+
/// Dart isolate (the isolate that can call [FlutterView.render]). The UI
660+
/// thread frame time is the total time spent executing the
661+
/// [PlatformDispatcher.onBeginFrame] callback. The "raster thread" is the
662+
/// thread (running on the CPU) that subsequently processes the [Scene]
663+
/// provided by the Dart code to turn it into GPU commands and send it to the
664+
/// GPU.
665665
///
666666
/// See also the [PerformanceOverlayOption] enum in the rendering library.
667667
/// for more details.
@@ -802,7 +802,7 @@ class SceneBuilder extends NativeFieldWrapperClass2 {
802802
///
803803
/// Returns a [Scene] containing the objects that have been added to
804804
/// this scene builder. The [Scene] can then be displayed on the
805-
/// screen with [Window.render].
805+
/// screen with [FlutterView.render].
806806
///
807807
/// After calling this function, the scene builder object is invalid and
808808
/// cannot be used further.

lib/ui/compositing/scene.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ Scene::Scene(std::shared_ptr<flutter::Layer> rootLayer,
4242
uint32_t rasterizerTracingThreshold,
4343
bool checkerboardRasterCacheImages,
4444
bool checkerboardOffscreenLayers) {
45+
// Currently only supports a single window.
4546
auto viewport_metrics = UIDartState::Current()
4647
->platform_configuration()
47-
->window()
48+
->get_window(0)
4849
->viewport_metrics();
4950

5051
layer_tree_ = std::make_unique<LayerTree>(

lib/ui/dart_ui.gni

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ dart_ui_files = [
1313
"//flutter/lib/ui/lerp.dart",
1414
"//flutter/lib/ui/natives.dart",
1515
"//flutter/lib/ui/painting.dart",
16+
"//flutter/lib/ui/platform_dispatcher.dart",
1617
"//flutter/lib/ui/plugins.dart",
1718
"//flutter/lib/ui/pointer.dart",
1819
"//flutter/lib/ui/semantics.dart",

0 commit comments

Comments
 (0)