Kevin Lubick | 217056c | 2018-09-20 17:39:31 -0400 | [diff] [blame] | 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 | |
| 25 | var CanvasKit = { |
| 26 | // public API (i.e. things we declare in the pre-js file) |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 27 | Color: function() {}, |
| 28 | /** @return {CanvasKit.SkRect} */ |
| 29 | LTRBRect: function() {}, |
Kevin Lubick | 0a1293c | 2018-12-03 12:31:04 -0500 | [diff] [blame^] | 30 | /** @return {CanvasKit.SkRect} */ |
| 31 | XYWHRect: function() {}, |
Kevin Lubick | 61ef7b2 | 2018-11-27 13:26:59 -0500 | [diff] [blame] | 32 | MakeBlurMaskFilter: function() {}, |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 33 | MakeCanvas: function() {}, |
| 34 | MakeCanvasSurface: function() {}, |
Kevin Lubick | b5ae3b5 | 2018-11-03 07:51:19 -0400 | [diff] [blame] | 35 | MakeImageShader: function() {}, |
Kevin Lubick | 0a1293c | 2018-12-03 12:31:04 -0500 | [diff] [blame^] | 36 | /** @return {CanvasKit.SkImage} */ |
| 37 | MakeImageFromEncoded: function() {}, |
Kevin Lubick | eb2f6b0 | 2018-11-29 15:07:02 -0500 | [diff] [blame] | 38 | /** @return {LinearCanvasGradient} */ |
Kevin Lubick | b5ae3b5 | 2018-11-03 07:51:19 -0400 | [diff] [blame] | 39 | MakeLinearGradientShader: function() {}, |
Kevin Lubick | 134be1d | 2018-10-30 15:05:04 -0400 | [diff] [blame] | 40 | MakeNimaActor: function() {}, |
Kevin Lubick | 61ef7b2 | 2018-11-27 13:26:59 -0500 | [diff] [blame] | 41 | MakeRadialGradientShader: function() {}, |
| 42 | MakeSWCanvasSurface: function() {}, |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 43 | MakeSkDashPathEffect: function() {}, |
Kevin Lubick | b5ae3b5 | 2018-11-03 07:51:19 -0400 | [diff] [blame] | 44 | MakeSkVertices: function() {}, |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 45 | MakeSurface: function() {}, |
Kevin Lubick | eb2f6b0 | 2018-11-29 15:07:02 -0500 | [diff] [blame] | 46 | /** @return {RadialCanvasGradient} */ |
| 47 | MakeTwoPointConicalGradientShader: function() {}, |
Kevin Lubick | 61ef7b2 | 2018-11-27 13:26:59 -0500 | [diff] [blame] | 48 | MakeWebGLCanvasSurface: function() {}, |
Kevin Lubick | 217056c | 2018-09-20 17:39:31 -0400 | [diff] [blame] | 49 | currentContext: function() {}, |
Kevin Lubick | 61ef7b2 | 2018-11-27 13:26:59 -0500 | [diff] [blame] | 50 | getColorComponents: function() {}, |
Kevin Lubick | 12c0e50 | 2018-11-28 12:51:56 -0500 | [diff] [blame] | 51 | getSkDataBytes: function() {}, |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 52 | initFonts: function() {}, |
Kevin Lubick | 12c0e50 | 2018-11-28 12:51:56 -0500 | [diff] [blame] | 53 | multiplyByAlpha: function() {}, |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 54 | setCurrentContext: function() {}, |
Kevin Lubick | 217056c | 2018-09-20 17:39:31 -0400 | [diff] [blame] | 55 | |
| 56 | // private API (i.e. things declared in the bindings that we use |
| 57 | // in the pre-js file) |
Kevin Lubick | b5ae3b5 | 2018-11-03 07:51:19 -0400 | [diff] [blame] | 58 | _MakeImageShader: function() {}, |
| 59 | _MakeLinearGradientShader: function() {}, |
Kevin Lubick | 134be1d | 2018-10-30 15:05:04 -0400 | [diff] [blame] | 60 | _MakeNimaActor: function() {}, |
Kevin Lubick | b5ae3b5 | 2018-11-03 07:51:19 -0400 | [diff] [blame] | 61 | _MakeRadialGradientShader: function() {}, |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 62 | _MakeSkDashPathEffect: function() {}, |
Kevin Lubick | b5ae3b5 | 2018-11-03 07:51:19 -0400 | [diff] [blame] | 63 | _MakeSkVertices: function() {}, |
Kevin Lubick | eb2f6b0 | 2018-11-29 15:07:02 -0500 | [diff] [blame] | 64 | _MakeTwoPointConicalGradientShader: function() {}, |
Kevin Lubick | 0a1293c | 2018-12-03 12:31:04 -0500 | [diff] [blame^] | 65 | _decodeImage: function() {}, |
Kevin Lubick | ea905ec | 2018-11-30 14:05:58 -0500 | [diff] [blame] | 66 | _getRasterDirectSurface: function() {}, |
Kevin Lubick | 134be1d | 2018-10-30 15:05:04 -0400 | [diff] [blame] | 67 | _getRasterN32PremulSurface: function() {}, |
| 68 | _getWebGLSurface: function() {}, |
Kevin Lubick | 217056c | 2018-09-20 17:39:31 -0400 | [diff] [blame] | 69 | |
Kevin Lubick | 1a05fce | 2018-11-20 12:51:16 -0500 | [diff] [blame] | 70 | // The testing object is meant to expose internal functions |
| 71 | // for more fine-grained testing, e.g. parseColor |
| 72 | _testing: {}, |
| 73 | |
Kevin Lubick | 217056c | 2018-09-20 17:39:31 -0400 | [diff] [blame] | 74 | // Objects and properties on CanvasKit |
| 75 | |
Kevin Lubick | 134be1d | 2018-10-30 15:05:04 -0400 | [diff] [blame] | 76 | NimaActor: { |
| 77 | // public API (from C++ bindings) |
| 78 | duration: function() {}, |
| 79 | getAnimationNames: function() {}, |
| 80 | render: function() {}, |
| 81 | seek: function() {}, |
| 82 | setAnimationByIndex: function() {}, |
| 83 | setAnimationByName: function() {}, |
| 84 | |
| 85 | // private API |
| 86 | }, |
| 87 | |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 88 | SkCanvas: { |
| 89 | // public API (from C++ bindings) |
| 90 | clear: function() {}, |
Kevin Lubick | eb2f6b0 | 2018-11-29 15:07:02 -0500 | [diff] [blame] | 91 | clipPath: function() {}, |
Kevin Lubick | 0a1293c | 2018-12-03 12:31:04 -0500 | [diff] [blame^] | 92 | drawImage: function() {}, |
| 93 | drawImageRect: function() {}, |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 94 | drawPaint: function() {}, |
| 95 | drawPath: function() {}, |
Kevin Lubick | 12c0e50 | 2018-11-28 12:51:56 -0500 | [diff] [blame] | 96 | drawRect: function() {}, |
Kevin Lubick | 61ef7b2 | 2018-11-27 13:26:59 -0500 | [diff] [blame] | 97 | drawShadow: function() {}, |
Kevin Lubick | 12c0e50 | 2018-11-28 12:51:56 -0500 | [diff] [blame] | 98 | drawText: function() {}, |
| 99 | drawVertices: function() {}, |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 100 | flush: function() {}, |
Kevin Lubick | eb2f6b0 | 2018-11-29 15:07:02 -0500 | [diff] [blame] | 101 | restore: function() {}, |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 102 | rotate: function() {}, |
| 103 | save: function() {}, |
| 104 | scale: function() {}, |
| 105 | setMatrix: function() {}, |
| 106 | skew: function() {}, |
| 107 | translate: function() {}, |
| 108 | |
| 109 | // private API |
| 110 | delete: function() {}, |
| 111 | }, |
| 112 | |
| 113 | SkImage: { |
Kevin Lubick | 0a1293c | 2018-12-03 12:31:04 -0500 | [diff] [blame^] | 114 | // public API (from C++ bindings) |
| 115 | height: function() {}, |
| 116 | width: function() {}, |
Alexander Khovansky | 3e11933 | 2018-11-15 02:01:19 +0300 | [diff] [blame] | 117 | // private API |
| 118 | _encodeToData: function() {}, |
| 119 | _encodeToDataWithFormat: function() {}, |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 120 | }, |
| 121 | |
Kevin Lubick | 1a05fce | 2018-11-20 12:51:16 -0500 | [diff] [blame] | 122 | SkMatrix: { |
Kevin Lubick | b9db390 | 2018-11-26 11:47:54 -0500 | [diff] [blame] | 123 | identity: function() {}, |
| 124 | mapPoints: function() {}, |
| 125 | multiply: function() {}, |
Kevin Lubick | 1a05fce | 2018-11-20 12:51:16 -0500 | [diff] [blame] | 126 | rotated: function() {}, |
Kevin Lubick | b9db390 | 2018-11-26 11:47:54 -0500 | [diff] [blame] | 127 | scaled: function() {}, |
| 128 | skewed: function() {}, |
| 129 | translated: function() {}, |
| 130 | }, |
| 131 | |
| 132 | SkPaint: { |
| 133 | // public API (from C++ bindings) |
| 134 | /** @return {CanvasKit.SkPaint} */ |
| 135 | copy: function() {}, |
Kevin Lubick | 12c0e50 | 2018-11-28 12:51:56 -0500 | [diff] [blame] | 136 | getBlendMode: function() {}, |
Kevin Lubick | 61ef7b2 | 2018-11-27 13:26:59 -0500 | [diff] [blame] | 137 | getColor: function() {}, |
Kevin Lubick | 0a1293c | 2018-12-03 12:31:04 -0500 | [diff] [blame^] | 138 | getFilterQuality: function() {}, |
Kevin Lubick | b9db390 | 2018-11-26 11:47:54 -0500 | [diff] [blame] | 139 | getStrokeCap: function() {}, |
| 140 | getStrokeJoin: function() {}, |
| 141 | getStrokeMiter: function() {}, |
| 142 | getStrokeWidth: function() {}, |
| 143 | getTextSize: function() {}, |
| 144 | measureText: function() {}, |
| 145 | setAntiAlias: function() {}, |
Kevin Lubick | 12c0e50 | 2018-11-28 12:51:56 -0500 | [diff] [blame] | 146 | setBlendMode: function() {}, |
Kevin Lubick | b9db390 | 2018-11-26 11:47:54 -0500 | [diff] [blame] | 147 | setColor: function() {}, |
Kevin Lubick | 0a1293c | 2018-12-03 12:31:04 -0500 | [diff] [blame^] | 148 | setFilterQuality: function() {}, |
Kevin Lubick | 61ef7b2 | 2018-11-27 13:26:59 -0500 | [diff] [blame] | 149 | setMaskFilter: function() {}, |
Kevin Lubick | b9db390 | 2018-11-26 11:47:54 -0500 | [diff] [blame] | 150 | setPathEffect: function() {}, |
| 151 | setShader: function() {}, |
| 152 | setStrokeCap: function() {}, |
| 153 | setStrokeJoin: function() {}, |
| 154 | setStrokeMiter: function() {}, |
| 155 | setStrokeWidth: function() {}, |
| 156 | setStyle: function() {}, |
| 157 | setTextSize: function() {}, |
| 158 | |
| 159 | //private API |
| 160 | delete: function() {}, |
Kevin Lubick | 1a05fce | 2018-11-20 12:51:16 -0500 | [diff] [blame] | 161 | }, |
| 162 | |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 163 | SkPath: { |
| 164 | // public API (from C++ bindings) |
Kevin Lubick | b9db390 | 2018-11-26 11:47:54 -0500 | [diff] [blame] | 165 | computeTightBounds: function() {}, |
| 166 | /** @return {CanvasKit.SkPath} */ |
| 167 | copy: function() {}, |
| 168 | countPoints: function() {}, |
| 169 | equals: function() {}, |
| 170 | getBounds: function() {}, |
| 171 | getFillType: function() {}, |
| 172 | getPoint: function() {}, |
| 173 | setFillType: function() {}, |
| 174 | toSVGString: function() {}, |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 175 | |
| 176 | // private API |
Kevin Lubick | 1a05fce | 2018-11-20 12:51:16 -0500 | [diff] [blame] | 177 | _addArc: function() {}, |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 178 | _addPath: function() {}, |
Kevin Lubick | 1a05fce | 2018-11-20 12:51:16 -0500 | [diff] [blame] | 179 | _addRect: function() {}, |
Alexander Khovansky | 3e11933 | 2018-11-15 02:01:19 +0300 | [diff] [blame] | 180 | _arc: function() {}, |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 181 | _arcTo: function() {}, |
| 182 | _close: function() {}, |
| 183 | _conicTo: function() {}, |
| 184 | _cubicTo: function() {}, |
Kevin Lubick | b5ae3b5 | 2018-11-03 07:51:19 -0400 | [diff] [blame] | 185 | _dash: function() {}, |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 186 | _lineTo: function() {}, |
| 187 | _moveTo: function() {}, |
| 188 | _op: function() {}, |
| 189 | _quadTo: function() {}, |
| 190 | _rect: function() {}, |
| 191 | _simplify: function() {}, |
Kevin Lubick | b5ae3b5 | 2018-11-03 07:51:19 -0400 | [diff] [blame] | 192 | _stroke: function() {}, |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 193 | _transform: function() {}, |
Kevin Lubick | b5ae3b5 | 2018-11-03 07:51:19 -0400 | [diff] [blame] | 194 | _trim: function() {}, |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 195 | delete: function() {}, |
Kevin Lubick | b9db390 | 2018-11-26 11:47:54 -0500 | [diff] [blame] | 196 | dump: function() {}, |
| 197 | dumpHex: function() {}, |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 198 | }, |
| 199 | |
| 200 | SkRect: { |
| 201 | fLeft: {}, |
| 202 | fTop: {}, |
| 203 | fRight: {}, |
| 204 | fBottom: {}, |
| 205 | }, |
| 206 | |
| 207 | SkSurface: { |
| 208 | // public API (from C++ bindings) |
| 209 | /** @return {CanvasKit.SkCanvas} */ |
| 210 | getCanvas: function() {}, |
| 211 | /** @return {CanvasKit.SkImage} */ |
| 212 | makeImageSnapshot: function() {}, |
| 213 | |
| 214 | // private API |
| 215 | _flush: function() {}, |
| 216 | _getRasterN32PremulSurface: function() {}, |
| 217 | _readPixels: function() {}, |
| 218 | delete: function() {}, |
| 219 | }, |
| 220 | |
Kevin Lubick | b5ae3b5 | 2018-11-03 07:51:19 -0400 | [diff] [blame] | 221 | SkVertices: { |
| 222 | // public API (from C++ bindings) |
Kevin Lubick | 12c0e50 | 2018-11-28 12:51:56 -0500 | [diff] [blame] | 223 | bounds: function() {}, |
| 224 | mode: function() {}, |
| 225 | uniqueID: function() {}, |
| 226 | vertexCount: function() {}, |
Kevin Lubick | b5ae3b5 | 2018-11-03 07:51:19 -0400 | [diff] [blame] | 227 | |
| 228 | // private API |
| 229 | /** @return {CanvasKit.SkVertices} */ |
| 230 | _applyBones: function() {}, |
| 231 | }, |
| 232 | |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 233 | // Constants and Enums |
| 234 | gpu: {}, |
| 235 | skottie: {}, |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 236 | |
Kevin Lubick | 61ef7b2 | 2018-11-27 13:26:59 -0500 | [diff] [blame] | 237 | TRANSPARENT: {}, |
| 238 | RED: {}, |
| 239 | BLUE: {}, |
| 240 | YELLOW: {}, |
| 241 | CYAN: {}, |
| 242 | BLACK: {}, |
Kevin Lubick | ea905ec | 2018-11-30 14:05:58 -0500 | [diff] [blame] | 243 | WHITE: {}, |
| 244 | |
| 245 | AlphaType: { |
| 246 | Opaque: {}, |
| 247 | Premul: {}, |
| 248 | Unpremul: {}, |
| 249 | }, |
Kevin Lubick | 61ef7b2 | 2018-11-27 13:26:59 -0500 | [diff] [blame] | 250 | |
| 251 | BlendMode: { |
| 252 | Clear: {}, |
| 253 | Src: {}, |
| 254 | Dst: {}, |
| 255 | SrcOver: {}, |
| 256 | DstOver: {}, |
| 257 | SrcIn: {}, |
| 258 | DstIn: {}, |
| 259 | SrcOut: {}, |
| 260 | DstOut: {}, |
| 261 | SrcATop: {}, |
| 262 | DstATop: {}, |
| 263 | Xor: {}, |
| 264 | Plus: {}, |
| 265 | Modulate: {}, |
| 266 | Screen: {}, |
| 267 | Overlay: {}, |
| 268 | Darken: {}, |
| 269 | Lighten: {}, |
| 270 | ColorDodge: {}, |
| 271 | ColorBurn: {}, |
| 272 | HardLight: {}, |
| 273 | SoftLight: {}, |
| 274 | Difference: {}, |
| 275 | Exclusion: {}, |
| 276 | Multiply: {}, |
| 277 | Hue: {}, |
| 278 | Saturation: {}, |
| 279 | Color: {}, |
| 280 | Luminosity: {}, |
| 281 | }, |
| 282 | |
| 283 | BlurStyle: { |
| 284 | Normal: {}, |
| 285 | Solid: {}, |
| 286 | Outer: {}, |
| 287 | Inner: {}, |
| 288 | }, |
| 289 | |
Kevin Lubick | eb2f6b0 | 2018-11-29 15:07:02 -0500 | [diff] [blame] | 290 | ClipOp: { |
| 291 | Difference: {}, |
| 292 | Intersect: {}, |
| 293 | }, |
| 294 | |
Kevin Lubick | ea905ec | 2018-11-30 14:05:58 -0500 | [diff] [blame] | 295 | ColorType: { |
| 296 | Alpha_8: {}, |
| 297 | RGB_565: {}, |
| 298 | ARGB_4444: {}, |
| 299 | RGBA_8888: {}, |
| 300 | RGB_888x: {}, |
| 301 | BGRA_8888: {}, |
| 302 | RGBA_1010102: {}, |
| 303 | RGB_101010x: {}, |
| 304 | Gray_8: {}, |
| 305 | RGBA_F16: {}, |
| 306 | RGBA_F32: {}, |
| 307 | }, |
| 308 | |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 309 | FillType: { |
Kevin Lubick | 1a05fce | 2018-11-20 12:51:16 -0500 | [diff] [blame] | 310 | Winding: {}, |
| 311 | EvenOdd: {}, |
| 312 | InverseWinding: {}, |
| 313 | InverseEvenOdd: {}, |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 314 | }, |
| 315 | |
Kevin Lubick | 0a1293c | 2018-12-03 12:31:04 -0500 | [diff] [blame^] | 316 | FilterQuality: { |
| 317 | None: {}, |
| 318 | Low: {}, |
| 319 | Medium: {}, |
| 320 | High: {}, |
| 321 | }, |
| 322 | |
Alexander Khovansky | 3e11933 | 2018-11-15 02:01:19 +0300 | [diff] [blame] | 323 | ImageFormat: { |
| 324 | PNG: {}, |
| 325 | JPEG: {}, |
| 326 | }, |
| 327 | |
Kevin Lubick | b9db390 | 2018-11-26 11:47:54 -0500 | [diff] [blame] | 328 | PaintStyle: { |
| 329 | Fill: {}, |
| 330 | Stroke: {}, |
| 331 | StrokeAndFill: {}, |
| 332 | }, |
| 333 | |
Kevin Lubick | eb2f6b0 | 2018-11-29 15:07:02 -0500 | [diff] [blame] | 334 | PathOp: { |
| 335 | Difference: {}, |
| 336 | Intersect: {}, |
| 337 | Union: {}, |
| 338 | XOR: {}, |
| 339 | ReverseDifference: {}, |
| 340 | }, |
| 341 | |
Kevin Lubick | b9db390 | 2018-11-26 11:47:54 -0500 | [diff] [blame] | 342 | StrokeCap: { |
| 343 | Butt: {}, |
| 344 | Round: {}, |
| 345 | Square: {}, |
| 346 | }, |
| 347 | |
| 348 | StrokeJoin: { |
| 349 | Miter: {}, |
| 350 | Round: {}, |
| 351 | Bevel: {}, |
| 352 | }, |
| 353 | |
Kevin Lubick | eb2f6b0 | 2018-11-29 15:07:02 -0500 | [diff] [blame] | 354 | TileMode: { |
| 355 | Clamp: {}, |
| 356 | Repeat: {}, |
| 357 | Mirror: {}, |
| 358 | }, |
| 359 | |
| 360 | VertexMode: { |
| 361 | Triangles: {}, |
| 362 | TrianglesStrip: {}, |
| 363 | TriangleFan: {}, |
| 364 | }, |
| 365 | |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 366 | // Things Enscriptem adds for us |
| 367 | |
Kevin Lubick | 53965c9 | 2018-10-11 08:51:55 -0400 | [diff] [blame] | 368 | /** Represents the heap of the WASM code |
| 369 | * @type {ArrayBuffer} |
| 370 | */ |
| 371 | buffer: {}, |
| 372 | /** |
| 373 | * @type {Float32Array} |
| 374 | */ |
Kevin Lubick | b5ae3b5 | 2018-11-03 07:51:19 -0400 | [diff] [blame] | 375 | HEAPF32: {}, |
Kevin Lubick | 53965c9 | 2018-10-11 08:51:55 -0400 | [diff] [blame] | 376 | /** |
| 377 | * @type {Uint8Array} |
| 378 | */ |
| 379 | HEAPU8: {}, |
Kevin Lubick | b5ae3b5 | 2018-11-03 07:51:19 -0400 | [diff] [blame] | 380 | /** |
| 381 | * @type {Uint16Array} |
| 382 | */ |
| 383 | HEAPU16: {}, |
| 384 | /** |
| 385 | * @type {Int32Array} |
| 386 | */ |
| 387 | HEAP32: {}, |
Kevin Lubick | 53965c9 | 2018-10-11 08:51:55 -0400 | [diff] [blame] | 388 | |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 389 | _malloc: function() {}, |
| 390 | _free: function() {}, |
| 391 | onRuntimeInitialized: function() {}, |
| 392 | }; |
Kevin Lubick | 217056c | 2018-09-20 17:39:31 -0400 | [diff] [blame] | 393 | |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 394 | // Public API things that are newly declared in the JS should go here. |
| 395 | // It's not enough to declare them above, because closure can still erase them |
| 396 | // unless they go on the prototype. |
Kevin Lubick | 1a05fce | 2018-11-20 12:51:16 -0500 | [diff] [blame] | 397 | CanvasKit.SkPath.prototype.addArc = function() {}; |
Kevin Lubick | 217056c | 2018-09-20 17:39:31 -0400 | [diff] [blame] | 398 | CanvasKit.SkPath.prototype.addPath = function() {}; |
Kevin Lubick | 1a05fce | 2018-11-20 12:51:16 -0500 | [diff] [blame] | 399 | CanvasKit.SkPath.prototype.addRect = function() {}; |
Alexander Khovansky | 3e11933 | 2018-11-15 02:01:19 +0300 | [diff] [blame] | 400 | CanvasKit.SkPath.prototype.arc = function() {}; |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 401 | CanvasKit.SkPath.prototype.arcTo = function() {}; |
Kevin Lubick | 217056c | 2018-09-20 17:39:31 -0400 | [diff] [blame] | 402 | CanvasKit.SkPath.prototype.close = function() {}; |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 403 | CanvasKit.SkPath.prototype.conicTo = function() {}; |
| 404 | CanvasKit.SkPath.prototype.cubicTo = function() {}; |
Kevin Lubick | b5ae3b5 | 2018-11-03 07:51:19 -0400 | [diff] [blame] | 405 | CanvasKit.SkPath.prototype.dash = function() {}; |
Kevin Lubick | 006a6f3 | 2018-10-19 14:34:34 -0400 | [diff] [blame] | 406 | CanvasKit.SkPath.prototype.lineTo = function() {}; |
| 407 | CanvasKit.SkPath.prototype.moveTo = function() {}; |
| 408 | CanvasKit.SkPath.prototype.op = function() {}; |
| 409 | CanvasKit.SkPath.prototype.quadTo = function() {}; |
| 410 | CanvasKit.SkPath.prototype.rect = function() {}; |
Kevin Lubick | 217056c | 2018-09-20 17:39:31 -0400 | [diff] [blame] | 411 | CanvasKit.SkPath.prototype.simplify = function() {}; |
Kevin Lubick | b5ae3b5 | 2018-11-03 07:51:19 -0400 | [diff] [blame] | 412 | CanvasKit.SkPath.prototype.stroke = function() {}; |
Kevin Lubick | 217056c | 2018-09-20 17:39:31 -0400 | [diff] [blame] | 413 | CanvasKit.SkPath.prototype.transform = function() {}; |
Kevin Lubick | b5ae3b5 | 2018-11-03 07:51:19 -0400 | [diff] [blame] | 414 | CanvasKit.SkPath.prototype.trim = function() {}; |
Kevin Lubick | 217056c | 2018-09-20 17:39:31 -0400 | [diff] [blame] | 415 | |
Kevin Lubick | 53965c9 | 2018-10-11 08:51:55 -0400 | [diff] [blame] | 416 | CanvasKit.SkSurface.prototype.flush = function() {}; |
Kevin Lubick | 5b90b84 | 2018-10-17 07:57:18 -0400 | [diff] [blame] | 417 | CanvasKit.SkSurface.prototype.dispose = function() {}; |
Kevin Lubick | 53965c9 | 2018-10-11 08:51:55 -0400 | [diff] [blame] | 418 | |
Kevin Lubick | 12c0e50 | 2018-11-28 12:51:56 -0500 | [diff] [blame] | 419 | /** @return {CanvasKit.SkVertices} */ |
Kevin Lubick | b5ae3b5 | 2018-11-03 07:51:19 -0400 | [diff] [blame] | 420 | CanvasKit.SkVertices.prototype.applyBones = function() {}; |
| 421 | |
Alexander Khovansky | 3e11933 | 2018-11-15 02:01:19 +0300 | [diff] [blame] | 422 | CanvasKit.SkImage.prototype.encodeToData = function() {}; |
| 423 | |
Kevin Lubick | b5ae3b5 | 2018-11-03 07:51:19 -0400 | [diff] [blame] | 424 | // Define StrokeOpts object |
| 425 | var StrokeOpts = {}; |
| 426 | StrokeOpts.prototype.width; |
| 427 | StrokeOpts.prototype.miter_limit; |
| 428 | StrokeOpts.prototype.cap; |
| 429 | StrokeOpts.prototype.join; |
| 430 | |
Kevin Lubick | eb2f6b0 | 2018-11-29 15:07:02 -0500 | [diff] [blame] | 431 | // Define everything created in the canvas2d spec here |
Kevin Lubick | b9db390 | 2018-11-26 11:47:54 -0500 | [diff] [blame] | 432 | var HTMLCanvas = {}; |
Kevin Lubick | 0a1293c | 2018-12-03 12:31:04 -0500 | [diff] [blame^] | 433 | HTMLCanvas.prototype.decodeImage = function() {}; |
| 434 | HTMLCanvas.prototype.dispose = function() {}; |
Kevin Lubick | b9db390 | 2018-11-26 11:47:54 -0500 | [diff] [blame] | 435 | HTMLCanvas.prototype.getContext = function() {}; |
| 436 | HTMLCanvas.prototype.toDataURL = function() {}; |
Kevin Lubick | b9db390 | 2018-11-26 11:47:54 -0500 | [diff] [blame] | 437 | |
| 438 | var CanvasRenderingContext2D = {}; |
| 439 | CanvasRenderingContext2D.prototype.addHitRegion = function() {}; |
| 440 | CanvasRenderingContext2D.prototype.arc = function() {}; |
| 441 | CanvasRenderingContext2D.prototype.arcTo = function() {}; |
| 442 | CanvasRenderingContext2D.prototype.beginPath = function() {}; |
| 443 | CanvasRenderingContext2D.prototype.bezierCurveTo = function() {}; |
| 444 | CanvasRenderingContext2D.prototype.clearHitRegions = function() {}; |
Kevin Lubick | 12c0e50 | 2018-11-28 12:51:56 -0500 | [diff] [blame] | 445 | CanvasRenderingContext2D.prototype.clearRect = function() {}; |
Kevin Lubick | eb2f6b0 | 2018-11-29 15:07:02 -0500 | [diff] [blame] | 446 | CanvasRenderingContext2D.prototype.clip = function() {}; |
Kevin Lubick | b9db390 | 2018-11-26 11:47:54 -0500 | [diff] [blame] | 447 | CanvasRenderingContext2D.prototype.closePath = function() {}; |
Kevin Lubick | eb2f6b0 | 2018-11-29 15:07:02 -0500 | [diff] [blame] | 448 | CanvasRenderingContext2D.prototype.createLinearGradient = function() {}; |
| 449 | CanvasRenderingContext2D.prototype.createRadialGradient = function() {}; |
Kevin Lubick | b9db390 | 2018-11-26 11:47:54 -0500 | [diff] [blame] | 450 | CanvasRenderingContext2D.prototype.drawFocusIfNeeded = function() {}; |
Kevin Lubick | 0a1293c | 2018-12-03 12:31:04 -0500 | [diff] [blame^] | 451 | CanvasRenderingContext2D.prototype.drawImage = function() {}; |
Kevin Lubick | b9db390 | 2018-11-26 11:47:54 -0500 | [diff] [blame] | 452 | CanvasRenderingContext2D.prototype.ellipse = function() {}; |
Kevin Lubick | 61ef7b2 | 2018-11-27 13:26:59 -0500 | [diff] [blame] | 453 | CanvasRenderingContext2D.prototype.fill = function() {}; |
Kevin Lubick | 12c0e50 | 2018-11-28 12:51:56 -0500 | [diff] [blame] | 454 | CanvasRenderingContext2D.prototype.fillRect = function() {}; |
Kevin Lubick | b9db390 | 2018-11-26 11:47:54 -0500 | [diff] [blame] | 455 | CanvasRenderingContext2D.prototype.fillText = function() {}; |
Kevin Lubick | 12c0e50 | 2018-11-28 12:51:56 -0500 | [diff] [blame] | 456 | CanvasRenderingContext2D.prototype.getLineDash = function() {}; |
Kevin Lubick | b9db390 | 2018-11-26 11:47:54 -0500 | [diff] [blame] | 457 | CanvasRenderingContext2D.prototype.lineTo = function() {}; |
| 458 | CanvasRenderingContext2D.prototype.measureText = function() {}; |
| 459 | CanvasRenderingContext2D.prototype.moveTo = function() {}; |
| 460 | CanvasRenderingContext2D.prototype.quadraticCurveTo = function() {}; |
| 461 | CanvasRenderingContext2D.prototype.rect = function() {}; |
| 462 | CanvasRenderingContext2D.prototype.removeHitRegion = function() {}; |
| 463 | CanvasRenderingContext2D.prototype.resetTransform = function() {}; |
Kevin Lubick | 61ef7b2 | 2018-11-27 13:26:59 -0500 | [diff] [blame] | 464 | CanvasRenderingContext2D.prototype.restore = function() {}; |
Kevin Lubick | b9db390 | 2018-11-26 11:47:54 -0500 | [diff] [blame] | 465 | CanvasRenderingContext2D.prototype.rotate = function() {}; |
Kevin Lubick | 61ef7b2 | 2018-11-27 13:26:59 -0500 | [diff] [blame] | 466 | CanvasRenderingContext2D.prototype.save = function() {}; |
Kevin Lubick | b9db390 | 2018-11-26 11:47:54 -0500 | [diff] [blame] | 467 | CanvasRenderingContext2D.prototype.scale = function() {}; |
| 468 | CanvasRenderingContext2D.prototype.scrollPathIntoView = function() {}; |
Kevin Lubick | 12c0e50 | 2018-11-28 12:51:56 -0500 | [diff] [blame] | 469 | CanvasRenderingContext2D.prototype.setLineDash = function() {}; |
Kevin Lubick | b9db390 | 2018-11-26 11:47:54 -0500 | [diff] [blame] | 470 | CanvasRenderingContext2D.prototype.setTransform = function() {}; |
| 471 | CanvasRenderingContext2D.prototype.stroke = function() {}; |
Kevin Lubick | 12c0e50 | 2018-11-28 12:51:56 -0500 | [diff] [blame] | 472 | CanvasRenderingContext2D.prototype.strokeRect = function() {}; |
Kevin Lubick | b9db390 | 2018-11-26 11:47:54 -0500 | [diff] [blame] | 473 | CanvasRenderingContext2D.prototype.strokeText = function() {}; |
| 474 | CanvasRenderingContext2D.prototype.transform = function() {}; |
| 475 | CanvasRenderingContext2D.prototype.translate = function() {}; |
| 476 | |
Kevin Lubick | eb2f6b0 | 2018-11-29 15:07:02 -0500 | [diff] [blame] | 477 | var LinearCanvasGradient = {}; |
| 478 | LinearCanvasGradient.prototype.addColorStop = function() {}; |
| 479 | var RadialCanvasGradient = {}; |
| 480 | RadialCanvasGradient.prototype.addColorStop = function() {}; |
| 481 | |
Kevin Lubick | 217056c | 2018-09-20 17:39:31 -0400 | [diff] [blame] | 482 | // Not sure why this is needed - might be a bug in emsdk that this isn't properly declared. |
Kevin Lubick | 6fccc9d | 2018-11-20 15:55:10 -0500 | [diff] [blame] | 483 | function loadWebAssemblyModule() {}; |
Kevin Lubick | 12c0e50 | 2018-11-28 12:51:56 -0500 | [diff] [blame] | 484 | |
| 485 | var DOMMatrix = {}; |