Skip to content

Commit b4040c8

Browse files
authored
Add benchmark for ColorFilter raster cache (#99542)
1 parent f6c4c3d commit b4040c8

File tree

8 files changed

+137
-0
lines changed

8 files changed

+137
-0
lines changed

.ci.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,6 +1515,18 @@ targets:
15151515
task_name: color_filter_and_fade_perf__timeline_summary
15161516
scheduler: luci
15171517

1518+
- name: Linux_android color_filter_cache_perf__e2e_summary
1519+
bringup: true
1520+
recipe: devicelab/devicelab_drone
1521+
presubmit: false
1522+
timeout: 60
1523+
properties:
1524+
tags: >
1525+
["devicelab","android","linux"]
1526+
task_name: color_filter_cache_perf__e2e_summary
1527+
benchmark: "true"
1528+
scheduler: luci
1529+
15181530
- name: Linux_android complex_layout_android__compile
15191531
recipe: devicelab/devicelab_drone
15201532
presubmit: false

TESTOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
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
2525
/dev/devicelab/bin/tasks/color_filter_and_fade_perf__e2e_summary.dart @zanderso @flutter/engine
26+
/dev/devicelab/bin/tasks/color_filter_cache_perf__e2e_summary.dart @flar @flutter/engine
2627
/dev/devicelab/bin/tasks/complex_layout_android__compile.dart @zanderso @flutter/tool
2728
/dev/devicelab/bin/tasks/complex_layout_android__scroll_smoothness.dart @zanderso @flutter/engine
2829
/dev/devicelab/bin/tasks/complex_layout_scroll_perf__devtools_memory.dart @zanderso @flutter/engine

dev/benchmarks/macrobenchmarks/lib/common.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const String kTextRouteName = '/text';
1515
const String kFullscreenTextRouteName = '/fullscreen_text';
1616
const String kAnimatedPlaceholderRouteName = '/animated_placeholder';
1717
const String kColorFilterAndFadeRouteName = '/color_filter_and_fade';
18+
const String kColorFilterCacheRouteName = '/color_filter_cache';
1819
const String kFadingChildAnimationRouteName = '/fading_child_animation';
1920
const String kImageFilteredTransformAnimationRouteName = '/imagefiltered_transform_animation';
2021
const String kMultiWidgetConstructionRouteName = '/multi_widget_construction';

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_placeholder.dart';
1111
import 'src/animation_with_microtasks.dart';
1212
import 'src/backdrop_filter.dart';
1313
import 'src/color_filter_and_fade.dart';
14+
import 'src/color_filter_cache.dart';
1415
import 'src/cubic_bezier.dart';
1516
import 'src/cull_opacity.dart';
1617
import 'src/filtered_child_animation.dart';
@@ -55,6 +56,7 @@ class MacrobenchmarksApp extends StatelessWidget {
5556
kFullscreenTextRouteName: (BuildContext context) => const TextFieldPage(),
5657
kAnimatedPlaceholderRouteName: (BuildContext context) => const AnimatedPlaceholderPage(),
5758
kColorFilterAndFadeRouteName: (BuildContext context) => const ColorFilterAndFadePage(),
59+
kColorFilterCacheRouteName: (BuildContext context) => const ColorFilterCachePage(),
5860
kFadingChildAnimationRouteName: (BuildContext context) => const FilteredChildAnimationPage(FilterType.opacity),
5961
kImageFilteredTransformAnimationRouteName: (BuildContext context) => const FilteredChildAnimationPage(FilterType.rotateFilter),
6062
kMultiWidgetConstructionRouteName: (BuildContext context) => const MultiWidgetConstructTable(10, 20),
@@ -166,6 +168,13 @@ class HomePage extends StatelessWidget {
166168
Navigator.pushNamed(context, kColorFilterAndFadeRouteName);
167169
},
168170
),
171+
ElevatedButton(
172+
key: const Key(kColorFilterCacheRouteName),
173+
child: const Text('Color Filter Cache'),
174+
onPressed: () {
175+
Navigator.pushNamed(context, kColorFilterCacheRouteName);
176+
},
177+
),
169178
ElevatedButton(
170179
key: const Key(kFadingChildAnimationRouteName),
171180
child: const Text('Fading Child Animation'),
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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+
9+
class ColorFilterCachePage extends StatefulWidget {
10+
const ColorFilterCachePage({Key? key}) : super(key: key);
11+
@override
12+
State<ColorFilterCachePage> createState() => _ColorFilterCachePageState();
13+
}
14+
15+
class _ColorFilterCachePageState extends State<ColorFilterCachePage>
16+
with TickerProviderStateMixin {
17+
final ScrollController _controller = ScrollController();
18+
@override
19+
void initState() {
20+
super.initState();
21+
_controller.addListener(() {
22+
if (_controller.offset < 20) {
23+
_controller.animateTo(150, duration: const Duration(milliseconds: 1000), curve: Curves.ease);
24+
} else if (_controller.offset > 130) {
25+
_controller.animateTo(0, duration: const Duration(milliseconds: 1000), curve: Curves.ease);
26+
}
27+
});
28+
Timer(const Duration(milliseconds: 1000), () {
29+
_controller.animateTo(150, duration: const Duration(milliseconds: 1000), curve: Curves.ease);
30+
});
31+
}
32+
33+
@override
34+
Widget build(BuildContext context) {
35+
return Scaffold(
36+
backgroundColor: Colors.lightBlue,
37+
body: ListView(
38+
controller: _controller,
39+
children: <Widget>[
40+
const SizedBox(height: 150),
41+
ColorFiltered(
42+
colorFilter: ColorFilter.mode(Colors.green[300]!, BlendMode.luminosity),
43+
child: Container(
44+
clipBehavior: Clip.antiAlias,
45+
decoration: const BoxDecoration(boxShadow: <BoxShadow>[
46+
BoxShadow(
47+
color: Colors.red,
48+
blurRadius: 5.0,
49+
),
50+
], color: Colors.blue, backgroundBlendMode: BlendMode.luminosity),
51+
child: Column(
52+
children: <Widget>[
53+
const Text('Color Filter Cache Pref Test'),
54+
Image.asset(
55+
'food/butternut_squash_soup.png',
56+
package: 'flutter_gallery_assets',
57+
fit: BoxFit.cover,
58+
width: 330,
59+
height: 210,
60+
),
61+
const Text('Color Filter Cache Pref Test'),
62+
],
63+
),
64+
),
65+
),
66+
const SizedBox(height: 1000),
67+
],
68+
),
69+
);
70+
}
71+
72+
@override
73+
void dispose() {
74+
_controller.dispose();
75+
super.dispose();
76+
}
77+
}
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+
'color_filter_cache_perf',
12+
kColorFilterCacheRouteName,
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(createColorFilterCachePerfE2ETest());
14+
}

dev/devicelab/lib/tasks/perf_tests.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,13 @@ TaskFunction createColorFilterAndFadePerfE2ETest() {
371371
).run;
372372
}
373373

374+
TaskFunction createColorFilterCachePerfE2ETest() {
375+
return PerfTest.e2e(
376+
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',
377+
'test/color_filter_cache_perf_e2e.dart',
378+
).run;
379+
}
380+
374381
TaskFunction createFadingChildAnimationPerfTest() {
375382
return PerfTest(
376383
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',

0 commit comments

Comments
 (0)