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