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