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