Skip to content

Commit 0b01da1

Browse files
committed
Update shader warm-up for recent Skia changes
The update is copied from an update we made to a Google-internal client: cl/260202900 The update will save 1 shader compilation. This should help solve our regression: flutter#31203 More regressions on iOS might be introduced later by flutter/engine#9813 (comment) Unfortunately, we didn't rebase our benchmarks so such regressions were not detected. Hence to fully solve flutter#31203, we might need to revert some change in flutter/engine#9813 to make iOS shader warm-up happen on the GPU thread again.
1 parent 8fe424f commit 0b01da1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

packages/flutter/lib/src/painting/shader_warm_up.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,21 @@ class DefaultShaderWarmUp extends ShaderWarmUp {
176176
canvas.translate(0.0, drawCallSpacing);
177177
}
178178

179+
// Draw a rect inside a rrect with a non-trivial intersection. If the
180+
// intersection is trivial (e.g., equals the rrect clip), Skia will optimize
181+
// the clip out.
182+
//
183+
// Add an integral or fractional translation to trigger Skia's non-AA or AA
184+
// optimizations (as did before in normal FillRectOp in rrect clip cases).
185+
for (double fraction in <double>[0.0, 0.5]) {
186+
canvas
187+
..save()
188+
..translate(fraction, fraction)
189+
..clipRRect(ui.RRect.fromLTRBR(8, 8, 328, 248, const ui.Radius.circular(16)))
190+
..drawRect(ui.Rect.fromLTRB(10, 10, 320, 240), ui.Paint())
191+
..restore();
192+
}
193+
179194
// Warm up shadow shaders.
180195
const ui.Color black = ui.Color(0xFF000000);
181196
canvas.save();

0 commit comments

Comments
 (0)