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