spine-html 1.22.2 → 1.22.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/MeshGlBlitter.d.ts +76 -14
- package/dist/MeshGlBlitter.d.ts.map +1 -1
- package/dist/index.js +333 -104
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/MeshGlBlitter.d.ts
CHANGED
|
@@ -30,8 +30,10 @@
|
|
|
30
30
|
* through the canvas's size then copies the wrong texels into every part —
|
|
31
31
|
* rectangles of another part's texture, cloth cut along straight edges, on a
|
|
32
32
|
* zoomed-in stage (rig-c/review#332). So a growth the browser does not grant
|
|
33
|
-
* in full is undone
|
|
34
|
-
*
|
|
33
|
+
* in full is undone and that area is not asked for again. A batch the granted
|
|
34
|
+
* buffer cannot hold — or one past `maxSize` — is drawn in passes through it,
|
|
35
|
+
* and a job larger than the buffer in tiles (see flush()); the canvas2d path
|
|
36
|
+
* is the caller's for a lost context only, never for size.
|
|
35
37
|
*
|
|
36
38
|
* Page textures are the one thing here with a lifetime, and since this object
|
|
37
39
|
* outlives every renderer they are reference-counted: a renderer retains each
|
|
@@ -43,7 +45,8 @@
|
|
|
43
45
|
* The canvas render mode (`CanvasRenderer`) draws through the same context: a
|
|
44
46
|
* `FrameJob` is a whole player's frame — every region and mesh as textured,
|
|
45
47
|
* vertex-coloured triangles in draw order, with the blend mode as batch state —
|
|
46
|
-
* into one rect, blitted onto that player's
|
|
48
|
+
* into one rect (or tiles of one, past the grant), blitted onto that player's
|
|
49
|
+
* one visible canvas, and rastered in that rect's own frame like a mesh job. It has its own
|
|
47
50
|
* program (colour and optional dark attributes) so the mesh tier's program and
|
|
48
51
|
* its output stay exactly what they were; both share the page textures and
|
|
49
52
|
* their reference counts.
|
|
@@ -95,7 +98,7 @@ export interface FrameRun {
|
|
|
95
98
|
* Positions are device px relative to the job's rect, top-left origin; the
|
|
96
99
|
* colour is premultiplied by its alpha and so is the dark colour. Drawn into
|
|
97
100
|
* one rect of the offscreen buffer, then blitted onto `canvas` in one
|
|
98
|
-
* `drawImage
|
|
101
|
+
* `drawImage` — or, past the grant, tile by tile (see flushFrame).
|
|
99
102
|
*/
|
|
100
103
|
export interface FrameJob {
|
|
101
104
|
canvas: HTMLCanvasElement;
|
|
@@ -115,13 +118,13 @@ declare class MeshGlBlitter {
|
|
|
115
118
|
liveTextureCount: number;
|
|
116
119
|
private readonly canvas;
|
|
117
120
|
private readonly gl;
|
|
118
|
-
private readonly
|
|
121
|
+
private readonly uScale;
|
|
119
122
|
private readonly uOrigin;
|
|
120
123
|
private readonly meshProgram;
|
|
121
124
|
private readonly meshPos;
|
|
122
125
|
private readonly meshUV;
|
|
123
126
|
private readonly frameProgram;
|
|
124
|
-
private readonly
|
|
127
|
+
private readonly frameScale;
|
|
125
128
|
private readonly frameOrigin;
|
|
126
129
|
private readonly framePos;
|
|
127
130
|
private readonly frameUV;
|
|
@@ -142,17 +145,65 @@ declare class MeshGlBlitter {
|
|
|
142
145
|
* (see the module comment); a growth to this area or more is not attempted.
|
|
143
146
|
*/
|
|
144
147
|
private refusedArea;
|
|
148
|
+
/** Test-only caps on the grant, and the tiling plant — see limitForTesting(). */
|
|
149
|
+
private testArea;
|
|
150
|
+
private testWidth;
|
|
151
|
+
private testHeight;
|
|
152
|
+
private tiling;
|
|
145
153
|
private vertexData;
|
|
146
|
-
/** Per-job packed rect origins, filled by flush(). */
|
|
154
|
+
/** Per-job packed rect origins (a tiled job's first tile), filled by flush(). */
|
|
147
155
|
private packX;
|
|
148
156
|
private packY;
|
|
149
157
|
constructor();
|
|
150
158
|
/**
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
159
|
+
* Rasterizes every job and blits it onto its per-part canvas. Returns false
|
|
160
|
+
* only when the context is lost, so that the caller draws the batch on its
|
|
161
|
+
* canvas2d path; a batch's size never sends it there.
|
|
162
|
+
*
|
|
163
|
+
* A batch that fits one buffer is one pass, shelf-packed as it always was.
|
|
164
|
+
* One that does not — a zoomed-in stage asks for more than the browser
|
|
165
|
+
* grants, or for more than `maxSize` — is drawn in passes through the
|
|
166
|
+
* largest buffer the browser grants in full: its pieces are shelf-packed
|
|
167
|
+
* into that buffer, a pass is drawn and blitted, and the next pass reuses
|
|
168
|
+
* the buffer. A piece is a whole job, or one tile of a job larger than the
|
|
169
|
+
* buffer.
|
|
170
|
+
*
|
|
171
|
+
* Every piece is rastered in its own job's rect (#187): the vertex upload is
|
|
172
|
+
* relative to the job and nothing else, and the viewport is the job's rect
|
|
173
|
+
* wherever the piece sits. A tile is the same viewport moved so that the
|
|
174
|
+
* tile lands in the buffer, scissored to the tile and blitted into the
|
|
175
|
+
* matching sub-rect of the part canvas — so a pixel does not depend on how
|
|
176
|
+
* its job was packed, which pass drew it, or how it was tiled.
|
|
154
177
|
*/
|
|
155
178
|
flush(jobs: MeshBlitJob[]): boolean;
|
|
179
|
+
/**
|
|
180
|
+
* Sets the viewport, the two uniforms and the scissor for one piece. The
|
|
181
|
+
* viewport is the job's own rect — or, for a job wider or taller than
|
|
182
|
+
* `maxSize`, the `maxSize` window of it that holds the piece, since a
|
|
183
|
+
* viewport cannot be larger — placed so that the piece's sub-rect lands on
|
|
184
|
+
* the piece's rect of the buffer; the scissor is that rect. Scissor and
|
|
185
|
+
* viewport are bottom-left origin; pieces are placed top-left.
|
|
186
|
+
*
|
|
187
|
+
* The clip-space mapping is `(p - origin) * scale - 1` with `scale` the
|
|
188
|
+
* window's 2 / size, a function of the job and the window alone. Written as
|
|
189
|
+
* `(p - origin) / size * 2 - 1` instead, SwiftShader drew the canvas mode's
|
|
190
|
+
* 6,901 px frame differently in two tilings (51,537 pixels); this form drew
|
|
191
|
+
* them identically, and the mesh tier identically either way.
|
|
192
|
+
*/
|
|
193
|
+
private placePiece;
|
|
194
|
+
/**
|
|
195
|
+
* Cuts each rect into pieces that fit a `bufW` × `bufH` buffer with its
|
|
196
|
+
* gutter — a rect that fits is one piece, a larger one is tiled, tiles never
|
|
197
|
+
* crossing a `maxSize` window — and shelf-packs them, tallest first, into
|
|
198
|
+
* consecutive passes of that buffer. A tile starts on the `ALIGN` grid of
|
|
199
|
+
* its job, so its job's corner keeps the buffer phase every piece has.
|
|
200
|
+
* Returns the pieces in pass order, or null when a rect needs tiling and
|
|
201
|
+
* tiling is off (a test-only plant) or the buffer is too small to tile.
|
|
202
|
+
*/
|
|
203
|
+
private plan;
|
|
204
|
+
/** The buffer sides this module will use: `maxSize`, or a test cap below it. */
|
|
205
|
+
private get limitW();
|
|
206
|
+
private get limitH();
|
|
156
207
|
/**
|
|
157
208
|
* Makes the drawing buffer hold at least `width` × `height`, growing it
|
|
158
209
|
* grow-only and quantized, and returns whether it does — as granted, not as
|
|
@@ -164,10 +215,21 @@ declare class MeshGlBlitter {
|
|
|
164
215
|
*/
|
|
165
216
|
private reserve;
|
|
166
217
|
/**
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
218
|
+
* Grows the buffer toward `width` × `height` as far as the browser grants
|
|
219
|
+
* in full, for a batch that one buffer cannot hold. The request is shrunk a
|
|
220
|
+
* quantum at a time, larger side first, never below the buffer already
|
|
221
|
+
* held, past every area the browser has refused; each refusal lowers that
|
|
222
|
+
* area, so the search ends — at worst on the buffer already held. Returns
|
|
223
|
+
* false only when even that is not granted in full.
|
|
224
|
+
*/
|
|
225
|
+
private acquire;
|
|
226
|
+
/**
|
|
227
|
+
* Draws one player's frame (the canvas render mode) and blits it onto
|
|
228
|
+
* `job.canvas`, whose full backing is cleared first. Returns false only when
|
|
229
|
+
* the context is lost, so the caller draws the frame on its canvas2d
|
|
230
|
+
* fallback. The frame is one job: drawn into one rect when the buffer holds
|
|
231
|
+
* it, otherwise tiled through passes exactly as flush() tiles a mesh, every
|
|
232
|
+
* tile re-issuing the frame's runs under its own scissor.
|
|
171
233
|
*/
|
|
172
234
|
flushFrame(job: FrameJob): boolean;
|
|
173
235
|
/** The mesh tier's layout, [x, y, u, v], and its premultiplied source-over. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MeshGlBlitter.d.ts","sourceRoot":"","sources":["../src/MeshGlBlitter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"MeshGlBlitter.d.ts","sourceRoot":"","sources":["../src/MeshGlBlitter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAgBjD,MAAM,WAAW,WAAW;IAC1B,2EAA2E;IAC3E,MAAM,EAAE,iBAAiB,CAAC;IAC1B,+EAA+E;IAC/E,IAAI,EAAE,gBAAgB,CAAC;IACvB;;;;;OAKG;IACH,GAAG,EAAE,OAAO,CAAC;IACb,mFAAmF;IACnF,QAAQ,EAAE,YAAY,CAAC;IACvB,mDAAmD;IACnD,GAAG,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IACvB,gDAAgD;IAChD,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IAC7B,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,iFAAiF;IACjF,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,gBAAgB,CAAC;IACvB,sCAAsC;IACtC,GAAG,EAAE,OAAO,CAAC;IACb,KAAK,EAAE,SAAS,CAAC;IACjB,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,YAAY,CAAC;IACnB,MAAM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