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