Quick fix for shader warm up (#28951)
Fix issues in https://github.com/flutter/flutter/pull/28687
This commit is contained in:
@@ -67,8 +67,6 @@ abstract class ShaderWarmUp {
|
||||
/// Trigger draw operations on a given canvas to warm up GPU shader
|
||||
/// compilation cache.
|
||||
///
|
||||
/// Parameter [image] is to be used for drawImage related operations.
|
||||
///
|
||||
/// To decide which draw operations to be added to your custom warm up
|
||||
/// process, try capture an skp using `flutter screenshot --observatory-
|
||||
/// port=<port> --type=skia` and analyze it with https://debugger.skia.org.
|
||||
@@ -90,7 +88,7 @@ abstract class ShaderWarmUp {
|
||||
final ui.Picture picture = recorder.endRecording();
|
||||
final TimelineTask shaderWarmUpTask = TimelineTask();
|
||||
shaderWarmUpTask.start('Warm-up shader');
|
||||
picture.toImage(size.width.ceil(), size.height.ceil()).then((ui.Image _) {
|
||||
picture.toImage(size.width.ceil(), size.height.ceil()).then((ui.Image image) {
|
||||
shaderWarmUpTask.finish();
|
||||
});
|
||||
}
|
||||
@@ -184,10 +182,9 @@ class DefaultShaderWarmUp extends ShaderWarmUp {
|
||||
..layout(const ui.ParagraphConstraints(width: 60.0));
|
||||
canvas.drawParagraph(paragraph, const ui.Offset(20.0, 20.0));
|
||||
|
||||
|
||||
// Construct an image for drawImage related operations
|
||||
const int imageWidth = 40;
|
||||
const int imageHeight = 40;
|
||||
const int imageWidth = 10;
|
||||
const int imageHeight = 10;
|
||||
final Uint8List pixels = Uint8List.fromList(List<int>.generate(
|
||||
imageWidth * imageHeight * 4,
|
||||
(int i) => i % 4 < 2 ? 0x00 : 0xFF, // opaque blue
|
||||
@@ -201,9 +198,9 @@ class DefaultShaderWarmUp extends ShaderWarmUp {
|
||||
final ui.Rect srcRect = ui.Rect.fromLTWH(0.0, 0.0, image.width.toDouble(), image.height.toDouble());
|
||||
canvas.drawImage(image, const ui.Offset(20.0, 20.0), ui.Paint());
|
||||
canvas.translate(80.0, 0.0);
|
||||
canvas.drawImageRect(image, srcRect, ui.Rect.fromLTWH(20.0, 20.0, 20.0, 20.0), paints[0]);
|
||||
canvas.drawImageRect(image, srcRect, ui.Rect.fromLTWH(20.0, 20.0, imageWidth * 0.6, imageWidth * 0.6), paints[0]);
|
||||
canvas.translate(80.0, 0.0);
|
||||
canvas.drawImageRect(image, srcRect, ui.Rect.fromLTWH(10.0, 10.0, 60.0, 60.0), paints[0]);
|
||||
canvas.drawImageRect(image, srcRect, ui.Rect.fromLTWH(10.0, 10.0, imageWidth * 1.5, imageWidth * 1.5), paints[0]);
|
||||
canvas.restore();
|
||||
completer.complete();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user