Cheaper frosted-glass blurs: sigma 4 and one backdrop read per bar
Blur sigma 16 -> 4 keeps CanvasKit on its direct blur path; under the 84% fill the look is unchanged (max 13/255 inside the pieces). SegmentedBar's pieces share a BackdropGroup so Impeller reads the content behind them once. Adds a scroll frame-time bench, a backdrop census and filler rows to the full-app probe. CPU CanvasKit, 560x900: run timeline p50 31.8 -> 22.1 ms, runs list 25.3 -> 19.9 ms.
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
// A page-side census of the backdrop blurs on screen, for the glass scroll
|
||||
// bench (tool/perf/glass_scroll_bench.mjs): `window.__backdropCensus()`
|
||||
// returns `{ blurs, reads }`: the backdrop filter layers in the current scene
|
||||
// (offstage routes are not in it), and how many reads of the content behind
|
||||
// they take where the engine shares a `BackdropGroup`'s read (Impeller; the
|
||||
// web renderer ignores the grouping and reads once per blur).
|
||||
import 'dart:js_interop';
|
||||
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
@JS('__backdropCensus')
|
||||
external set _backdropCensus(JSFunction census);
|
||||
|
||||
void installBackdropCensus() {
|
||||
_backdropCensus = (() {
|
||||
var blurs = 0;
|
||||
var ungrouped = 0;
|
||||
final keys = <BackdropKey>{};
|
||||
void visit(Layer layer) {
|
||||
if (layer is BackdropFilterLayer) {
|
||||
blurs++;
|
||||
final key = layer.backdropKey;
|
||||
if (key == null) {
|
||||
ungrouped++;
|
||||
} else {
|
||||
keys.add(key);
|
||||
}
|
||||
}
|
||||
if (layer is ContainerLayer) {
|
||||
for (
|
||||
var child = layer.firstChild;
|
||||
child != null;
|
||||
child = child.nextSibling
|
||||
) {
|
||||
visit(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (final view in RendererBinding.instance.renderViews) {
|
||||
// The scene's root layer.
|
||||
// ignore: invalid_use_of_protected_member
|
||||
final root = view.layer;
|
||||
if (root != null) visit(root);
|
||||
}
|
||||
return {'blurs': blurs, 'reads': ungrouped + keys.length}.jsify();
|
||||
}).toJS;
|
||||
}
|
||||
Reference in New Issue
Block a user