blob: d90aa1bc3df9f8d548588a1c23154edeac04c5b8 [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 = {
26 // public API (i.e. things we declare in the pre-js file)
Kevin Lubick006a6f32018-10-19 14:34:34 -040027 Color: function() {},
28 /** @return {CanvasKit.SkRect} */
29 LTRBRect: function() {},
Kevin Lubick0a1293c2018-12-03 12:31:04 -050030 /** @return {CanvasKit.SkRect} */
31 XYWHRect: function() {},
Kevin Lubick7d644e12019-09-11 14:22:22 -040032 /** @return {CanvasKit.SkRRect} */
33 RRectXY: function() {},
Kevin Lubick52b9f372018-12-04 13:57:36 -050034 /** @return {ImageData} */
35 ImageData: function() {},
Kevin Lubick543f3522019-03-08 10:04:28 -050036
37 GetWebGLContext: function() {},
Kevin Lubick61ef7b22018-11-27 13:26:59 -050038 MakeBlurMaskFilter: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -040039 MakeCanvas: function() {},
40 MakeCanvasSurface: function() {},
Kevin Lubick543f3522019-03-08 10:04:28 -050041 MakeGrContext: function() {},
Kevin Lubick6b921b72019-09-18 16:18:17 -040042 /** @return {CanvasKit.SkAnimatedImage} */
43 MakeAnimatedImageFromEncoded: function() {},
Kevin Lubick0a1293c2018-12-03 12:31:04 -050044 /** @return {CanvasKit.SkImage} */
45 MakeImageFromEncoded: function() {},
Kevin Lubickeb2f6b02018-11-29 15:07:02 -050046 /** @return {LinearCanvasGradient} */
Kevin Lubickb5ae3b52018-11-03 07:51:19 -040047 MakeLinearGradientShader: function() {},
Kevin Lubick543f3522019-03-08 10:04:28 -050048 MakeOnScreenGLSurface: function() {},
Kevin Lubickda3d8ac2019-01-07 11:08:55 -050049 MakePathFromCmds: function() {},
Kevin Lubicka40f8322018-12-17 16:01:36 -050050 MakePathFromOp: function() {},
51 MakePathFromSVGString: function() {},
Kevin Lubick61ef7b22018-11-27 13:26:59 -050052 MakeRadialGradientShader: function() {},
Kevin Lubick543f3522019-03-08 10:04:28 -050053 MakeRenderTarget: function() {},
Kevin Lubick61ef7b22018-11-27 13:26:59 -050054 MakeSWCanvasSurface: function() {},
Kevin Lubickf5ea37f2019-02-28 10:06:18 -050055 MakeManagedAnimation: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -040056 MakeSkDashPathEffect: function() {},
Kevin Lubickb5ae3b52018-11-03 07:51:19 -040057 MakeSkVertices: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -040058 MakeSurface: function() {},
Kevin Lubickeb2f6b02018-11-29 15:07:02 -050059 /** @return {RadialCanvasGradient} */
60 MakeTwoPointConicalGradientShader: function() {},
Kevin Lubick61ef7b22018-11-27 13:26:59 -050061 MakeWebGLCanvasSurface: function() {},
Kevin Lubick50f377e2019-09-11 15:23:00 -040062 /** @return {TonalColors} */
63 computeTonalColors: function() {},
Kevin Lubick217056c2018-09-20 17:39:31 -040064 currentContext: function() {},
Kevin Lubick61ef7b22018-11-27 13:26:59 -050065 getColorComponents: function() {},
Kevin Lubick12c0e502018-11-28 12:51:56 -050066 getSkDataBytes: function() {},
Kevin Lubick12c0e502018-11-28 12:51:56 -050067 multiplyByAlpha: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -040068 setCurrentContext: function() {},
Kevin Lubick217056c2018-09-20 17:39:31 -040069
70 // private API (i.e. things declared in the bindings that we use
71 // in the pre-js file)
Kevin Lubick52b9f372018-12-04 13:57:36 -050072 _MakeImage: function() {},
Kevin Lubickb5ae3b52018-11-03 07:51:19 -040073 _MakeLinearGradientShader: function() {},
Kevin Lubickda3d8ac2019-01-07 11:08:55 -050074 _MakePathFromCmds: function() {},
Kevin Lubickb5ae3b52018-11-03 07:51:19 -040075 _MakeRadialGradientShader: function() {},
Kevin Lubickf5ea37f2019-02-28 10:06:18 -050076 _MakeManagedAnimation: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -040077 _MakeSkDashPathEffect: function() {},
Kevin Lubickb5ae3b52018-11-03 07:51:19 -040078 _MakeSkVertices: function() {},
Kevin Lubickeb2f6b02018-11-29 15:07:02 -050079 _MakeTwoPointConicalGradientShader: function() {},
Kevin Lubick6b921b72019-09-18 16:18:17 -040080 _decodeAnimatedImage: function() {},
Kevin Lubick0a1293c2018-12-03 12:31:04 -050081 _decodeImage: function() {},
Kevin Lubick1ba9c4d2019-02-22 10:04:06 -050082 _drawShapedText: function() {},
Kevin Lubickea905ec2018-11-30 14:05:58 -050083 _getRasterDirectSurface: function() {},
Kevin Lubick134be1d2018-10-30 15:05:04 -040084 _getRasterN32PremulSurface: function() {},
Kevin Lubick217056c2018-09-20 17:39:31 -040085
Kevin Lubick1a05fce2018-11-20 12:51:16 -050086 // The testing object is meant to expose internal functions
87 // for more fine-grained testing, e.g. parseColor
88 _testing: {},
89
Kevin Lubick217056c2018-09-20 17:39:31 -040090 // Objects and properties on CanvasKit
91
Kevin Lubickcd544662019-03-22 15:41:36 -040092 GrContext: {
93 // public API (from C++ bindings)
94 getResourceCacheLimitBytes: function() {},
95 getResourceCacheUsageBytes: function() {},
96 setResourceCacheLimitBytes: function() {},
97 },
98
Kevin Lubickd3cfbca2019-03-15 15:36:29 -040099 RSXFormBuilder: function() {},
Kevin Lubickee91c072019-03-29 10:39:52 -0400100 SkColorBuilder: function() {},
101 SkRectBuilder: function() {},
Kevin Lubickd3cfbca2019-03-15 15:36:29 -0400102
Kevin Lubick1ba9c4d2019-02-22 10:04:06 -0500103 ShapedText: {
104 // public API (from C++ bindings)
105 getBounds: function() {},
106 },
107
Kevin Lubick6b921b72019-09-18 16:18:17 -0400108 SkAnimatedImage: {
109 // public API (from C++ bindings)
110 getRepetitionCount: function() {},
111 decodeNextFrame: function() {},
112 },
113
Kevin Lubick006a6f32018-10-19 14:34:34 -0400114 SkCanvas: {
115 // public API (from C++ bindings)
116 clear: function() {},
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500117 clipPath: function() {},
Kevin Lubick5d5723c2018-12-07 10:09:11 -0500118 clipRect: function() {},
119 concat: function() {},
Kevin Lubickda3d8ac2019-01-07 11:08:55 -0500120 drawArc: function() {},
Kevin Lubicke384df42019-08-26 15:48:09 -0400121 drawCircle: function() {},
Kevin Lubick2e5fe352019-09-03 12:59:06 -0400122 drawDRRect: function() {},
Kevin Lubick6b921b72019-09-18 16:18:17 -0400123 drawAnimatedImage: function() {},
Kevin Lubick0a1293c2018-12-03 12:31:04 -0500124 drawImage: function() {},
125 drawImageRect: function() {},
Kevin Lubickda3d8ac2019-01-07 11:08:55 -0500126 drawLine: function() {},
127 drawOval: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400128 drawPaint: function() {},
129 drawPath: function() {},
Kevin Lubickcc13fd32019-04-05 13:00:01 -0400130 drawPicture: function() {},
Kevin Lubick2e5fe352019-09-03 12:59:06 -0400131 drawRRect: function() {},
Kevin Lubick12c0e502018-11-28 12:51:56 -0500132 drawRect: function() {},
Kevin Lubickda3d8ac2019-01-07 11:08:55 -0500133 drawRoundRect: function() {},
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500134 drawShadow: function() {},
Kevin Lubick12c0e502018-11-28 12:51:56 -0500135 drawText: function() {},
Kevin Lubickec4903d2019-01-14 08:36:08 -0500136 drawTextBlob: function() {},
Kevin Lubick12c0e502018-11-28 12:51:56 -0500137 drawVertices: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400138 flush: function() {},
Kevin Lubick2e5fe352019-09-03 12:59:06 -0400139 getSaveCount: function() {},
Kevin Lubick5d5723c2018-12-07 10:09:11 -0500140 getTotalMatrix: function() {},
Kevin Lubick543f3522019-03-08 10:04:28 -0500141 makeSurface: function() {},
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500142 restore: function() {},
Kevin Lubickb3574c92019-03-06 08:25:36 -0500143 restoreToCount: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400144 rotate: function() {},
145 save: function() {},
Kevin Lubickb3574c92019-03-06 08:25:36 -0500146 saveLayer: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400147 scale: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400148 skew: function() {},
149 translate: function() {},
150
151 // private API
Kevin Lubickee91c072019-03-29 10:39:52 -0400152 _drawAtlas: function() {},
Kevin Lubickec4903d2019-01-14 08:36:08 -0500153 _drawSimpleText: function() {},
Kevin Lubick52b9f372018-12-04 13:57:36 -0500154 _readPixels: function() {},
155 _writePixels: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400156 delete: function() {},
157 },
158
Kevin Lubickd3729342019-09-12 11:11:25 -0400159 SkColorFilter: {
160 // public API (from C++ bindings and JS interface)
161 MakeBlend: function() {},
162 MakeCompose: function() {},
163 MakeLerp: function() {},
164 MakeLinearToSRGBGamma: function() {},
165 MakeMatrix: function() {},
166 MakeSRGBToLinearGamma: function() {},
167 // private API (from C++ bindings)
168 _makeMatrix: function() {},
169 },
170
171 SkColorMatrix: {
172 concat: function() {},
173 identity: function() {},
174 postTranslate: function() {},
175 rotated: function() {},
176 scaled: function() {},
177 },
178
Kevin Lubick35ac0382019-01-02 15:13:57 -0500179 SkFont: {
180 // public API (from C++ bindings)
181 getScaleX: function() {},
182 getSize: function() {},
183 getSkewX: function() {},
184 getTypeface: function() {},
185 measureText: function() {},
186 setScaleX: function() {},
187 setSize: function() {},
188 setSkewX: function() {},
189 setTypeface: function() {},
Kevin Lubickd3cfbca2019-03-15 15:36:29 -0400190 // private API (from C++ bindings)
191 _getWidths: function() {},
Kevin Lubick35ac0382019-01-02 15:13:57 -0500192 },
193
Kevin Lubickddd0a332018-12-12 10:35:13 -0500194 SkFontMgr: {
195 // public API (from C++ bindings)
196 RefDefault: function() {},
197 countFamilies: function() {},
198
199 // private API
200 _makeTypefaceFromData: function() {},
201 },
202
Kevin Lubick006a6f32018-10-19 14:34:34 -0400203 SkImage: {
Kevin Lubick0a1293c2018-12-03 12:31:04 -0500204 // public API (from C++ bindings)
205 height: function() {},
206 width: function() {},
Alexander Khovansky3e119332018-11-15 02:01:19 +0300207 // private API
208 _encodeToData: function() {},
209 _encodeToDataWithFormat: function() {},
Kevin Lubicka064c282019-04-04 09:28:53 -0400210 _makeShader: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400211 },
212
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500213 SkMatrix: {
Kevin Lubickb9db3902018-11-26 11:47:54 -0500214 identity: function() {},
Kevin Lubickf3555182019-03-14 10:55:10 -0400215 invert: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500216 mapPoints: function() {},
217 multiply: function() {},
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500218 rotated: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500219 scaled: function() {},
220 skewed: function() {},
221 translated: function() {},
222 },
223
224 SkPaint: {
225 // public API (from C++ bindings)
226 /** @return {CanvasKit.SkPaint} */
227 copy: function() {},
Kevin Lubick12c0e502018-11-28 12:51:56 -0500228 getBlendMode: function() {},
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500229 getColor: function() {},
Kevin Lubick0a1293c2018-12-03 12:31:04 -0500230 getFilterQuality: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500231 getStrokeCap: function() {},
232 getStrokeJoin: function() {},
233 getStrokeMiter: function() {},
234 getStrokeWidth: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500235 setAntiAlias: function() {},
Kevin Lubick12c0e502018-11-28 12:51:56 -0500236 setBlendMode: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500237 setColor: function() {},
Kevin Lubick0a1293c2018-12-03 12:31:04 -0500238 setFilterQuality: function() {},
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500239 setMaskFilter: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500240 setPathEffect: function() {},
241 setShader: function() {},
242 setStrokeCap: function() {},
243 setStrokeJoin: function() {},
244 setStrokeMiter: function() {},
245 setStrokeWidth: function() {},
246 setStyle: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500247
248 //private API
249 delete: function() {},
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500250 },
251
Kevin Lubick006a6f32018-10-19 14:34:34 -0400252 SkPath: {
253 // public API (from C++ bindings)
Kevin Lubickb9db3902018-11-26 11:47:54 -0500254 computeTightBounds: function() {},
Kevin Lubick1646e7d2018-12-07 13:03:08 -0500255 contains: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500256 /** @return {CanvasKit.SkPath} */
257 copy: function() {},
258 countPoints: function() {},
259 equals: function() {},
260 getBounds: function() {},
261 getFillType: function() {},
262 getPoint: function() {},
Kevin Lubick1646e7d2018-12-07 13:03:08 -0500263 isEmpty: function() {},
Kevin Lubick2b79d1c2018-12-14 16:10:38 -0500264 isVolatile: function() {},
Kevin Lubickda3d8ac2019-01-07 11:08:55 -0500265 reset: function() {},
266 rewind: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500267 setFillType: function() {},
Kevin Lubick2b79d1c2018-12-14 16:10:38 -0500268 setIsVolatile: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500269 toSVGString: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400270
271 // private API
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500272 _addArc: function() {},
Kevin Lubicke384df42019-08-26 15:48:09 -0400273 _addOval: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400274 _addPath: function() {},
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500275 _addRect: function() {},
Kevin Lubickda3d8ac2019-01-07 11:08:55 -0500276 _addRoundRect: function() {},
Alexander Khovansky3e119332018-11-15 02:01:19 +0300277 _arc: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400278 _arcTo: function() {},
279 _close: function() {},
280 _conicTo: function() {},
281 _cubicTo: function() {},
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400282 _dash: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400283 _lineTo: function() {},
284 _moveTo: function() {},
285 _op: function() {},
286 _quadTo: function() {},
287 _rect: function() {},
288 _simplify: function() {},
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400289 _stroke: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400290 _transform: function() {},
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400291 _trim: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400292 delete: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500293 dump: function() {},
294 dumpHex: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400295 },
296
Kevin Lubickd3cfbca2019-03-15 15:36:29 -0400297 SkPathMeasure: {
298 getLength: function() {},
299 getPosTan: function() {},
300 isClosed: function() {},
301 nextContour: function() {},
302 },
303
Kevin Lubickcc13fd32019-04-05 13:00:01 -0400304 SkPicture: {
305 DEBUGONLY_serialize: function() {},
306 },
307
308 SkPictureRecorder: {
309 beginRecording: function() {},
310 finishRecordingAsPicture: function() {},
311 },
312
Kevin Lubick006a6f32018-10-19 14:34:34 -0400313 SkRect: {
314 fLeft: {},
315 fTop: {},
316 fRight: {},
317 fBottom: {},
318 },
319
Kevin Lubick2e5fe352019-09-03 12:59:06 -0400320 SkRRect: {
321 rect: {},
Kevin Lubick7d644e12019-09-11 14:22:22 -0400322 rx1: {},
323 ry1: {},
324 rx2: {},
325 ry2: {},
326 rx3: {},
327 ry3: {},
328 rx4: {},
329 ry4: {},
Kevin Lubick2e5fe352019-09-03 12:59:06 -0400330 },
331
Kevin Lubick006a6f32018-10-19 14:34:34 -0400332 SkSurface: {
333 // public API (from C++ bindings)
334 /** @return {CanvasKit.SkCanvas} */
335 getCanvas: function() {},
336 /** @return {CanvasKit.SkImage} */
337 makeImageSnapshot: function() {},
Kevin Lubick543f3522019-03-08 10:04:28 -0500338 makeSurface: function() {},
Kevin Lubickcd544662019-03-22 15:41:36 -0400339 grContext: {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400340
341 // private API
342 _flush: function() {},
343 _getRasterN32PremulSurface: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400344 delete: function() {},
345 },
346
Kevin Lubickec4903d2019-01-14 08:36:08 -0500347 SkTextBlob: {
Kevin Lubickd3cfbca2019-03-15 15:36:29 -0400348 // public API (both C++ and JS bindings)
349 MakeFromRSXform: function() {},
Kevin Lubickec4903d2019-01-14 08:36:08 -0500350 MakeFromText: function() {},
Kevin Lubickd3cfbca2019-03-15 15:36:29 -0400351 MakeOnPath: function() {},
352 // private API (from C++ bindings)
353 _MakeFromRSXform: function() {},
Kevin Lubickec4903d2019-01-14 08:36:08 -0500354 _MakeFromText: function() {},
355 },
356
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400357 SkVertices: {
358 // public API (from C++ bindings)
Kevin Lubick12c0e502018-11-28 12:51:56 -0500359 bounds: function() {},
360 mode: function() {},
361 uniqueID: function() {},
362 vertexCount: function() {},
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400363
364 // private API
365 /** @return {CanvasKit.SkVertices} */
366 _applyBones: function() {},
367 },
368
Kevin Lubickd6ba7252019-06-03 14:38:05 -0400369 _SkVerticesBuilder: {
370 // public API (from C++ bindings)
371 boneIndices: function() {},
372 boneWeights: function() {},
373 colors: function() {},
374 detach: function() {},
375 indices: function() {},
376 positions: function() {},
377 texCoords: function() {},
378 },
379
Kevin Lubick006a6f32018-10-19 14:34:34 -0400380 // Constants and Enums
381 gpu: {},
382 skottie: {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400383
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500384 TRANSPARENT: {},
385 RED: {},
386 BLUE: {},
387 YELLOW: {},
388 CYAN: {},
389 BLACK: {},
Kevin Lubickea905ec2018-11-30 14:05:58 -0500390 WHITE: {},
391
Kevin Lubickda3d8ac2019-01-07 11:08:55 -0500392 MOVE_VERB: {},
393 LINE_VERB: {},
394 QUAD_VERB: {},
395 CONIC_VERB: {},
396 CUBIC_VERB: {},
397 CLOSE_VERB: {},
398
Kevin Lubickea905ec2018-11-30 14:05:58 -0500399 AlphaType: {
400 Opaque: {},
401 Premul: {},
402 Unpremul: {},
403 },
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500404
405 BlendMode: {
406 Clear: {},
407 Src: {},
408 Dst: {},
409 SrcOver: {},
410 DstOver: {},
411 SrcIn: {},
412 DstIn: {},
413 SrcOut: {},
414 DstOut: {},
415 SrcATop: {},
416 DstATop: {},
417 Xor: {},
418 Plus: {},
419 Modulate: {},
420 Screen: {},
421 Overlay: {},
422 Darken: {},
423 Lighten: {},
424 ColorDodge: {},
425 ColorBurn: {},
426 HardLight: {},
427 SoftLight: {},
428 Difference: {},
429 Exclusion: {},
430 Multiply: {},
431 Hue: {},
432 Saturation: {},
433 Color: {},
434 Luminosity: {},
435 },
436
437 BlurStyle: {
438 Normal: {},
439 Solid: {},
440 Outer: {},
441 Inner: {},
442 },
443
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500444 ClipOp: {
445 Difference: {},
446 Intersect: {},
447 },
448
Kevin Lubickea905ec2018-11-30 14:05:58 -0500449 ColorType: {
450 Alpha_8: {},
451 RGB_565: {},
452 ARGB_4444: {},
453 RGBA_8888: {},
454 RGB_888x: {},
455 BGRA_8888: {},
456 RGBA_1010102: {},
457 RGB_101010x: {},
458 Gray_8: {},
459 RGBA_F16: {},
460 RGBA_F32: {},
461 },
462
Kevin Lubick006a6f32018-10-19 14:34:34 -0400463 FillType: {
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500464 Winding: {},
465 EvenOdd: {},
466 InverseWinding: {},
467 InverseEvenOdd: {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400468 },
469
Kevin Lubick0a1293c2018-12-03 12:31:04 -0500470 FilterQuality: {
471 None: {},
472 Low: {},
473 Medium: {},
474 High: {},
475 },
476
Alexander Khovansky3e119332018-11-15 02:01:19 +0300477 ImageFormat: {
478 PNG: {},
479 JPEG: {},
480 },
481
Kevin Lubickb9db3902018-11-26 11:47:54 -0500482 PaintStyle: {
483 Fill: {},
484 Stroke: {},
485 StrokeAndFill: {},
486 },
487
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500488 PathOp: {
489 Difference: {},
490 Intersect: {},
491 Union: {},
492 XOR: {},
493 ReverseDifference: {},
494 },
495
Kevin Lubickb9db3902018-11-26 11:47:54 -0500496 StrokeCap: {
497 Butt: {},
498 Round: {},
499 Square: {},
500 },
501
502 StrokeJoin: {
503 Miter: {},
504 Round: {},
505 Bevel: {},
506 },
507
Kevin Lubickec4903d2019-01-14 08:36:08 -0500508 TextEncoding: {
509 UTF8: {},
510 UTF16: {},
511 UTF32: {},
512 GlyphID: {},
513 },
514
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500515 TileMode: {
516 Clamp: {},
517 Repeat: {},
518 Mirror: {},
Kevin Lubickd29edd72018-12-07 08:29:52 -0500519 Decal: {},
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500520 },
521
522 VertexMode: {
523 Triangles: {},
524 TrianglesStrip: {},
525 TriangleFan: {},
526 },
527
Kevin Lubick006a6f32018-10-19 14:34:34 -0400528 // Things Enscriptem adds for us
529
Kevin Lubick53965c92018-10-11 08:51:55 -0400530 /** Represents the heap of the WASM code
531 * @type {ArrayBuffer}
532 */
533 buffer: {},
534 /**
535 * @type {Float32Array}
536 */
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400537 HEAPF32: {},
Kevin Lubick53965c92018-10-11 08:51:55 -0400538 /**
539 * @type {Uint8Array}
540 */
541 HEAPU8: {},
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400542 /**
543 * @type {Uint16Array}
544 */
545 HEAPU16: {},
546 /**
547 * @type {Int32Array}
548 */
549 HEAP32: {},
Kevin Lubickf5ea37f2019-02-28 10:06:18 -0500550 /**
551 * @type {Uint32Array}
552 */
553 HEAPU32: {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400554 _malloc: function() {},
555 _free: function() {},
556 onRuntimeInitialized: function() {},
557};
Kevin Lubick217056c2018-09-20 17:39:31 -0400558
Kevin Lubick006a6f32018-10-19 14:34:34 -0400559// Public API things that are newly declared in the JS should go here.
560// It's not enough to declare them above, because closure can still erase them
561// unless they go on the prototype.
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500562CanvasKit.SkPath.prototype.addArc = function() {};
Kevin Lubicke384df42019-08-26 15:48:09 -0400563CanvasKit.SkPath.prototype.addOval = function() {};
Kevin Lubick217056c2018-09-20 17:39:31 -0400564CanvasKit.SkPath.prototype.addPath = function() {};
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500565CanvasKit.SkPath.prototype.addRect = function() {};
Kevin Lubickda3d8ac2019-01-07 11:08:55 -0500566CanvasKit.SkPath.prototype.addRoundRect = function() {};
Alexander Khovansky3e119332018-11-15 02:01:19 +0300567CanvasKit.SkPath.prototype.arc = function() {};
Kevin Lubick006a6f32018-10-19 14:34:34 -0400568CanvasKit.SkPath.prototype.arcTo = function() {};
Kevin Lubick217056c2018-09-20 17:39:31 -0400569CanvasKit.SkPath.prototype.close = function() {};
Kevin Lubick006a6f32018-10-19 14:34:34 -0400570CanvasKit.SkPath.prototype.conicTo = function() {};
571CanvasKit.SkPath.prototype.cubicTo = function() {};
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400572CanvasKit.SkPath.prototype.dash = function() {};
Kevin Lubick006a6f32018-10-19 14:34:34 -0400573CanvasKit.SkPath.prototype.lineTo = function() {};
574CanvasKit.SkPath.prototype.moveTo = function() {};
Kevin Lubicke384df42019-08-26 15:48:09 -0400575CanvasKit.SkPath.prototype.offset = function() {};
Kevin Lubick006a6f32018-10-19 14:34:34 -0400576CanvasKit.SkPath.prototype.op = function() {};
577CanvasKit.SkPath.prototype.quadTo = function() {};
578CanvasKit.SkPath.prototype.rect = function() {};
Kevin Lubick217056c2018-09-20 17:39:31 -0400579CanvasKit.SkPath.prototype.simplify = function() {};
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400580CanvasKit.SkPath.prototype.stroke = function() {};
Kevin Lubick217056c2018-09-20 17:39:31 -0400581CanvasKit.SkPath.prototype.transform = function() {};
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400582CanvasKit.SkPath.prototype.trim = function() {};
Kevin Lubick217056c2018-09-20 17:39:31 -0400583
Kevin Lubickcc13fd32019-04-05 13:00:01 -0400584CanvasKit.SkPicture.prototype.DEBUGONLY_saveAsFile = function() {};
585
Kevin Lubick5b90b842018-10-17 07:57:18 -0400586CanvasKit.SkSurface.prototype.dispose = function() {};
Kevin Lubick359a7e32019-03-19 09:34:37 -0400587CanvasKit.SkSurface.prototype.flush = function() {};
588CanvasKit.SkSurface.prototype.requestAnimationFrame = function() {};
Kevin Lubickcc13fd32019-04-05 13:00:01 -0400589CanvasKit.SkSurface.prototype.captureFrameAsSkPicture = function() {};
Kevin Lubick53965c92018-10-11 08:51:55 -0400590
Kevin Lubick12c0e502018-11-28 12:51:56 -0500591/** @return {CanvasKit.SkVertices} */
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400592CanvasKit.SkVertices.prototype.applyBones = function() {};
593
Alexander Khovansky3e119332018-11-15 02:01:19 +0300594CanvasKit.SkImage.prototype.encodeToData = function() {};
Kevin Lubicka064c282019-04-04 09:28:53 -0400595CanvasKit.SkImage.prototype.makeShader = function() {};
Alexander Khovansky3e119332018-11-15 02:01:19 +0300596
Kevin Lubickee91c072019-03-29 10:39:52 -0400597CanvasKit.SkCanvas.prototype.drawAtlas = function() {};
Kevin Lubickec4903d2019-01-14 08:36:08 -0500598CanvasKit.SkCanvas.prototype.drawText = function() {};
Kevin Lubick52b9f372018-12-04 13:57:36 -0500599/** @return {Uint8Array} */
600CanvasKit.SkCanvas.prototype.readPixels = function() {};
601CanvasKit.SkCanvas.prototype.writePixels = function() {};
602
Kevin Lubickddd0a332018-12-12 10:35:13 -0500603CanvasKit.SkFontMgr.prototype.MakeTypefaceFromData = function() {};
604
Kevin Lubickd3cfbca2019-03-15 15:36:29 -0400605CanvasKit.SkFont.prototype.getWidths = function() {};
606
607CanvasKit.RSXFormBuilder.prototype.build = function() {};
608CanvasKit.RSXFormBuilder.prototype.delete = function() {};
609CanvasKit.RSXFormBuilder.prototype.push = function() {};
Kevin Lubickee91c072019-03-29 10:39:52 -0400610CanvasKit.RSXFormBuilder.prototype.set = function() {};
611
612CanvasKit.SkColorBuilder.prototype.build = function() {};
613CanvasKit.SkColorBuilder.prototype.delete = function() {};
614CanvasKit.SkColorBuilder.prototype.push = function() {};
615CanvasKit.SkColorBuilder.prototype.set = function() {};
Kevin Lubickd3cfbca2019-03-15 15:36:29 -0400616
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400617// Define StrokeOpts object
618var StrokeOpts = {};
619StrokeOpts.prototype.width;
620StrokeOpts.prototype.miter_limit;
621StrokeOpts.prototype.cap;
622StrokeOpts.prototype.join;
Kevin Lubick1646e7d2018-12-07 13:03:08 -0500623StrokeOpts.prototype.precision;
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400624
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500625// Define everything created in the canvas2d spec here
Kevin Lubickb9db3902018-11-26 11:47:54 -0500626var HTMLCanvas = {};
Kevin Lubick0a1293c2018-12-03 12:31:04 -0500627HTMLCanvas.prototype.decodeImage = function() {};
628HTMLCanvas.prototype.dispose = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500629HTMLCanvas.prototype.getContext = function() {};
Kevin Lubick8e4a3312018-12-14 15:03:41 -0500630HTMLCanvas.prototype.loadFont = function() {};
Kevin Lubicka40f8322018-12-17 16:01:36 -0500631HTMLCanvas.prototype.makePath2D = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500632HTMLCanvas.prototype.toDataURL = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500633
634var CanvasRenderingContext2D = {};
635CanvasRenderingContext2D.prototype.addHitRegion = function() {};
636CanvasRenderingContext2D.prototype.arc = function() {};
637CanvasRenderingContext2D.prototype.arcTo = function() {};
638CanvasRenderingContext2D.prototype.beginPath = function() {};
639CanvasRenderingContext2D.prototype.bezierCurveTo = function() {};
640CanvasRenderingContext2D.prototype.clearHitRegions = function() {};
Kevin Lubick12c0e502018-11-28 12:51:56 -0500641CanvasRenderingContext2D.prototype.clearRect = function() {};
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500642CanvasRenderingContext2D.prototype.clip = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500643CanvasRenderingContext2D.prototype.closePath = function() {};
Kevin Lubick52b9f372018-12-04 13:57:36 -0500644CanvasRenderingContext2D.prototype.createImageData = function() {};
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500645CanvasRenderingContext2D.prototype.createLinearGradient = function() {};
Kevin Lubickd29edd72018-12-07 08:29:52 -0500646CanvasRenderingContext2D.prototype.createPattern = function() {};
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500647CanvasRenderingContext2D.prototype.createRadialGradient = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500648CanvasRenderingContext2D.prototype.drawFocusIfNeeded = function() {};
Kevin Lubick0a1293c2018-12-03 12:31:04 -0500649CanvasRenderingContext2D.prototype.drawImage = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500650CanvasRenderingContext2D.prototype.ellipse = function() {};
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500651CanvasRenderingContext2D.prototype.fill = function() {};
Kevin Lubick12c0e502018-11-28 12:51:56 -0500652CanvasRenderingContext2D.prototype.fillRect = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500653CanvasRenderingContext2D.prototype.fillText = function() {};
Kevin Lubick52b9f372018-12-04 13:57:36 -0500654CanvasRenderingContext2D.prototype.getImageData = function() {};
Kevin Lubick12c0e502018-11-28 12:51:56 -0500655CanvasRenderingContext2D.prototype.getLineDash = function() {};
Kevin Lubick1646e7d2018-12-07 13:03:08 -0500656CanvasRenderingContext2D.prototype.isPointInPath = function() {};
657CanvasRenderingContext2D.prototype.isPointInStroke = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500658CanvasRenderingContext2D.prototype.lineTo = function() {};
659CanvasRenderingContext2D.prototype.measureText = function() {};
660CanvasRenderingContext2D.prototype.moveTo = function() {};
Kevin Lubick52b9f372018-12-04 13:57:36 -0500661CanvasRenderingContext2D.prototype.putImageData = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500662CanvasRenderingContext2D.prototype.quadraticCurveTo = function() {};
663CanvasRenderingContext2D.prototype.rect = function() {};
664CanvasRenderingContext2D.prototype.removeHitRegion = function() {};
665CanvasRenderingContext2D.prototype.resetTransform = function() {};
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500666CanvasRenderingContext2D.prototype.restore = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500667CanvasRenderingContext2D.prototype.rotate = function() {};
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500668CanvasRenderingContext2D.prototype.save = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500669CanvasRenderingContext2D.prototype.scale = function() {};
670CanvasRenderingContext2D.prototype.scrollPathIntoView = function() {};
Kevin Lubick12c0e502018-11-28 12:51:56 -0500671CanvasRenderingContext2D.prototype.setLineDash = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500672CanvasRenderingContext2D.prototype.setTransform = function() {};
673CanvasRenderingContext2D.prototype.stroke = function() {};
Kevin Lubick12c0e502018-11-28 12:51:56 -0500674CanvasRenderingContext2D.prototype.strokeRect = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500675CanvasRenderingContext2D.prototype.strokeText = function() {};
676CanvasRenderingContext2D.prototype.transform = function() {};
677CanvasRenderingContext2D.prototype.translate = function() {};
678
Kevin Lubicka40f8322018-12-17 16:01:36 -0500679var Path2D = {};
680Path2D.prototype.addPath = function() {};
681Path2D.prototype.arc = function() {};
682Path2D.prototype.arcTo = function() {};
683Path2D.prototype.bezierCurveTo = function() {};
684Path2D.prototype.closePath = function() {};
685Path2D.prototype.ellipse = function() {};
686Path2D.prototype.lineTo = function() {};
687Path2D.prototype.moveTo = function() {};
688Path2D.prototype.quadraticCurveTo = function() {};
689Path2D.prototype.rect = function() {};
690
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500691var LinearCanvasGradient = {};
692LinearCanvasGradient.prototype.addColorStop = function() {};
693var RadialCanvasGradient = {};
694RadialCanvasGradient.prototype.addColorStop = function() {};
Kevin Lubickd29edd72018-12-07 08:29:52 -0500695var CanvasPattern = {};
696CanvasPattern.prototype.setTransform = function() {};
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500697
Kevin Lubick52b9f372018-12-04 13:57:36 -0500698var ImageData = {
699 /**
700 * @type {Uint8ClampedArray}
701 */
702 data: {},
703 height: {},
704 width: {},
705};
706
Kevin Lubickd29edd72018-12-07 08:29:52 -0500707var DOMMatrix = {
708 a: {},
709 b: {},
710 c: {},
711 d: {},
712 e: {},
713 f: {},
714};
715
Kevin Lubick217056c2018-09-20 17:39:31 -0400716// 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 -0500717function loadWebAssemblyModule() {};