未验证 提交 03d770fb 编写于 作者: G George Wright 提交者: GitHub

Revert "Roll CanvasKit to 0.23" (#24461)

* Revert "Roll CanvasKit to 0.23 (#24249)"

This reverts commit afe6cce5.

* Update goldens to reverted master
上级 8f4cca42
repository: https://github.com/flutter/goldens.git
revision: 1c6b4fcf242ef6c4475340d30aadad754b8a0c54
revision: 568eeb3a86d70e810c3a87fc6350539519bc628e
......@@ -75,12 +75,10 @@ const bool canvasKitForceCpuOnly = bool.fromEnvironment(
/// NPM, update this URL to `https://unpkg.com/canvaskit-wasm@0.34.0/bin/`.
const String canvasKitBaseUrl = String.fromEnvironment(
'FLUTTER_WEB_CANVASKIT_URL',
defaultValue: 'https://unpkg.com/canvaskit-wasm@0.23.0/bin/',
defaultValue: 'https://unpkg.com/canvaskit-wasm@0.22.0/bin/',
);
final String canvasKitBuildUrl =
canvasKitBaseUrl + (kProfileMode ? 'profiling/' : '');
final String canvasKitJavaScriptBindingsUrl =
canvasKitBuildUrl + 'canvaskit.js';
final String canvasKitBuildUrl = canvasKitBaseUrl + (kProfileMode ? 'profiling/' : '');
final String canvasKitJavaScriptBindingsUrl = canvasKitBuildUrl + 'canvaskit.js';
String canvasKitWasmModuleUrl(String file) => canvasKitBuildUrl + file;
/// Initialize CanvasKit.
......@@ -91,10 +89,8 @@ Future<void> initializeCanvasKit() {
late StreamSubscription<html.Event> loadSubscription;
loadSubscription = domRenderer.canvasKitScript!.onLoad.listen((_) {
loadSubscription.cancel();
final CanvasKitInitPromise canvasKitInitPromise =
CanvasKitInit(CanvasKitInitOptions(
locateFile: js.allowInterop(
(String file, String unusedBase) => canvasKitWasmModuleUrl(file)),
final CanvasKitInitPromise canvasKitInitPromise = CanvasKitInit(CanvasKitInitOptions(
locateFile: js.allowInterop((String file, String unusedBase) => canvasKitWasmModuleUrl(file)),
));
canvasKitInitPromise.then(js.allowInterop((CanvasKit ck) {
canvasKit = ck;
......
......@@ -1313,7 +1313,7 @@ void _paragraphTests() {
expect(paragraph.getIdeographicBaseline(), within<double>(distance: 0.5, from: 28));
expect(paragraph.getLongestLine(), 50);
expect(paragraph.getMaxIntrinsicWidth(), 50);
expect(paragraph.getMinIntrinsicWidth(), 50);
expect(paragraph.getMinIntrinsicWidth(), 0);
expect(paragraph.getMaxWidth(), 55);
expect(paragraph.getRectsForRange(1, 3, canvasKit.RectHeightStyle.Tight, canvasKit.RectWidthStyle.Max), <double>[]);
expect(paragraph.getRectsForPlaceholders(), hasLength(1));
......
......@@ -20,14 +20,9 @@ void testMain() {
group('CanvasKit', () {
setUpCanvasKitTest();
setUp(() {
window.debugOverrideDevicePixelRatio(1);
});
test('Surface allocates canvases efficiently', () {
final Surface surface = Surface(HtmlViewEmbedder());
final CkSurface original =
surface.acquireFrame(ui.Size(9, 19)).skiaSurface;
final CkSurface original = surface.acquireFrame(ui.Size(9, 19)).skiaSurface;
// Expect exact requested dimensions.
expect(original.width(), 9);
......@@ -43,8 +38,7 @@ void testMain() {
// The first increase will allocate a new surface, but will overallocate
// by 40% to accommodate future increases.
final CkSurface firstIncrease =
surface.acquireFrame(ui.Size(10, 20)).skiaSurface;
final CkSurface firstIncrease = surface.acquireFrame(ui.Size(10, 20)).skiaSurface;
expect(firstIncrease, isNot(same(original)));
// Expect overallocated dimensions
......@@ -54,8 +48,7 @@ void testMain() {
expect(surface.htmlCanvas!.style.height, '28px');
// Subsequent increases within 40% reuse the old surface.
final CkSurface secondIncrease =
surface.acquireFrame(ui.Size(11, 22)).skiaSurface;
final CkSurface secondIncrease = surface.acquireFrame(ui.Size(11, 22)).skiaSurface;
expect(secondIncrease, same(firstIncrease));
// Increases beyond the 40% limit will cause a new allocation.
......@@ -69,8 +62,7 @@ void testMain() {
expect(surface.htmlCanvas!.style.height, '56px');
// Shrink again. Reuse the last allocated surface.
final CkSurface shrunk2 =
surface.acquireFrame(ui.Size(5, 15)).skiaSurface;
final CkSurface shrunk2 = surface.acquireFrame(ui.Size(5, 15)).skiaSurface;
expect(shrunk2, same(huge));
});
......@@ -79,30 +71,25 @@ void testMain() {
() async {
final Surface surface = Surface(HtmlViewEmbedder());
expect(surface.debugForceNewContext, isTrue);
final CkSurface before =
surface.acquireFrame(ui.Size(9, 19)).skiaSurface;
final CkSurface before = surface.acquireFrame(ui.Size(9, 19)).skiaSurface;
expect(surface.debugForceNewContext, isFalse);
// Pump a timer to flush any microtasks.
await Future<void>.delayed(Duration.zero);
final CkSurface afterAcquireFrame =
surface.acquireFrame(ui.Size(9, 19)).skiaSurface;
final CkSurface afterAcquireFrame = surface.acquireFrame(ui.Size(9, 19)).skiaSurface;
// Existing context is reused.
expect(afterAcquireFrame, same(before));
// Emulate WebGL context loss.
final html.CanvasElement canvas =
surface.htmlElement.children.single as html.CanvasElement;
final html.CanvasElement canvas = surface.htmlElement.children.single as html.CanvasElement;
final dynamic ctx = canvas.getContext('webgl2');
final dynamic loseContextExtension =
ctx.getExtension('WEBGL_lose_context');
final dynamic loseContextExtension = ctx.getExtension('WEBGL_lose_context');
loseContextExtension.loseContext();
// Pump a timer to allow the "lose context" event to propagate.
await Future<void>.delayed(Duration.zero);
expect(surface.debugForceNewContext, isTrue);
final CkSurface afterContextLost =
surface.acquireFrame(ui.Size(9, 19)).skiaSurface;
final CkSurface afterContextLost = surface.acquireFrame(ui.Size(9, 19)).skiaSurface;
// A new cotext is created.
expect(afterContextLost, isNot(same(before)));
},
......@@ -113,8 +100,7 @@ void testMain() {
// Regression test for https://github.com/flutter/flutter/issues/75286
test('updates canvas logical size when device-pixel ratio changes', () {
final Surface surface = Surface(HtmlViewEmbedder());
final CkSurface original =
surface.acquireFrame(ui.Size(10, 16)).skiaSurface;
final CkSurface original = surface.acquireFrame(ui.Size(10, 16)).skiaSurface;
expect(original.width(), 10);
expect(original.height(), 16);
......@@ -124,8 +110,7 @@ void testMain() {
// Increase device-pixel ratio: this makes CSS pixels bigger, so we need
// fewer of them to cover the browser window.
window.debugOverrideDevicePixelRatio(2.0);
final CkSurface highDpr =
surface.acquireFrame(ui.Size(10, 16)).skiaSurface;
final CkSurface highDpr = surface.acquireFrame(ui.Size(10, 16)).skiaSurface;
expect(highDpr.width(), 10);
expect(highDpr.height(), 16);
expect(surface.htmlCanvas!.style.width, '5px');
......@@ -134,8 +119,7 @@ void testMain() {
// Decrease device-pixel ratio: this makes CSS pixels smaller, so we need
// more of them to cover the browser window.
window.debugOverrideDevicePixelRatio(0.5);
final CkSurface lowDpr =
surface.acquireFrame(ui.Size(10, 16)).skiaSurface;
final CkSurface lowDpr = surface.acquireFrame(ui.Size(10, 16)).skiaSurface;
expect(lowDpr.width(), 10);
expect(lowDpr.height(), 16);
expect(surface.htmlCanvas!.style.width, '20px');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册