shader warm up with canvaskit and corresponding test (#113060)
This commit is contained in:
@@ -69,3 +69,6 @@ const double precisionErrorTolerance = 1e-10;
|
||||
|
||||
/// A constant that is true if the application was compiled to run on the web.
|
||||
const bool kIsWeb = bool.fromEnvironment('dart.library.js_util');
|
||||
|
||||
/// A constant that is true if the application is using canvasKit
|
||||
const bool isCanvasKit = bool.fromEnvironment('FLUTTER_WEB_USE_SKIA');
|
||||
|
||||
@@ -87,7 +87,7 @@ abstract class ShaderWarmUp {
|
||||
await warmUpOnCanvas(canvas);
|
||||
final ui.Picture picture = recorder.endRecording();
|
||||
assert(debugCaptureShaderWarmUpPicture(picture));
|
||||
if (!kIsWeb) { // Picture.toImage is not yet implemented on the web.
|
||||
if (!kIsWeb || isCanvasKit) { // Picture.toImage is not yet implemented on the web.
|
||||
final TimelineTask shaderWarmUpTask = TimelineTask();
|
||||
shaderWarmUpTask.start('Warm-up shader');
|
||||
try {
|
||||
|
||||
29
packages/flutter/test/painting/shader_warm_up_test.dart
Normal file
29
packages/flutter/test/painting/shader_warm_up_test.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
// 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/foundation.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
test('ShaderWarmUp', () {
|
||||
final FakeShaderWarmUp shaderWarmUp = FakeShaderWarmUp();
|
||||
PaintingBinding.shaderWarmUp = shaderWarmUp;
|
||||
debugCaptureShaderWarmUpImage = expectAsync1((ui.Image image) => true);
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
expect(shaderWarmUp.ranWarmUp, true);
|
||||
}, skip: kIsWeb && !isCanvasKit); // [intended] Testing only for canvasKit
|
||||
}
|
||||
|
||||
class FakeShaderWarmUp extends ShaderWarmUp {
|
||||
bool ranWarmUp = false;
|
||||
|
||||
@override
|
||||
Future<bool> warmUpOnCanvas(ui.Canvas canvas) {
|
||||
ranWarmUp = true;
|
||||
return Future<bool>.delayed(Duration.zero, () => true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user