Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 992ca8f

Browse files
committed
[web] Migrate Flutter Web to JS static interop - 7.
1 parent 541b636 commit 992ca8f

File tree

1 file changed

+37
-14
lines changed

1 file changed

+37
-14
lines changed

lib/web_ui/lib/src/engine/canvaskit/canvaskit_api.dart

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -927,23 +927,20 @@ class SkPaint {
927927

928928
@JS()
929929
@anonymous
930+
@staticInterop
930931
abstract class CkFilterOptions {}
931932

932933
@JS()
933934
@anonymous
935+
@staticInterop
934936
class _CkCubicFilterOptions extends CkFilterOptions {
935-
external double get B;
936-
external double get C;
937-
938937
external factory _CkCubicFilterOptions({double B, double C});
939938
}
940939

941940
@JS()
942941
@anonymous
942+
@staticInterop
943943
class _CkTransformFilterOptions extends CkFilterOptions {
944-
external SkFilterMode get filter;
945-
external SkMipmapMode get mipmap;
946-
947944
external factory _CkTransformFilterOptions(
948945
{SkFilterMode filter, SkMipmapMode mipmap});
949946
}
@@ -974,12 +971,18 @@ CkFilterOptions toSkFilterOptions(ui.FilterQuality filterQuality) {
974971

975972
@JS()
976973
@anonymous
977-
class SkMaskFilter {
974+
@staticInterop
975+
class SkMaskFilter {}
976+
977+
extension SkMaskFilterExtension on SkMaskFilter {
978978
external void delete();
979979
}
980980

981981
@JS()
982-
class SkColorFilterNamespace {
982+
@staticInterop
983+
class SkColorFilterNamespace {}
984+
985+
extension SkColorFilterNamespaceExtension on SkColorFilterNamespace {
983986
external SkColorFilter? MakeBlend(Float32List color, SkBlendMode blendMode);
984987
external SkColorFilter MakeMatrix(
985988
Float32List matrix, // 20-element matrix
@@ -991,12 +994,18 @@ class SkColorFilterNamespace {
991994

992995
@JS()
993996
@anonymous
994-
class SkColorFilter {
997+
@staticInterop
998+
class SkColorFilter {}
999+
1000+
extension SkColorFilterExtension on SkColorFilter {
9951001
external void delete();
9961002
}
9971003

9981004
@JS()
999-
class SkImageFilterNamespace {
1005+
@staticInterop
1006+
class SkImageFilterNamespace {}
1007+
1008+
extension SkImageFilterNamespaceExtension on SkImageFilterNamespace {
10001009
external SkImageFilter MakeBlur(
10011010
double sigmaX,
10021011
double sigmaY,
@@ -1023,12 +1032,18 @@ class SkImageFilterNamespace {
10231032

10241033
@JS()
10251034
@anonymous
1026-
class SkImageFilter {
1035+
@staticInterop
1036+
class SkImageFilter {}
1037+
1038+
extension SkImageFilterExtension on SkImageFilter {
10271039
external void delete();
10281040
}
10291041

10301042
@JS()
1031-
class SkPathNamespace {
1043+
@staticInterop
1044+
class SkPathNamespace {}
1045+
1046+
extension SkPathNamespaceExtension on SkPathNamespace {
10321047
/// Creates an [SkPath] using commands obtained from [SkPath.toCmds].
10331048
external SkPath MakeFromCmds(List<dynamic> pathCommands);
10341049

@@ -1119,6 +1134,7 @@ Float32List toSkColorStops(List<double>? colorStops) {
11191134
external _NativeFloat32ArrayType get _nativeFloat32ArrayType;
11201135

11211136
@JS()
1137+
@staticInterop
11221138
class _NativeFloat32ArrayType {}
11231139

11241140
@JS('window.flutterCanvasKit.Malloc')
@@ -1149,7 +1165,10 @@ external void freeFloat32List(SkFloat32List list);
11491165
/// when WASM grows its memory. Call [toTypedArray] to get a new instance
11501166
/// that's attached to the current WASM memory block.
11511167
@JS()
1152-
class SkFloat32List {
1168+
@staticInterop
1169+
class SkFloat32List {}
1170+
1171+
extension SkFloat32ListExtension on SkFloat32List {
11531172
/// Returns the [Float32List] object backed by WASM memory.
11541173
///
11551174
/// Do not reuse the returned list across multiple WASM function/method
@@ -1204,8 +1223,12 @@ Float32List toSharedSkColor3(ui.Color color) {
12041223
final SkFloat32List _sharedSkColor3 = mallocFloat32List(4);
12051224

12061225
@JS('window.flutterCanvasKit.Path')
1226+
@staticInterop
12071227
class SkPath {
1208-
external SkPath([SkPath? other]);
1228+
external factory SkPath([SkPath? other]);
1229+
}
1230+
1231+
extension SkPathExtension on SkPath {
12091232
external void setFillType(SkFillType fillType);
12101233
external void addArc(
12111234
Float32List oval,

0 commit comments

Comments
 (0)