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