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