blob: 0ef36e77e45b7f99d3c787bd10de0d2c964d3978 [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 Lubick0a1293c2018-12-03 12:31:04 -050042 /** @return {CanvasKit.SkImage} */
43 MakeImageFromEncoded: function() {},
Kevin Lubickeb2f6b02018-11-29 15:07:02 -050044 /** @return {LinearCanvasGradient} */
Kevin Lubickb5ae3b52018-11-03 07:51:19 -040045 MakeLinearGradientShader: function() {},
Kevin Lubick543f3522019-03-08 10:04:28 -050046 MakeOnScreenGLSurface: function() {},
Kevin Lubickda3d8ac2019-01-07 11:08:55 -050047 MakePathFromCmds: function() {},
Kevin Lubicka40f8322018-12-17 16:01:36 -050048 MakePathFromOp: function() {},
49 MakePathFromSVGString: function() {},
Kevin Lubick61ef7b22018-11-27 13:26:59 -050050 MakeRadialGradientShader: function() {},
Kevin Lubick543f3522019-03-08 10:04:28 -050051 MakeRenderTarget: function() {},
Kevin Lubick61ef7b22018-11-27 13:26:59 -050052 MakeSWCanvasSurface: function() {},
Kevin Lubickf5ea37f2019-02-28 10:06:18 -050053 MakeManagedAnimation: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -040054 MakeSkDashPathEffect: function() {},
Kevin Lubickb5ae3b52018-11-03 07:51:19 -040055 MakeSkVertices: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -040056 MakeSurface: function() {},
Kevin Lubickeb2f6b02018-11-29 15:07:02 -050057 /** @return {RadialCanvasGradient} */
58 MakeTwoPointConicalGradientShader: function() {},
Kevin Lubick61ef7b22018-11-27 13:26:59 -050059 MakeWebGLCanvasSurface: function() {},
Kevin Lubick217056c2018-09-20 17:39:31 -040060 currentContext: function() {},
Kevin Lubick61ef7b22018-11-27 13:26:59 -050061 getColorComponents: function() {},
Kevin Lubick12c0e502018-11-28 12:51:56 -050062 getSkDataBytes: function() {},
Kevin Lubick12c0e502018-11-28 12:51:56 -050063 multiplyByAlpha: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -040064 setCurrentContext: function() {},
Kevin Lubick217056c2018-09-20 17:39:31 -040065
66 // private API (i.e. things declared in the bindings that we use
67 // in the pre-js file)
Kevin Lubick52b9f372018-12-04 13:57:36 -050068 _MakeImage: function() {},
Kevin Lubickb5ae3b52018-11-03 07:51:19 -040069 _MakeLinearGradientShader: function() {},
Kevin Lubickda3d8ac2019-01-07 11:08:55 -050070 _MakePathFromCmds: function() {},
Kevin Lubickb5ae3b52018-11-03 07:51:19 -040071 _MakeRadialGradientShader: function() {},
Kevin Lubickf5ea37f2019-02-28 10:06:18 -050072 _MakeManagedAnimation: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -040073 _MakeSkDashPathEffect: function() {},
Kevin Lubickb5ae3b52018-11-03 07:51:19 -040074 _MakeSkVertices: function() {},
Kevin Lubickeb2f6b02018-11-29 15:07:02 -050075 _MakeTwoPointConicalGradientShader: function() {},
Kevin Lubick0a1293c2018-12-03 12:31:04 -050076 _decodeImage: function() {},
Kevin Lubick1ba9c4d2019-02-22 10:04:06 -050077 _drawShapedText: function() {},
Kevin Lubickea905ec2018-11-30 14:05:58 -050078 _getRasterDirectSurface: function() {},
Kevin Lubick134be1d2018-10-30 15:05:04 -040079 _getRasterN32PremulSurface: function() {},
Kevin Lubick217056c2018-09-20 17:39:31 -040080
Kevin Lubick1a05fce2018-11-20 12:51:16 -050081 // The testing object is meant to expose internal functions
82 // for more fine-grained testing, e.g. parseColor
83 _testing: {},
84
Kevin Lubick217056c2018-09-20 17:39:31 -040085 // Objects and properties on CanvasKit
86
Kevin Lubickcd544662019-03-22 15:41:36 -040087 GrContext: {
88 // public API (from C++ bindings)
89 getResourceCacheLimitBytes: function() {},
90 getResourceCacheUsageBytes: function() {},
91 setResourceCacheLimitBytes: function() {},
92 },
93
Kevin Lubickd3cfbca2019-03-15 15:36:29 -040094 RSXFormBuilder: function() {},
Kevin Lubickee91c072019-03-29 10:39:52 -040095 SkColorBuilder: function() {},
96 SkRectBuilder: function() {},
Kevin Lubickd3cfbca2019-03-15 15:36:29 -040097
Kevin Lubick1ba9c4d2019-02-22 10:04:06 -050098 ShapedText: {
99 // public API (from C++ bindings)
100 getBounds: function() {},
101 },
102
Kevin Lubick006a6f32018-10-19 14:34:34 -0400103 SkCanvas: {
104 // public API (from C++ bindings)
105 clear: function() {},
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500106 clipPath: function() {},
Kevin Lubick5d5723c2018-12-07 10:09:11 -0500107 clipRect: function() {},
108 concat: function() {},
Kevin Lubickda3d8ac2019-01-07 11:08:55 -0500109 drawArc: function() {},
Kevin Lubicke384df42019-08-26 15:48:09 -0400110 drawCircle: function() {},
Kevin Lubick2e5fe352019-09-03 12:59:06 -0400111 drawDRRect: function() {},
Kevin Lubick0a1293c2018-12-03 12:31:04 -0500112 drawImage: function() {},
113 drawImageRect: function() {},
Kevin Lubickda3d8ac2019-01-07 11:08:55 -0500114 drawLine: function() {},
115 drawOval: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400116 drawPaint: function() {},
117 drawPath: function() {},
Kevin Lubickcc13fd32019-04-05 13:00:01 -0400118 drawPicture: function() {},
Kevin Lubick2e5fe352019-09-03 12:59:06 -0400119 drawRRect: function() {},
Kevin Lubick12c0e502018-11-28 12:51:56 -0500120 drawRect: function() {},
Kevin Lubickda3d8ac2019-01-07 11:08:55 -0500121 drawRoundRect: function() {},
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500122 drawShadow: function() {},
Kevin Lubick12c0e502018-11-28 12:51:56 -0500123 drawText: function() {},
Kevin Lubickec4903d2019-01-14 08:36:08 -0500124 drawTextBlob: function() {},
Kevin Lubick12c0e502018-11-28 12:51:56 -0500125 drawVertices: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400126 flush: function() {},
Kevin Lubick2e5fe352019-09-03 12:59:06 -0400127 getSaveCount: function() {},
Kevin Lubick5d5723c2018-12-07 10:09:11 -0500128 getTotalMatrix: function() {},
Kevin Lubick543f3522019-03-08 10:04:28 -0500129 makeSurface: function() {},
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500130 restore: function() {},
Kevin Lubickb3574c92019-03-06 08:25:36 -0500131 restoreToCount: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400132 rotate: function() {},
133 save: function() {},
Kevin Lubickb3574c92019-03-06 08:25:36 -0500134 saveLayer: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400135 scale: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400136 skew: function() {},
137 translate: function() {},
138
139 // private API
Kevin Lubickee91c072019-03-29 10:39:52 -0400140 _drawAtlas: function() {},
Kevin Lubickec4903d2019-01-14 08:36:08 -0500141 _drawSimpleText: function() {},
Kevin Lubick52b9f372018-12-04 13:57:36 -0500142 _readPixels: function() {},
143 _writePixels: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400144 delete: function() {},
145 },
146
Kevin Lubick35ac0382019-01-02 15:13:57 -0500147 SkFont: {
148 // public API (from C++ bindings)
149 getScaleX: function() {},
150 getSize: function() {},
151 getSkewX: function() {},
152 getTypeface: function() {},
153 measureText: function() {},
154 setScaleX: function() {},
155 setSize: function() {},
156 setSkewX: function() {},
157 setTypeface: function() {},
Kevin Lubickd3cfbca2019-03-15 15:36:29 -0400158 // private API (from C++ bindings)
159 _getWidths: function() {},
Kevin Lubick35ac0382019-01-02 15:13:57 -0500160 },
161
Kevin Lubickddd0a332018-12-12 10:35:13 -0500162 SkFontMgr: {
163 // public API (from C++ bindings)
164 RefDefault: function() {},
165 countFamilies: function() {},
166
167 // private API
168 _makeTypefaceFromData: function() {},
169 },
170
Kevin Lubick006a6f32018-10-19 14:34:34 -0400171 SkImage: {
Kevin Lubick0a1293c2018-12-03 12:31:04 -0500172 // public API (from C++ bindings)
173 height: function() {},
174 width: function() {},
Alexander Khovansky3e119332018-11-15 02:01:19 +0300175 // private API
176 _encodeToData: function() {},
177 _encodeToDataWithFormat: function() {},
Kevin Lubicka064c282019-04-04 09:28:53 -0400178 _makeShader: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400179 },
180
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500181 SkMatrix: {
Kevin Lubickb9db3902018-11-26 11:47:54 -0500182 identity: function() {},
Kevin Lubickf3555182019-03-14 10:55:10 -0400183 invert: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500184 mapPoints: function() {},
185 multiply: function() {},
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500186 rotated: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500187 scaled: function() {},
188 skewed: function() {},
189 translated: function() {},
190 },
191
192 SkPaint: {
193 // public API (from C++ bindings)
194 /** @return {CanvasKit.SkPaint} */
195 copy: function() {},
Kevin Lubick12c0e502018-11-28 12:51:56 -0500196 getBlendMode: function() {},
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500197 getColor: function() {},
Kevin Lubick0a1293c2018-12-03 12:31:04 -0500198 getFilterQuality: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500199 getStrokeCap: function() {},
200 getStrokeJoin: function() {},
201 getStrokeMiter: function() {},
202 getStrokeWidth: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500203 setAntiAlias: function() {},
Kevin Lubick12c0e502018-11-28 12:51:56 -0500204 setBlendMode: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500205 setColor: function() {},
Kevin Lubick0a1293c2018-12-03 12:31:04 -0500206 setFilterQuality: function() {},
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500207 setMaskFilter: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500208 setPathEffect: function() {},
209 setShader: function() {},
210 setStrokeCap: function() {},
211 setStrokeJoin: function() {},
212 setStrokeMiter: function() {},
213 setStrokeWidth: function() {},
214 setStyle: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500215
216 //private API
217 delete: function() {},
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500218 },
219
Kevin Lubick006a6f32018-10-19 14:34:34 -0400220 SkPath: {
221 // public API (from C++ bindings)
Kevin Lubickb9db3902018-11-26 11:47:54 -0500222 computeTightBounds: function() {},
Kevin Lubick1646e7d2018-12-07 13:03:08 -0500223 contains: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500224 /** @return {CanvasKit.SkPath} */
225 copy: function() {},
226 countPoints: function() {},
227 equals: function() {},
228 getBounds: function() {},
229 getFillType: function() {},
230 getPoint: function() {},
Kevin Lubick1646e7d2018-12-07 13:03:08 -0500231 isEmpty: function() {},
Kevin Lubick2b79d1c2018-12-14 16:10:38 -0500232 isVolatile: function() {},
Kevin Lubickda3d8ac2019-01-07 11:08:55 -0500233 reset: function() {},
234 rewind: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500235 setFillType: function() {},
Kevin Lubick2b79d1c2018-12-14 16:10:38 -0500236 setIsVolatile: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500237 toSVGString: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400238
239 // private API
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500240 _addArc: function() {},
Kevin Lubicke384df42019-08-26 15:48:09 -0400241 _addOval: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400242 _addPath: function() {},
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500243 _addRect: function() {},
Kevin Lubickda3d8ac2019-01-07 11:08:55 -0500244 _addRoundRect: function() {},
Alexander Khovansky3e119332018-11-15 02:01:19 +0300245 _arc: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400246 _arcTo: function() {},
247 _close: function() {},
248 _conicTo: function() {},
249 _cubicTo: function() {},
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400250 _dash: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400251 _lineTo: function() {},
252 _moveTo: function() {},
253 _op: function() {},
254 _quadTo: function() {},
255 _rect: function() {},
256 _simplify: function() {},
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400257 _stroke: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400258 _transform: function() {},
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400259 _trim: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400260 delete: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500261 dump: function() {},
262 dumpHex: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400263 },
264
Kevin Lubickd3cfbca2019-03-15 15:36:29 -0400265 SkPathMeasure: {
266 getLength: function() {},
267 getPosTan: function() {},
268 isClosed: function() {},
269 nextContour: function() {},
270 },
271
Kevin Lubickcc13fd32019-04-05 13:00:01 -0400272 SkPicture: {
273 DEBUGONLY_serialize: function() {},
274 },
275
276 SkPictureRecorder: {
277 beginRecording: function() {},
278 finishRecordingAsPicture: function() {},
279 },
280
Kevin Lubick006a6f32018-10-19 14:34:34 -0400281 SkRect: {
282 fLeft: {},
283 fTop: {},
284 fRight: {},
285 fBottom: {},
286 },
287
Kevin Lubick2e5fe352019-09-03 12:59:06 -0400288 SkRRect: {
289 rect: {},
Kevin Lubick7d644e12019-09-11 14:22:22 -0400290 rx1: {},
291 ry1: {},
292 rx2: {},
293 ry2: {},
294 rx3: {},
295 ry3: {},
296 rx4: {},
297 ry4: {},
Kevin Lubick2e5fe352019-09-03 12:59:06 -0400298 },
299
Kevin Lubick006a6f32018-10-19 14:34:34 -0400300 SkSurface: {
301 // public API (from C++ bindings)
302 /** @return {CanvasKit.SkCanvas} */
303 getCanvas: function() {},
304 /** @return {CanvasKit.SkImage} */
305 makeImageSnapshot: function() {},
Kevin Lubick543f3522019-03-08 10:04:28 -0500306 makeSurface: function() {},
Kevin Lubickcd544662019-03-22 15:41:36 -0400307 grContext: {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400308
309 // private API
310 _flush: function() {},
311 _getRasterN32PremulSurface: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400312 delete: function() {},
313 },
314
Kevin Lubickec4903d2019-01-14 08:36:08 -0500315 SkTextBlob: {
Kevin Lubickd3cfbca2019-03-15 15:36:29 -0400316 // public API (both C++ and JS bindings)
317 MakeFromRSXform: function() {},
Kevin Lubickec4903d2019-01-14 08:36:08 -0500318 MakeFromText: function() {},
Kevin Lubickd3cfbca2019-03-15 15:36:29 -0400319 MakeOnPath: function() {},
320 // private API (from C++ bindings)
321 _MakeFromRSXform: function() {},
Kevin Lubickec4903d2019-01-14 08:36:08 -0500322 _MakeFromText: function() {},
323 },
324
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400325 SkVertices: {
326 // public API (from C++ bindings)
Kevin Lubick12c0e502018-11-28 12:51:56 -0500327 bounds: function() {},
328 mode: function() {},
329 uniqueID: function() {},
330 vertexCount: function() {},
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400331
332 // private API
333 /** @return {CanvasKit.SkVertices} */
334 _applyBones: function() {},
335 },
336
Kevin Lubickd6ba7252019-06-03 14:38:05 -0400337 _SkVerticesBuilder: {
338 // public API (from C++ bindings)
339 boneIndices: function() {},
340 boneWeights: function() {},
341 colors: function() {},
342 detach: function() {},
343 indices: function() {},
344 positions: function() {},
345 texCoords: function() {},
346 },
347
Kevin Lubick006a6f32018-10-19 14:34:34 -0400348 // Constants and Enums
349 gpu: {},
350 skottie: {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400351
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500352 TRANSPARENT: {},
353 RED: {},
354 BLUE: {},
355 YELLOW: {},
356 CYAN: {},
357 BLACK: {},
Kevin Lubickea905ec2018-11-30 14:05:58 -0500358 WHITE: {},
359
Kevin Lubickda3d8ac2019-01-07 11:08:55 -0500360 MOVE_VERB: {},
361 LINE_VERB: {},
362 QUAD_VERB: {},
363 CONIC_VERB: {},
364 CUBIC_VERB: {},
365 CLOSE_VERB: {},
366
Kevin Lubickea905ec2018-11-30 14:05:58 -0500367 AlphaType: {
368 Opaque: {},
369 Premul: {},
370 Unpremul: {},
371 },
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500372
373 BlendMode: {
374 Clear: {},
375 Src: {},
376 Dst: {},
377 SrcOver: {},
378 DstOver: {},
379 SrcIn: {},
380 DstIn: {},
381 SrcOut: {},
382 DstOut: {},
383 SrcATop: {},
384 DstATop: {},
385 Xor: {},
386 Plus: {},
387 Modulate: {},
388 Screen: {},
389 Overlay: {},
390 Darken: {},
391 Lighten: {},
392 ColorDodge: {},
393 ColorBurn: {},
394 HardLight: {},
395 SoftLight: {},
396 Difference: {},
397 Exclusion: {},
398 Multiply: {},
399 Hue: {},
400 Saturation: {},
401 Color: {},
402 Luminosity: {},
403 },
404
405 BlurStyle: {
406 Normal: {},
407 Solid: {},
408 Outer: {},
409 Inner: {},
410 },
411
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500412 ClipOp: {
413 Difference: {},
414 Intersect: {},
415 },
416
Kevin Lubickea905ec2018-11-30 14:05:58 -0500417 ColorType: {
418 Alpha_8: {},
419 RGB_565: {},
420 ARGB_4444: {},
421 RGBA_8888: {},
422 RGB_888x: {},
423 BGRA_8888: {},
424 RGBA_1010102: {},
425 RGB_101010x: {},
426 Gray_8: {},
427 RGBA_F16: {},
428 RGBA_F32: {},
429 },
430
Kevin Lubick006a6f32018-10-19 14:34:34 -0400431 FillType: {
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500432 Winding: {},
433 EvenOdd: {},
434 InverseWinding: {},
435 InverseEvenOdd: {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400436 },
437
Kevin Lubick0a1293c2018-12-03 12:31:04 -0500438 FilterQuality: {
439 None: {},
440 Low: {},
441 Medium: {},
442 High: {},
443 },
444
Alexander Khovansky3e119332018-11-15 02:01:19 +0300445 ImageFormat: {
446 PNG: {},
447 JPEG: {},
448 },
449
Kevin Lubickb9db3902018-11-26 11:47:54 -0500450 PaintStyle: {
451 Fill: {},
452 Stroke: {},
453 StrokeAndFill: {},
454 },
455
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500456 PathOp: {
457 Difference: {},
458 Intersect: {},
459 Union: {},
460 XOR: {},
461 ReverseDifference: {},
462 },
463
Kevin Lubickb9db3902018-11-26 11:47:54 -0500464 StrokeCap: {
465 Butt: {},
466 Round: {},
467 Square: {},
468 },
469
470 StrokeJoin: {
471 Miter: {},
472 Round: {},
473 Bevel: {},
474 },
475
Kevin Lubickec4903d2019-01-14 08:36:08 -0500476 TextEncoding: {
477 UTF8: {},
478 UTF16: {},
479 UTF32: {},
480 GlyphID: {},
481 },
482
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500483 TileMode: {
484 Clamp: {},
485 Repeat: {},
486 Mirror: {},
Kevin Lubickd29edd72018-12-07 08:29:52 -0500487 Decal: {},
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500488 },
489
490 VertexMode: {
491 Triangles: {},
492 TrianglesStrip: {},
493 TriangleFan: {},
494 },
495
Kevin Lubick006a6f32018-10-19 14:34:34 -0400496 // Things Enscriptem adds for us
497
Kevin Lubick53965c92018-10-11 08:51:55 -0400498 /** Represents the heap of the WASM code
499 * @type {ArrayBuffer}
500 */
501 buffer: {},
502 /**
503 * @type {Float32Array}
504 */
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400505 HEAPF32: {},
Kevin Lubick53965c92018-10-11 08:51:55 -0400506 /**
507 * @type {Uint8Array}
508 */
509 HEAPU8: {},
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400510 /**
511 * @type {Uint16Array}
512 */
513 HEAPU16: {},
514 /**
515 * @type {Int32Array}
516 */
517 HEAP32: {},
Kevin Lubickf5ea37f2019-02-28 10:06:18 -0500518 /**
519 * @type {Uint32Array}
520 */
521 HEAPU32: {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400522 _malloc: function() {},
523 _free: function() {},
524 onRuntimeInitialized: function() {},
525};
Kevin Lubick217056c2018-09-20 17:39:31 -0400526
Kevin Lubick006a6f32018-10-19 14:34:34 -0400527// Public API things that are newly declared in the JS should go here.
528// It's not enough to declare them above, because closure can still erase them
529// unless they go on the prototype.
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500530CanvasKit.SkPath.prototype.addArc = function() {};
Kevin Lubicke384df42019-08-26 15:48:09 -0400531CanvasKit.SkPath.prototype.addOval = function() {};
Kevin Lubick217056c2018-09-20 17:39:31 -0400532CanvasKit.SkPath.prototype.addPath = function() {};
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500533CanvasKit.SkPath.prototype.addRect = function() {};
Kevin Lubickda3d8ac2019-01-07 11:08:55 -0500534CanvasKit.SkPath.prototype.addRoundRect = function() {};
Alexander Khovansky3e119332018-11-15 02:01:19 +0300535CanvasKit.SkPath.prototype.arc = function() {};
Kevin Lubick006a6f32018-10-19 14:34:34 -0400536CanvasKit.SkPath.prototype.arcTo = function() {};
Kevin Lubick217056c2018-09-20 17:39:31 -0400537CanvasKit.SkPath.prototype.close = function() {};
Kevin Lubick006a6f32018-10-19 14:34:34 -0400538CanvasKit.SkPath.prototype.conicTo = function() {};
539CanvasKit.SkPath.prototype.cubicTo = function() {};
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400540CanvasKit.SkPath.prototype.dash = function() {};
Kevin Lubick006a6f32018-10-19 14:34:34 -0400541CanvasKit.SkPath.prototype.lineTo = function() {};
542CanvasKit.SkPath.prototype.moveTo = function() {};
Kevin Lubicke384df42019-08-26 15:48:09 -0400543CanvasKit.SkPath.prototype.offset = function() {};
Kevin Lubick006a6f32018-10-19 14:34:34 -0400544CanvasKit.SkPath.prototype.op = function() {};
545CanvasKit.SkPath.prototype.quadTo = function() {};
546CanvasKit.SkPath.prototype.rect = function() {};
Kevin Lubick217056c2018-09-20 17:39:31 -0400547CanvasKit.SkPath.prototype.simplify = function() {};
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400548CanvasKit.SkPath.prototype.stroke = function() {};
Kevin Lubick217056c2018-09-20 17:39:31 -0400549CanvasKit.SkPath.prototype.transform = function() {};
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400550CanvasKit.SkPath.prototype.trim = function() {};
Kevin Lubick217056c2018-09-20 17:39:31 -0400551
Kevin Lubickcc13fd32019-04-05 13:00:01 -0400552CanvasKit.SkPicture.prototype.DEBUGONLY_saveAsFile = function() {};
553
Kevin Lubick5b90b842018-10-17 07:57:18 -0400554CanvasKit.SkSurface.prototype.dispose = function() {};
Kevin Lubick359a7e32019-03-19 09:34:37 -0400555CanvasKit.SkSurface.prototype.flush = function() {};
556CanvasKit.SkSurface.prototype.requestAnimationFrame = function() {};
Kevin Lubickcc13fd32019-04-05 13:00:01 -0400557CanvasKit.SkSurface.prototype.captureFrameAsSkPicture = function() {};
Kevin Lubick53965c92018-10-11 08:51:55 -0400558
Kevin Lubick12c0e502018-11-28 12:51:56 -0500559/** @return {CanvasKit.SkVertices} */
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400560CanvasKit.SkVertices.prototype.applyBones = function() {};
561
Alexander Khovansky3e119332018-11-15 02:01:19 +0300562CanvasKit.SkImage.prototype.encodeToData = function() {};
Kevin Lubicka064c282019-04-04 09:28:53 -0400563CanvasKit.SkImage.prototype.makeShader = function() {};
Alexander Khovansky3e119332018-11-15 02:01:19 +0300564
Kevin Lubickee91c072019-03-29 10:39:52 -0400565CanvasKit.SkCanvas.prototype.drawAtlas = function() {};
Kevin Lubickec4903d2019-01-14 08:36:08 -0500566CanvasKit.SkCanvas.prototype.drawText = function() {};
Kevin Lubick52b9f372018-12-04 13:57:36 -0500567/** @return {Uint8Array} */
568CanvasKit.SkCanvas.prototype.readPixels = function() {};
569CanvasKit.SkCanvas.prototype.writePixels = function() {};
570
Kevin Lubickddd0a332018-12-12 10:35:13 -0500571CanvasKit.SkFontMgr.prototype.MakeTypefaceFromData = function() {};
572
Kevin Lubickd3cfbca2019-03-15 15:36:29 -0400573CanvasKit.SkFont.prototype.getWidths = function() {};
574
575CanvasKit.RSXFormBuilder.prototype.build = function() {};
576CanvasKit.RSXFormBuilder.prototype.delete = function() {};
577CanvasKit.RSXFormBuilder.prototype.push = function() {};
Kevin Lubickee91c072019-03-29 10:39:52 -0400578CanvasKit.RSXFormBuilder.prototype.set = function() {};
579
580CanvasKit.SkColorBuilder.prototype.build = function() {};
581CanvasKit.SkColorBuilder.prototype.delete = function() {};
582CanvasKit.SkColorBuilder.prototype.push = function() {};
583CanvasKit.SkColorBuilder.prototype.set = function() {};
Kevin Lubickd3cfbca2019-03-15 15:36:29 -0400584
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400585// Define StrokeOpts object
586var StrokeOpts = {};
587StrokeOpts.prototype.width;
588StrokeOpts.prototype.miter_limit;
589StrokeOpts.prototype.cap;
590StrokeOpts.prototype.join;
Kevin Lubick1646e7d2018-12-07 13:03:08 -0500591StrokeOpts.prototype.precision;
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400592
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500593// Define everything created in the canvas2d spec here
Kevin Lubickb9db3902018-11-26 11:47:54 -0500594var HTMLCanvas = {};
Kevin Lubick0a1293c2018-12-03 12:31:04 -0500595HTMLCanvas.prototype.decodeImage = function() {};
596HTMLCanvas.prototype.dispose = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500597HTMLCanvas.prototype.getContext = function() {};
Kevin Lubick8e4a3312018-12-14 15:03:41 -0500598HTMLCanvas.prototype.loadFont = function() {};
Kevin Lubicka40f8322018-12-17 16:01:36 -0500599HTMLCanvas.prototype.makePath2D = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500600HTMLCanvas.prototype.toDataURL = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500601
602var CanvasRenderingContext2D = {};
603CanvasRenderingContext2D.prototype.addHitRegion = function() {};
604CanvasRenderingContext2D.prototype.arc = function() {};
605CanvasRenderingContext2D.prototype.arcTo = function() {};
606CanvasRenderingContext2D.prototype.beginPath = function() {};
607CanvasRenderingContext2D.prototype.bezierCurveTo = function() {};
608CanvasRenderingContext2D.prototype.clearHitRegions = function() {};
Kevin Lubick12c0e502018-11-28 12:51:56 -0500609CanvasRenderingContext2D.prototype.clearRect = function() {};
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500610CanvasRenderingContext2D.prototype.clip = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500611CanvasRenderingContext2D.prototype.closePath = function() {};
Kevin Lubick52b9f372018-12-04 13:57:36 -0500612CanvasRenderingContext2D.prototype.createImageData = function() {};
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500613CanvasRenderingContext2D.prototype.createLinearGradient = function() {};
Kevin Lubickd29edd72018-12-07 08:29:52 -0500614CanvasRenderingContext2D.prototype.createPattern = function() {};
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500615CanvasRenderingContext2D.prototype.createRadialGradient = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500616CanvasRenderingContext2D.prototype.drawFocusIfNeeded = function() {};
Kevin Lubick0a1293c2018-12-03 12:31:04 -0500617CanvasRenderingContext2D.prototype.drawImage = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500618CanvasRenderingContext2D.prototype.ellipse = function() {};
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500619CanvasRenderingContext2D.prototype.fill = function() {};
Kevin Lubick12c0e502018-11-28 12:51:56 -0500620CanvasRenderingContext2D.prototype.fillRect = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500621CanvasRenderingContext2D.prototype.fillText = function() {};
Kevin Lubick52b9f372018-12-04 13:57:36 -0500622CanvasRenderingContext2D.prototype.getImageData = function() {};
Kevin Lubick12c0e502018-11-28 12:51:56 -0500623CanvasRenderingContext2D.prototype.getLineDash = function() {};
Kevin Lubick1646e7d2018-12-07 13:03:08 -0500624CanvasRenderingContext2D.prototype.isPointInPath = function() {};
625CanvasRenderingContext2D.prototype.isPointInStroke = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500626CanvasRenderingContext2D.prototype.lineTo = function() {};
627CanvasRenderingContext2D.prototype.measureText = function() {};
628CanvasRenderingContext2D.prototype.moveTo = function() {};
Kevin Lubick52b9f372018-12-04 13:57:36 -0500629CanvasRenderingContext2D.prototype.putImageData = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500630CanvasRenderingContext2D.prototype.quadraticCurveTo = function() {};
631CanvasRenderingContext2D.prototype.rect = function() {};
632CanvasRenderingContext2D.prototype.removeHitRegion = function() {};
633CanvasRenderingContext2D.prototype.resetTransform = function() {};
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500634CanvasRenderingContext2D.prototype.restore = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500635CanvasRenderingContext2D.prototype.rotate = function() {};
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500636CanvasRenderingContext2D.prototype.save = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500637CanvasRenderingContext2D.prototype.scale = function() {};
638CanvasRenderingContext2D.prototype.scrollPathIntoView = function() {};
Kevin Lubick12c0e502018-11-28 12:51:56 -0500639CanvasRenderingContext2D.prototype.setLineDash = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500640CanvasRenderingContext2D.prototype.setTransform = function() {};
641CanvasRenderingContext2D.prototype.stroke = function() {};
Kevin Lubick12c0e502018-11-28 12:51:56 -0500642CanvasRenderingContext2D.prototype.strokeRect = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500643CanvasRenderingContext2D.prototype.strokeText = function() {};
644CanvasRenderingContext2D.prototype.transform = function() {};
645CanvasRenderingContext2D.prototype.translate = function() {};
646
Kevin Lubicka40f8322018-12-17 16:01:36 -0500647var Path2D = {};
648Path2D.prototype.addPath = function() {};
649Path2D.prototype.arc = function() {};
650Path2D.prototype.arcTo = function() {};
651Path2D.prototype.bezierCurveTo = function() {};
652Path2D.prototype.closePath = function() {};
653Path2D.prototype.ellipse = function() {};
654Path2D.prototype.lineTo = function() {};
655Path2D.prototype.moveTo = function() {};
656Path2D.prototype.quadraticCurveTo = function() {};
657Path2D.prototype.rect = function() {};
658
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500659var LinearCanvasGradient = {};
660LinearCanvasGradient.prototype.addColorStop = function() {};
661var RadialCanvasGradient = {};
662RadialCanvasGradient.prototype.addColorStop = function() {};
Kevin Lubickd29edd72018-12-07 08:29:52 -0500663var CanvasPattern = {};
664CanvasPattern.prototype.setTransform = function() {};
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500665
Kevin Lubick52b9f372018-12-04 13:57:36 -0500666var ImageData = {
667 /**
668 * @type {Uint8ClampedArray}
669 */
670 data: {},
671 height: {},
672 width: {},
673};
674
Kevin Lubickd29edd72018-12-07 08:29:52 -0500675var DOMMatrix = {
676 a: {},
677 b: {},
678 c: {},
679 d: {},
680 e: {},
681 f: {},
682};
683
Kevin Lubick217056c2018-09-20 17:39:31 -0400684// 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 -0500685function loadWebAssemblyModule() {};