Skip to content

Commit 7261b98

Browse files
authored
Enabling the ImageFiltered(ImageFilter.matrix) page of macrobenchmark (flutter#58277)
1 parent 309e0aa commit 7261b98

File tree

9 files changed

+73
-2
lines changed

9 files changed

+73
-2
lines changed

dev/benchmarks/macrobenchmarks/lib/common.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ const String kTextRouteName = '/text';
1313
const String kAnimatedPlaceholderRouteName = '/animated_placeholder';
1414
const String kColorFilterAndFadeRouteName = '/color_filter_and_fade';
1515
const String kFadingChildAnimationRouteName = '/fading_child_animation';
16+
const String kImageFilteredTransformAnimationRouteName = '/imagefiltered_transform_animation';
17+
18+
const String kScrollableName = '/macrobenchmark_listview';

dev/benchmarks/macrobenchmarks/lib/main.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class MacrobenchmarksApp extends StatelessWidget {
4242
kAnimatedPlaceholderRouteName: (BuildContext context) => AnimatedPlaceholderPage(),
4343
kColorFilterAndFadeRouteName: (BuildContext context) => ColorFilterAndFadePage(),
4444
kFadingChildAnimationRouteName: (BuildContext context) => const FilteredChildAnimationPage(FilterType.opacity),
45+
kImageFilteredTransformAnimationRouteName: (BuildContext context) => const FilteredChildAnimationPage(FilterType.rotateFilter),
4546
},
4647
);
4748
}
@@ -55,6 +56,7 @@ class HomePage extends StatelessWidget {
5556
return Scaffold(
5657
appBar: AppBar(title: const Text(kMacrobenchmarks)),
5758
body: ListView(
59+
key: const Key(kScrollableName),
5860
children: <Widget>[
5961
RaisedButton(
6062
key: const Key(kCullOpacityRouteName),
@@ -133,6 +135,13 @@ class HomePage extends StatelessWidget {
133135
Navigator.pushNamed(context, kFadingChildAnimationRouteName);
134136
},
135137
),
138+
RaisedButton(
139+
key: const Key(kImageFilteredTransformAnimationRouteName),
140+
child: const Text('ImageFiltered Transform Animation'),
141+
onPressed: () {
142+
Navigator.pushNamed(context, kImageFilteredTransformAnimationRouteName);
143+
},
144+
),
136145
],
137146
),
138147
);

dev/benchmarks/macrobenchmarks/lib/src/filtered_child_animation.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ class _FilteredChildAnimationPageState extends State<FilteredChildAnimationPage>
4242
super.initState();
4343
WidgetsBinding.instance.addPostFrameCallback((_) {
4444
final RenderBox childBox = _childKey.currentContext.findRenderObject() as RenderBox;
45-
final Offset localCenter = childBox.paintBounds.center;
46-
_childCenter = childBox.localToGlobal(localCenter);
45+
_childCenter = childBox.paintBounds.center;
4746
});
4847
_controller = AnimationController(vsync: this, duration: const Duration(seconds: 2));
4948
_controller.repeat();
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2014 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:flutter_driver/driver_extension.dart';
6+
import 'package:macrobenchmarks/main.dart' as app;
7+
8+
void main() {
9+
enableFlutterDriverExtension();
10+
app.main();
11+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2014 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:macrobenchmarks/common.dart';
6+
7+
import 'util.dart';
8+
9+
void main() {
10+
macroPerfTest(
11+
'imagefiltered_transform_animation_perf',
12+
kImageFilteredTransformAnimationRouteName,
13+
pageDelay: const Duration(seconds: 1),
14+
duration: const Duration(seconds: 10),
15+
);
16+
}

dev/benchmarks/macrobenchmarks/test_driver/util.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import 'dart:async';
77
import 'package:flutter_driver/flutter_driver.dart';
88
import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
99

10+
import 'package:macrobenchmarks/common.dart';
11+
1012
void macroPerfTest(
1113
String testName,
1214
String routeName,
@@ -27,8 +29,11 @@ void macroPerfTest(
2729

2830
await driver.forceGC();
2931

32+
final SerializableFinder scrollable = find.byValueKey(kScrollableName);
33+
expect(scrollable, isNotNull);
3034
final SerializableFinder button = find.byValueKey(routeName);
3135
expect(button, isNotNull);
36+
await driver.scrollUntilVisible(scrollable, button, dyScroll: -50.0);
3237
await driver.tap(button);
3338

3439
if (pageDelay != null) {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2014 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
import 'package:flutter_devicelab/tasks/perf_tests.dart';
8+
import 'package:flutter_devicelab/framework/adb.dart';
9+
import 'package:flutter_devicelab/framework/framework.dart';
10+
11+
Future<void> main() async {
12+
deviceOperatingSystem = DeviceOperatingSystem.android;
13+
await task(createImageFilteredTransformAnimationPerfTest());
14+
}

dev/devicelab/lib/tasks/perf_tests.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,14 @@ TaskFunction createFadingChildAnimationPerfTest() {
217217
).run;
218218
}
219219

220+
TaskFunction createImageFilteredTransformAnimationPerfTest() {
221+
return PerfTest(
222+
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',
223+
'test_driver/imagefiltered_transform_animation_perf.dart',
224+
'imagefiltered_transform_animation_perf',
225+
).run;
226+
}
227+
220228
/// Measure application startup performance.
221229
class StartupTest {
222230
const StartupTest(this.testDirectory, { this.reportMetrics = true });

dev/devicelab/manifest.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,12 @@ tasks:
213213
stage: devicelab
214214
required_agent_capabilities: ["mac/android"]
215215

216+
imagefiltered_transform_animation_perf__timeline_summary:
217+
description: >
218+
Measures the runtime performance of imagefiltered widget with transform on Android.
219+
stage: devicelab
220+
required_agent_capabilities: ["mac/android"]
221+
216222
flavors_test:
217223
description: >
218224
Checks that flavored builds work on Android.

0 commit comments

Comments
 (0)