forked from flutter/flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
No shrinking for BackdropFilter's cull rect (flutter#28174)
* No shrinking for BackdropFilter's cull rect This will be a breaking change. Our old behavior may generate confusions for a sample app like our added golden test: Skia will shrink the cull rect (and thus the filtered area) to the text. The new behavior will fill the BackdropFilter to its parent/ancestor clip. This is more in align with our clip behaviors (no clip by default). If this breaks your app, wrap the BackdropFilter with a ClipRect. [wip] The golden images are not uploaded yet. I'll wait for the initial round of review to approve the golden test before uploading them. * Statically define the callback * Add TODO to remind the hacking code removal * Nit fix * Update goldens
- Loading branch information
Showing
2 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2018 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'dart:io'; | ||
import 'dart:ui'; | ||
|
||
import 'package:flutter/widgets.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
void main() { | ||
testWidgets('BackdropFilter\'s cull rect does not shrink', (WidgetTester tester) async { | ||
await tester.pumpWidget( | ||
MaterialApp( | ||
home: Scaffold( | ||
body: Stack( | ||
fit: StackFit.expand, | ||
children: <Widget>[ | ||
Text('0 0 ' * 10000), | ||
Center( | ||
// ClipRect needed for filtering the 200x200 area instead of the | ||
// whole screen. | ||
child: ClipRect( | ||
child: BackdropFilter( | ||
filter: ImageFilter.blur( | ||
sigmaX: 5.0, | ||
sigmaY: 5.0, | ||
), | ||
child: Container( | ||
alignment: Alignment.center, | ||
width: 200.0, | ||
height: 200.0, | ||
child: const Text('Hello World'), | ||
), | ||
), | ||
), | ||
), | ||
], | ||
) | ||
) | ||
) | ||
); | ||
await expectLater( | ||
find.byType(RepaintBoundary).first, | ||
matchesGoldenFile('backdrop_filter_test.cull_rect.1.png'), | ||
skip: !Platform.isLinux, | ||
); | ||
}); | ||
} |