Skip to content

Commit

Permalink
[web] Migrate Flutter Web to JS static interop - 2
Browse files Browse the repository at this point in the history
  • Loading branch information
joshualitt committed Apr 5, 2022
1 parent 7b2e6e5 commit 54e2518
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions lib/web_ui/lib/src/engine/canvaskit/canvaskit_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ typedef LocateFileCallback = String Function(String file, String unusedBase);

@JS()
@anonymous
@staticInterop
class CanvasKitInitOptions {
external factory CanvasKitInitOptions({
required LocateFileCallback locateFile,
Expand All @@ -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);
}

Expand All @@ -191,6 +195,7 @@ class ColorSpace {}

@JS()
@anonymous
@staticInterop
class SkWebGLContextOptions {
external factory SkWebGLContextOptions({
required int antialias,
Expand All @@ -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();
Expand All @@ -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 {
Expand Down

0 comments on commit 54e2518

Please sign in to comment.