xref: /aosp_15_r20/external/skia/modules/pathkit/externs.js (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
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 PathKit.
7 *
8 * Emscripten does not support automatically generating an externs file, so we
9 * do it by hand. The general process is to write some JS code, and then put any
10 * calls to PathKit or related things in here. Running ./compile.sh and then
11 * looking at the minified results or running the Release-PathKit trybot should
12 * verify nothing was missed. Optionally, looking directly at the minified
13 * pathkit.js can be useful when developing locally.
14 *
15 * Docs:
16 *   https://github.com/cljsjs/packages/wiki/Creating-Externs
17 *   https://github.com/google/closure-compiler/wiki/Types-in-the-Closure-Type-System
18 *
19 * Example externs:
20 *   https://github.com/google/closure-compiler/tree/master/externs
21 */
22
23var PathKit = {
24	SkBits2FloatUnsigned: function(num) {},
25	_malloc: function(size) {},
26	_free: function(ptr) {},
27	onRuntimeInitialized: function() {},
28	_FromCmds: function(ptr, size) {},
29	loadCmdsTypedArray: function(arr) {},
30	FromCmds: function(arr) {},
31	_SkCubicMap: function(cp1, cp2) {},
32	cubicYFromX: function(cpx1, cpy1, cpx2, cpy2, X) {},
33	cubicPtFromT: function(cpx1, cpy1, cpx2, cpy2, T) {},
34
35	/**
36	 * @type {Float32Array}
37	 */
38	HEAPF32: {},
39
40	SkPath: {
41		_addPath: function(path, scaleX, skewX, transX, skewY, scaleY, transY, pers0, pers1, pers2) {},
42		_arc: function(x, y, radius, startAngle, endAngle, ccw) {},
43		_arcTo: function(x1, y1, x2, y2, radius) {},
44		_asWinding: function() {},
45		_dash: function(on, off, phase) {},
46		_close: function() {},
47		_conicTo: function(x1, y1, x2, y2, w) {},
48		copy: function() {},
49		_cubicTo: function(cp1x, cp1y, cp2x, cp2y, x, y) {},
50		_ellipse: function(x, y, radiusX, radiusY, rotation, startAngle, endAngle, ccw) {},
51		_isEmpty: function() {},
52		_lineTo: function(x1, y1) {},
53		_moveTo: function(x1, y1) {},
54		_op: function(otherPath, op) {},
55		_quadTo: function(cpx, cpy, x, y) {},
56		_rect: function(x, y, w, h) {},
57		_reverseAddPath: function(path) {},
58		_simplify: function() {},
59		_stroke: function(opts) {},
60		_trim: function(startT, stopT, isComplement) {},
61		_transform: function() {}, // takes 1 or 9 params
62	},
63
64	StrokeCap: {
65		BUTT: {},
66		ROUND: {},
67		SQUARE: {},
68	},
69	StrokeJoin: {
70		MITER: {},
71		ROUND: {},
72		BEVEL: {},
73	}
74};
75
76// Define StrokeOpts object
77var StrokeOpts = {};
78StrokeOpts.prototype.width;
79StrokeOpts.prototype.miter_limit;
80StrokeOpts.prototype.cap;
81StrokeOpts.prototype.join;
82
83// Define CubicMap object
84var CubicMap = {};
85CubicMap.prototype.computeYFromX = function(x) {};
86CubicMap.prototype.computePtFromT = function(t) {};
87
88
89// For whatever reason, the closure compiler thinks it can rename some of our
90// prototype methods.  Not entirely sure why.
91// Listing them here prevents that.
92PathKit.SkPath.prototype.addPath = function() {};
93PathKit.SkPath.prototype.arc = function(x, y, radius, startAngle, endAngle, ccw) {};
94PathKit.SkPath.prototype.arcTo = function(x1, y1, x2, y2, radius) {};
95PathKit.SkPath.prototype.asWinding = function() {};
96PathKit.SkPath.prototype.bezierCurveTo = function(cp1x, cp1y, cp2x, cp2y, x, y) {};
97PathKit.SkPath.prototype.close = function() {};
98PathKit.SkPath.prototype.closePath = function() {};
99PathKit.SkPath.prototype.conicTo = function(x1, y1, x2, y2, w) {};
100PathKit.SkPath.prototype.cubicTo = function(cp1x, cp1y, cp2x, cp2y, x, y) {};
101PathKit.SkPath.prototype.dash = function(on, off, phase) {};
102PathKit.SkPath.prototype.ellipse = function(x, y, radiusX, radiusY, rotation, startAngle, endAngle, ccw) {};
103PathKit.SkPath.prototype.isEmpty = function() {};
104PathKit.SkPath.prototype.lineTo = function(x, y) {};
105PathKit.SkPath.prototype.moveTo = function(x, y) {};
106PathKit.SkPath.prototype.op = function(otherPath, op) {};
107PathKit.SkPath.prototype.quadTo = function(x1, y1, x2, y2) {};
108PathKit.SkPath.prototype.quadraticCurveTo = function(x1, y1, x2, y2) {};
109PathKit.SkPath.prototype.rect = function(x, y, w, h) {};
110PathKit.SkPath.prototype.reverseAddPath = function() {};
111PathKit.SkPath.prototype.simplify = function() {};
112PathKit.SkPath.prototype.stroke = function(opts) {};
113PathKit.SkPath.prototype.transform = function() {};
114PathKit.SkPath.prototype.trim = function(startT, stopT, isComplement) {};
115