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>
82
82
/// The constraints used for the root layout.
83
83
ViewConfiguration get configuration => _configuration;
84
84
ViewConfiguration _configuration;
85
+
85
86
/// The configuration is initially set by the `configuration` argument
86
87
/// passed to the constructor.
87
88
///
@@ -90,8 +91,11 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
90
91
assert (value != null );
91
92
if (configuration == value)
92
93
return ;
94
+ final ViewConfiguration oldConfiguration = _configuration;
93
95
_configuration = value;
94
- replaceRootLayer (_updateMatricesAndCreateNewRootLayer ());
96
+ if (oldConfiguration.toMatrix () != _configuration.toMatrix ()) {
97
+ replaceRootLayer (_updateMatricesAndCreateNewRootLayer ());
98
+ }
95
99
assert (_rootTransform != null );
96
100
markNeedsLayout ();
97
101
}
Original file line number Diff line number Diff line change @@ -47,6 +47,20 @@ void main() {
47
47
view.configuration = createViewConfiguration (devicePixelRatio: 5.0 );
48
48
expect (identical (view.debugLayer, firstLayer), false );
49
49
});
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
+ });
50
64
});
51
65
52
66
test ('ViewConfiguration == and hashCode' , () {
Original file line number Diff line number Diff line change @@ -1779,7 +1779,7 @@ class TestViewConfiguration extends ViewConfiguration {
1779
1779
TestViewConfiguration ._(Size size, ui.FlutterView window)
1780
1780
: _paintMatrix = _getMatrix (size, window.devicePixelRatio, window),
1781
1781
_hitTestMatrix = _getMatrix (size, 1.0 , window),
1782
- super (size: size);
1782
+ super (size: size, devicePixelRatio : window.devicePixelRatio );
1783
1783
1784
1784
static Matrix4 _getMatrix (Size size, double devicePixelRatio, ui.FlutterView window) {
1785
1785
final double inverseRatio = devicePixelRatio / window.devicePixelRatio;
You can’t perform that action at this time.
0 commit comments