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