This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[framework] make ImageFiltered a repaint boundary (#116385)
* ++ * ++ * ++
- Loading branch information
1 parent
5c97543
commit e065c7f
Showing
3 changed files
with
75 additions
and
22 deletions.
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
57 changes: 57 additions & 0 deletions
57
packages/flutter/test/widgets/animated_image_filtered_repaint_test.dart
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,57 @@ | ||
// Copyright 2014 The Flutter 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:ui'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/rendering.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
testWidgets('ImageFiltered avoids repainting child as it animates', (WidgetTester tester) async { | ||
RenderTestObject.paintCount = 0; | ||
await tester.pumpWidget( | ||
Container( | ||
color: Colors.red, | ||
child: ImageFiltered( | ||
imageFilter: ImageFilter.blur(sigmaX: 5, sigmaY: 5), | ||
child: const TestWidget(), | ||
), | ||
) | ||
); | ||
|
||
expect(RenderTestObject.paintCount, 1); | ||
|
||
await tester.pumpWidget( | ||
Container( | ||
color: Colors.red, | ||
child: ImageFiltered( | ||
imageFilter: ImageFilter.blur(sigmaX: 6, sigmaY: 6), | ||
child: const TestWidget(), | ||
), | ||
) | ||
); | ||
|
||
expect(RenderTestObject.paintCount, 1); | ||
}); | ||
} | ||
|
||
class TestWidget extends SingleChildRenderObjectWidget { | ||
const TestWidget({super.key, super.child}); | ||
|
||
@override | ||
RenderObject createRenderObject(BuildContext context) { | ||
return RenderTestObject(); | ||
} | ||
} | ||
|
||
class RenderTestObject extends RenderProxyBox { | ||
static int paintCount = 0; | ||
|
||
@override | ||
void paint(PaintingContext context, Offset offset) { | ||
paintCount += 1; | ||
super.paint(context, offset); | ||
} | ||
} |
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