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