This repository was archived by the owner on Feb 22, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +20
-2
lines changed
Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
8282 /// The constraints used for the root layout.
8383 ViewConfiguration get configuration => _configuration;
8484 ViewConfiguration _configuration;
85+
8586 /// The configuration is initially set by the `configuration` argument
8687 /// passed to the constructor.
8788 ///
@@ -90,8 +91,11 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
9091 assert (value != null );
9192 if (configuration == value)
9293 return ;
94+ final ViewConfiguration oldConfiguration = _configuration;
9395 _configuration = value;
94- replaceRootLayer (_updateMatricesAndCreateNewRootLayer ());
96+ if (oldConfiguration.toMatrix () != _configuration.toMatrix ()) {
97+ replaceRootLayer (_updateMatricesAndCreateNewRootLayer ());
98+ }
9599 assert (_rootTransform != null );
96100 markNeedsLayout ();
97101 }
Original file line number Diff line number Diff line change @@ -47,6 +47,20 @@ void main() {
4747 view.configuration = createViewConfiguration (devicePixelRatio: 5.0 );
4848 expect (identical (view.debugLayer, firstLayer), false );
4949 });
50+
51+ test ('does not replace the root layer unnecessarily when window resize' , () {
52+ final ui.FlutterView window = TestWindow (window: RendererBinding .instance.window);
53+ final RenderView view = RenderView (
54+ configuration: createViewConfiguration (size: const Size (100.0 , 100.0 )),
55+ window: window,
56+ );
57+ final PipelineOwner owner = PipelineOwner ();
58+ view.attach (owner);
59+ view.prepareInitialFrame ();
60+ final ContainerLayer firstLayer = view.debugLayer! ;
61+ view.configuration = createViewConfiguration (size: const Size (100.0 , 1117.0 ));
62+ expect (identical (view.debugLayer, firstLayer), true );
63+ });
5064 });
5165
5266 test ('ViewConfiguration == and hashCode' , () {
Original file line number Diff line number Diff line change @@ -1779,7 +1779,7 @@ class TestViewConfiguration extends ViewConfiguration {
17791779 TestViewConfiguration ._(Size size, ui.FlutterView window)
17801780 : _paintMatrix = _getMatrix (size, window.devicePixelRatio, window),
17811781 _hitTestMatrix = _getMatrix (size, 1.0 , window),
1782- super (size: size);
1782+ super (size: size, devicePixelRatio : window.devicePixelRatio );
17831783
17841784 static Matrix4 _getMatrix (Size size, double devicePixelRatio, ui.FlutterView window) {
17851785 final double inverseRatio = devicePixelRatio / window.devicePixelRatio;
You can’t perform that action at this time.
0 commit comments