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