• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//
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 or in the cpp bindings)
27  Color: function() {},
28  Color4f: function() {},
29  ColorAsInt: function() {},
30  LTRBRect: function() {},
31  XYWHRect: function() {},
32  LTRBiRect: function() {},
33  XYWHiRect: function() {},
34  RRectXY: function() {},
35  /** @return {ImageData} */
36  ImageData: function() {},
37
38  GetWebGLContext: function() {},
39  MakeCanvas: function() {},
40  MakeCanvasSurface: function() {},
41  MakeGrContext: function() {}, // deprecated
42  MakeWebGLContext: function() {},
43  /** @return {CanvasKit.AnimatedImage} */
44  MakeAnimatedImageFromEncoded: function() {},
45  /** @return {CanvasKit.Image} */
46  MakeImage: function() {},
47  /** @return {CanvasKit.Image} */
48  MakeImageFromEncoded: function() {},
49  MakeImageFromCanvasImageSource: function() {},
50  MakeOnScreenGLSurface: function() {},
51  MakeRenderTarget: function() {},
52  MakePicture: function() {},
53  MakeSWCanvasSurface: function() {},
54  MakeManagedAnimation: function() {},
55  MakeVertices: function() {},
56  MakeSurface: function() {},
57  MakeGPUDeviceContext: function() {},
58  MakeGPUCanvasContext: function() {},
59  MakeGPUCanvasSurface: function() {},
60  MakeGPUTextureSurface: function() {},
61  MakeRasterDirectSurface: function() {},
62  MakeWebGLCanvasSurface: function() {},
63  Malloc: function() {},
64  MallocGlyphIDs: function() {},
65  MakeLazyImageFromTextureSource: function() {},
66  Free: function() {},
67  computeTonalColors: function() {},
68  deleteContext: function() {},
69  getColorComponents: function() {},
70  getDecodeCacheLimitBytes: function() {},
71  getDecodeCacheUsageBytes: function() {},
72  multiplyByAlpha: function() {},
73  parseColorString: function() {},
74  setDecodeCacheLimitBytes: function() {},
75  getShadowLocalBounds: function() {},
76  // Defined by emscripten.
77  createContext: function() {},
78
79  // Added by debugger when it extends canvaskit
80  MinVersion: function() {},
81  SkpFilePlayer: function() {},
82
83  // private API (i.e. things declared in the bindings that we use
84  // in the pre-js file)
85  _MakeGrContext: function() {},
86  _MakeImage: function() {},
87  _MakeManagedAnimation: function() {},
88  _MakeOnScreenGLSurface: function() {},
89  _MakePicture: function() {},
90  _MakeRenderTargetII: function() {},
91  _MakeRenderTargetWH: function() {},
92  _computeTonalColors: function() {},
93  _decodeAnimatedImage: function() {},
94  _decodeImage: function() {},
95  _getShadowLocalBounds: function() {},
96  _setTextureCleanup: function() {},
97
98  // The testing object is meant to expose internal functions
99  // for more fine-grained testing, e.g. parseColor
100  _testing: {},
101
102  // Objects and properties on CanvasKit
103
104  Animation: {
105    prototype: {
106      render: function() {},
107      size: function() {},
108    },
109    _render: function() {},
110    _size: function() {},
111  },
112
113  Blender: {
114    Mode: function() {},
115  },
116
117  GrDirectContext: {
118    // public API (from webgl.js)
119    prototype: {
120      getResourceCacheLimitBytes: function () {},
121      getResourceCacheUsageBytes: function () {},
122      releaseResourcesAndAbandonContext: function () {},
123      setResourceCacheLimitBytes: function () {},
124    },
125
126    // private API (from C++ bindings)
127    _getResourceCacheLimitBytes: function() {},
128    _getResourceCacheUsageBytes: function() {},
129    _releaseResourcesAndAbandonContext: function() {},
130    _setResourceCacheLimitBytes: function() {},
131  },
132
133  ManagedAnimation: {
134    prototype: {
135      render: function() {},
136      seek: function() {},
137      seekFrame: function() {},
138      setColor: function() {},
139      setColorSlot: function() {},
140      getColorSlot: function() {},
141      setScalarSlot: function() {},
142      getScalarSlot: function() {},
143      setVec2Slot: function() {},
144      getVec2Slot: function() {},
145      setTextSlot: function() {},
146      getTextSlot: function() {},
147      setImageSlot: function() {},
148      setTransform: function() {},
149      size: function() {},
150
151      attachEditor:          function() {},
152      enableEditor:          function() {},
153      dispatchEditorKey:     function() {},
154      dispatchEditorPointer: function() {},
155      setEditorCursorWeight: function() {},
156    },
157    _render: function() {},
158    _seek: function() {},
159    _seekFrame: function() {},
160    _setTransform: function() {},
161    _getSlotInfo: function() {},
162    _setColorSlot: function() {},
163    _getColorSlot: function() {},
164    _setVec2Slot: function() {},
165    _getVec2Slot: function() {},
166    _setTextSlot: function() {},
167    _size: function() {},
168  },
169
170  Paragraph: {
171    // public API (from C++ bindings)
172    didExceedMaxLines: function() {},
173    getAlphabeticBaseline: function() {},
174    getGlyphPositionAtCoordinate: function() {},
175    getHeight: function() {},
176    getIdeographicBaseline: function() {},
177    getLineMetrics: function() {},
178    getLineMetricsAt: function() {},
179    getLineNumberAt: function() {},
180    getLongestLine: function() {},
181    getMaxIntrinsicWidth: function() {},
182    getMaxWidth: function() {},
183    getMinIntrinsicWidth: function() {},
184    getNumberOfLines: function() {},
185    getWordBoundary: function() {},
186    getShapedLines: function() {},
187    layout: function() {},
188
189    // private API
190    /** @return {Float32Array} */
191    _getClosestGlyphInfoAtCoordinate: function() {},
192    _getGlyphInfoAt: function() {},
193    _getRectsForRange: function() {},
194    _getRectsForPlaceholders: function() {},
195  },
196
197  ParagraphBuilder: {
198    Make: function() {},
199    MakeFromFontProvider: function() {},
200    MakeFromFontCollection: function() {},
201    ShapeText: function() {},
202    RequiresClientICU() {},
203
204    addText: function() {},
205    build: function() {},
206
207    setWordsUtf8: function() {},
208    setWordsUtf16: function() {},
209    setGraphemeBreaksUtf8: function() {},
210    setGraphemeBreaksUtf16: function() {},
211    setLineBreaksUtf8: function() {},
212    setLineBreaksUtf16: function() {},
213
214    getText: function() {},
215    pop: function() {},
216    reset: function() {},
217
218    prototype: {
219      pushStyle: function() {},
220      pushPaintStyle: function() {},
221      addPlaceholder: function() {},
222    },
223
224    // private API
225    _Make: function() {},
226    _MakeFromFontProvider: function() {},
227    _MakeFromFontCollection: function() {},
228    _ShapeText: function() {},
229    _pushStyle: function() {},
230    _pushPaintStyle: function() {},
231    _addPlaceholder: function() {},
232
233    _setWordsUtf8: function() {},
234    _setWordsUtf16: function() {},
235    _setGraphemeBreaksUtf8: function() {},
236    _setGraphemeBreaksUtf16: function() {},
237    _setLineBreaksUtf8: function() {},
238    _setLineBreaksUtf16: function() {},
239  },
240
241  Bidi: {
242    Make: function() {},
243    getBidiRegions: function () {},
244    reorderVisual: function () {},
245    // private API
246    _getBidiRegions: function() {},
247    _reorderVisual: function() {},
248  },
249
250  CodeUnits: {
251    Make: function() {},
252    compute: function() {},
253    // private API
254    _compute: function() {},
255  },
256
257  RuntimeEffect: {
258    // public API (from JS bindings)
259    Make: function() {},
260    MakeForBlender: function() {},
261    getUniform: function() {},
262    getUniformCount: function() {},
263    getUniformFloatCount: function() {},
264    getUniformName: function() {},
265    prototype: {
266      makeShader: function() {},
267      makeShaderWithChildren: function() {},
268      makeBlender: function() {},
269    },
270    // private API (from C++ bindings)
271    _Make: function() {},
272    _MakeForBlender: function() {},
273    _makeShader: function() {},
274    _makeShaderWithChildren: function() {},
275    _makeBlender: function() {},
276  },
277
278  ParagraphStyle: function() {},
279
280  AnimatedImage: {
281    // public API (from C++ bindings)
282    decodeNextFrame: function() {},
283    getFrameCount: function() {},
284    getRepetitionCount: function() {},
285    height: function() {},
286    makeImageAtCurrentFrame: function() {},
287    reset: function() {},
288    width: function() {},
289  },
290
291  Canvas: {
292    // public API (from C++ bindings)
293    clipPath: function() {},
294    getSaveCount: function() {},
295    makeSurface: function() {},
296    restore: function() {},
297    restoreToCount: function() {},
298    rotate: function() {},
299    save: function() {},
300    saveLayerPaint: function() {},
301    scale: function() {},
302    skew: function() {},
303    translate: function() {},
304
305    prototype: {
306      clear: function() {},
307      clipRRect: function() {},
308      clipRect: function() {},
309      concat: function() {},
310      drawArc: function() {},
311      drawAtlas: function() {},
312      drawCircle: function() {},
313      drawColor: function() {},
314      drawColorComponents: function() {},
315      drawColorInt: function() {},
316      drawDRRect: function() {},
317      drawGlyphs: function() {},
318      drawImage: function() {},
319      drawImageCubic: function() {},
320      drawImageNine: function() {},
321      drawImageOptions: function() {},
322      drawImageRect: function() {},
323      drawImageRectCubic: function() {},
324      drawImageRectOptions: function() {},
325      drawLine: function() {},
326      drawOval: function() {},
327      drawPaint: function() {},
328      drawParagraph: function() {},
329      drawPatch: function() {},
330      drawPath: function() {},
331      drawPicture: function() {},
332      drawPoints: function() {},
333      drawRRect:  function() {},
334      drawRect4f: function() {},
335      drawRect: function() {},
336      drawShadow: function() {},
337      drawText: function() {},
338      drawTextBlob: function() {},
339      drawVertices: function() {},
340      getDeviceClipBounds: function() {},
341      quickReject: function() {},
342      getLocalToDevice: function() {},
343      getTotalMatrix: function() {},
344      readPixels: function() {},
345      saveLayer: function() {},
346      writePixels : function() {},
347    },
348
349    // private API
350    _clear: function() {},
351    _clipRRect: function() {},
352    _clipRect: function() {},
353    _concat: function() {},
354    _drawArc: function() {},
355    _drawAtlasCubic: function() {},
356    _drawAtlasOptions: function() {},
357    _drawCircle: function() {},
358    _drawColor: function() {},
359    _drawColorInt: function() {},
360    _drawDRRect:  function() {},
361    _drawGlyphs: function() {},
362    _drawImage: function() {},
363    _drawImageCubic: function() {},
364    _drawImageNine: function() {},
365    _drawImageOptions: function() {},
366    _drawImageRect: function() {},
367    _drawImageRectCubic: function() {},
368    _drawImageRectOptions: function() {},
369    _drawLine: function() {},
370    _drawOval: function() {},
371    _drawPaint: function() {},
372    _drawParagraph: function() {},
373    _drawPatch: function() {},
374    _drawPath: function() {},
375    _drawPicture: function() {},
376    _drawPoints: function() {},
377    _drawRRect:  function() {},
378    _drawRect4f: function() {},
379    _drawRect: function() {},
380    _drawShadow: function() {},
381    _drawSimpleText: function() {},
382    _drawTextBlob: function() {},
383    _drawVertices: function() {},
384    _getDeviceClipBounds: function() {},
385    _quickReject: function() {},
386    _getLocalToDevice: function() {},
387    _getTotalMatrix: function() {},
388    _readPixels: function() {},
389    _saveLayer: function() {},
390    _writePixels: function() {},
391    delete: function() {},
392  },
393
394  ColorFilter: {
395    // public API (from C++ bindings and JS interface)
396    MakeBlend: function() {},
397    MakeCompose: function() {},
398    MakeLerp: function() {},
399    MakeLinearToSRGBGamma: function() {},
400    MakeMatrix: function() {},
401    MakeSRGBToLinearGamma: function() {},
402    // private API (from C++ bindings)
403    _MakeBlend: function() {},
404    _makeMatrix: function() {},
405  },
406
407  ColorMatrix: {
408    concat: function() {},
409    identity: function() {},
410    postTranslate: function() {},
411    rotated: function() {},
412    scaled: function() {},
413  },
414
415  ColorSpace: {
416    Equals: function() {},
417    SRGB: {},
418    DISPLAY_P3: {},
419    ADOBE_RGB: {},
420    // private API (from C++ bindings)
421    _MakeSRGB: function() {},
422    _MakeDisplayP3: function() {},
423    _MakeAdobeRGB: function() {},
424  },
425
426  ContourMeasureIter: {
427    next: function() {},
428  },
429
430  ContourMeasure: {
431    getSegment: function() {},
432    isClosed: function() {},
433    length: function() {},
434    prototype: {
435      getPosTan: function() {},
436    },
437    _getPosTan: function() {},
438  },
439
440  Font: {
441    // public API (from C++ bindings)
442    getMetrics: function() {},
443    getScaleX: function() {},
444    getSize: function() {},
445    getSkewX: function() {},
446    isEmbolden: function() {},
447    getTypeface: function() {},
448    setHinting: function() {},
449    setLinearMetrics: function() {},
450    setScaleX: function() {},
451    setSize: function() {},
452    setSkewX: function() {},
453    setEmbolden: function() {},
454    setSubpixel: function() {},
455    setTypeface: function() {},
456
457    prototype: {
458      getGlyphBounds: function() {},
459      getGlyphIDs: function() {},
460      getGlyphWidths: function() {},
461      getGlyphIntercepts: function() {},
462    },
463
464    // private API (from C++ bindings)
465    _getGlyphIDs: function() {},
466    _getGlyphIntercepts: function() {},
467    _getGlyphWidthBounds: function() {},
468  },
469
470  FontMgr: {
471    // public API (from C++ and JS bindings)
472    FromData: function() {},
473    countFamilies: function() {},
474    getFamilyName: function() {},
475    matchFamilyStyle: function() {},
476
477    // private API
478    _makeTypefaceFromData: function() {},
479    _fromData: function() {},
480  },
481
482  TypefaceFontProvider: {
483    // public API (from C++ and JS bindings)
484    Make: function() {},
485    registerFont: function() {},
486
487    // private API
488    _registerFont: function() {},
489  },
490
491  FontCollection: {
492    // public API (from C++ and JS bindings)
493    Make: function() {},
494    setDefaultFontManager: function() {},
495    enableFontFallback: function() {},
496  },
497
498  Image: {
499    // public API (from C++ bindings)
500    encodeToBytes: function() {},
501    getColorSpace: function() {},
502    getImageInfo: function() {},
503    makeCopyWithDefaultMipmaps: function() {},
504    height: function() {},
505    width: function() {},
506
507    prototype: {
508      makeShaderCubic: function() {},
509      makeShaderOptions: function() {},
510    },
511    // private API
512    _encodeToBytes: function() {},
513    _makeFromGenerator: function() {},
514    _makeShaderCubic: function() {},
515    _makeShaderOptions: function() {},
516  },
517
518  ImageFilter: {
519    MakeBlend: function() {},
520    MakeBlur: function() {},
521    MakeColorFilter: function() {},
522    MakeCompose: function() {},
523    MakeDilate: function() {},
524    MakeDisplacementMap: function() {},
525    MakeDropShadow: function() {},
526    MakeDropShadowOnly: function() {},
527    MakeErode: function() {},
528    MakeImage: function() {},
529    MakeMatrixTransform: function() {},
530    MakeOffset: function() {},
531
532    prototype: {
533      getOutputBounds: function() {},
534    },
535
536    // private API
537    _getOutputBounds: function() {},
538    _MakeDropShadow: function() {},
539    _MakeDropShadowOnly: function() {},
540    _MakeImageCubic: function() {},
541    _MakeImageOptions: function() {},
542    _MakeMatrixTransformCubic: function() {},
543    _MakeMatrixTransformOptions: function() {},
544  },
545
546  // These are defined in interface.js
547  M44: {
548    identity: function() {},
549    invert: function() {},
550    mustInvert: function() {},
551    multiply: function() {},
552    rotatedUnitSinCos: function() {},
553    rotated: function() {},
554    scaled: function() {},
555    translated: function() {},
556    lookat: function() {},
557    perspective: function() {},
558    rc: function() {},
559    transpose: function() {},
560    setupCamera: function() {},
561  },
562
563  Matrix: {
564    identity: function() {},
565    invert: function() {},
566    mapPoints: function() {},
567    multiply: function() {},
568    rotated: function() {},
569    scaled: function() {},
570    skewed: function() {},
571    translated: function() {},
572  },
573
574  MaskFilter: {
575    MakeBlur: function() {},
576  },
577
578  MipmapMode: {
579    None: {},
580    Nearest: {},
581    Linear: {},
582  },
583
584  Paint: {
585    // public API (from C++ bindings)
586    /** @return {CanvasKit.Paint} */
587    copy: function() {},
588    getStrokeCap: function() {},
589    getStrokeJoin: function() {},
590    getStrokeMiter: function() {},
591    getStrokeWidth: function() {},
592    setAntiAlias: function() {},
593    setBlendMode: function() {},
594    setBlender: function() {},
595    setColorInt: function() {},
596    setDither: function() {},
597    setImageFilter: function() {},
598    setMaskFilter: function() {},
599    setPathEffect: function() {},
600    setShader: function() {},
601    setStrokeCap: function() {},
602    setStrokeJoin: function() {},
603    setStrokeMiter: function() {},
604    setStrokeWidth: function() {},
605    setStyle: function() {},
606
607    prototype: {
608      getColor: function() {},
609      setColor: function() {},
610      setColorComponents: function() {},
611      setColorInt: function() {},
612    },
613
614    // Private API
615    delete: function() {},
616    _getColor: function() {},
617    _setColor: function() {},
618  },
619
620  PathEffect: {
621    MakeCorner: function() {},
622    MakeDash: function() {},
623    MakeDiscrete: function() {},
624    MakePath1D: function() {},
625    MakeLine2D: function() {},
626    MakePath2D: function() {},
627
628    // Private C++ API
629    _MakeDash: function() {},
630    _MakeLine2D: function() {},
631    _MakePath2D: function() {},
632  },
633
634  Path: {
635    // public API (from C++ and JS bindings)
636    CanInterpolate: function() {},
637    MakeFromCmds: function() {},
638    MakeFromPathInterpolation: function() {},
639    MakeFromSVGString: function() {},
640    MakeFromOp: function() {},
641    MakeFromVerbsPointsWeights: function() {},
642    contains: function() {},
643    /** @return {CanvasKit.Path} */
644    copy: function() {},
645    countPoints: function() {},
646    equals: function() {},
647    getFillType: function() {},
648    isEmpty: function() {},
649    isVolatile: function() {},
650    makeAsWinding: function() {},
651    reset: function() {},
652    rewind: function() {},
653    setFillType: function() {},
654    setIsVolatile: function() {},
655    toCmds: function() {},
656    toSVGString: function() {},
657
658    prototype: {
659      addArc: function() {},
660      addCircle: function() {},
661      addOval: function() {},
662      addPath: function() {},
663      addPoly: function() {},
664      addRect: function() {},
665      addRRect: function() {},
666      addVerbsPointsWeights: function() {},
667      arc: function() {},
668      arcToOval: function() {},
669      arcToRotated: function() {},
670      arcToTangent: function() {},
671      close: function() {},
672      conicTo: function() {},
673      computeTightBounds: function() {},
674      cubicTo: function() {},
675      dash: function() {},
676      getBounds: function() {},
677      getPoint: function() {},
678      lineTo: function() {},
679      moveTo: function() {},
680      offset: function() {},
681      op: function() {},
682      quadTo: function() {},
683      rArcTo: function() {},
684      rConicTo: function() {},
685      rCubicTo: function() {},
686      rLineTo: function() {},
687      rMoveTo: function() {},
688      rQuadTo: function() {},
689      simplify: function() {},
690      stroke: function() {},
691      transform: function() {},
692      trim: function() {},
693    },
694
695    // private API
696    _MakeFromCmds: function() {},
697    _MakeFromVerbsPointsWeights: function() {},
698    _addArc: function() {},
699    _addCircle: function() {},
700    _addOval: function() {},
701    _addPath: function() {},
702    _addPoly: function() {},
703    _addRect: function() {},
704    _addRRect: function() {},
705    _addVerbsPointsWeights: function() {},
706    _arcToOval: function() {},
707    _arcToRotated: function() {},
708    _arcToTangent: function() {},
709    _close: function() {},
710    _conicTo: function() {},
711    _computeTightBounds: function() {},
712    _cubicTo: function() {},
713    _dash: function() {},
714    _getBounds: function() {},
715    _getPoint: function() {},
716    _lineTo: function() {},
717    _moveTo: function() {},
718    _op: function() {},
719    _quadTo: function() {},
720    _rArcTo: function() {},
721    _rConicTo: function() {},
722    _rCubicTo: function() {},
723    _rect: function() {},
724    _rLineTo: function() {},
725    _rMoveTo: function() {},
726    _rQuadTo: function() {},
727    _simplify: function() {},
728    _stroke: function() {},
729    _transform: function() {},
730    _trim: function() {},
731    delete: function() {},
732    dump: function() {},
733    dumpHex: function() {},
734  },
735
736  Picture: {
737    serialize: function() {},
738    approximateByteSize: function() {},
739    prototype: {
740      makeShader: function() {},
741      cullRect: function () {},
742    },
743    _makeShader: function() {},
744    _cullRect: function () {},
745  },
746
747  PictureRecorder: {
748    finishRecordingAsPicture: function() {},
749    prototype: {
750      beginRecording: function() {},
751    },
752    _beginRecording: function() {},
753  },
754
755  Shader: {
756    // Deprecated names
757    Blend: function() {},
758    Color: function() {},
759    Lerp: function() {},
760    // public API (from JS / C++ bindings)
761    MakeBlend: function() {},
762    MakeColor: function() {},
763    MakeFractalNoise: function() {},
764    MakeLinearGradient: function() {},
765    MakeRadialGradient: function() {},
766    MakeSweepGradient: function() {},
767    MakeTurbulence: function() {},
768    MakeTwoPointConicalGradient: function() {},
769
770    // private API (from C++ bindings)
771    _MakeColor: function() {},
772    _MakeLinearGradient: function() {},
773    _MakeRadialGradient: function() {},
774    _MakeSweepGradient: function() {},
775    _MakeTwoPointConicalGradient: function() {},
776  },
777
778  Surface: {
779    // public API (from C++ bindings)
780    imageInfo: function() {},
781
782    sampleCnt: function() {},
783    reportBackendTypeIsGPU: function() {},
784
785    prototype: {
786      getCanvas: function() {},
787      makeImageFromTexture: function() {},
788      makeImageFromTextureSource: function() {},
789      /** @return {CanvasKit.Image} */
790      makeImageSnapshot: function() {},
791      makeSurface: function() {},
792      updateTextureFromSource: function() {},
793    },
794
795    // private API
796    _flush: function() {},
797    _getCanvas: function() {},
798    _makeImageFromTexture: function() {},
799    _makeImageSnapshot: function() {},
800    _makeSurface: function() {},
801    _makeRasterDirect: function() {},
802    _resetContext: function() {},
803    delete: function() {},
804  },
805
806  TextBlob: {
807    // public API (both C++ and JS bindings)
808    MakeFromGlyphs: function() {},
809    MakeFromRSXform: function() {},
810    MakeFromRSXformGlyphs: function() {},
811    MakeFromText: function() {},
812    MakeOnPath: function() {},
813    // private API (from C++ bindings)
814    _MakeFromGlyphs: function() {},
815    _MakeFromRSXform: function() {},
816    _MakeFromRSXformGlyphs: function() {},
817    _MakeFromText: function() {},
818  },
819
820  Typeface: {
821    GetDefault: function() {},
822    MakeTypefaceFromData: function() {},
823    prototype: {
824      getGlyphIDs: function() {},
825      getFamilyName: function() {},
826    },
827    _MakeTypefaceFromData: function() {},
828    _getGlyphIDs: function() {},
829  },
830
831  // These are defined in interface.js
832  Vector: {
833    add: function() {},
834    sub: function() {},
835    dot: function() {},
836    cross: function() {},
837    normalize: function() {},
838    mulScalar: function() {},
839    length: function() {},
840    lengthSquared: function() {},
841    dist: function() {},
842  },
843
844  Vertices: {
845    // public API (from C++ bindings)
846    uniqueID: function() {},
847
848    prototype: {
849      bounds: function() {},
850    },
851    // private API (from C++ bindings)
852
853    _bounds: function() {},
854  },
855
856  _VerticesBuilder: {
857    colors: function() {},
858    detach: function() {},
859    indices: function() {},
860    positions: function() {},
861    texCoords: function() {},
862  },
863
864  TextStyle: function() {},
865
866  SkpDebugPlayer: {
867    // public API (from C++ bindings)
868    loadSkp: function() {},
869  },
870
871  // Constants and Enums
872  gpu: {},
873  skottie: {},
874
875  TRANSPARENT: {},
876  BLACK: {},
877  WHITE: {},
878  RED: {},
879  GREEN: {},
880  BLUE: {},
881  YELLOW: {},
882  CYAN: {},
883  MAGENTA: {},
884
885  MOVE_VERB: {},
886  LINE_VERB: {},
887  QUAD_VERB: {},
888  CONIC_VERB: {},
889  CUBIC_VERB: {},
890  CLOSE_VERB: {},
891
892  NoDecoration: {},
893  UnderlineDecoration: {},
894  OverlineDecoration: {},
895  LineThroughDecoration: {},
896
897  SaveLayerInitWithPrevious: {},
898  SaveLayerF16ColorType: {},
899
900  Affinity: {
901    Upstream: {},
902    Downstream: {},
903  },
904
905  AlphaType: {
906    Opaque: {},
907    Premul: {},
908    Unpremul: {},
909  },
910
911  BlendMode: {
912    Clear: {},
913    Src: {},
914    Dst: {},
915    SrcOver: {},
916    DstOver: {},
917    SrcIn: {},
918    DstIn: {},
919    SrcOut: {},
920    DstOut: {},
921    SrcATop: {},
922    DstATop: {},
923    Xor: {},
924    Plus: {},
925    Modulate: {},
926    Screen: {},
927    Overlay: {},
928    Darken: {},
929    Lighten: {},
930    ColorDodge: {},
931    ColorBurn: {},
932    HardLight: {},
933    SoftLight: {},
934    Difference: {},
935    Exclusion: {},
936    Multiply: {},
937    Hue: {},
938    Saturation: {},
939    Color: {},
940    Luminosity: {},
941  },
942
943  BlurStyle: {
944    Normal: {},
945    Solid: {},
946    Outer: {},
947    Inner: {},
948  },
949
950  ClipOp: {
951    Difference: {},
952    Intersect: {},
953  },
954
955  ColorType: {
956    Alpha_8: {},
957    RGB_565: {},
958    ARGB_4444: {},
959    RGBA_8888: {},
960    RGB_888x: {},
961    BGRA_8888: {},
962    RGBA_1010102: {},
963    RGB_101010x: {},
964    Gray_8: {},
965    RGBA_F16: {},
966    RGBA_F32: {},
967  },
968
969  FillType: {
970    Winding: {},
971    EvenOdd: {},
972  },
973
974  FilterMode: {
975    Linear: {},
976    Nearest: {},
977  },
978
979  FontSlant: {
980    Upright: {},
981    Italic: {},
982    Oblique: {},
983  },
984
985  FontHinting: {
986    None: {},
987    Slight: {},
988    Normal: {},
989    Full: {},
990  },
991
992  FontWeight: {
993    Invisible: {},
994    Thin: {},
995    ExtraLight: {},
996    Light: {},
997    Normal: {},
998    Medium: {},
999    SemiBold: {},
1000    Bold: {},
1001    ExtraBold: {},
1002    Black: {},
1003    ExtraBlack: {},
1004  },
1005
1006  FontWidth: {
1007    UltraCondensed: {},
1008    ExtraCondensed: {},
1009    Condensed: {},
1010    SemiCondensed: {},
1011    Normal: {},
1012    SemiExpanded: {},
1013    Expanded: {},
1014    ExtraExpanded: {},
1015    UltraExpanded: {},
1016  },
1017
1018  GlyphRunFlags: {
1019    IsWhiteSpace: {},
1020  },
1021
1022  ImageFormat: {
1023    PNG: {},
1024    JPEG: {},
1025  },
1026
1027  PaintStyle: {
1028    Fill: {},
1029    Stroke: {},
1030  },
1031
1032  PathOp: {
1033    Difference: {},
1034    Intersect: {},
1035    Union: {},
1036    XOR: {},
1037    ReverseDifference: {},
1038  },
1039
1040  PointMode: {
1041    Points: {},
1042    Lines: {},
1043    Polygon: {},
1044  },
1045
1046  RectHeightStyle: {
1047    Tight: {},
1048    Max: {},
1049    IncludeLineSpacingMiddle: {},
1050    IncludeLineSpacingTop: {},
1051    IncludeLineSpacingBottom: {},
1052    Strut: {},
1053  },
1054
1055  RectWidthStyle: {
1056    Tight: {},
1057    Max: {},
1058  },
1059
1060  StrokeCap: {
1061    Butt: {},
1062    Round: {},
1063    Square: {},
1064  },
1065
1066  StrokeJoin: {
1067    Miter: {},
1068    Round: {},
1069    Bevel: {},
1070  },
1071
1072  TextAlign: {
1073    Left: {},
1074    Right: {},
1075    Center: {},
1076    Justify: {},
1077    Start: {},
1078    End: {},
1079  },
1080
1081  TextDirection: {
1082    LTR: {},
1083    RTL: {},
1084  },
1085
1086  LineBreakType : {
1087    SoftLineBreak: {},
1088    HardLineBreak: {},
1089  },
1090
1091  TextHeightBehavior: {
1092    All: {},
1093    DisableFirstAscent: {},
1094    DisableLastDescent: {},
1095    DisableAll: {},
1096  },
1097
1098  DecorationStyle: {
1099    Solid: {},
1100    Double: {},
1101    Dotted: {},
1102    Dashed: {},
1103    Wavy: {},
1104  },
1105
1106  PlaceholderAlignment: {
1107    Baseline: {},
1108    AboveBaseline: {},
1109    BelowBaseline: {},
1110    Top: {},
1111    Bottom: {},
1112    Middle: {},
1113  },
1114
1115  TextBaseline: {
1116    Alphabetic: {},
1117    Ideographic: {},
1118  },
1119
1120  TileMode: {
1121    Clamp: {},
1122    Repeat: {},
1123    Mirror: {},
1124    Decal: {},
1125  },
1126
1127  VertexMode: {
1128    Triangles: {},
1129    TrianglesStrip: {},
1130    TriangleFan: {},
1131  },
1132
1133  InputState: {
1134    Up: {},
1135    Down: {},
1136    Move: {},
1137    Right: {},
1138    Left: {},
1139  },
1140
1141  ModifierKey: {
1142    None: {},
1143    Shift: {},
1144    Control: {},
1145    Option: {},
1146    Command: {},
1147    FirstPass: {},
1148  },
1149
1150  CodeUnitFlags: {
1151    NoCodeUnitFlag: {},
1152    Whitespace: {},
1153    Space: {},
1154    Control: {},
1155    Ideographic: {},
1156  },
1157
1158  // Things Enscriptem adds for us
1159
1160  /**
1161   * @type {Float32Array}
1162   */
1163  HEAPF32: {},
1164  /**
1165   * @type {Float64Array}
1166   */
1167  HEAPF64: {},
1168  /**
1169   * @type {Uint8Array}
1170   */
1171  HEAPU8: {},
1172  /**
1173   * @type {Uint16Array}
1174   */
1175  HEAPU16: {},
1176  /**
1177   * @type {Uint32Array}
1178   */
1179  HEAPU32: {},
1180  /**
1181   * @type {Int8Array}
1182   */
1183  HEAP8: {},
1184  /**
1185   * @type {Int16Array}
1186   */
1187  HEAP16: {},
1188  /**
1189   * @type {Int32Array}
1190   */
1191  HEAP32: {},
1192
1193  _malloc: function() {},
1194  _free: function() {},
1195  onRuntimeInitialized: function() {},
1196};
1197
1198// Public API things that are newly declared in the JS should go here.
1199// It's not enough to declare them above, because closure can still erase them
1200// unless they go on the prototype.
1201CanvasKit.Paragraph.prototype.getRectsForRange = function() {};
1202CanvasKit.Paragraph.prototype.getRectsForPlaceholders = function() {};
1203CanvasKit.Paragraph.prototype.getClosestGlyphInfoAtCoordinate = function() {};
1204CanvasKit.Paragraph.prototype.getGlyphInfoAt = function() {};
1205
1206CanvasKit.Surface.prototype.dispose = function() {};
1207CanvasKit.Surface.prototype.flush = function() {};
1208CanvasKit.Surface.prototype.requestAnimationFrame = function() {};
1209CanvasKit.Surface.prototype.drawOnce = function() {};
1210
1211CanvasKit.RuntimeEffect.prototype.makeShader = function() {};
1212CanvasKit.RuntimeEffect.prototype.makeShaderWithChildren = function() {};
1213
1214// Define StrokeOpts object
1215var StrokeOpts = {};
1216StrokeOpts.prototype.width;
1217StrokeOpts.prototype.miter_limit;
1218StrokeOpts.prototype.cap;
1219StrokeOpts.prototype.join;
1220StrokeOpts.prototype.precision;
1221
1222// Define everything created in the canvas2d spec here
1223var HTMLCanvas = {};
1224HTMLCanvas.prototype.decodeImage = function() {};
1225HTMLCanvas.prototype.dispose = function() {};
1226HTMLCanvas.prototype.getContext = function() {};
1227HTMLCanvas.prototype.loadFont = function() {};
1228HTMLCanvas.prototype.makePath2D = function() {};
1229HTMLCanvas.prototype.toDataURL = function() {};
1230
1231var ImageBitmapRenderingContext = {};
1232ImageBitmapRenderingContext.prototype.transferFromImageBitmap = function() {};
1233
1234var CanvasRenderingContext2D = {};
1235CanvasRenderingContext2D.prototype.addHitRegion = function() {};
1236CanvasRenderingContext2D.prototype.arc = function() {};
1237CanvasRenderingContext2D.prototype.arcTo = function() {};
1238CanvasRenderingContext2D.prototype.beginPath = function() {};
1239CanvasRenderingContext2D.prototype.bezierCurveTo = function() {};
1240CanvasRenderingContext2D.prototype.clearHitRegions = function() {};
1241CanvasRenderingContext2D.prototype.clearRect = function() {};
1242CanvasRenderingContext2D.prototype.clip = function() {};
1243CanvasRenderingContext2D.prototype.closePath = function() {};
1244CanvasRenderingContext2D.prototype.createImageData = function() {};
1245CanvasRenderingContext2D.prototype.createLinearGradient = function() {};
1246CanvasRenderingContext2D.prototype.createPattern = function() {};
1247CanvasRenderingContext2D.prototype.createRadialGradient = function() {};
1248CanvasRenderingContext2D.prototype.drawFocusIfNeeded = function() {};
1249CanvasRenderingContext2D.prototype.drawImage = function() {};
1250CanvasRenderingContext2D.prototype.ellipse = function() {};
1251CanvasRenderingContext2D.prototype.fill = function() {};
1252CanvasRenderingContext2D.prototype.fillRect = function() {};
1253CanvasRenderingContext2D.prototype.fillText = function() {};
1254CanvasRenderingContext2D.prototype.getImageData = function() {};
1255CanvasRenderingContext2D.prototype.getLineDash = function() {};
1256CanvasRenderingContext2D.prototype.isPointInPath = function() {};
1257CanvasRenderingContext2D.prototype.isPointInStroke = function() {};
1258CanvasRenderingContext2D.prototype.lineTo = function() {};
1259CanvasRenderingContext2D.prototype.measureText = function() {};
1260CanvasRenderingContext2D.prototype.moveTo = function() {};
1261CanvasRenderingContext2D.prototype.putImageData = function() {};
1262CanvasRenderingContext2D.prototype.quadraticCurveTo = function() {};
1263CanvasRenderingContext2D.prototype.rect = function() {};
1264CanvasRenderingContext2D.prototype.removeHitRegion = function() {};
1265CanvasRenderingContext2D.prototype.resetTransform = function() {};
1266CanvasRenderingContext2D.prototype.restore = function() {};
1267CanvasRenderingContext2D.prototype.rotate = function() {};
1268CanvasRenderingContext2D.prototype.save = function() {};
1269CanvasRenderingContext2D.prototype.scale = function() {};
1270CanvasRenderingContext2D.prototype.scrollPathIntoView = function() {};
1271CanvasRenderingContext2D.prototype.setLineDash = function() {};
1272CanvasRenderingContext2D.prototype.setTransform = function() {};
1273CanvasRenderingContext2D.prototype.stroke = function() {};
1274CanvasRenderingContext2D.prototype.strokeRect = function() {};
1275CanvasRenderingContext2D.prototype.strokeText = function() {};
1276CanvasRenderingContext2D.prototype.transform = function() {};
1277CanvasRenderingContext2D.prototype.translate = function() {};
1278
1279var Path2D = {};
1280Path2D.prototype.addPath = function() {};
1281Path2D.prototype.arc = function() {};
1282Path2D.prototype.arcTo = function() {};
1283Path2D.prototype.bezierCurveTo = function() {};
1284Path2D.prototype.closePath = function() {};
1285Path2D.prototype.ellipse = function() {};
1286Path2D.prototype.lineTo = function() {};
1287Path2D.prototype.moveTo = function() {};
1288Path2D.prototype.quadraticCurveTo = function() {};
1289Path2D.prototype.rect = function() {};
1290
1291var LinearCanvasGradient = {};
1292LinearCanvasGradient.prototype.addColorStop = function() {};
1293var RadialCanvasGradient = {};
1294RadialCanvasGradient.prototype.addColorStop = function() {};
1295var CanvasPattern = {};
1296CanvasPattern.prototype.setTransform = function() {};
1297
1298var ImageData = {
1299  /**
1300   * @type {Uint8ClampedArray}
1301   */
1302  data: {},
1303  height: {},
1304  width: {},
1305};
1306
1307var DOMMatrix = {
1308  a: {},
1309  b: {},
1310  c: {},
1311  d: {},
1312  e: {},
1313  f: {},
1314};
1315
1316// Not sure why this is needed - might be a bug in emsdk that this isn't properly declared.
1317function loadWebAssemblyModule() {};
1318
1319// This is a part of emscripten's webgl glue code. Preserving this attribute is necessary
1320// to override it in the puppeteer tests
1321var LibraryEGL = {
1322  contextAttributes: {
1323    majorVersion: {}
1324  }
1325}
1326