Skip to content

Commit eb13b0c

Browse files
joshualittjustinmc
authored andcommitted
[web] Migrate Flutter Web to JS static interop - 7. (flutter#32519)
1 parent c0dcbae commit eb13b0c

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
@@ -1072,23 +1072,20 @@ class SkPaint {
10721072

10731073
@JS()
10741074
@anonymous
1075+
@staticInterop
10751076
abstract class CkFilterOptions {}
10761077

10771078
@JS()
10781079
@anonymous
1080+
@staticInterop
10791081
class _CkCubicFilterOptions extends CkFilterOptions {
1080-
external double get B;
1081-
external double get C;
1082-
10831082
external factory _CkCubicFilterOptions({double B, double C});
10841083
}
10851084

10861085
@JS()
10871086
@anonymous
1087+
@staticInterop
10881088
class _CkTransformFilterOptions extends CkFilterOptions {
1089-
external SkFilterMode get filter;
1090-
external SkMipmapMode get mipmap;
1091-
10921089
external factory _CkTransformFilterOptions(
10931090
{SkFilterMode filter, SkMipmapMode mipmap});
10941091
}
@@ -1119,12 +1116,18 @@ CkFilterOptions toSkFilterOptions(ui.FilterQuality filterQuality) {
11191116

11201117
@JS()
11211118
@anonymous
1122-
class SkMaskFilter {
1119+
@staticInterop
1120+
class SkMaskFilter {}
1121+
1122+
extension SkMaskFilterExtension on SkMaskFilter {
11231123
external void delete();
11241124
}
11251125

11261126
@JS()
1127-
class SkColorFilterNamespace {
1127+
@staticInterop
1128+
class SkColorFilterNamespace {}
1129+
1130+
extension SkColorFilterNamespaceExtension on SkColorFilterNamespace {
11281131
external SkColorFilter? MakeBlend(Float32List color, SkBlendMode blendMode);
11291132
external SkColorFilter MakeMatrix(
11301133
Float32List matrix, // 20-element matrix
@@ -1136,12 +1139,18 @@ class SkColorFilterNamespace {
11361139

11371140
@JS()
11381141
@anonymous
1139-
class SkColorFilter {
1142+
@staticInterop
1143+
class SkColorFilter {}
1144+
1145+
extension SkColorFilterExtension on SkColorFilter {
11401146
external void delete();
11411147
}
11421148

11431149
@JS()
1144-
class SkImageFilterNamespace {
1150+
@staticInterop
1151+
class SkImageFilterNamespace {}
1152+
1153+
extension SkImageFilterNamespaceExtension on SkImageFilterNamespace {
11451154
external SkImageFilter MakeBlur(
11461155
double sigmaX,
11471156
double sigmaY,
@@ -1168,12 +1177,18 @@ class SkImageFilterNamespace {
11681177

11691178
@JS()
11701179
@anonymous
1171-
class SkImageFilter {
1180+
@staticInterop
1181+
class SkImageFilter {}
1182+
1183+
extension SkImageFilterExtension on SkImageFilter {
11721184
external void delete();
11731185
}
11741186

11751187
@JS()
1176-
class SkPathNamespace {
1188+
@staticInterop
1189+
class SkPathNamespace {}
1190+
1191+
extension SkPathNamespaceExtension on SkPathNamespace {
11771192
/// Creates an [SkPath] using commands obtained from [SkPath.toCmds].
11781193
external SkPath MakeFromCmds(List<dynamic> pathCommands);
11791194

@@ -1264,6 +1279,7 @@ Float32List toSkColorStops(List<double>? colorStops) {
12641279
external _NativeFloat32ArrayType get _nativeFloat32ArrayType;
12651280

12661281
@JS()
1282+
@staticInterop
12671283
class _NativeFloat32ArrayType {}
12681284

12691285
@JS('window.flutterCanvasKit.Malloc')
@@ -1294,7 +1310,10 @@ external void freeFloat32List(SkFloat32List list);
12941310
/// when WASM grows its memory. Call [toTypedArray] to get a new instance
12951311
/// that's attached to the current WASM memory block.
12961312
@JS()
1297-
class SkFloat32List {
1313+
@staticInterop
1314+
class SkFloat32List {}
1315+
1316+
extension SkFloat32ListExtension on SkFloat32List {
12981317
/// Returns the [Float32List] object backed by WASM memory.
12991318
///
13001319
/// Do not reuse the returned list across multiple WASM function/method
@@ -1349,8 +1368,12 @@ Float32List toSharedSkColor3(ui.Color color) {
13491368
final SkFloat32List _sharedSkColor3 = mallocFloat32List(4);
13501369

13511370
@JS('window.flutterCanvasKit.Path')
1371+
@staticInterop
13521372
class SkPath {
1353-
external SkPath([SkPath? other]);
1373+
external factory SkPath([SkPath? other]);
1374+
}
1375+
1376+
extension SkPathExtension on SkPath {
13541377
external void setFillType(SkFillType fillType);
13551378
external void addArc(
13561379
Float32List oval,

0 commit comments

Comments
 (0)