Skip to content

Commit

Permalink
[web] Migrate Flutter Web to JS static interop - 2 (#32427)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshualitt authored Apr 6, 2022
1 parent fe6a51a commit 0299ffd
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 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 @@ -210,8 +218,10 @@ class SkSurface {
}

@JS()
@anonymous
class SkGrContext {
@staticInterop
class SkGrContext {}

extension SkGrContextExtension on SkGrContext {
external void setResourceCacheLimitBytes(int limit);
external void releaseResourcesAndAbandonContext();
external void delete();
Expand Down

0 comments on commit 0299ffd

Please sign in to comment.