blob: 717084d72c553a694afee9b4c3200795cfa6f7e1 [file] [log] [blame]
Kevin Lubick217056c2018-09-20 17:39:31 -04001/*
2 * This externs file prevents the Closure JS compiler from minifying away
3 * names of objects created by Emscripten.
4 * Basically, by defining empty objects and functions here, Closure will
5 * know not to rename them. This is needed because of our pre-js files,
6 * that is, the JS we hand-write to bundle into the output. That JS will be
7 * hit by the closure compiler and thus needs to know about what functions
8 * have special names and should not be minified.
9 *
10 * Emscripten does not support automatically generating an externs file, so we
11 * do it by hand. The general process is to write some JS code, and then put any
12 * calls to CanvasKit or related things in here. Running ./compile.sh and then
13 * looking at the minified results or running the Release trybot should
14 * verify nothing was missed. Optionally, looking directly at the minified
15 * pathkit.js can be useful when developing locally.
16 *
17 * Docs:
18 * https://github.com/cljsjs/packages/wiki/Creating-Externs
19 * https://github.com/google/closure-compiler/wiki/Types-in-the-Closure-Type-System
20 *
21 * Example externs:
22 * https://github.com/google/closure-compiler/tree/master/externs
23 */
24
25var CanvasKit = {
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -050026 // public API (i.e. things we declare in the pre-js file or in the cpp bindings)
27 Color: function() {},
28 /** @return {CanvasKit.SkRect} */
29 LTRBRect: function() {},
30 /** @return {CanvasKit.SkRect} */
31 XYWHRect: function() {},
32 /** @return {CanvasKit.SkRRect} */
33 RRectXY: function() {},
34 /** @return {ImageData} */
35 ImageData: function() {},
Kevin Lubick543f3522019-03-08 10:04:28 -050036
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -050037 GetWebGLContext: function() {},
38 MakeBlurMaskFilter: function() {},
39 MakeCanvas: function() {},
40 MakeCanvasSurface: function() {},
41 MakeGrContext: function() {},
42 /** @return {CanvasKit.SkAnimatedImage} */
43 MakeAnimatedImageFromEncoded: function() {},
44 /** @return {CanvasKit.SkImage} */
45 MakeImage: function() {},
46 /** @return {CanvasKit.SkImage} */
47 MakeImageFromEncoded: function() {},
48 /** @return {LinearCanvasGradient} */
49 MakeLinearGradientShader: function() {},
50 MakeOnScreenGLSurface: function() {},
51 MakePathFromCmds: function() {},
52 MakePathFromOp: function() {},
53 MakePathFromSVGString: function() {},
54 MakeRadialGradientShader: function() {},
55 MakeRenderTarget: function() {},
56 MakeSkPicture: function() {},
57 MakeSWCanvasSurface: function() {},
58 MakeManagedAnimation: function() {},
59 MakeParticles: function() {},
60 MakeSkDashPathEffect: function() {},
61 MakeSkVertices: function() {},
62 MakeSurface: function() {},
63 /** @return {RadialCanvasGradient} */
64 MakeTwoPointConicalGradientShader: function() {},
65 MakeWebGLCanvasSurface: function() {},
66 /** @return {TypedArray} */
67 Malloc: function() {},
68 /** @return {TonalColors} */
69 computeTonalColors: function() {},
70 currentContext: function() {},
71 getColorComponents: function() {},
72 getDecodeCacheLimitBytes: function() {},
73 getDecodeCacheUsageBytes: function() {},
74 getSkDataBytes: function() {},
75 multiplyByAlpha: function() {},
76 parseColorString: function() {},
77 setCurrentContext: function() {},
78 setDecodeCacheLimitBytes: function() {},
Kevin Lubick217056c2018-09-20 17:39:31 -040079
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -050080 // private API (i.e. things declared in the bindings that we use
81 // in the pre-js file)
82 _MakeImage: function() {},
83 _MakeLinearGradientShader: function() {},
84 _MakePathFromCmds: function() {},
85 _MakeRadialGradientShader: function() {},
86 _MakeManagedAnimation: function() {},
87 _MakeParticles: function() {},
88 _MakeSkDashPathEffect: function() {},
89 _MakeSkPicture: function() {},
90 _MakeSkVertices: function() {},
91 _MakeTwoPointConicalGradientShader: function() {},
92 _decodeAnimatedImage: function() {},
93 _decodeImage: function() {},
94 _drawShapedText: function() {},
95 _getRasterDirectSurface: function() {},
96 _getRasterN32PremulSurface: function() {},
Kevin Lubick217056c2018-09-20 17:39:31 -040097
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -050098 // The testing object is meant to expose internal functions
99 // for more fine-grained testing, e.g. parseColor
100 _testing: {},
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500101
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500102 // Objects and properties on CanvasKit
Kevin Lubick217056c2018-09-20 17:39:31 -0400103
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500104 GrContext: {
105 // public API (from C++ bindings)
106 getResourceCacheLimitBytes: function() {},
107 getResourceCacheUsageBytes: function() {},
108 releaseResourcesAndAbandonContext: function() {},
109 setResourceCacheLimitBytes: function() {},
110 },
Kevin Lubickcd544662019-03-22 15:41:36 -0400111
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500112 Paragraph: {
113 // public API (from C++ bindings)
114 didExceedMaxLines: function() {},
115 getAlphabeticBaseline: function() {},
116 getGlyphPositionAtCoordinate: function() {},
117 getHeight: function() {},
118 getIdeographicBaseline: function() {},
119 getLongestLine: function() {},
120 getMaxIntrinsicWidth: function() {},
121 getMaxWidth: function() {},
122 getMinIntrinsicWidth: function() {},
123 getWordBoundary: function() {},
124 layout: function() {},
Kevin Lubick369f6a52019-10-03 11:22:08 -0400125
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500126 // private API
127 /** @return {Float32Array} */
128 _getRectsForRange: function() {},
129 },
Kevin Lubick369f6a52019-10-03 11:22:08 -0400130
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500131 SkRuntimeEffect: {
132 // public API (from C++ bindings)
133 Make: function() {},
Kevin Lubick4b5b6452019-12-06 13:55:58 -0500134
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500135 // private API
136 _makeShader: function() {},
137 _makeShaderWithChildren: function() {},
138 },
Kevin Lubick4b5b6452019-12-06 13:55:58 -0500139
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500140 ParagraphStyle: function() {},
141 RSXFormBuilder: function() {},
142 SkColorBuilder: function() {},
143 SkRectBuilder: function() {},
Kevin Lubickd3cfbca2019-03-15 15:36:29 -0400144
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500145 ShapedText: {
146 // public API (from C++ bindings)
147 getBounds: function() {},
148 },
Kevin Lubick1ba9c4d2019-02-22 10:04:06 -0500149
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500150 SkAnimatedImage: {
151 // public API (from C++ bindings)
152 decodeNextFrame: function() {},
153 getFrameCount: function() {},
154 getRepetitionCount: function() {},
155 height: function() {},
156 reset: function() {},
157 width: function() {},
158 },
Kevin Lubick6b921b72019-09-18 16:18:17 -0400159
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500160 SkCanvas: {
161 // public API (from C++ bindings)
162 clear: function() {},
163 clipPath: function() {},
164 clipRRect: function() {},
165 clipRect: function() {},
166 concat: function() {},
167 drawAnimatedImage: function() {},
168 drawArc: function() {},
169 drawCircle: function() {},
170 drawColor: function() {},
171 drawDRRect: function() {},
172 drawImage: function() {},
173 drawImageNine: function() {},
174 drawImageRect: function() {},
175 drawLine: function() {},
176 drawOval: function() {},
177 drawPaint: function() {},
178 drawParagraph: function() {},
179 drawPath: function() {},
180 drawPicture: function() {},
181 drawRRect: function() {},
182 drawRect: function() {},
183 drawRoundRect: function() {},
184 drawShadow: function() {},
185 drawText: function() {},
186 drawTextBlob: function() {},
187 drawVertices: function() {},
188 flush: function() {},
189 getSaveCount: function() {},
190 getTotalMatrix: function() {},
191 makeSurface: function() {},
192 restore: function() {},
193 restoreToCount: function() {},
194 rotate: function() {},
195 save: function() {},
196 saveLayer: function() {},
197 scale: function() {},
198 skew: function() {},
199 translate: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400200
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500201 // private API
202 _drawAtlas: function() {},
203 _drawPoints: function() {},
204 _drawSimpleText: function() {},
205 _readPixels: function() {},
206 _writePixels: function() {},
207 delete: function() {},
208 },
Kevin Lubick006a6f32018-10-19 14:34:34 -0400209
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500210 SkColorFilter: {
211 // public API (from C++ bindings and JS interface)
212 MakeBlend: function() {},
213 MakeCompose: function() {},
214 MakeLerp: function() {},
215 MakeLinearToSRGBGamma: function() {},
216 MakeMatrix: function() {},
217 MakeSRGBToLinearGamma: function() {},
218 // private API (from C++ bindings)
219 _makeMatrix: function() {},
220 },
Kevin Lubickd3729342019-09-12 11:11:25 -0400221
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500222 SkColorMatrix: {
223 concat: function() {},
224 identity: function() {},
225 postTranslate: function() {},
226 rotated: function() {},
227 scaled: function() {},
228 },
Kevin Lubickd3729342019-09-12 11:11:25 -0400229
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500230 SkContourMeasureIter: {
231 next: function() {},
232 },
Kevin Lubicke59c1672019-11-20 14:17:53 -0500233
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500234 SkContourMeasure: {
235 getPosTan: function() {},
236 getSegment: function() {},
237 isClosed: function() {},
238 length: function() {},
239 },
Kevin Lubicke59c1672019-11-20 14:17:53 -0500240
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500241 SkFont: {
242 // public API (from C++ bindings)
243 getScaleX: function() {},
244 getSize: function() {},
245 getSkewX: function() {},
246 getTypeface: function() {},
247 measureText: function() {},
248 setHinting: function() {},
249 setLinearMetrics: function() {},
250 setScaleX: function() {},
251 setSize: function() {},
252 setSkewX: function() {},
253 setSubpixel: function() {},
254 setTypeface: function() {},
255 // private API (from C++ bindings)
256 _getWidths: function() {},
257 },
Kevin Lubick35ac0382019-01-02 15:13:57 -0500258
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500259 SkFontMgr: {
260 // public API (from C++ and JS bindings)
261 FromData: function() {},
262 RefDefault: function() {},
263 countFamilies: function() {},
264 getFamilyName: function() {},
Kevin Lubickddd0a332018-12-12 10:35:13 -0500265
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500266 // private API
267 _makeTypefaceFromData: function() {},
268 _fromData: function() {},
269 },
Kevin Lubickddd0a332018-12-12 10:35:13 -0500270
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500271 SkImage: {
272 // public API (from C++ bindings)
273 height: function() {},
274 width: function() {},
275 // private API
276 _encodeToData: function() {},
277 _encodeToDataWithFormat: function() {},
278 _makeShader: function() {},
279 },
Kevin Lubick006a6f32018-10-19 14:34:34 -0400280
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500281 SkImageFilter: {
282 MakeBlur: function() {},
283 MakeColorFilter: function() {},
284 MakeCompose: function() {},
285 MakeMatrixTransform: function() {},
286 },
Kevin Lubick15b40232019-10-29 09:55:39 -0400287
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500288 // These are defined in interface.js
289 SkM44: {
290 identity: function() {},
291 invert: function() {},
292 multiply: function() {},
293 rotatedUnitSinCos: function() {},
294 rotated: function() {},
295 scaled: function() {},
296 translated: function() {},
297 lookat: function() {},
298 perspective: function() {},
299 rc: function() {},
300 transpose: function() {},
301 },
Nathaniel Nifong77798b42020-02-21 17:15:22 -0500302
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500303 SkMatrix: {
304 identity: function() {},
305 invert: function() {},
306 mapPoints: function() {},
307 multiply: function() {},
308 rotated: function() {},
309 scaled: function() {},
310 skewed: function() {},
311 translated: function() {},
312 },
Kevin Lubickb9db3902018-11-26 11:47:54 -0500313
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500314 SkMaskFilter: {
315 MakeBlur: function() {},
316 },
Kevin Lubick15b40232019-10-29 09:55:39 -0400317
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500318 SkPaint: {
319 // public API (from C++ bindings)
320 /** @return {CanvasKit.SkPaint} */
321 copy: function() {},
322 getBlendMode: function() {},
323 getColor: function() {},
324 getFilterQuality: function() {},
325 getStrokeCap: function() {},
326 getStrokeJoin: function() {},
327 getStrokeMiter: function() {},
328 getStrokeWidth: function() {},
329 setAntiAlias: function() {},
330 setBlendMode: function() {},
331 setColor: function() {},
332 setFilterQuality: function() {},
333 setImageFilter: function() {},
334 setMaskFilter: function() {},
335 setPathEffect: function() {},
336 setShader: function() {},
337 setStrokeCap: function() {},
338 setStrokeJoin: function() {},
339 setStrokeMiter: function() {},
340 setStrokeWidth: function() {},
341 setStyle: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500342
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500343 // Private API
344 delete: function() {},
345 },
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500346
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500347 SkPathEffect: {
348 MakeDash: function() {},
349 },
Nathaniel Nifong23b0ed92020-03-04 15:43:50 -0500350
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500351 SkParticleEffect: {
352 // public API (from C++ bindings)
353 draw: function() {},
354 getEffectUniform: function() {},
355 getEffectUniformCount: function() {},
356 getEffectUniformFloatCount: function() {},
357 getEffectUniformName: function() {},
358 getParticleUniformCount: function() {},
359 getParticleUniformFloatCount: function() {},
360 getParticleUniformName: function() {},
361 getParticleUniform: function() {},
362 setPosition: function() {},
363 setRate: function() {},
364 start: function() {},
365 update: function() {},
Kevin Lubickf8f9cd82020-02-21 08:26:59 -0500366
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500367 // private API (from C++ bindings)
368 _effectUniformPtr: function() {},
369 _particleUniformPtr: function() {},
370 },
Kevin Lubickf8f9cd82020-02-21 08:26:59 -0500371
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500372 SkPath: {
373 // public API (from C++ bindings)
374 computeTightBounds: function() {},
375 contains: function() {},
376 /** @return {CanvasKit.SkPath} */
377 copy: function() {},
378 countPoints: function() {},
379 equals: function() {},
380 getBounds: function() {},
381 getFillType: function() {},
382 getPoint: function() {},
383 isEmpty: function() {},
384 isVolatile: function() {},
385 reset: function() {},
386 rewind: function() {},
387 setFillType: function() {},
388 setIsVolatile: function() {},
389 toSVGString: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400390
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500391 // private API
392 _addArc: function() {},
393 _addOval: function() {},
394 _addPath: function() {},
395 _addRect: function() {},
396 _addPoly: function() {},
397 _addRoundRect: function() {},
398 _arc: function() {},
399 _arcTo: function() {},
400 _close: function() {},
401 _conicTo: function() {},
402 _cubicTo: function() {},
403 _dash: function() {},
404 _lineTo: function() {},
405 _moveTo: function() {},
406 _op: function() {},
407 _quadTo: function() {},
408 _rArcTo: function() {},
409 _rConicTo: function() {},
410 _rCubicTo: function() {},
411 _rLineTo: function() {},
412 _rMoveTo: function() {},
413 _rQuadTo: function() {},
414 _rect: function() {},
415 _simplify: function() {},
416 _stroke: function() {},
417 _transform: function() {},
418 _trim: function() {},
419 delete: function() {},
420 dump: function() {},
421 dumpHex: function() {},
422 },
Kevin Lubickd3cfbca2019-03-15 15:36:29 -0400423
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500424 SkPathMeasure: {
425 getLength: function() {},
426 getSegment: function() {},
427 getPosTan: function() {},
428 isClosed: function() {},
429 nextContour: function() {},
430 },
Kevin Lubickcc13fd32019-04-05 13:00:01 -0400431
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500432 SkPicture: {
433 serialize: function() {},
434 },
Kevin Lubickcc13fd32019-04-05 13:00:01 -0400435
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500436 SkPictureRecorder: {
437 beginRecording: function() {},
438 finishRecordingAsPicture: function() {},
439 },
Kevin Lubick006a6f32018-10-19 14:34:34 -0400440
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500441 SkRect: {
442 fLeft: {},
443 fTop: {},
444 fRight: {},
445 fBottom: {},
446 },
Kevin Lubick2e5fe352019-09-03 12:59:06 -0400447
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500448 SkRRect: {
449 rect: {},
450 rx1: {},
451 ry1: {},
452 rx2: {},
453 ry2: {},
454 rx3: {},
455 ry3: {},
456 rx4: {},
457 ry4: {},
458 },
Kevin Lubick62836902019-12-09 09:04:26 -0500459
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500460 SkShader: {
461 Blend: function() {},
462 Color: function() {},
463 Empty: function() {},
464 Lerp: function() {},
Kevin Lubick62836902019-12-09 09:04:26 -0500465
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500466 _Blend: function() {},
467 _Lerp: function() {},
468 },
Kevin Lubick006a6f32018-10-19 14:34:34 -0400469
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500470 SkSurface: {
471 // public API (from C++ bindings)
472 /** @return {CanvasKit.SkCanvas} */
473 getCanvas: function() {},
474 /** @return {CanvasKit.SkImage} */
475 makeImageSnapshot: function() {},
476 makeSurface: function() {},
477 grContext: {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400478
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500479 // private API
480 _flush: function() {},
481 _getRasterN32PremulSurface: function() {},
482 delete: function() {},
483 },
Kevin Lubickec4903d2019-01-14 08:36:08 -0500484
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500485 SkTextBlob: {
486 // public API (both C++ and JS bindings)
487 MakeFromRSXform: function() {},
488 MakeFromText: function() {},
489 MakeOnPath: function() {},
490 // private API (from C++ bindings)
491 _MakeFromRSXform: function() {},
492 _MakeFromText: function() {},
493 },
Nathaniel Nifong77798b42020-02-21 17:15:22 -0500494
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500495 // These are defined in interface.js
496 SkVector: {
497 add: function() {},
498 sub: function() {},
499 dot: function() {},
500 cross: function() {},
501 normalize: function() {},
502 mulScalar: function() {},
503 length: function() {},
504 lengthSquared: function() {},
505 dist: function() {},
506 },
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400507
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500508 SkVertices: {
509 // public API (from C++ bindings)
510 bounds: function() {},
511 mode: function() {},
512 uniqueID: function() {},
513 vertexCount: function() {},
514 },
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400515
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500516 _SkVerticesBuilder: {
517 colors: function() {},
518 detach: function() {},
519 indices: function() {},
520 positions: function() {},
521 texCoords: function() {},
522 },
Kevin Lubickd6ba7252019-06-03 14:38:05 -0400523
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500524 TextStyle: function() {},
Kevin Lubick369f6a52019-10-03 11:22:08 -0400525
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500526 // Constants and Enums
527 gpu: {},
528 skottie: {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400529
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500530 TRANSPARENT: {},
531 RED: {},
532 BLUE: {},
533 YELLOW: {},
534 CYAN: {},
535 BLACK: {},
536 WHITE: {},
Kevin Lubickea905ec2018-11-30 14:05:58 -0500537
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500538 MOVE_VERB: {},
539 LINE_VERB: {},
540 QUAD_VERB: {},
541 CONIC_VERB: {},
542 CUBIC_VERB: {},
543 CLOSE_VERB: {},
Kevin Lubickda3d8ac2019-01-07 11:08:55 -0500544
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500545 NoDecoration: {},
546 UnderlineDecoration: {},
547 OverlineDecoration: {},
548 LineThroughDecoration: {},
Kevin Lubick369f6a52019-10-03 11:22:08 -0400549
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500550 SaveLayerInitWithPrevious: {},
551 SaveLayerF16ColorType: {},
Kevin Lubick77d9b5c2019-10-29 10:48:26 -0400552
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500553 Affinity: {
554 Upstream: {},
555 Downstream: {},
556 },
Kevin Lubick369f6a52019-10-03 11:22:08 -0400557
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500558 AlphaType: {
559 Opaque: {},
560 Premul: {},
561 Unpremul: {},
562 },
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500563
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500564 BlendMode: {
565 Clear: {},
566 Src: {},
567 Dst: {},
568 SrcOver: {},
569 DstOver: {},
570 SrcIn: {},
571 DstIn: {},
572 SrcOut: {},
573 DstOut: {},
574 SrcATop: {},
575 DstATop: {},
576 Xor: {},
577 Plus: {},
578 Modulate: {},
579 Screen: {},
580 Overlay: {},
581 Darken: {},
582 Lighten: {},
583 ColorDodge: {},
584 ColorBurn: {},
585 HardLight: {},
586 SoftLight: {},
587 Difference: {},
588 Exclusion: {},
589 Multiply: {},
590 Hue: {},
591 Saturation: {},
592 Color: {},
593 Luminosity: {},
594 },
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500595
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500596 BlurStyle: {
597 Normal: {},
598 Solid: {},
599 Outer: {},
600 Inner: {},
601 },
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500602
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500603 ClipOp: {
604 Difference: {},
605 Intersect: {},
606 },
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500607
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500608 ColorType: {
609 Alpha_8: {},
610 RGB_565: {},
611 ARGB_4444: {},
612 RGBA_8888: {},
613 RGB_888x: {},
614 BGRA_8888: {},
615 RGBA_1010102: {},
616 RGB_101010x: {},
617 Gray_8: {},
618 RGBA_F16: {},
619 RGBA_F32: {},
620 },
Kevin Lubickea905ec2018-11-30 14:05:58 -0500621
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500622 FillType: {
623 Winding: {},
624 EvenOdd: {},
625 InverseWinding: {},
626 InverseEvenOdd: {},
627 },
Kevin Lubick006a6f32018-10-19 14:34:34 -0400628
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500629 FilterQuality: {
630 None: {},
631 Low: {},
632 Medium: {},
633 High: {},
634 },
Kevin Lubick0a1293c2018-12-03 12:31:04 -0500635
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500636 FontSlant: {
637 Upright: {},
638 Italic: {},
639 Oblique: {},
640 },
Kevin Lubickd3b1fe62019-10-21 10:50:26 -0400641
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500642 FontHinting: {
643 None: {},
644 Slight: {},
645 Normal: {},
646 Full: {},
647 },
Kevin Lubickbde9fcc2020-02-28 08:09:08 -0500648
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500649 FontWeight: {
650 Invisible: {},
651 Thin: {},
652 ExtraLight: {},
653 Light: {},
654 Normal: {},
655 Medium: {},
656 SemiBold: {},
657 Bold: {},
658 ExtraBold: {},
659 Black: {},
660 ExtraBlack: {},
661 },
Kevin Lubickd3b1fe62019-10-21 10:50:26 -0400662
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500663 FontWidth: {
664 UltraCondensed: {},
665 ExtraCondensed: {},
666 Condensed: {},
667 SemiCondensed: {},
668 Normal: {},
669 SemiExpanded: {},
670 Expanded: {},
671 ExtraExpanded: {},
672 UltraExpanded: {},
673 },
Kevin Lubickd3b1fe62019-10-21 10:50:26 -0400674
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500675 ImageFormat: {
676 PNG: {},
677 JPEG: {},
678 },
Alexander Khovansky3e119332018-11-15 02:01:19 +0300679
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500680 PaintStyle: {
681 Fill: {},
682 Stroke: {},
683 StrokeAndFill: {},
684 },
Kevin Lubickb9db3902018-11-26 11:47:54 -0500685
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500686 PathOp: {
687 Difference: {},
688 Intersect: {},
689 Union: {},
690 XOR: {},
691 ReverseDifference: {},
692 },
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500693
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500694 PointMode: {
695 Points: {},
696 Lines: {},
697 Polygon: {},
698 },
Kevin Lubick37ab53e2019-11-11 10:06:08 -0500699
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500700 RectHeightStyle: {
701 Tight: {},
702 Max: {},
703 IncludeLineSpacingMiddle: {},
704 IncludeLineSpacingTop: {},
705 IncludeLineSpacingBottom: {},
706 },
Kevin Lubick369f6a52019-10-03 11:22:08 -0400707
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500708 RectWidthStyle: {
709 Tight: {},
710 Max: {},
711 },
Kevin Lubick369f6a52019-10-03 11:22:08 -0400712
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500713 StrokeCap: {
714 Butt: {},
715 Round: {},
716 Square: {},
717 },
Kevin Lubickb9db3902018-11-26 11:47:54 -0500718
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500719 StrokeJoin: {
720 Miter: {},
721 Round: {},
722 Bevel: {},
723 },
Kevin Lubickb9db3902018-11-26 11:47:54 -0500724
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500725 TextAlign: {
726 Left: {},
727 Right: {},
728 Center: {},
729 Justify: {},
730 Start: {},
731 End: {},
732 },
Kevin Lubick369f6a52019-10-03 11:22:08 -0400733
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500734 TextDirection: {
735 LTR: {},
736 RTL: {},
737 },
Kevin Lubickd3b1fe62019-10-21 10:50:26 -0400738
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500739 TextEncoding: {
740 UTF8: {},
741 UTF16: {},
742 UTF32: {},
743 GlyphID: {},
744 },
Kevin Lubickec4903d2019-01-14 08:36:08 -0500745
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500746 TileMode: {
747 Clamp: {},
748 Repeat: {},
749 Mirror: {},
750 Decal: {},
751 },
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500752
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500753 VertexMode: {
754 Triangles: {},
755 TrianglesStrip: {},
756 TriangleFan: {},
757 },
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500758
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500759 // Things Enscriptem adds for us
Kevin Lubick006a6f32018-10-19 14:34:34 -0400760
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500761 /**
762 * @type {Float32Array}
763 */
764 HEAPF32: {},
765 /**
766 * @type {Float64Array}
767 */
768 HEAPF64: {},
769 /**
770 * @type {Uint8Array}
771 */
772 HEAPU8: {},
773 /**
774 * @type {Uint16Array}
775 */
776 HEAPU16: {},
777 /**
778 * @type {Uint32Array}
779 */
780 HEAPU32: {},
781 /**
782 * @type {Int8Array}
783 */
784 HEAP8: {},
785 /**
786 * @type {Int16Array}
787 */
788 HEAP16: {},
789 /**
790 * @type {Int32Array}
791 */
792 HEAP32: {},
Kevin Lubickfa5a1382019-10-09 10:46:14 -0400793
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500794 _malloc: function() {},
795 _free: function() {},
796 onRuntimeInitialized: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400797};
Kevin Lubick217056c2018-09-20 17:39:31 -0400798
Kevin Lubick006a6f32018-10-19 14:34:34 -0400799// Public API things that are newly declared in the JS should go here.
800// It's not enough to declare them above, because closure can still erase them
801// unless they go on the prototype.
Kevin Lubick369f6a52019-10-03 11:22:08 -0400802CanvasKit.Paragraph.prototype.getRectsForRange = function() {};
803
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500804CanvasKit.SkPath.prototype.addArc = function() {};
Kevin Lubicke384df42019-08-26 15:48:09 -0400805CanvasKit.SkPath.prototype.addOval = function() {};
Kevin Lubick217056c2018-09-20 17:39:31 -0400806CanvasKit.SkPath.prototype.addPath = function() {};
Kevin Lubick37ab53e2019-11-11 10:06:08 -0500807CanvasKit.SkPath.prototype.addPoly = function() {};
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500808CanvasKit.SkPath.prototype.addRect = function() {};
Kevin Lubickda3d8ac2019-01-07 11:08:55 -0500809CanvasKit.SkPath.prototype.addRoundRect = function() {};
Alexander Khovansky3e119332018-11-15 02:01:19 +0300810CanvasKit.SkPath.prototype.arc = function() {};
Kevin Lubick006a6f32018-10-19 14:34:34 -0400811CanvasKit.SkPath.prototype.arcTo = function() {};
Kevin Lubick217056c2018-09-20 17:39:31 -0400812CanvasKit.SkPath.prototype.close = function() {};
Kevin Lubick006a6f32018-10-19 14:34:34 -0400813CanvasKit.SkPath.prototype.conicTo = function() {};
814CanvasKit.SkPath.prototype.cubicTo = function() {};
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400815CanvasKit.SkPath.prototype.dash = function() {};
Kevin Lubick006a6f32018-10-19 14:34:34 -0400816CanvasKit.SkPath.prototype.lineTo = function() {};
817CanvasKit.SkPath.prototype.moveTo = function() {};
Kevin Lubicke384df42019-08-26 15:48:09 -0400818CanvasKit.SkPath.prototype.offset = function() {};
Kevin Lubick006a6f32018-10-19 14:34:34 -0400819CanvasKit.SkPath.prototype.op = function() {};
820CanvasKit.SkPath.prototype.quadTo = function() {};
Kevin Lubick79b71342019-11-01 14:36:52 -0400821CanvasKit.SkPath.prototype.rArcTo = function() {};
822CanvasKit.SkPath.prototype.rConicTo = function() {};
823CanvasKit.SkPath.prototype.rCubicTo = function() {};
824CanvasKit.SkPath.prototype.rLineTo = function() {};
825CanvasKit.SkPath.prototype.rMoveTo = function() {};
826CanvasKit.SkPath.prototype.rQuadTo = function() {};
Kevin Lubick006a6f32018-10-19 14:34:34 -0400827CanvasKit.SkPath.prototype.rect = function() {};
Kevin Lubick217056c2018-09-20 17:39:31 -0400828CanvasKit.SkPath.prototype.simplify = function() {};
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400829CanvasKit.SkPath.prototype.stroke = function() {};
Kevin Lubick217056c2018-09-20 17:39:31 -0400830CanvasKit.SkPath.prototype.transform = function() {};
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400831CanvasKit.SkPath.prototype.trim = function() {};
Kevin Lubick217056c2018-09-20 17:39:31 -0400832
Kevin Lubicka4f218d2020-01-14 08:39:09 -0500833CanvasKit.SkPicture.prototype.saveAsFile = function() {};
Kevin Lubickcc13fd32019-04-05 13:00:01 -0400834
Kevin Lubick5b90b842018-10-17 07:57:18 -0400835CanvasKit.SkSurface.prototype.dispose = function() {};
Kevin Lubick359a7e32019-03-19 09:34:37 -0400836CanvasKit.SkSurface.prototype.flush = function() {};
837CanvasKit.SkSurface.prototype.requestAnimationFrame = function() {};
Bryce Thomas2c5b8562020-01-22 13:49:41 -0800838CanvasKit.SkSurface.prototype.drawOnce = function() {};
Kevin Lubickcc13fd32019-04-05 13:00:01 -0400839CanvasKit.SkSurface.prototype.captureFrameAsSkPicture = function() {};
Kevin Lubick53965c92018-10-11 08:51:55 -0400840
Alexander Khovansky3e119332018-11-15 02:01:19 +0300841CanvasKit.SkImage.prototype.encodeToData = function() {};
Kevin Lubicka064c282019-04-04 09:28:53 -0400842CanvasKit.SkImage.prototype.makeShader = function() {};
Alexander Khovansky3e119332018-11-15 02:01:19 +0300843
Kevin Lubickee91c072019-03-29 10:39:52 -0400844CanvasKit.SkCanvas.prototype.drawAtlas = function() {};
Kevin Lubick37ab53e2019-11-11 10:06:08 -0500845CanvasKit.SkCanvas.prototype.drawPoints = function() {};
Kevin Lubickec4903d2019-01-14 08:36:08 -0500846CanvasKit.SkCanvas.prototype.drawText = function() {};
Kevin Lubick52b9f372018-12-04 13:57:36 -0500847/** @return {Uint8Array} */
848CanvasKit.SkCanvas.prototype.readPixels = function() {};
849CanvasKit.SkCanvas.prototype.writePixels = function() {};
850
Kevin Lubickddd0a332018-12-12 10:35:13 -0500851CanvasKit.SkFontMgr.prototype.MakeTypefaceFromData = function() {};
852
Kevin Lubickd3cfbca2019-03-15 15:36:29 -0400853CanvasKit.SkFont.prototype.getWidths = function() {};
854
855CanvasKit.RSXFormBuilder.prototype.build = function() {};
856CanvasKit.RSXFormBuilder.prototype.delete = function() {};
857CanvasKit.RSXFormBuilder.prototype.push = function() {};
Kevin Lubickee91c072019-03-29 10:39:52 -0400858CanvasKit.RSXFormBuilder.prototype.set = function() {};
859
860CanvasKit.SkColorBuilder.prototype.build = function() {};
861CanvasKit.SkColorBuilder.prototype.delete = function() {};
862CanvasKit.SkColorBuilder.prototype.push = function() {};
863CanvasKit.SkColorBuilder.prototype.set = function() {};
Kevin Lubickd3cfbca2019-03-15 15:36:29 -0400864
Kevin Lubickf3d6c362020-01-06 08:11:52 -0500865CanvasKit.SkRuntimeEffect.prototype.makeShader = function() {};
Kevin Lubickecd87622020-02-22 07:37:33 -0500866CanvasKit.SkRuntimeEffect.prototype.makeShaderWithChildren = function() {};
Kevin Lubick4b5b6452019-12-06 13:55:58 -0500867
Kevin Lubickf8f9cd82020-02-21 08:26:59 -0500868CanvasKit.SkParticleEffect.prototype.effectUniforms = function() {};
869CanvasKit.SkParticleEffect.prototype.particleUniforms = function() {};
870
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400871// Define StrokeOpts object
872var StrokeOpts = {};
873StrokeOpts.prototype.width;
874StrokeOpts.prototype.miter_limit;
875StrokeOpts.prototype.cap;
876StrokeOpts.prototype.join;
Kevin Lubick1646e7d2018-12-07 13:03:08 -0500877StrokeOpts.prototype.precision;
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400878
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500879// Define everything created in the canvas2d spec here
Kevin Lubickb9db3902018-11-26 11:47:54 -0500880var HTMLCanvas = {};
Kevin Lubick0a1293c2018-12-03 12:31:04 -0500881HTMLCanvas.prototype.decodeImage = function() {};
882HTMLCanvas.prototype.dispose = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500883HTMLCanvas.prototype.getContext = function() {};
Kevin Lubick8e4a3312018-12-14 15:03:41 -0500884HTMLCanvas.prototype.loadFont = function() {};
Kevin Lubicka40f8322018-12-17 16:01:36 -0500885HTMLCanvas.prototype.makePath2D = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500886HTMLCanvas.prototype.toDataURL = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500887
888var CanvasRenderingContext2D = {};
889CanvasRenderingContext2D.prototype.addHitRegion = function() {};
890CanvasRenderingContext2D.prototype.arc = function() {};
891CanvasRenderingContext2D.prototype.arcTo = function() {};
892CanvasRenderingContext2D.prototype.beginPath = function() {};
893CanvasRenderingContext2D.prototype.bezierCurveTo = function() {};
894CanvasRenderingContext2D.prototype.clearHitRegions = function() {};
Kevin Lubick12c0e502018-11-28 12:51:56 -0500895CanvasRenderingContext2D.prototype.clearRect = function() {};
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500896CanvasRenderingContext2D.prototype.clip = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500897CanvasRenderingContext2D.prototype.closePath = function() {};
Kevin Lubick52b9f372018-12-04 13:57:36 -0500898CanvasRenderingContext2D.prototype.createImageData = function() {};
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500899CanvasRenderingContext2D.prototype.createLinearGradient = function() {};
Kevin Lubickd29edd72018-12-07 08:29:52 -0500900CanvasRenderingContext2D.prototype.createPattern = function() {};
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500901CanvasRenderingContext2D.prototype.createRadialGradient = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500902CanvasRenderingContext2D.prototype.drawFocusIfNeeded = function() {};
Kevin Lubick0a1293c2018-12-03 12:31:04 -0500903CanvasRenderingContext2D.prototype.drawImage = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500904CanvasRenderingContext2D.prototype.ellipse = function() {};
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500905CanvasRenderingContext2D.prototype.fill = function() {};
Kevin Lubick12c0e502018-11-28 12:51:56 -0500906CanvasRenderingContext2D.prototype.fillRect = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500907CanvasRenderingContext2D.prototype.fillText = function() {};
Kevin Lubick52b9f372018-12-04 13:57:36 -0500908CanvasRenderingContext2D.prototype.getImageData = function() {};
Kevin Lubick12c0e502018-11-28 12:51:56 -0500909CanvasRenderingContext2D.prototype.getLineDash = function() {};
Kevin Lubick1646e7d2018-12-07 13:03:08 -0500910CanvasRenderingContext2D.prototype.isPointInPath = function() {};
911CanvasRenderingContext2D.prototype.isPointInStroke = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500912CanvasRenderingContext2D.prototype.lineTo = function() {};
913CanvasRenderingContext2D.prototype.measureText = function() {};
914CanvasRenderingContext2D.prototype.moveTo = function() {};
Kevin Lubick52b9f372018-12-04 13:57:36 -0500915CanvasRenderingContext2D.prototype.putImageData = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500916CanvasRenderingContext2D.prototype.quadraticCurveTo = function() {};
917CanvasRenderingContext2D.prototype.rect = function() {};
918CanvasRenderingContext2D.prototype.removeHitRegion = function() {};
919CanvasRenderingContext2D.prototype.resetTransform = function() {};
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500920CanvasRenderingContext2D.prototype.restore = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500921CanvasRenderingContext2D.prototype.rotate = function() {};
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500922CanvasRenderingContext2D.prototype.save = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500923CanvasRenderingContext2D.prototype.scale = function() {};
924CanvasRenderingContext2D.prototype.scrollPathIntoView = function() {};
Kevin Lubick12c0e502018-11-28 12:51:56 -0500925CanvasRenderingContext2D.prototype.setLineDash = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500926CanvasRenderingContext2D.prototype.setTransform = function() {};
927CanvasRenderingContext2D.prototype.stroke = function() {};
Kevin Lubick12c0e502018-11-28 12:51:56 -0500928CanvasRenderingContext2D.prototype.strokeRect = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500929CanvasRenderingContext2D.prototype.strokeText = function() {};
930CanvasRenderingContext2D.prototype.transform = function() {};
931CanvasRenderingContext2D.prototype.translate = function() {};
932
Kevin Lubicka40f8322018-12-17 16:01:36 -0500933var Path2D = {};
934Path2D.prototype.addPath = function() {};
935Path2D.prototype.arc = function() {};
936Path2D.prototype.arcTo = function() {};
937Path2D.prototype.bezierCurveTo = function() {};
938Path2D.prototype.closePath = function() {};
939Path2D.prototype.ellipse = function() {};
940Path2D.prototype.lineTo = function() {};
941Path2D.prototype.moveTo = function() {};
942Path2D.prototype.quadraticCurveTo = function() {};
943Path2D.prototype.rect = function() {};
944
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500945var LinearCanvasGradient = {};
946LinearCanvasGradient.prototype.addColorStop = function() {};
947var RadialCanvasGradient = {};
948RadialCanvasGradient.prototype.addColorStop = function() {};
Kevin Lubickd29edd72018-12-07 08:29:52 -0500949var CanvasPattern = {};
950CanvasPattern.prototype.setTransform = function() {};
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500951
Kevin Lubick52b9f372018-12-04 13:57:36 -0500952var ImageData = {
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500953 /**
954 * @type {Uint8ClampedArray}
955 */
956 data: {},
957 height: {},
958 width: {},
Kevin Lubick52b9f372018-12-04 13:57:36 -0500959};
960
Kevin Lubickd29edd72018-12-07 08:29:52 -0500961var DOMMatrix = {
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500962 a: {},
963 b: {},
964 c: {},
965 d: {},
966 e: {},
967 f: {},
Kevin Lubickd29edd72018-12-07 08:29:52 -0500968};
969
Kevin Lubick217056c2018-09-20 17:39:31 -0400970// Not sure why this is needed - might be a bug in emsdk that this isn't properly declared.
Kevin Lubick6fccc9d2018-11-20 15:55:10 -0500971function loadWebAssemblyModule() {};