blob: 6e5d7fe3cfd007e79036fe4f77d6f843955fc288 [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: {
Kevin Lubick61887c72019-09-26 13:20:50 -0400195 // public API (from C++ and JS bindings)
196 FromData: function() {},
Kevin Lubickddd0a332018-12-12 10:35:13 -0500197 RefDefault: function() {},
198 countFamilies: function() {},
199
200 // private API
201 _makeTypefaceFromData: function() {},
Kevin Lubick61887c72019-09-26 13:20:50 -0400202 _fromData: function() {},
Kevin Lubickddd0a332018-12-12 10:35:13 -0500203 },
204
Kevin Lubick006a6f32018-10-19 14:34:34 -0400205 SkImage: {
Kevin Lubick0a1293c2018-12-03 12:31:04 -0500206 // public API (from C++ bindings)
207 height: function() {},
208 width: function() {},
Alexander Khovansky3e119332018-11-15 02:01:19 +0300209 // private API
210 _encodeToData: function() {},
211 _encodeToDataWithFormat: function() {},
Kevin Lubicka064c282019-04-04 09:28:53 -0400212 _makeShader: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400213 },
214
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500215 SkMatrix: {
Kevin Lubickb9db3902018-11-26 11:47:54 -0500216 identity: function() {},
Kevin Lubickf3555182019-03-14 10:55:10 -0400217 invert: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500218 mapPoints: function() {},
219 multiply: function() {},
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500220 rotated: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500221 scaled: function() {},
222 skewed: function() {},
223 translated: function() {},
224 },
225
226 SkPaint: {
227 // public API (from C++ bindings)
228 /** @return {CanvasKit.SkPaint} */
229 copy: function() {},
Kevin Lubick12c0e502018-11-28 12:51:56 -0500230 getBlendMode: function() {},
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500231 getColor: function() {},
Kevin Lubick0a1293c2018-12-03 12:31:04 -0500232 getFilterQuality: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500233 getStrokeCap: function() {},
234 getStrokeJoin: function() {},
235 getStrokeMiter: function() {},
236 getStrokeWidth: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500237 setAntiAlias: function() {},
Kevin Lubick12c0e502018-11-28 12:51:56 -0500238 setBlendMode: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500239 setColor: function() {},
Kevin Lubick0a1293c2018-12-03 12:31:04 -0500240 setFilterQuality: function() {},
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500241 setMaskFilter: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500242 setPathEffect: function() {},
243 setShader: function() {},
244 setStrokeCap: function() {},
245 setStrokeJoin: function() {},
246 setStrokeMiter: function() {},
247 setStrokeWidth: function() {},
248 setStyle: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500249
250 //private API
251 delete: function() {},
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500252 },
253
Kevin Lubick006a6f32018-10-19 14:34:34 -0400254 SkPath: {
255 // public API (from C++ bindings)
Kevin Lubickb9db3902018-11-26 11:47:54 -0500256 computeTightBounds: function() {},
Kevin Lubick1646e7d2018-12-07 13:03:08 -0500257 contains: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500258 /** @return {CanvasKit.SkPath} */
259 copy: function() {},
260 countPoints: function() {},
261 equals: function() {},
262 getBounds: function() {},
263 getFillType: function() {},
264 getPoint: function() {},
Kevin Lubick1646e7d2018-12-07 13:03:08 -0500265 isEmpty: function() {},
Kevin Lubick2b79d1c2018-12-14 16:10:38 -0500266 isVolatile: function() {},
Kevin Lubickda3d8ac2019-01-07 11:08:55 -0500267 reset: function() {},
268 rewind: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500269 setFillType: function() {},
Kevin Lubick2b79d1c2018-12-14 16:10:38 -0500270 setIsVolatile: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500271 toSVGString: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400272
273 // private API
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500274 _addArc: function() {},
Kevin Lubicke384df42019-08-26 15:48:09 -0400275 _addOval: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400276 _addPath: function() {},
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500277 _addRect: function() {},
Kevin Lubickda3d8ac2019-01-07 11:08:55 -0500278 _addRoundRect: function() {},
Alexander Khovansky3e119332018-11-15 02:01:19 +0300279 _arc: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400280 _arcTo: function() {},
281 _close: function() {},
282 _conicTo: function() {},
283 _cubicTo: function() {},
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400284 _dash: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400285 _lineTo: function() {},
286 _moveTo: function() {},
287 _op: function() {},
288 _quadTo: function() {},
289 _rect: function() {},
290 _simplify: function() {},
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400291 _stroke: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400292 _transform: function() {},
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400293 _trim: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400294 delete: function() {},
Kevin Lubickb9db3902018-11-26 11:47:54 -0500295 dump: function() {},
296 dumpHex: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400297 },
298
Kevin Lubickd3cfbca2019-03-15 15:36:29 -0400299 SkPathMeasure: {
300 getLength: function() {},
301 getPosTan: function() {},
302 isClosed: function() {},
303 nextContour: function() {},
304 },
305
Kevin Lubickcc13fd32019-04-05 13:00:01 -0400306 SkPicture: {
307 DEBUGONLY_serialize: function() {},
308 },
309
310 SkPictureRecorder: {
311 beginRecording: function() {},
312 finishRecordingAsPicture: function() {},
313 },
314
Kevin Lubick006a6f32018-10-19 14:34:34 -0400315 SkRect: {
316 fLeft: {},
317 fTop: {},
318 fRight: {},
319 fBottom: {},
320 },
321
Kevin Lubick2e5fe352019-09-03 12:59:06 -0400322 SkRRect: {
323 rect: {},
Kevin Lubick7d644e12019-09-11 14:22:22 -0400324 rx1: {},
325 ry1: {},
326 rx2: {},
327 ry2: {},
328 rx3: {},
329 ry3: {},
330 rx4: {},
331 ry4: {},
Kevin Lubick2e5fe352019-09-03 12:59:06 -0400332 },
333
Kevin Lubick006a6f32018-10-19 14:34:34 -0400334 SkSurface: {
335 // public API (from C++ bindings)
336 /** @return {CanvasKit.SkCanvas} */
337 getCanvas: function() {},
338 /** @return {CanvasKit.SkImage} */
339 makeImageSnapshot: function() {},
Kevin Lubick543f3522019-03-08 10:04:28 -0500340 makeSurface: function() {},
Kevin Lubickcd544662019-03-22 15:41:36 -0400341 grContext: {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400342
343 // private API
344 _flush: function() {},
345 _getRasterN32PremulSurface: function() {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400346 delete: function() {},
347 },
348
Kevin Lubickec4903d2019-01-14 08:36:08 -0500349 SkTextBlob: {
Kevin Lubickd3cfbca2019-03-15 15:36:29 -0400350 // public API (both C++ and JS bindings)
351 MakeFromRSXform: function() {},
Kevin Lubickec4903d2019-01-14 08:36:08 -0500352 MakeFromText: function() {},
Kevin Lubickd3cfbca2019-03-15 15:36:29 -0400353 MakeOnPath: function() {},
354 // private API (from C++ bindings)
355 _MakeFromRSXform: function() {},
Kevin Lubickec4903d2019-01-14 08:36:08 -0500356 _MakeFromText: function() {},
357 },
358
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400359 SkVertices: {
360 // public API (from C++ bindings)
Kevin Lubick12c0e502018-11-28 12:51:56 -0500361 bounds: function() {},
362 mode: function() {},
363 uniqueID: function() {},
364 vertexCount: function() {},
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400365
366 // private API
367 /** @return {CanvasKit.SkVertices} */
368 _applyBones: function() {},
369 },
370
Kevin Lubickd6ba7252019-06-03 14:38:05 -0400371 _SkVerticesBuilder: {
372 // public API (from C++ bindings)
373 boneIndices: function() {},
374 boneWeights: function() {},
375 colors: function() {},
376 detach: function() {},
377 indices: function() {},
378 positions: function() {},
379 texCoords: function() {},
380 },
381
Kevin Lubick006a6f32018-10-19 14:34:34 -0400382 // Constants and Enums
383 gpu: {},
384 skottie: {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400385
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500386 TRANSPARENT: {},
387 RED: {},
388 BLUE: {},
389 YELLOW: {},
390 CYAN: {},
391 BLACK: {},
Kevin Lubickea905ec2018-11-30 14:05:58 -0500392 WHITE: {},
393
Kevin Lubickda3d8ac2019-01-07 11:08:55 -0500394 MOVE_VERB: {},
395 LINE_VERB: {},
396 QUAD_VERB: {},
397 CONIC_VERB: {},
398 CUBIC_VERB: {},
399 CLOSE_VERB: {},
400
Kevin Lubickea905ec2018-11-30 14:05:58 -0500401 AlphaType: {
402 Opaque: {},
403 Premul: {},
404 Unpremul: {},
405 },
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500406
407 BlendMode: {
408 Clear: {},
409 Src: {},
410 Dst: {},
411 SrcOver: {},
412 DstOver: {},
413 SrcIn: {},
414 DstIn: {},
415 SrcOut: {},
416 DstOut: {},
417 SrcATop: {},
418 DstATop: {},
419 Xor: {},
420 Plus: {},
421 Modulate: {},
422 Screen: {},
423 Overlay: {},
424 Darken: {},
425 Lighten: {},
426 ColorDodge: {},
427 ColorBurn: {},
428 HardLight: {},
429 SoftLight: {},
430 Difference: {},
431 Exclusion: {},
432 Multiply: {},
433 Hue: {},
434 Saturation: {},
435 Color: {},
436 Luminosity: {},
437 },
438
439 BlurStyle: {
440 Normal: {},
441 Solid: {},
442 Outer: {},
443 Inner: {},
444 },
445
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500446 ClipOp: {
447 Difference: {},
448 Intersect: {},
449 },
450
Kevin Lubickea905ec2018-11-30 14:05:58 -0500451 ColorType: {
452 Alpha_8: {},
453 RGB_565: {},
454 ARGB_4444: {},
455 RGBA_8888: {},
456 RGB_888x: {},
457 BGRA_8888: {},
458 RGBA_1010102: {},
459 RGB_101010x: {},
460 Gray_8: {},
461 RGBA_F16: {},
462 RGBA_F32: {},
463 },
464
Kevin Lubick006a6f32018-10-19 14:34:34 -0400465 FillType: {
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500466 Winding: {},
467 EvenOdd: {},
468 InverseWinding: {},
469 InverseEvenOdd: {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400470 },
471
Kevin Lubick0a1293c2018-12-03 12:31:04 -0500472 FilterQuality: {
473 None: {},
474 Low: {},
475 Medium: {},
476 High: {},
477 },
478
Alexander Khovansky3e119332018-11-15 02:01:19 +0300479 ImageFormat: {
480 PNG: {},
481 JPEG: {},
482 },
483
Kevin Lubickb9db3902018-11-26 11:47:54 -0500484 PaintStyle: {
485 Fill: {},
486 Stroke: {},
487 StrokeAndFill: {},
488 },
489
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500490 PathOp: {
491 Difference: {},
492 Intersect: {},
493 Union: {},
494 XOR: {},
495 ReverseDifference: {},
496 },
497
Kevin Lubickb9db3902018-11-26 11:47:54 -0500498 StrokeCap: {
499 Butt: {},
500 Round: {},
501 Square: {},
502 },
503
504 StrokeJoin: {
505 Miter: {},
506 Round: {},
507 Bevel: {},
508 },
509
Kevin Lubickec4903d2019-01-14 08:36:08 -0500510 TextEncoding: {
511 UTF8: {},
512 UTF16: {},
513 UTF32: {},
514 GlyphID: {},
515 },
516
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500517 TileMode: {
518 Clamp: {},
519 Repeat: {},
520 Mirror: {},
Kevin Lubickd29edd72018-12-07 08:29:52 -0500521 Decal: {},
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500522 },
523
524 VertexMode: {
525 Triangles: {},
526 TrianglesStrip: {},
527 TriangleFan: {},
528 },
529
Kevin Lubick006a6f32018-10-19 14:34:34 -0400530 // Things Enscriptem adds for us
531
Kevin Lubick53965c92018-10-11 08:51:55 -0400532 /** Represents the heap of the WASM code
533 * @type {ArrayBuffer}
534 */
535 buffer: {},
536 /**
537 * @type {Float32Array}
538 */
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400539 HEAPF32: {},
Kevin Lubick53965c92018-10-11 08:51:55 -0400540 /**
541 * @type {Uint8Array}
542 */
543 HEAPU8: {},
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400544 /**
545 * @type {Uint16Array}
546 */
547 HEAPU16: {},
548 /**
549 * @type {Int32Array}
550 */
551 HEAP32: {},
Kevin Lubickf5ea37f2019-02-28 10:06:18 -0500552 /**
553 * @type {Uint32Array}
554 */
555 HEAPU32: {},
Kevin Lubick006a6f32018-10-19 14:34:34 -0400556 _malloc: function() {},
557 _free: function() {},
558 onRuntimeInitialized: function() {},
559};
Kevin Lubick217056c2018-09-20 17:39:31 -0400560
Kevin Lubick006a6f32018-10-19 14:34:34 -0400561// Public API things that are newly declared in the JS should go here.
562// It's not enough to declare them above, because closure can still erase them
563// unless they go on the prototype.
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500564CanvasKit.SkPath.prototype.addArc = function() {};
Kevin Lubicke384df42019-08-26 15:48:09 -0400565CanvasKit.SkPath.prototype.addOval = function() {};
Kevin Lubick217056c2018-09-20 17:39:31 -0400566CanvasKit.SkPath.prototype.addPath = function() {};
Kevin Lubick1a05fce2018-11-20 12:51:16 -0500567CanvasKit.SkPath.prototype.addRect = function() {};
Kevin Lubickda3d8ac2019-01-07 11:08:55 -0500568CanvasKit.SkPath.prototype.addRoundRect = function() {};
Alexander Khovansky3e119332018-11-15 02:01:19 +0300569CanvasKit.SkPath.prototype.arc = function() {};
Kevin Lubick006a6f32018-10-19 14:34:34 -0400570CanvasKit.SkPath.prototype.arcTo = function() {};
Kevin Lubick217056c2018-09-20 17:39:31 -0400571CanvasKit.SkPath.prototype.close = function() {};
Kevin Lubick006a6f32018-10-19 14:34:34 -0400572CanvasKit.SkPath.prototype.conicTo = function() {};
573CanvasKit.SkPath.prototype.cubicTo = function() {};
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400574CanvasKit.SkPath.prototype.dash = function() {};
Kevin Lubick006a6f32018-10-19 14:34:34 -0400575CanvasKit.SkPath.prototype.lineTo = function() {};
576CanvasKit.SkPath.prototype.moveTo = function() {};
Kevin Lubicke384df42019-08-26 15:48:09 -0400577CanvasKit.SkPath.prototype.offset = function() {};
Kevin Lubick006a6f32018-10-19 14:34:34 -0400578CanvasKit.SkPath.prototype.op = function() {};
579CanvasKit.SkPath.prototype.quadTo = function() {};
580CanvasKit.SkPath.prototype.rect = function() {};
Kevin Lubick217056c2018-09-20 17:39:31 -0400581CanvasKit.SkPath.prototype.simplify = function() {};
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400582CanvasKit.SkPath.prototype.stroke = function() {};
Kevin Lubick217056c2018-09-20 17:39:31 -0400583CanvasKit.SkPath.prototype.transform = function() {};
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400584CanvasKit.SkPath.prototype.trim = function() {};
Kevin Lubick217056c2018-09-20 17:39:31 -0400585
Kevin Lubickcc13fd32019-04-05 13:00:01 -0400586CanvasKit.SkPicture.prototype.DEBUGONLY_saveAsFile = function() {};
587
Kevin Lubick5b90b842018-10-17 07:57:18 -0400588CanvasKit.SkSurface.prototype.dispose = function() {};
Kevin Lubick359a7e32019-03-19 09:34:37 -0400589CanvasKit.SkSurface.prototype.flush = function() {};
590CanvasKit.SkSurface.prototype.requestAnimationFrame = function() {};
Kevin Lubickcc13fd32019-04-05 13:00:01 -0400591CanvasKit.SkSurface.prototype.captureFrameAsSkPicture = function() {};
Kevin Lubick53965c92018-10-11 08:51:55 -0400592
Kevin Lubick12c0e502018-11-28 12:51:56 -0500593/** @return {CanvasKit.SkVertices} */
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400594CanvasKit.SkVertices.prototype.applyBones = function() {};
595
Alexander Khovansky3e119332018-11-15 02:01:19 +0300596CanvasKit.SkImage.prototype.encodeToData = function() {};
Kevin Lubicka064c282019-04-04 09:28:53 -0400597CanvasKit.SkImage.prototype.makeShader = function() {};
Alexander Khovansky3e119332018-11-15 02:01:19 +0300598
Kevin Lubickee91c072019-03-29 10:39:52 -0400599CanvasKit.SkCanvas.prototype.drawAtlas = function() {};
Kevin Lubickec4903d2019-01-14 08:36:08 -0500600CanvasKit.SkCanvas.prototype.drawText = function() {};
Kevin Lubick52b9f372018-12-04 13:57:36 -0500601/** @return {Uint8Array} */
602CanvasKit.SkCanvas.prototype.readPixels = function() {};
603CanvasKit.SkCanvas.prototype.writePixels = function() {};
604
Kevin Lubickddd0a332018-12-12 10:35:13 -0500605CanvasKit.SkFontMgr.prototype.MakeTypefaceFromData = function() {};
606
Kevin Lubickd3cfbca2019-03-15 15:36:29 -0400607CanvasKit.SkFont.prototype.getWidths = function() {};
608
609CanvasKit.RSXFormBuilder.prototype.build = function() {};
610CanvasKit.RSXFormBuilder.prototype.delete = function() {};
611CanvasKit.RSXFormBuilder.prototype.push = function() {};
Kevin Lubickee91c072019-03-29 10:39:52 -0400612CanvasKit.RSXFormBuilder.prototype.set = function() {};
613
614CanvasKit.SkColorBuilder.prototype.build = function() {};
615CanvasKit.SkColorBuilder.prototype.delete = function() {};
616CanvasKit.SkColorBuilder.prototype.push = function() {};
617CanvasKit.SkColorBuilder.prototype.set = function() {};
Kevin Lubickd3cfbca2019-03-15 15:36:29 -0400618
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400619// Define StrokeOpts object
620var StrokeOpts = {};
621StrokeOpts.prototype.width;
622StrokeOpts.prototype.miter_limit;
623StrokeOpts.prototype.cap;
624StrokeOpts.prototype.join;
Kevin Lubick1646e7d2018-12-07 13:03:08 -0500625StrokeOpts.prototype.precision;
Kevin Lubickb5ae3b52018-11-03 07:51:19 -0400626
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500627// Define everything created in the canvas2d spec here
Kevin Lubickb9db3902018-11-26 11:47:54 -0500628var HTMLCanvas = {};
Kevin Lubick0a1293c2018-12-03 12:31:04 -0500629HTMLCanvas.prototype.decodeImage = function() {};
630HTMLCanvas.prototype.dispose = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500631HTMLCanvas.prototype.getContext = function() {};
Kevin Lubick8e4a3312018-12-14 15:03:41 -0500632HTMLCanvas.prototype.loadFont = function() {};
Kevin Lubicka40f8322018-12-17 16:01:36 -0500633HTMLCanvas.prototype.makePath2D = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500634HTMLCanvas.prototype.toDataURL = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500635
636var CanvasRenderingContext2D = {};
637CanvasRenderingContext2D.prototype.addHitRegion = function() {};
638CanvasRenderingContext2D.prototype.arc = function() {};
639CanvasRenderingContext2D.prototype.arcTo = function() {};
640CanvasRenderingContext2D.prototype.beginPath = function() {};
641CanvasRenderingContext2D.prototype.bezierCurveTo = function() {};
642CanvasRenderingContext2D.prototype.clearHitRegions = function() {};
Kevin Lubick12c0e502018-11-28 12:51:56 -0500643CanvasRenderingContext2D.prototype.clearRect = function() {};
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500644CanvasRenderingContext2D.prototype.clip = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500645CanvasRenderingContext2D.prototype.closePath = function() {};
Kevin Lubick52b9f372018-12-04 13:57:36 -0500646CanvasRenderingContext2D.prototype.createImageData = function() {};
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500647CanvasRenderingContext2D.prototype.createLinearGradient = function() {};
Kevin Lubickd29edd72018-12-07 08:29:52 -0500648CanvasRenderingContext2D.prototype.createPattern = function() {};
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500649CanvasRenderingContext2D.prototype.createRadialGradient = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500650CanvasRenderingContext2D.prototype.drawFocusIfNeeded = function() {};
Kevin Lubick0a1293c2018-12-03 12:31:04 -0500651CanvasRenderingContext2D.prototype.drawImage = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500652CanvasRenderingContext2D.prototype.ellipse = function() {};
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500653CanvasRenderingContext2D.prototype.fill = function() {};
Kevin Lubick12c0e502018-11-28 12:51:56 -0500654CanvasRenderingContext2D.prototype.fillRect = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500655CanvasRenderingContext2D.prototype.fillText = function() {};
Kevin Lubick52b9f372018-12-04 13:57:36 -0500656CanvasRenderingContext2D.prototype.getImageData = function() {};
Kevin Lubick12c0e502018-11-28 12:51:56 -0500657CanvasRenderingContext2D.prototype.getLineDash = function() {};
Kevin Lubick1646e7d2018-12-07 13:03:08 -0500658CanvasRenderingContext2D.prototype.isPointInPath = function() {};
659CanvasRenderingContext2D.prototype.isPointInStroke = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500660CanvasRenderingContext2D.prototype.lineTo = function() {};
661CanvasRenderingContext2D.prototype.measureText = function() {};
662CanvasRenderingContext2D.prototype.moveTo = function() {};
Kevin Lubick52b9f372018-12-04 13:57:36 -0500663CanvasRenderingContext2D.prototype.putImageData = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500664CanvasRenderingContext2D.prototype.quadraticCurveTo = function() {};
665CanvasRenderingContext2D.prototype.rect = function() {};
666CanvasRenderingContext2D.prototype.removeHitRegion = function() {};
667CanvasRenderingContext2D.prototype.resetTransform = function() {};
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500668CanvasRenderingContext2D.prototype.restore = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500669CanvasRenderingContext2D.prototype.rotate = function() {};
Kevin Lubick61ef7b22018-11-27 13:26:59 -0500670CanvasRenderingContext2D.prototype.save = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500671CanvasRenderingContext2D.prototype.scale = function() {};
672CanvasRenderingContext2D.prototype.scrollPathIntoView = function() {};
Kevin Lubick12c0e502018-11-28 12:51:56 -0500673CanvasRenderingContext2D.prototype.setLineDash = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500674CanvasRenderingContext2D.prototype.setTransform = function() {};
675CanvasRenderingContext2D.prototype.stroke = function() {};
Kevin Lubick12c0e502018-11-28 12:51:56 -0500676CanvasRenderingContext2D.prototype.strokeRect = function() {};
Kevin Lubickb9db3902018-11-26 11:47:54 -0500677CanvasRenderingContext2D.prototype.strokeText = function() {};
678CanvasRenderingContext2D.prototype.transform = function() {};
679CanvasRenderingContext2D.prototype.translate = function() {};
680
Kevin Lubicka40f8322018-12-17 16:01:36 -0500681var Path2D = {};
682Path2D.prototype.addPath = function() {};
683Path2D.prototype.arc = function() {};
684Path2D.prototype.arcTo = function() {};
685Path2D.prototype.bezierCurveTo = function() {};
686Path2D.prototype.closePath = function() {};
687Path2D.prototype.ellipse = function() {};
688Path2D.prototype.lineTo = function() {};
689Path2D.prototype.moveTo = function() {};
690Path2D.prototype.quadraticCurveTo = function() {};
691Path2D.prototype.rect = function() {};
692
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500693var LinearCanvasGradient = {};
694LinearCanvasGradient.prototype.addColorStop = function() {};
695var RadialCanvasGradient = {};
696RadialCanvasGradient.prototype.addColorStop = function() {};
Kevin Lubickd29edd72018-12-07 08:29:52 -0500697var CanvasPattern = {};
698CanvasPattern.prototype.setTransform = function() {};
Kevin Lubickeb2f6b02018-11-29 15:07:02 -0500699
Kevin Lubick52b9f372018-12-04 13:57:36 -0500700var ImageData = {
701 /**
702 * @type {Uint8ClampedArray}
703 */
704 data: {},
705 height: {},
706 width: {},
707};
708
Kevin Lubickd29edd72018-12-07 08:29:52 -0500709var DOMMatrix = {
710 a: {},
711 b: {},
712 c: {},
713 d: {},
714 e: {},
715 f: {},
716};
717
Kevin Lubick217056c2018-09-20 17:39:31 -0400718// 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 -0500719function loadWebAssemblyModule() {};