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