Skip to content

Commit b3d7a69

Browse files
authored
Add benchmark for clipper layers raster cache (#102495)
* Add clipper raster cache benchmarks * fix ci test error * Add PhysicalModel widget to test * Set top margin adaptive screen height * Remove PhysicalModel
1 parent 6bba577 commit b3d7a69

File tree

8 files changed

+152
-0
lines changed

8 files changed

+152
-0
lines changed

.ci.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,17 @@ targets:
13351335
task_name: channels_integration_test
13361336
scheduler: luci
13371337

1338+
- name: Linux_android clipper_cache_perf__e2e_summary
1339+
bringup: true
1340+
recipe: devicelab/devicelab_drone
1341+
presubmit: false
1342+
timeout: 60
1343+
properties:
1344+
tags: >
1345+
["devicelab","android","linux"]
1346+
task_name: clipper_cache_perf__e2e_summary
1347+
scheduler: luci
1348+
13381349
- name: Linux_android color_filter_and_fade_perf__e2e_summary
13391350
recipe: devicelab/devicelab_drone
13401351
presubmit: false

TESTOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
/dev/devicelab/bin/tasks/backdrop_filter_perf__e2e_summary.dart @zanderso @flutter/engine
2323
/dev/devicelab/bin/tasks/basic_material_app_android__compile.dart @zanderso @flutter/tool
2424
/dev/devicelab/bin/tasks/codegen_integration.dart @zanderso @flutter/tool
25+
/dev/devicelab/bin/tasks/clipper_cache_perf__e2e_summary.dart @flar @flutter/engine
2526
/dev/devicelab/bin/tasks/color_filter_and_fade_perf__e2e_summary.dart @zanderso @flutter/engine
2627
/dev/devicelab/bin/tasks/shader_mask_cache_perf__e2e_summary.dart @flar @flutter/engine
2728
/dev/devicelab/bin/tasks/color_filter_cache_perf__e2e_summary.dart @flar @flutter/engine

dev/benchmarks/macrobenchmarks/lib/common.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const String kLargeImagesRouteName = '/large_images';
1414
const String kTextRouteName = '/text';
1515
const String kFullscreenTextRouteName = '/fullscreen_text';
1616
const String kAnimatedPlaceholderRouteName = '/animated_placeholder';
17+
const String kClipperCacheRouteName = '/clipper_cache';
1718
const String kColorFilterAndFadeRouteName = '/color_filter_and_fade';
1819
const String kColorFilterCacheRouteName = '/color_filter_cache';
1920
const String kFadingChildAnimationRouteName = '/fading_child_animation';

dev/benchmarks/macrobenchmarks/lib/main.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import 'src/animated_image.dart';
1111
import 'src/animated_placeholder.dart';
1212
import 'src/animation_with_microtasks.dart';
1313
import 'src/backdrop_filter.dart';
14+
import 'src/clipper_cache.dart';
1415
import 'src/color_filter_and_fade.dart';
1516
import 'src/color_filter_cache.dart';
1617
import 'src/cubic_bezier.dart';
@@ -58,6 +59,7 @@ class MacrobenchmarksApp extends StatelessWidget {
5859
kTextRouteName: (BuildContext context) => const TextPage(),
5960
kFullscreenTextRouteName: (BuildContext context) => const TextFieldPage(),
6061
kAnimatedPlaceholderRouteName: (BuildContext context) => const AnimatedPlaceholderPage(),
62+
kClipperCacheRouteName: (BuildContext context) => const ClipperCachePage(),
6163
kColorFilterAndFadeRouteName: (BuildContext context) => const ColorFilterAndFadePage(),
6264
kColorFilterCacheRouteName: (BuildContext context) => const ColorFilterCachePage(),
6365
kFadingChildAnimationRouteName: (BuildContext context) => const FilteredChildAnimationPage(FilterType.opacity),
@@ -168,6 +170,13 @@ class HomePage extends StatelessWidget {
168170
Navigator.pushNamed(context, kAnimatedPlaceholderRouteName);
169171
},
170172
),
173+
ElevatedButton(
174+
key: const Key(kClipperCacheRouteName),
175+
child: const Text('Clipper Cache'),
176+
onPressed: () {
177+
Navigator.pushNamed(context, kClipperCacheRouteName);
178+
},
179+
),
171180
ElevatedButton(
172181
key: const Key(kColorFilterAndFadeRouteName),
173182
child: const Text('Color Filter and Fade'),
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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+
import 'dart:ui';
7+
import 'package:flutter/material.dart';
8+
import 'picture_cache.dart';
9+
10+
class ClipperCachePage extends StatefulWidget {
11+
const ClipperCachePage({super.key});
12+
@override
13+
State<ClipperCachePage> createState() => _ClipperCachePageState();
14+
}
15+
16+
class _ClipperCachePageState extends State<ClipperCachePage>
17+
with TickerProviderStateMixin {
18+
final double _animateOffset = 100;
19+
final ScrollController _controller = ScrollController();
20+
final bool _isComplex = true;
21+
late double _topMargin;
22+
23+
@override
24+
void initState() {
25+
super.initState();
26+
const double itemHeight = 140;
27+
_topMargin = (window.physicalSize.height / window.devicePixelRatio - itemHeight * 3) / 2;
28+
if (_topMargin < 0) {
29+
_topMargin = 0;
30+
}
31+
_controller.addListener(() {
32+
if (_controller.offset < 10) {
33+
_controller.animateTo(_animateOffset, duration: const Duration(milliseconds: 1000), curve: Curves.ease);
34+
} else if (_controller.offset > _animateOffset - 10) {
35+
_controller.animateTo(0, duration: const Duration(milliseconds: 1000), curve: Curves.ease);
36+
}
37+
});
38+
Timer(const Duration(milliseconds: 500), () {
39+
_controller.animateTo(_animateOffset, duration: const Duration(milliseconds: 1000), curve: Curves.ease);
40+
});
41+
}
42+
43+
@override
44+
Widget build(BuildContext context) {
45+
return Scaffold(
46+
backgroundColor: Colors.blue,
47+
body: ListView(
48+
controller: _controller,
49+
children: <Widget>[
50+
SizedBox(height: _topMargin),
51+
ClipPath(
52+
clipBehavior: Clip.antiAliasWithSaveLayer,
53+
child: _makeChild(0, _isComplex)
54+
),
55+
ClipRect(
56+
clipBehavior: Clip.antiAliasWithSaveLayer,
57+
child: _makeChild(1, _isComplex)
58+
),
59+
ClipRRect(
60+
clipBehavior: Clip.antiAliasWithSaveLayer,
61+
child: _makeChild(2, _isComplex)
62+
),
63+
const SizedBox(height: 1000),
64+
],
65+
),
66+
);
67+
}
68+
69+
Widget _makeChild(int itemIndex, bool complex) {
70+
final BoxDecoration decoration = BoxDecoration(
71+
color: Colors.white70,
72+
boxShadow: const <BoxShadow>[
73+
BoxShadow(
74+
blurRadius: 5.0,
75+
),
76+
],
77+
borderRadius: BorderRadius.circular(5.0),
78+
);
79+
return RepaintBoundary(
80+
child: Container(
81+
margin: const EdgeInsets.fromLTRB(10, 5, 10, 5),
82+
decoration: complex ? decoration : null,
83+
child: ListItem(index: itemIndex),
84+
),
85+
);
86+
}
87+
88+
@override
89+
void dispose() {
90+
_controller.dispose();
91+
super.dispose();
92+
}
93+
}
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+
macroPerfTestE2E(
11+
'clipper_cache_perf',
12+
kClipperCacheRouteName,
13+
pageDelay: const Duration(seconds: 1),
14+
duration: const Duration(seconds: 10),
15+
);
16+
}
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/framework/devices.dart';
8+
import 'package:flutter_devicelab/framework/framework.dart';
9+
import 'package:flutter_devicelab/tasks/perf_tests.dart';
10+
11+
Future<void> main() async {
12+
deviceOperatingSystem = DeviceOperatingSystem.android;
13+
await task(createClipperCachePerfE2ETest());
14+
}

dev/devicelab/lib/tasks/perf_tests.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,13 @@ TaskFunction createFullscreenTextfieldPerfE2ETest() {
353353
).run;
354354
}
355355

356+
TaskFunction createClipperCachePerfE2ETest() {
357+
return PerfTest.e2e(
358+
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',
359+
'test/clipper_cache_perf_e2e.dart',
360+
).run;
361+
}
362+
356363
TaskFunction createColorFilterAndFadePerfTest() {
357364
return PerfTest(
358365
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',

0 commit comments

Comments
 (0)