blob: f097782d23e1d7c1d178410aefe20930d54a2659 [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() {},
Dan Field3d44f732020-03-16 09:17:30 -070086 _MakeSweepGradientShader: function() {},
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -050087 _MakeManagedAnimation: function() {},
88 _MakeParticles: function() {},
89 _MakeSkDashPathEffect: function() {},
90 _MakeSkPicture: function() {},
91 _MakeSkVertices: function() {},
92 _MakeTwoPointConicalGradientShader: function() {},
93 _decodeAnimatedImage: function() {},
94 _decodeImage: function() {},
95 _drawShapedText: function() {},
96 _getRasterDirectSurface: function() {},
97 _getRasterN32PremulSurface: function() {},
Kevin Lubick217056c2018-09-20 17:39:31 -040098
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -050099 // The testing object is meant to expose internal functions
100 // for more fine-grained testing, e.g. parseColor
101 _testing: {},
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500102
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500103 // Objects and properties on CanvasKit
Kevin Lubick217056c2018-09-20 17:39:31 -0400104
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500105 GrContext: {
106 // public API (from C++ bindings)
107 getResourceCacheLimitBytes: function() {},
108 getResourceCacheUsageBytes: function() {},
109 releaseResourcesAndAbandonContext: function() {},
110 setResourceCacheLimitBytes: function() {},
111 },
Kevin Lubickcd544662019-03-22 15:41:36 -0400112
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500113 Paragraph: {
114 // public API (from C++ bindings)
115 didExceedMaxLines: function() {},
116 getAlphabeticBaseline: function() {},
117 getGlyphPositionAtCoordinate: function() {},
118 getHeight: function() {},
119 getIdeographicBaseline: function() {},
120 getLongestLine: function() {},
121 getMaxIntrinsicWidth: function() {},
122 getMaxWidth: function() {},
123 getMinIntrinsicWidth: function() {},
124 getWordBoundary: function() {},
125 layout: function() {},
Kevin Lubick369f6a52019-10-03 11:22:08 -0400126
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500127 // private API
128 /** @return {Float32Array} */
129 _getRectsForRange: function() {},
130 },
Kevin Lubick369f6a52019-10-03 11:22:08 -0400131
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500132 SkRuntimeEffect: {
133 // public API (from C++ bindings)
134 Make: function() {},
Kevin Lubick4b5b6452019-12-06 13:55:58 -0500135
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500136 // private API
137 _makeShader: function() {},
138 _makeShaderWithChildren: function() {},
139 },
Kevin Lubick4b5b6452019-12-06 13:55:58 -0500140
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500141 ParagraphStyle: function() {},
142 RSXFormBuilder: function() {},
143 SkColorBuilder: function() {},
144 SkRectBuilder: function() {},
Kevin Lubickd3cfbca2019-03-15 15:36:29 -0400145
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500146 ShapedText: {
147 // public API (from C++ bindings)
148 getBounds: function() {},
149 },
Kevin Lubick1ba9c4d2019-02-22 10:04:06 -0500150
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500151 SkAnimatedImage: {
152 // public API (from C++ bindings)
153 decodeNextFrame: function() {},
154 getFrameCount: function() {},
155 getRepetitionCount: function() {},
156 height: function() {},
157 reset: function() {},
158 width: function() {},
159 },
Kevin Lubick6b921b72019-09-18 16:18:17 -0400160
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500161 SkCanvas: {
162 // public API (from C++ bindings)
163 clear: function() {},
164 clipPath: function() {},
165 clipRRect: function() {},
166 clipRect: function() {},
167 concat: function() {},
168 drawAnimatedImage: function() {},
169 drawArc: function() {},
170 drawCircle: function() {},
171 drawColor: function() {},
172 drawDRRect: function() {},
173 drawImage: function() {},
174 drawImageNine: function() {},
175 drawImageRect: function() {},
176 drawLine: function() {},
177 drawOval: function() {},
178 drawPaint: function() {},
179 drawParagraph: function() {},
180 drawPath: function() {},
181 drawPicture: function() {},
182 drawRRect: function() {},
183 drawRect: function() {},
184 drawRoundRect: function() {},
185 drawShadow: function() {},
186 drawText: function() {},
187 drawTextBlob: function() {},
188 drawVertices: function() {},
189 flush: function() {},
190 getSaveCount: function() {},
191 getTotalMatrix: function() {},
192 makeSurface: function() {},
193 restore: function() {},
194 restoreToCount: function() {},
195 rotate: function() {},
196 save: function() {},
Kevin Lubick7957d532020-03-16 18:08:32 +0000197 saveLayer: function() {},
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500198 scale: function() {},
199 skew: function() {},
200 translate: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400201
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500202 // private API
203 _drawAtlas: function() {},
204 _drawPoints: function() {},
205 _drawSimpleText: function() {},
206 _readPixels: function() {},
207 _writePixels: function() {},
208 delete: function() {},
209 },
Kevin Lubick006a6f32018-10-19 14:34:34 -0400210
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500211 SkColorFilter: {
212 // public API (from C++ bindings and JS interface)
213 MakeBlend: function() {},
214 MakeCompose: function() {},
215 MakeLerp: function() {},
216 MakeLinearToSRGBGamma: function() {},
217 MakeMatrix: function() {},
218 MakeSRGBToLinearGamma: function() {},
219 // private API (from C++ bindings)
220 _makeMatrix: function() {},
221 },
Kevin Lubickd3729342019-09-12 11:11:25 -0400222
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500223 SkColorMatrix: {
224 concat: function() {},
225 identity: function() {},
226 postTranslate: function() {},
227 rotated: function() {},
228 scaled: function() {},
229 },
Kevin Lubickd3729342019-09-12 11:11:25 -0400230
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500231 SkContourMeasureIter: {
232 next: function() {},
233 },
Kevin Lubicke59c1672019-11-20 14:17:53 -0500234
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500235 SkContourMeasure: {
236 getPosTan: function() {},
237 getSegment: function() {},
238 isClosed: function() {},
239 length: function() {},
240 },
Kevin Lubicke59c1672019-11-20 14:17:53 -0500241
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500242 SkFont: {
243 // public API (from C++ bindings)
244 getScaleX: function() {},
245 getSize: function() {},
246 getSkewX: function() {},
247 getTypeface: function() {},
248 measureText: function() {},
249 setHinting: function() {},
250 setLinearMetrics: function() {},
251 setScaleX: function() {},
252 setSize: function() {},
253 setSkewX: function() {},
254 setSubpixel: function() {},
255 setTypeface: function() {},
256 // private API (from C++ bindings)
257 _getWidths: function() {},
258 },
Kevin Lubick35ac0382019-01-02 15:13:57 -0500259
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500260 SkFontMgr: {
261 // public API (from C++ and JS bindings)
262 FromData: function() {},
263 RefDefault: function() {},
264 countFamilies: function() {},
265 getFamilyName: function() {},
Kevin Lubickddd0a332018-12-12 10:35:13 -0500266
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500267 // private API
268 _makeTypefaceFromData: function() {},
269 _fromData: function() {},
270 },
Kevin Lubickddd0a332018-12-12 10:35:13 -0500271
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500272 SkImage: {
273 // public API (from C++ bindings)
274 height: function() {},
275 width: function() {},
276 // private API
277 _encodeToData: function() {},
278 _encodeToDataWithFormat: function() {},
279 _makeShader: function() {},
280 },
Kevin Lubick006a6f32018-10-19 14:34:34 -0400281
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500282 SkImageFilter: {
283 MakeBlur: function() {},
284 MakeColorFilter: function() {},
285 MakeCompose: function() {},
286 MakeMatrixTransform: function() {},
287 },
Kevin Lubick15b40232019-10-29 09:55:39 -0400288
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500289 // These are defined in interface.js
290 SkM44: {
291 identity: function() {},
292 invert: function() {},
293 multiply: function() {},
294 rotatedUnitSinCos: function() {},
295 rotated: function() {},
296 scaled: function() {},
297 translated: function() {},
298 lookat: function() {},
299 perspective: function() {},
300 rc: function() {},
301 transpose: function() {},
302 },
Nathaniel Nifong77798b42020-02-21 17:15:22 -0500303
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500304 SkMatrix: {
305 identity: function() {},
306 invert: function() {},
307 mapPoints: function() {},
308 multiply: function() {},
309 rotated: function() {},
310 scaled: function() {},
311 skewed: function() {},
312 translated: function() {},
313 },
Kevin Lubickb9db3902018-11-26 11:47:54 -0500314
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500315 SkMaskFilter: {
316 MakeBlur: function() {},
317 },
Kevin Lubick15b40232019-10-29 09:55:39 -0400318
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500319 SkPaint: {
320 // public API (from C++ bindings)
321 /** @return {CanvasKit.SkPaint} */
322 copy: function() {},
323 getBlendMode: function() {},
324 getColor: function() {},
325 getFilterQuality: function() {},
326 getStrokeCap: function() {},
327 getStrokeJoin: function() {},
328 getStrokeMiter: function() {},
329 getStrokeWidth: function() {},
330 setAntiAlias: function() {},
331 setBlendMode: function() {},
332 setColor: function() {},
333 setFilterQuality: function() {},
334 setImageFilter: function() {},
335 setMaskFilter: function() {},
336 setPathEffect: function() {},
337 setShader: function() {},
338 setStrokeCap: function() {},
339 setStrokeJoin: function() {},
340 setStrokeMiter: function() {},
341 setStrokeWidth: function() {},
342 setStyle: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500343
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500344 // Private API
345 delete: function() {},
346 },
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500347
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500348 SkPathEffect: {
349 MakeDash: function() {},
350 },
Nathaniel Nifong23b0ed92020-03-04 15:43:50 -0500351
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500352 SkParticleEffect: {
353 // public API (from C++ bindings)
354 draw: function() {},
355 getEffectUniform: function() {},
356 getEffectUniformCount: function() {},
357 getEffectUniformFloatCount: function() {},
358 getEffectUniformName: function() {},
359 getParticleUniformCount: function() {},
360 getParticleUniformFloatCount: function() {},
361 getParticleUniformName: function() {},
362 getParticleUniform: function() {},
363 setPosition: function() {},
364 setRate: function() {},
365 start: function() {},
366 update: function() {},
Kevin Lubickf8f9cd82020-02-21 08:26:59 -0500367
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500368 // private API (from C++ bindings)
369 _effectUniformPtr: function() {},
370 _particleUniformPtr: function() {},
371 },
Kevin Lubickf8f9cd82020-02-21 08:26:59 -0500372
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500373 SkPath: {
374 // public API (from C++ bindings)
375 computeTightBounds: function() {},
376 contains: function() {},
377 /** @return {CanvasKit.SkPath} */
378 copy: function() {},
379 countPoints: function() {},
380 equals: function() {},
381 getBounds: function() {},
382 getFillType: function() {},
383 getPoint: function() {},
384 isEmpty: function() {},
385 isVolatile: function() {},
386 reset: function() {},
387 rewind: function() {},
388 setFillType: function() {},
389 setIsVolatile: function() {},
390 toSVGString: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400391
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500392 // private API
393 _addArc: function() {},
394 _addOval: function() {},
395 _addPath: function() {},
396 _addRect: function() {},
397 _addPoly: function() {},
398 _addRoundRect: function() {},
399 _arc: function() {},
400 _arcTo: function() {},
401 _close: function() {},
402 _conicTo: function() {},
403 _cubicTo: function() {},
404 _dash: function() {},
405 _lineTo: function() {},
406 _moveTo: function() {},
407 _op: function() {},
408 _quadTo: function() {},
409 _rArcTo: function() {},
410 _rConicTo: function() {},
411 _rCubicTo: function() {},
412 _rLineTo: function() {},
413 _rMoveTo: function() {},
414 _rQuadTo: function() {},
415 _rect: function() {},
416 _simplify: function() {},
417 _stroke: function() {},
418 _transform: function() {},
419 _trim: function() {},
420 delete: function() {},
421 dump: function() {},
422 dumpHex: function() {},
423 },
Kevin Lubickd3cfbca2019-03-15 15:36:29 -0400424
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500425 SkPathMeasure: {
426 getLength: function() {},
427 getSegment: function() {},
428 getPosTan: function() {},
429 isClosed: function() {},
430 nextContour: function() {},
431 },
Kevin Lubickcc13fd32019-04-05 13:00:01 -0400432
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500433 SkPicture: {
434 serialize: function() {},
435 },
Kevin Lubickcc13fd32019-04-05 13:00:01 -0400436
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500437 SkPictureRecorder: {
438 beginRecording: function() {},
439 finishRecordingAsPicture: function() {},
440 },
Kevin Lubick006a6f32018-10-19 14:34:34 -0400441
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500442 SkRect: {
443 fLeft: {},
444 fTop: {},
445 fRight: {},
446 fBottom: {},
447 },
Kevin Lubick2e5fe352019-09-03 12:59:06 -0400448
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500449 SkRRect: {
450 rect: {},
451 rx1: {},
452 ry1: {},
453 rx2: {},
454 ry2: {},
455 rx3: {},
456 ry3: {},
457 rx4: {},
458 ry4: {},
459 },
Kevin Lubick62836902019-12-09 09:04:26 -0500460
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500461 SkShader: {
462 Blend: function() {},
463 Color: function() {},
464 Empty: function() {},
465 Lerp: function() {},
Nathaniel Nifongd96c3c72020-03-09 10:50:43 -0400466 MakeLinearGradient: function() {},
467 MakeRadialGradient: function() {},
468 MakeTwoPointConicalGradient: function() {},
Dan Field3d44f732020-03-16 09:17:30 -0700469 MakeSweepGradient: function() {},
Kevin Lubick62836902019-12-09 09:04:26 -0500470
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500471 _Blend: function() {},
472 _Lerp: function() {},
473 },
Kevin Lubick006a6f32018-10-19 14:34:34 -0400474
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500475 SkSurface: {
476 // public API (from C++ bindings)
477 /** @return {CanvasKit.SkCanvas} */
478 getCanvas: function() {},
479 /** @return {CanvasKit.SkImage} */
480 makeImageSnapshot: function() {},
481 makeSurface: function() {},
482 grContext: {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400483
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500484 // private API
485 _flush: function() {},
486 _getRasterN32PremulSurface: function() {},
487 delete: function() {},
488 },
Kevin Lubickec4903d2019-01-14 08:36:08 -0500489
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500490 SkTextBlob: {
491 // public API (both C++ and JS bindings)
492 MakeFromRSXform: function() {},
493 MakeFromText: function() {},
494 MakeOnPath: function() {},
495 // private API (from C++ bindings)
496 _MakeFromRSXform: function() {},
497 _MakeFromText: function() {},
498 },
Nathaniel Nifong77798b42020-02-21 17:15:22 -0500499
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500500 // These are defined in interface.js
501 SkVector: {
502 add: function() {},
503 sub: function() {},
504 dot: function() {},
505 cross: function() {},
506 normalize: function() {},
507 mulScalar: function() {},
508 length: function() {},
509 lengthSquared: function() {},
510 dist: function() {},
511 },
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400512
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500513 SkVertices: {
514 // public API (from C++ bindings)
515 bounds: function() {},
516 mode: function() {},
517 uniqueID: function() {},
518 vertexCount: function() {},
519 },
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400520
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500521 _SkVerticesBuilder: {
522 colors: function() {},
523 detach: function() {},
524 indices: function() {},
525 positions: function() {},
526 texCoords: function() {},
527 },
Kevin Lubickd6ba7252019-06-03 14:38:05 -0400528
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500529 TextStyle: function() {},
Kevin Lubick369f6a52019-10-03 11:22:08 -0400530
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500531 // Constants and Enums
532 gpu: {},
533 skottie: {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400534
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500535 TRANSPARENT: {},
536 RED: {},
537 BLUE: {},
538 YELLOW: {},
539 CYAN: {},
540 BLACK: {},
541 WHITE: {},
Kevin Lubickea905ec2018-11-30 14:05:58 -0500542
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500543 MOVE_VERB: {},
544 LINE_VERB: {},
545 QUAD_VERB: {},
546 CONIC_VERB: {},
547 CUBIC_VERB: {},
548 CLOSE_VERB: {},
Kevin Lubickda3d8ac2019-01-07 11:08:55 -0500549
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500550 NoDecoration: {},
551 UnderlineDecoration: {},
552 OverlineDecoration: {},
553 LineThroughDecoration: {},
Kevin Lubick369f6a52019-10-03 11:22:08 -0400554
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500555 SaveLayerInitWithPrevious: {},
556 SaveLayerF16ColorType: {},
Kevin Lubick77d9b5c2019-10-29 10:48:26 -0400557
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500558 Affinity: {
559 Upstream: {},
560 Downstream: {},
561 },
Kevin Lubick369f6a52019-10-03 11:22:08 -0400562
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500563 AlphaType: {
564 Opaque: {},
565 Premul: {},
566 Unpremul: {},
567 },
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500568
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500569 BlendMode: {
570 Clear: {},
571 Src: {},
572 Dst: {},
573 SrcOver: {},
574 DstOver: {},
575 SrcIn: {},
576 DstIn: {},
577 SrcOut: {},
578 DstOut: {},
579 SrcATop: {},
580 DstATop: {},
581 Xor: {},
582 Plus: {},
583 Modulate: {},
584 Screen: {},
585 Overlay: {},
586 Darken: {},
587 Lighten: {},
588 ColorDodge: {},
589 ColorBurn: {},
590 HardLight: {},
591 SoftLight: {},
592 Difference: {},
593 Exclusion: {},
594 Multiply: {},
595 Hue: {},
596 Saturation: {},
597 Color: {},
598 Luminosity: {},
599 },
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500600
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500601 BlurStyle: {
602 Normal: {},
603 Solid: {},
604 Outer: {},
605 Inner: {},
606 },
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500607
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500608 ClipOp: {
609 Difference: {},
610 Intersect: {},
611 },
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500612
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500613 ColorType: {
614 Alpha_8: {},
615 RGB_565: {},
616 ARGB_4444: {},
617 RGBA_8888: {},
618 RGB_888x: {},
619 BGRA_8888: {},
620 RGBA_1010102: {},
621 RGB_101010x: {},
622 Gray_8: {},
623 RGBA_F16: {},
624 RGBA_F32: {},
625 },
Kevin Lubickea905ec2018-11-30 14:05:58 -0500626
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500627 FillType: {
628 Winding: {},
629 EvenOdd: {},
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500630 },
Kevin Lubick006a6f32018-10-19 14:34:34 -0400631
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500632 FilterQuality: {
633 None: {},
634 Low: {},
635 Medium: {},
636 High: {},
637 },
Kevin Lubick0a1293c2018-12-03 12:31:04 -0500638
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500639 FontSlant: {
640 Upright: {},
641 Italic: {},
642 Oblique: {},
643 },
Kevin Lubickd3b1fe62019-10-21 10:50:26 -0400644
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500645 FontHinting: {
646 None: {},
647 Slight: {},
648 Normal: {},
649 Full: {},
650 },
Kevin Lubickbde9fcc2020-02-28 08:09:08 -0500651
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500652 FontWeight: {
653 Invisible: {},
654 Thin: {},
655 ExtraLight: {},
656 Light: {},
657 Normal: {},
658 Medium: {},
659 SemiBold: {},
660 Bold: {},
661 ExtraBold: {},
662 Black: {},
663 ExtraBlack: {},
664 },
Kevin Lubickd3b1fe62019-10-21 10:50:26 -0400665
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500666 FontWidth: {
667 UltraCondensed: {},
668 ExtraCondensed: {},
669 Condensed: {},
670 SemiCondensed: {},
671 Normal: {},
672 SemiExpanded: {},
673 Expanded: {},
674 ExtraExpanded: {},
675 UltraExpanded: {},
676 },
Kevin Lubickd3b1fe62019-10-21 10:50:26 -0400677
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500678 ImageFormat: {
679 PNG: {},
680 JPEG: {},
681 },
Alexander Khovansky3e119332018-11-15 02:01:19 +0300682
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500683 PaintStyle: {
684 Fill: {},
685 Stroke: {},
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500686 },
Kevin Lubickb9db3902018-11-26 11:47:54 -0500687
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500688 PathOp: {
689 Difference: {},
690 Intersect: {},
691 Union: {},
692 XOR: {},
693 ReverseDifference: {},
694 },
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500695
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500696 PointMode: {
697 Points: {},
698 Lines: {},
699 Polygon: {},
700 },
Kevin Lubick37ab53e2019-11-11 10:06:08 -0500701
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500702 RectHeightStyle: {
703 Tight: {},
704 Max: {},
705 IncludeLineSpacingMiddle: {},
706 IncludeLineSpacingTop: {},
707 IncludeLineSpacingBottom: {},
708 },
Kevin Lubick369f6a52019-10-03 11:22:08 -0400709
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500710 RectWidthStyle: {
711 Tight: {},
712 Max: {},
713 },
Kevin Lubick369f6a52019-10-03 11:22:08 -0400714
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500715 StrokeCap: {
716 Butt: {},
717 Round: {},
718 Square: {},
719 },
Kevin Lubickb9db3902018-11-26 11:47:54 -0500720
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500721 StrokeJoin: {
722 Miter: {},
723 Round: {},
724 Bevel: {},
725 },
Kevin Lubickb9db3902018-11-26 11:47:54 -0500726
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500727 TextAlign: {
728 Left: {},
729 Right: {},
730 Center: {},
731 Justify: {},
732 Start: {},
733 End: {},
734 },
Kevin Lubick369f6a52019-10-03 11:22:08 -0400735
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500736 TextDirection: {
737 LTR: {},
738 RTL: {},
739 },
Kevin Lubickd3b1fe62019-10-21 10:50:26 -0400740
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500741 TileMode: {
742 Clamp: {},
743 Repeat: {},
744 Mirror: {},
745 Decal: {},
746 },
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500747
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500748 VertexMode: {
749 Triangles: {},
750 TrianglesStrip: {},
751 TriangleFan: {},
752 },
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500753
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500754 // Things Enscriptem adds for us
Kevin Lubick006a6f32018-10-19 14:34:34 -0400755
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500756 /**
757 * @type {Float32Array}
758 */
759 HEAPF32: {},
760 /**
761 * @type {Float64Array}
762 */
763 HEAPF64: {},
764 /**
765 * @type {Uint8Array}
766 */
767 HEAPU8: {},
768 /**
769 * @type {Uint16Array}
770 */
771 HEAPU16: {},
772 /**
773 * @type {Uint32Array}
774 */
775 HEAPU32: {},
776 /**
777 * @type {Int8Array}
778 */
779 HEAP8: {},
780 /**
781 * @type {Int16Array}
782 */
783 HEAP16: {},
784 /**
785 * @type {Int32Array}
786 */
787 HEAP32: {},
Kevin Lubickfa5a1382019-10-09 10:46:14 -0400788
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500789 _malloc: function() {},
790 _free: function() {},
791 onRuntimeInitialized: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400792};
Kevin Lubick217056c2018-09-20 17:39:31 -0400793
Kevin Lubick006a6f32018-10-19 14:34:34 -0400794// Public API things that are newly declared in the JS should go here.
795// It's not enough to declare them above, because closure can still erase them
796// unless they go on the prototype.
Kevin Lubick369f6a52019-10-03 11:22:08 -0400797CanvasKit.Paragraph.prototype.getRectsForRange = function() {};
798
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500799CanvasKit.SkPath.prototype.addArc = function() {};
Kevin Lubicke384df42019-08-26 15:48:09 -0400800CanvasKit.SkPath.prototype.addOval = function() {};
Kevin Lubick217056c2018-09-20 17:39:31 -0400801CanvasKit.SkPath.prototype.addPath = function() {};
Kevin Lubick37ab53e2019-11-11 10:06:08 -0500802CanvasKit.SkPath.prototype.addPoly = function() {};
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500803CanvasKit.SkPath.prototype.addRect = function() {};
Kevin Lubickda3d8ac2019-01-07 11:08:55 -0500804CanvasKit.SkPath.prototype.addRoundRect = function() {};
Alexander Khovansky3e119332018-11-15 02:01:19 +0300805CanvasKit.SkPath.prototype.arc = function() {};
Kevin Lubick006a6f32018-10-19 14:34:34 -0400806CanvasKit.SkPath.prototype.arcTo = function() {};
Kevin Lubick217056c2018-09-20 17:39:31 -0400807CanvasKit.SkPath.prototype.close = function() {};
Kevin Lubick006a6f32018-10-19 14:34:34 -0400808CanvasKit.SkPath.prototype.conicTo = function() {};
809CanvasKit.SkPath.prototype.cubicTo = function() {};
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400810CanvasKit.SkPath.prototype.dash = function() {};
Kevin Lubick006a6f32018-10-19 14:34:34 -0400811CanvasKit.SkPath.prototype.lineTo = function() {};
812CanvasKit.SkPath.prototype.moveTo = function() {};
Kevin Lubicke384df42019-08-26 15:48:09 -0400813CanvasKit.SkPath.prototype.offset = function() {};
Kevin Lubick006a6f32018-10-19 14:34:34 -0400814CanvasKit.SkPath.prototype.op = function() {};
815CanvasKit.SkPath.prototype.quadTo = function() {};
Kevin Lubick79b71342019-11-01 14:36:52 -0400816CanvasKit.SkPath.prototype.rArcTo = function() {};
817CanvasKit.SkPath.prototype.rConicTo = function() {};
818CanvasKit.SkPath.prototype.rCubicTo = function() {};
819CanvasKit.SkPath.prototype.rLineTo = function() {};
820CanvasKit.SkPath.prototype.rMoveTo = function() {};
821CanvasKit.SkPath.prototype.rQuadTo = function() {};
Kevin Lubick006a6f32018-10-19 14:34:34 -0400822CanvasKit.SkPath.prototype.rect = function() {};
Kevin Lubick217056c2018-09-20 17:39:31 -0400823CanvasKit.SkPath.prototype.simplify = function() {};
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400824CanvasKit.SkPath.prototype.stroke = function() {};
Kevin Lubick217056c2018-09-20 17:39:31 -0400825CanvasKit.SkPath.prototype.transform = function() {};
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400826CanvasKit.SkPath.prototype.trim = function() {};
Kevin Lubick217056c2018-09-20 17:39:31 -0400827
Kevin Lubicka4f218d2020-01-14 08:39:09 -0500828CanvasKit.SkPicture.prototype.saveAsFile = function() {};
Kevin Lubickcc13fd32019-04-05 13:00:01 -0400829
Kevin Lubick5b90b842018-10-17 07:57:18 -0400830CanvasKit.SkSurface.prototype.dispose = function() {};
Kevin Lubick359a7e32019-03-19 09:34:37 -0400831CanvasKit.SkSurface.prototype.flush = function() {};
832CanvasKit.SkSurface.prototype.requestAnimationFrame = function() {};
Bryce Thomas2c5b8562020-01-22 13:49:41 -0800833CanvasKit.SkSurface.prototype.drawOnce = function() {};
Kevin Lubickcc13fd32019-04-05 13:00:01 -0400834CanvasKit.SkSurface.prototype.captureFrameAsSkPicture = function() {};
Kevin Lubick53965c92018-10-11 08:51:55 -0400835
Alexander Khovansky3e119332018-11-15 02:01:19 +0300836CanvasKit.SkImage.prototype.encodeToData = function() {};
Kevin Lubicka064c282019-04-04 09:28:53 -0400837CanvasKit.SkImage.prototype.makeShader = function() {};
Alexander Khovansky3e119332018-11-15 02:01:19 +0300838
Kevin Lubickee91c072019-03-29 10:39:52 -0400839CanvasKit.SkCanvas.prototype.drawAtlas = function() {};
Kevin Lubick37ab53e2019-11-11 10:06:08 -0500840CanvasKit.SkCanvas.prototype.drawPoints = function() {};
Kevin Lubickec4903d2019-01-14 08:36:08 -0500841CanvasKit.SkCanvas.prototype.drawText = function() {};
Kevin Lubick52b9f372018-12-04 13:57:36 -0500842/** @return {Uint8Array} */
843CanvasKit.SkCanvas.prototype.readPixels = function() {};
844CanvasKit.SkCanvas.prototype.writePixels = function() {};
845
Kevin Lubickddd0a332018-12-12 10:35:13 -0500846CanvasKit.SkFontMgr.prototype.MakeTypefaceFromData = function() {};
847
Kevin Lubickd3cfbca2019-03-15 15:36:29 -0400848CanvasKit.SkFont.prototype.getWidths = function() {};
849
850CanvasKit.RSXFormBuilder.prototype.build = function() {};
851CanvasKit.RSXFormBuilder.prototype.delete = function() {};
852CanvasKit.RSXFormBuilder.prototype.push = function() {};
Kevin Lubickee91c072019-03-29 10:39:52 -0400853CanvasKit.RSXFormBuilder.prototype.set = function() {};
854
855CanvasKit.SkColorBuilder.prototype.build = function() {};
856CanvasKit.SkColorBuilder.prototype.delete = function() {};
857CanvasKit.SkColorBuilder.prototype.push = function() {};
858CanvasKit.SkColorBuilder.prototype.set = function() {};
Kevin Lubickd3cfbca2019-03-15 15:36:29 -0400859
Kevin Lubickf3d6c362020-01-06 08:11:52 -0500860CanvasKit.SkRuntimeEffect.prototype.makeShader = function() {};
Kevin Lubickecd87622020-02-22 07:37:33 -0500861CanvasKit.SkRuntimeEffect.prototype.makeShaderWithChildren = function() {};
Kevin Lubick4b5b6452019-12-06 13:55:58 -0500862
Kevin Lubickf8f9cd82020-02-21 08:26:59 -0500863CanvasKit.SkParticleEffect.prototype.effectUniforms = function() {};
864CanvasKit.SkParticleEffect.prototype.particleUniforms = function() {};
865
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400866// Define StrokeOpts object
867var StrokeOpts = {};
868StrokeOpts.prototype.width;
869StrokeOpts.prototype.miter_limit;
870StrokeOpts.prototype.cap;
871StrokeOpts.prototype.join;
Kevin Lubick1646e7d2018-12-07 13:03:08 -0500872StrokeOpts.prototype.precision;
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400873
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500874// Define everything created in the canvas2d spec here
Kevin Lubickb9db3902018-11-26 11:47:54 -0500875var HTMLCanvas = {};
Kevin Lubick0a1293c2018-12-03 12:31:04 -0500876HTMLCanvas.prototype.decodeImage = function() {};
877HTMLCanvas.prototype.dispose = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500878HTMLCanvas.prototype.getContext = function() {};
Kevin Lubick8e4a3312018-12-14 15:03:41 -0500879HTMLCanvas.prototype.loadFont = function() {};
Kevin Lubicka40f8322018-12-17 16:01:36 -0500880HTMLCanvas.prototype.makePath2D = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500881HTMLCanvas.prototype.toDataURL = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500882
883var CanvasRenderingContext2D = {};
884CanvasRenderingContext2D.prototype.addHitRegion = function() {};
885CanvasRenderingContext2D.prototype.arc = function() {};
886CanvasRenderingContext2D.prototype.arcTo = function() {};
887CanvasRenderingContext2D.prototype.beginPath = function() {};
888CanvasRenderingContext2D.prototype.bezierCurveTo = function() {};
889CanvasRenderingContext2D.prototype.clearHitRegions = function() {};
Kevin Lubick12c0e502018-11-28 12:51:56 -0500890CanvasRenderingContext2D.prototype.clearRect = function() {};
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500891CanvasRenderingContext2D.prototype.clip = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500892CanvasRenderingContext2D.prototype.closePath = function() {};
Kevin Lubick52b9f372018-12-04 13:57:36 -0500893CanvasRenderingContext2D.prototype.createImageData = function() {};
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500894CanvasRenderingContext2D.prototype.createLinearGradient = function() {};
Kevin Lubickd29edd72018-12-07 08:29:52 -0500895CanvasRenderingContext2D.prototype.createPattern = function() {};
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500896CanvasRenderingContext2D.prototype.createRadialGradient = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500897CanvasRenderingContext2D.prototype.drawFocusIfNeeded = function() {};
Kevin Lubick0a1293c2018-12-03 12:31:04 -0500898CanvasRenderingContext2D.prototype.drawImage = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500899CanvasRenderingContext2D.prototype.ellipse = function() {};
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500900CanvasRenderingContext2D.prototype.fill = function() {};
Kevin Lubick12c0e502018-11-28 12:51:56 -0500901CanvasRenderingContext2D.prototype.fillRect = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500902CanvasRenderingContext2D.prototype.fillText = function() {};
Kevin Lubick52b9f372018-12-04 13:57:36 -0500903CanvasRenderingContext2D.prototype.getImageData = function() {};
Kevin Lubick12c0e502018-11-28 12:51:56 -0500904CanvasRenderingContext2D.prototype.getLineDash = function() {};
Kevin Lubick1646e7d2018-12-07 13:03:08 -0500905CanvasRenderingContext2D.prototype.isPointInPath = function() {};
906CanvasRenderingContext2D.prototype.isPointInStroke = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500907CanvasRenderingContext2D.prototype.lineTo = function() {};
908CanvasRenderingContext2D.prototype.measureText = function() {};
909CanvasRenderingContext2D.prototype.moveTo = function() {};
Kevin Lubick52b9f372018-12-04 13:57:36 -0500910CanvasRenderingContext2D.prototype.putImageData = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500911CanvasRenderingContext2D.prototype.quadraticCurveTo = function() {};
912CanvasRenderingContext2D.prototype.rect = function() {};
913CanvasRenderingContext2D.prototype.removeHitRegion = function() {};
914CanvasRenderingContext2D.prototype.resetTransform = function() {};
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500915CanvasRenderingContext2D.prototype.restore = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500916CanvasRenderingContext2D.prototype.rotate = function() {};
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500917CanvasRenderingContext2D.prototype.save = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500918CanvasRenderingContext2D.prototype.scale = function() {};
919CanvasRenderingContext2D.prototype.scrollPathIntoView = function() {};
Kevin Lubick12c0e502018-11-28 12:51:56 -0500920CanvasRenderingContext2D.prototype.setLineDash = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500921CanvasRenderingContext2D.prototype.setTransform = function() {};
922CanvasRenderingContext2D.prototype.stroke = function() {};
Kevin Lubick12c0e502018-11-28 12:51:56 -0500923CanvasRenderingContext2D.prototype.strokeRect = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500924CanvasRenderingContext2D.prototype.strokeText = function() {};
925CanvasRenderingContext2D.prototype.transform = function() {};
926CanvasRenderingContext2D.prototype.translate = function() {};
927
Kevin Lubicka40f8322018-12-17 16:01:36 -0500928var Path2D = {};
929Path2D.prototype.addPath = function() {};
930Path2D.prototype.arc = function() {};
931Path2D.prototype.arcTo = function() {};
932Path2D.prototype.bezierCurveTo = function() {};
933Path2D.prototype.closePath = function() {};
934Path2D.prototype.ellipse = function() {};
935Path2D.prototype.lineTo = function() {};
936Path2D.prototype.moveTo = function() {};
937Path2D.prototype.quadraticCurveTo = function() {};
938Path2D.prototype.rect = function() {};
939
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500940var LinearCanvasGradient = {};
941LinearCanvasGradient.prototype.addColorStop = function() {};
942var RadialCanvasGradient = {};
943RadialCanvasGradient.prototype.addColorStop = function() {};
Kevin Lubickd29edd72018-12-07 08:29:52 -0500944var CanvasPattern = {};
945CanvasPattern.prototype.setTransform = function() {};
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500946
Kevin Lubick52b9f372018-12-04 13:57:36 -0500947var ImageData = {
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500948 /**
949 * @type {Uint8ClampedArray}
950 */
951 data: {},
952 height: {},
953 width: {},
Kevin Lubick52b9f372018-12-04 13:57:36 -0500954};
955
Kevin Lubickd29edd72018-12-07 08:29:52 -0500956var DOMMatrix = {
Nathaniel Nifong6066a0c2020-03-05 10:27:14 -0500957 a: {},
958 b: {},
959 c: {},
960 d: {},
961 e: {},
962 f: {},
Kevin Lubickd29edd72018-12-07 08:29:52 -0500963};
964
Kevin Lubick217056c2018-09-20 17:39:31 -0400965// 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 -0500966function loadWebAssemblyModule() {};