[devicelab] add regular old blur benchmark (#123879)
[devicelab] add regular old blur benchmark
This commit is contained in:
@@ -33,6 +33,7 @@ const String kGradientPerfRouteName = '/gradient_perf';
|
||||
const String kAnimatedComplexOpacityPerfRouteName = '/animated_complex_opacity';
|
||||
const String kAnimatedComplexImageFilteredPerfRouteName = '/animated_complex_image_filtered';
|
||||
const String kListTextLayoutRouteName = '/list_text_layout';
|
||||
const String kAnimatedBlurBackdropFilter = '/animated_blur_backdrop_filter';
|
||||
|
||||
const String kOpacityPeepholeOneRectRouteName = '$kOpacityPeepholeRouteName/one_big_rect';
|
||||
const String kOpacityPeepholeColumnOfOpacityRouteName = '$kOpacityPeepholeRouteName/column_of_opacity';
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'common.dart';
|
||||
|
||||
import 'src/animated_blur_backdrop_filter.dart';
|
||||
import 'src/animated_complex_image_filtered.dart';
|
||||
import 'src/animated_complex_opacity.dart';
|
||||
import 'src/animated_image.dart';
|
||||
@@ -84,6 +84,7 @@ class MacrobenchmarksApp extends StatelessWidget {
|
||||
kAnimatedComplexOpacityPerfRouteName: (BuildContext context) => const AnimatedComplexOpacity(),
|
||||
kListTextLayoutRouteName: (BuildContext context) => const ColumnOfText(),
|
||||
kAnimatedComplexImageFilteredPerfRouteName: (BuildContext context) => const AnimatedComplexImageFiltered(),
|
||||
kAnimatedBlurBackdropFilter: (BuildContext context) => const AnimatedBlurBackdropFilter(),
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -311,6 +312,13 @@ class HomePage extends StatelessWidget {
|
||||
Navigator.pushNamed(context, kListTextLayoutRouteName);
|
||||
},
|
||||
),
|
||||
ElevatedButton(
|
||||
key: const Key(kAnimatedBlurBackdropFilter),
|
||||
child: const Text('An animating backdrop filter'),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(context, kAnimatedBlurBackdropFilter);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
// 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' as ui;
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
// Various tests to verify that animated image filtered layers do not
|
||||
// dirty children even without explicit repaint boundaries. These intentionally use
|
||||
// text to ensure we don't measure the opacity peephole case.
|
||||
class AnimatedBlurBackdropFilter extends StatefulWidget {
|
||||
const AnimatedBlurBackdropFilter({ super.key });
|
||||
|
||||
@override
|
||||
State<AnimatedBlurBackdropFilter> createState() => _AnimatedBlurBackdropFilterState();
|
||||
}
|
||||
|
||||
class _AnimatedBlurBackdropFilterState extends State<AnimatedBlurBackdropFilter> with SingleTickerProviderStateMixin {
|
||||
late final AnimationController controller = AnimationController(vsync: this, duration: const Duration(milliseconds: 5000));
|
||||
late final Animation<double> animation = controller.drive(Tween<double>(begin: 0.0, end: 1.0));
|
||||
ui.ImageFilter imageFilter = ui.ImageFilter.blur();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
controller.repeat();
|
||||
animation.addListener(() {
|
||||
setState(() {
|
||||
imageFilter = ui.ImageFilter.blur(
|
||||
sigmaX: animation.value * 16,
|
||||
sigmaY: animation.value * 16,
|
||||
tileMode: TileMode.decal,
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Stack(
|
||||
children: <Widget>[
|
||||
ListView(
|
||||
children: <Widget>[
|
||||
for (int i = 0; i < 30; i++)
|
||||
Center(
|
||||
child: Transform.scale(scale: 1.01, child: const ModeratelyComplexWidget()),
|
||||
),
|
||||
],
|
||||
),
|
||||
BackdropFilter(
|
||||
filter: imageFilter,
|
||||
child: const SizedBox.expand(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ModeratelyComplexWidget extends StatelessWidget {
|
||||
const ModeratelyComplexWidget({ super.key });
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Material(
|
||||
elevation: 10,
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: ListTile(
|
||||
leading: Icon(Icons.abc, size: 24),
|
||||
title: DecoratedBox(decoration: BoxDecoration(color: Colors.red), child: Text('Hello World')),
|
||||
trailing: FlutterLogo(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// 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 'package:macrobenchmarks/common.dart';
|
||||
|
||||
import 'util.dart';
|
||||
|
||||
void main() {
|
||||
macroPerfTest(
|
||||
'animated_blur_backdrop_filter_perf',
|
||||
kAnimatedBlurBackdropFilter,
|
||||
pageDelay: const Duration(seconds: 1),
|
||||
duration: const Duration(seconds: 10),
|
||||
);
|
||||
}
|
||||
@@ -23,7 +23,7 @@ Future<void> runDriverTestForRoute(String routeName, DriverTestCallBack body) as
|
||||
expect(scrollable, isNotNull);
|
||||
final SerializableFinder button = find.byValueKey(routeName);
|
||||
expect(button, isNotNull);
|
||||
await driver.scrollUntilVisible(scrollable, button, dyScroll: -50.0);
|
||||
await driver.scrollUntilVisible(scrollable, button, dyScroll: -100.0);
|
||||
await driver.tap(button);
|
||||
|
||||
await body(driver);
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// 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:async';
|
||||
|
||||
import 'package:flutter_devicelab/framework/devices.dart';
|
||||
import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
deviceOperatingSystem = DeviceOperatingSystem.android;
|
||||
await task(createAnimatedBlurBackropFilterPerfTest(enableImpeller: true));
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// 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:async';
|
||||
|
||||
import 'package:flutter_devicelab/framework/devices.dart';
|
||||
import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
deviceOperatingSystem = DeviceOperatingSystem.ios;
|
||||
await task(createAnimatedBlurBackropFilterPerfTest());
|
||||
}
|
||||
@@ -620,6 +620,19 @@ TaskFunction createGradientStaticPerfE2ETest() {
|
||||
).run;
|
||||
}
|
||||
|
||||
TaskFunction createAnimatedBlurBackropFilterPerfTest({
|
||||
bool enableImpeller = false,
|
||||
}) {
|
||||
return PerfTest(
|
||||
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',
|
||||
'test_driver/run_app.dart',
|
||||
'animated_blur_backdrop_filter_perf',
|
||||
enableImpeller: enableImpeller,
|
||||
testDriver: 'test_driver/animated_blur_backdrop_filter_perf_test.dart',
|
||||
saveTraceFile: true,
|
||||
).run;
|
||||
}
|
||||
|
||||
TaskFunction createAnimatedComplexOpacityPerfE2ETest({
|
||||
bool enableImpeller = false,
|
||||
}) {
|
||||
|
||||
Reference in New Issue
Block a user