Unverified Commit 7462c4a6 authored by alanwutang11's avatar alanwutang11 Committed by GitHub

shader warm up with canvaskit and corresponding test (#113060)

parent e99fc8e5
......@@ -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 {
......
// 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);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment