From 54e25188e1ae00aaac4e0679826d89dcec6edbb5 Mon Sep 17 00:00:00 2001 From: Joshua Litt Date: Tue, 5 Apr 2022 16:54:45 +0000 Subject: [PATCH] [web] Migrate Flutter Web to JS static interop - 2 --- .../src/engine/canvaskit/canvaskit_api.dart | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/web_ui/lib/src/engine/canvaskit/canvaskit_api.dart b/lib/web_ui/lib/src/engine/canvaskit/canvaskit_api.dart index 05c55d2c15561..752b6138886ce 100644 --- a/lib/web_ui/lib/src/engine/canvaskit/canvaskit_api.dart +++ b/lib/web_ui/lib/src/engine/canvaskit/canvaskit_api.dart @@ -170,6 +170,7 @@ typedef LocateFileCallback = String Function(String file, String unusedBase); @JS() @anonymous +@staticInterop class CanvasKitInitOptions { external factory CanvasKitInitOptions({ required LocateFileCallback locateFile, @@ -179,7 +180,10 @@ class CanvasKitInitOptions { typedef CanvasKitInitCallback = void Function(CanvasKit canvasKit); @JS() -class CanvasKitInitPromise { +@staticInterop +class CanvasKitInitPromise {} + +extension CanvasKitInitPromiseExtension on CanvasKitInitPromise { external void then(CanvasKitInitCallback callback); } @@ -191,6 +195,7 @@ class ColorSpace {} @JS() @anonymous +@staticInterop class SkWebGLContextOptions { external factory SkWebGLContextOptions({ required int antialias, @@ -200,7 +205,10 @@ class SkWebGLContextOptions { } @JS('window.flutterCanvasKit.Surface') -class SkSurface { +@staticInterop +class SkSurface {} + +extension SkSurfaceExtension on SkSurface { external SkCanvas getCanvas(); external void flush(); external int width(); @@ -209,14 +217,18 @@ class SkSurface { external SkImage makeImageSnapshot(); } + @JS() -@anonymous -class SkGrContext { +@staticInterop +class SkGrContext {} + +extension SkGrContextExtension on SkGrContext { external void setResourceCacheLimitBytes(int limit); external void releaseResourcesAndAbandonContext(); external void delete(); } + @JS() @anonymous class SkFontSlantEnum {