spine-html 1.22.1 → 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 +99 -12
- package/dist/MeshGlBlitter.d.ts.map +1 -1
- package/dist/index.js +364 -113
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/MeshGlBlitter.d.ts
CHANGED
|
@@ -23,6 +23,18 @@
|
|
|
23
23
|
* grows quantized and never shrinks, mirroring the per-part backing policy
|
|
24
24
|
* (reallocating GPU surfaces per frame is a Safari killer).
|
|
25
25
|
*
|
|
26
|
+
* It only ever holds a size the browser granted in full. The WebGL spec lets
|
|
27
|
+
* the browser hand back a drawing buffer smaller than the canvas's
|
|
28
|
+
* width × height, and Chromium does once the area passes its cap (5760 ×
|
|
29
|
+
* 5760 for an 8192 × 8192 request, measured): drawing and reading back
|
|
30
|
+
* through the canvas's size then copies the wrong texels into every part —
|
|
31
|
+
* rectangles of another part's texture, cloth cut along straight edges, on a
|
|
32
|
+
* zoomed-in stage (rig-c/review#332). So a growth the browser does not grant
|
|
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.
|
|
37
|
+
*
|
|
26
38
|
* Page textures are the one thing here with a lifetime, and since this object
|
|
27
39
|
* outlives every renderer they are reference-counted: a renderer retains each
|
|
28
40
|
* page it queues a job for and releases them in dispose(), and the last
|
|
@@ -33,7 +45,8 @@
|
|
|
33
45
|
* The canvas render mode (`CanvasRenderer`) draws through the same context: a
|
|
34
46
|
* `FrameJob` is a whole player's frame — every region and mesh as textured,
|
|
35
47
|
* vertex-coloured triangles in draw order, with the blend mode as batch state —
|
|
36
|
-
* 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
|
|
37
50
|
* program (colour and optional dark attributes) so the mesh tier's program and
|
|
38
51
|
* its output stay exactly what they were; both share the page textures and
|
|
39
52
|
* their reference counts.
|
|
@@ -85,7 +98,7 @@ export interface FrameRun {
|
|
|
85
98
|
* Positions are device px relative to the job's rect, top-left origin; the
|
|
86
99
|
* colour is premultiplied by its alpha and so is the dark colour. Drawn into
|
|
87
100
|
* one rect of the offscreen buffer, then blitted onto `canvas` in one
|
|
88
|
-
* `drawImage
|
|
101
|
+
* `drawImage` — or, past the grant, tile by tile (see flushFrame).
|
|
89
102
|
*/
|
|
90
103
|
export interface FrameJob {
|
|
91
104
|
canvas: HTMLCanvasElement;
|
|
@@ -105,13 +118,13 @@ declare class MeshGlBlitter {
|
|
|
105
118
|
liveTextureCount: number;
|
|
106
119
|
private readonly canvas;
|
|
107
120
|
private readonly gl;
|
|
108
|
-
private readonly
|
|
121
|
+
private readonly uScale;
|
|
109
122
|
private readonly uOrigin;
|
|
110
123
|
private readonly meshProgram;
|
|
111
124
|
private readonly meshPos;
|
|
112
125
|
private readonly meshUV;
|
|
113
126
|
private readonly frameProgram;
|
|
114
|
-
private readonly
|
|
127
|
+
private readonly frameScale;
|
|
115
128
|
private readonly frameOrigin;
|
|
116
129
|
private readonly framePos;
|
|
117
130
|
private readonly frameUV;
|
|
@@ -127,22 +140,96 @@ declare class MeshGlBlitter {
|
|
|
127
140
|
*/
|
|
128
141
|
private textures;
|
|
129
142
|
private readonly maxSize;
|
|
143
|
+
/**
|
|
144
|
+
* The smallest drawing-buffer area the browser has refused to grant in full
|
|
145
|
+
* (see the module comment); a growth to this area or more is not attempted.
|
|
146
|
+
*/
|
|
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;
|
|
130
153
|
private vertexData;
|
|
131
|
-
/** Per-job packed rect origins, filled by flush(). */
|
|
154
|
+
/** Per-job packed rect origins (a tiled job's first tile), filled by flush(). */
|
|
132
155
|
private packX;
|
|
133
156
|
private packY;
|
|
134
157
|
constructor();
|
|
135
158
|
/**
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
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.
|
|
139
177
|
*/
|
|
140
178
|
flush(jobs: MeshBlitJob[]): boolean;
|
|
141
179
|
/**
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
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();
|
|
207
|
+
/**
|
|
208
|
+
* Makes the drawing buffer hold at least `width` × `height`, growing it
|
|
209
|
+
* grow-only and quantized, and returns whether it does — as granted, not as
|
|
210
|
+
* asked. A growth the browser grants only in part is undone (the previous
|
|
211
|
+
* size was granted in full) and its area remembered, so a zoom held past
|
|
212
|
+
* the cap declines each frame without reallocating the buffer twice per
|
|
213
|
+
* frame. Resizing clears the buffer, which is fine: every rect is cleared
|
|
214
|
+
* and redrawn anyway.
|
|
215
|
+
*/
|
|
216
|
+
private reserve;
|
|
217
|
+
/**
|
|
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.
|
|
146
233
|
*/
|
|
147
234
|
flushFrame(job: FrameJob): boolean;
|
|
148
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,CA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