@swf2es/web 0.1.28 → 0.1.30

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.
@@ -0,0 +1,73 @@
1
+ import type { FrameStats } from "./playback.js";
2
+ type GL = WebGLRenderingContext | WebGL2RenderingContext;
3
+ /**
4
+ * Its look, which a page may give its own through custom properties on the
5
+ * element (font, color, background, border, muted, the labels' colour, and
6
+ * opacity, the background's, 0.7 by default, which multiplies a background's
7
+ * own alpha), as the demo site gives its
8
+ * theme's; by default the browser's light or dark colours, as the context
9
+ * menu's. The background lets the SWF show through; a halo of it around
10
+ * each figure keeps the figures readable over white text or busy content.
11
+ * No backdrop blur: blurring a canvas that changes every frame costs the
12
+ * GPU every frame.
13
+ */
14
+ export declare const METER_STYLE: string;
15
+ /** The element's corners the meter may sit in, in the order the context menu moves it through. */
16
+ export declare const METER_CORNERS: readonly ["top-left", "top-right", "bottom-left", "bottom-right"];
17
+ export type MeterCorner = (typeof METER_CORNERS)[number];
18
+ export declare function isMeterCorner(value: unknown): value is MeterCorner;
19
+ /** The corner after `corner`, the first after the last. */
20
+ export declare function nextCorner(corner: MeterCorner): MeterCorner;
21
+ /** The viewer's corner as last kept: top-left where none is, or storage is refused. */
22
+ export declare function storedCorner(): MeterCorner;
23
+ export declare function storeCorner(corner: MeterCorner): void;
24
+ /** The viewer's choice as last kept: off where none is, or storage is refused. */
25
+ export declare function storedMeter(): boolean;
26
+ export declare function storeMeter(on: boolean): void;
27
+ export declare class PerformanceMeter {
28
+ private readonly memory;
29
+ private readonly root;
30
+ private readonly cells;
31
+ private shown;
32
+ /** Whether a player plays, whose frames the meter hears. */
33
+ private playing;
34
+ private timer;
35
+ private readonly counter;
36
+ /** The loop's last KEPT calls, a ring: each one's time, frames played, and ms (-1 for no work). */
37
+ private readonly times;
38
+ private readonly frames;
39
+ private readonly costs;
40
+ private readonly sorted;
41
+ private next;
42
+ private count;
43
+ /** When the calls counted began: shown, or a SWF started, whichever came last. */
44
+ private since;
45
+ /** The SWF's frame rate as of the last call, 0 before one. */
46
+ private rate;
47
+ /** The draws, and the calls that made them, of the frames that drew since the last showing. */
48
+ private draws;
49
+ private calls;
50
+ private drawnFrames;
51
+ /** Shown in `parent`, the element's shadow root; `memory` is the element's wasmMemory. */
52
+ constructor(parent: Node, memory: () => {
53
+ codegen: number;
54
+ native: number;
55
+ });
56
+ /** Put the meter in `corner` of the element. */
57
+ place(corner: MeterCorner): void;
58
+ /** Show the meter and measure, or hide it and stop. */
59
+ show(on: boolean): void;
60
+ /** A player begun, drawing with `gl`, or none playing: what was counted before is let go. */
61
+ attach(gl: GL | null, playing: boolean): void;
62
+ /** The timer runs while the meter shows a player's figures; it shows them at once as it starts. */
63
+ private tick;
64
+ private reset;
65
+ /** Each call of the player's loop, kept in the ring without allocating. */
66
+ readonly heard: (stats: FrameStats) => void;
67
+ private readonly update;
68
+ private text;
69
+ /** Put `cost` among the first `n` sorted, by insertion: a second's few hundred, twice a second. */
70
+ private insert;
71
+ }
72
+ export {};
73
+ //# sourceMappingURL=meter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meter.d.ts","sourceRoot":"","sources":["../src/meter.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAMhD,KAAK,EAAE,GAAG,qBAAqB,GAAG,sBAAsB,CAAC;AAEzD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW,QAwBoD,CAAC;AAyC7E,kGAAkG;AAClG,eAAO,MAAM,aAAa,YAAI,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,CAAU,CAAC;AAC/F,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAElE;AAED,2DAA2D;AAC3D,wBAAgB,UAAU,CAAC,MAAM,EA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uDAAuD;IACvD,IAAI,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,CAatB;IAED,6FAA6F;IAC7F,MAAM,CAAC,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAK5C;IAED,mGAAmG;IACnG,OAAO,CAAC,IAAI;IAcZ,OAAO,CAAC,KAAK;IAUb,2EAA2E;IAC3E,QAAQ,CAAC,KAAK,UAAW,UAAU,KAAG,IAAI,CAmBxC;IAEF,OAAO,CAAC,QAAQ,CAAC,MAAM,CAoDrB;IAEF,OAAO,CAAC,IAAI;IAOZ,mGAAmG;IACnG,OAAO,CAAC,MAAM;CAUf"}
package/dist/meter.js ADDED
@@ -0,0 +1,422 @@
1
+ /**
2
+ * Its look, which a page may give its own through custom properties on the
3
+ * element (font, color, background, border, muted, the labels' colour, and
4
+ * opacity, the background's, 0.7 by default, which multiplies a background's
5
+ * own alpha), as the demo site gives its
6
+ * theme's; by default the browser's light or dark colours, as the context
7
+ * menu's. The background lets the SWF show through; a halo of it around
8
+ * each figure keeps the figures readable over white text or busy content.
9
+ * No backdrop blur: blurring a canvas that changes every frame costs the
10
+ * GPU every frame.
11
+ */
12
+ export const METER_STYLE = " .meter { --swf2es-meter-fill: var(--swf2es-meter-background, Canvas);" +
13
+ " position: absolute; top: 6px; left: 6px; z-index: 3; display: grid;" +
14
+ " grid-template-columns: max-content max-content; gap: 0 8px; box-sizing: border-box;" +
15
+ " max-width: calc(100% - 12px); max-height: calc(100% - 12px); overflow: hidden;" +
16
+ " margin: 0; padding: 3px 7px;" +
17
+ " font: var(--swf2es-meter-font, 11px/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);" +
18
+ " font-variant-numeric: tabular-nums; color-scheme: light dark;" +
19
+ " color: var(--swf2es-meter-color, CanvasText);" +
20
+ " background: color-mix(in srgb, var(--swf2es-meter-fill)" +
21
+ " clamp(0%, calc(var(--swf2es-meter-opacity, 0.7) * 100%), 100%), transparent);" +
22
+ " border: 1px solid color-mix(in srgb, var(--swf2es-meter-border, GrayText) 50%, transparent);" +
23
+ " border-radius: 4px;" +
24
+ " text-shadow: 1px 0 0 var(--swf2es-meter-fill), -1px 0 0 var(--swf2es-meter-fill)," +
25
+ " 0 1px 0 var(--swf2es-meter-fill), 0 -1px 0 var(--swf2es-meter-fill)," +
26
+ " 0 0 2px var(--swf2es-meter-fill);" +
27
+ " pointer-events: none; user-select: none }" +
28
+ " .meter[data-corner$=right] { left: auto; right: 6px }" +
29
+ " .meter[data-corner^=bottom] { top: auto; bottom: 6px }" +
30
+ " .meter[hidden], .meter > div[hidden] { display: none }" +
31
+ " .meter > div { display: contents }" +
32
+ " .meter dt { color: var(--swf2es-meter-muted, color-mix(in srgb, CanvasText 70%, Canvas)) }" +
33
+ " .meter dd { margin: 0; text-align: right }" +
34
+ // High contrast drops text-shadow, the halo the figures need over a box the SWF shows through.
35
+ " @media (forced-colors: active) { .meter { --swf2es-meter-opacity: 1 } }";
36
+ /** Each figure's name, in the dd's `data-figure`, and its label. */
37
+ const FIGURES = [
38
+ ["fps", "fps"],
39
+ ["frame", "frame"],
40
+ ["sub-draws", "sub-draws"],
41
+ ["gl-calls", "GL calls"],
42
+ ["heap", "JS heap"],
43
+ ["codegen", "codegen"],
44
+ ["native", "native"],
45
+ ];
46
+ /**
47
+ * The draw functions counted, each with where its count of draws is: -1 for
48
+ * one, else the index of its last argument, a multi-draw's drawcount.
49
+ */
50
+ const DRAWS = [
51
+ ["drawArrays", -1],
52
+ ["drawElements", -1],
53
+ ["drawArraysInstanced", -1],
54
+ ["drawElementsInstanced", -1],
55
+ ];
56
+ const MULTI_DRAWS = [
57
+ ["multiDrawArraysWEBGL", 5],
58
+ ["multiDrawElementsWEBGL", 6],
59
+ ["multiDrawArraysInstancedWEBGL", 7],
60
+ ["multiDrawElementsInstancedWEBGL", 8],
61
+ ];
62
+ /** The calls of the loop kept: a second's at 500 a second, more than any display's rate. */
63
+ const KEPT = 512;
64
+ /** The span the figures cover, and how often they are shown, in ms. */
65
+ const SPAN = 1000;
66
+ const EVERY = 500;
67
+ const MB = 1024 * 1024;
68
+ /** Where the viewer's choice is kept for every element of the origin, "1" for on. */
69
+ const STORED = "swf2es.performanceMeter";
70
+ /** Where the viewer's choice of corner is kept, likewise. */
71
+ const STORED_CORNER = "swf2es.performanceMeterCorner";
72
+ /** The element's corners the meter may sit in, in the order the context menu moves it through. */
73
+ export const METER_CORNERS = ["top-left", "top-right", "bottom-left", "bottom-right"];
74
+ export function isMeterCorner(value) {
75
+ return METER_CORNERS.includes(value);
76
+ }
77
+ /** The corner after `corner`, the first after the last. */
78
+ export function nextCorner(corner) {
79
+ return METER_CORNERS[(METER_CORNERS.indexOf(corner) + 1) % METER_CORNERS.length];
80
+ }
81
+ /** The viewer's corner as last kept: top-left where none is, or storage is refused. */
82
+ export function storedCorner() {
83
+ try {
84
+ const corner = localStorage.getItem(STORED_CORNER);
85
+ return isMeterCorner(corner) ? corner : "top-left";
86
+ }
87
+ catch {
88
+ return "top-left";
89
+ }
90
+ }
91
+ export function storeCorner(corner) {
92
+ try {
93
+ if (corner === "top-left") {
94
+ localStorage.removeItem(STORED_CORNER);
95
+ }
96
+ else {
97
+ localStorage.setItem(STORED_CORNER, corner);
98
+ }
99
+ }
100
+ catch {
101
+ // Kept for this page alone.
102
+ }
103
+ }
104
+ /** The viewer's choice as last kept: off where none is, or storage is refused. */
105
+ export function storedMeter() {
106
+ try {
107
+ return localStorage.getItem(STORED) === "1";
108
+ }
109
+ catch {
110
+ return false;
111
+ }
112
+ }
113
+ export function storeMeter(on) {
114
+ try {
115
+ if (on) {
116
+ localStorage.setItem(STORED, "1");
117
+ }
118
+ else {
119
+ localStorage.removeItem(STORED);
120
+ }
121
+ }
122
+ catch {
123
+ // Kept for this page alone.
124
+ }
125
+ }
126
+ /**
127
+ * The draw calls made on a context, counted by wrapping its draw functions
128
+ * only while the meter shows: off, and before a context is given, the
129
+ * context has its own functions back, its canvas none of the counter's
130
+ * listeners, and the count costs nothing. A multi-draw is one call and the
131
+ * draws it makes, as the GPU sees them. The renderer counts neither itself.
132
+ */
133
+ class DrawCounter {
134
+ draws = 0;
135
+ calls = 0;
136
+ gl = null;
137
+ shown = false;
138
+ restores = [];
139
+ /** Count `gl`'s draws, while shown; null for none. */
140
+ attach(gl) {
141
+ if (gl === this.gl) {
142
+ return;
143
+ }
144
+ this.listen(false);
145
+ this.unwrap();
146
+ this.gl = gl;
147
+ if (this.shown) {
148
+ this.listen(true);
149
+ this.wrap();
150
+ }
151
+ }
152
+ show(shown) {
153
+ if (shown === this.shown) {
154
+ return;
155
+ }
156
+ this.shown = shown;
157
+ this.listen(shown);
158
+ if (shown) {
159
+ this.wrap();
160
+ }
161
+ else {
162
+ this.unwrap();
163
+ }
164
+ }
165
+ /** Hear the context lost and given back, or no longer. */
166
+ listen(on) {
167
+ const canvas = this.gl?.canvas;
168
+ if (!canvas) {
169
+ return;
170
+ }
171
+ if (on) {
172
+ canvas.addEventListener("webglcontextlost", this.lost);
173
+ canvas.addEventListener("webglcontextrestored", this.restored);
174
+ }
175
+ else {
176
+ canvas.removeEventListener("webglcontextlost", this.lost);
177
+ canvas.removeEventListener("webglcontextrestored", this.restored);
178
+ }
179
+ }
180
+ lost = () => this.unwrap();
181
+ // The renderer's own listener, added before this one, has fetched the extensions anew.
182
+ restored = () => this.wrap();
183
+ wrap() {
184
+ const gl = this.gl;
185
+ this.unwrap();
186
+ if (!gl || !this.shown || gl.isContextLost()) {
187
+ return;
188
+ }
189
+ for (const [name, drawcount] of DRAWS) {
190
+ this.patch(gl, name, drawcount);
191
+ }
192
+ const multi = gl.getExtension("WEBGL_multi_draw");
193
+ if (multi) {
194
+ for (const [name, drawcount] of MULTI_DRAWS) {
195
+ this.patch(multi, name, drawcount);
196
+ }
197
+ }
198
+ }
199
+ unwrap() {
200
+ for (const restore of this.restores.splice(0)) {
201
+ restore();
202
+ }
203
+ }
204
+ /**
205
+ * Wrap `target[name]`, to be put back as it was, a property of its own or
206
+ * its prototype's: with as many arguments as the widest multi-draw takes,
207
+ * the rest undefined, which WebGL ignores, so that a draw allocates no
208
+ * array of its arguments.
209
+ */
210
+ patch(target, name, drawcount) {
211
+ const functions = target;
212
+ const original = functions[name];
213
+ if (typeof original !== "function") {
214
+ return;
215
+ }
216
+ const own = Object.getOwnPropertyDescriptor(target, name);
217
+ functions[name] = (a, b, c, d, e, f, g, h, i) => {
218
+ this.calls++;
219
+ this.draws +=
220
+ drawcount === 5
221
+ ? f
222
+ : drawcount === 6
223
+ ? g
224
+ : drawcount === 7
225
+ ? h
226
+ : drawcount === 8
227
+ ? i
228
+ : 1;
229
+ return original.call(target, a, b, c, d, e, f, g, h, i);
230
+ };
231
+ this.restores.push(() => {
232
+ if (own) {
233
+ Object.defineProperty(target, name, own);
234
+ }
235
+ else {
236
+ delete functions[name];
237
+ }
238
+ });
239
+ }
240
+ }
241
+ export class PerformanceMeter {
242
+ memory;
243
+ root;
244
+ cells = new Map();
245
+ shown = false;
246
+ /** Whether a player plays, whose frames the meter hears. */
247
+ playing = false;
248
+ timer;
249
+ counter = new DrawCounter();
250
+ /** The loop's last KEPT calls, a ring: each one's time, frames played, and ms (-1 for no work). */
251
+ times = new Float64Array(KEPT);
252
+ frames = new Float64Array(KEPT);
253
+ costs = new Float64Array(KEPT);
254
+ sorted = new Float64Array(KEPT);
255
+ next = 0;
256
+ count = 0;
257
+ /** When the calls counted began: shown, or a SWF started, whichever came last. */
258
+ since = 0;
259
+ /** The SWF's frame rate as of the last call, 0 before one. */
260
+ rate = 0;
261
+ /** The draws, and the calls that made them, of the frames that drew since the last showing. */
262
+ draws = 0;
263
+ calls = 0;
264
+ drawnFrames = 0;
265
+ /** Shown in `parent`, the element's shadow root; `memory` is the element's wasmMemory. */
266
+ constructor(parent, memory) {
267
+ this.memory = memory;
268
+ this.root = document.createElement("dl");
269
+ this.root.className = "meter";
270
+ this.root.dataset.corner = "top-left";
271
+ this.root.hidden = true;
272
+ this.root.setAttribute("aria-label", "Performance");
273
+ for (const [name, label] of FIGURES) {
274
+ const row = document.createElement("div");
275
+ const dt = document.createElement("dt");
276
+ dt.textContent = label;
277
+ const dd = document.createElement("dd");
278
+ dd.dataset.figure = name;
279
+ dd.textContent = "–";
280
+ row.append(dt, dd);
281
+ this.root.append(row);
282
+ this.cells.set(name, dd);
283
+ }
284
+ parent.appendChild(this.root);
285
+ }
286
+ /** Put the meter in `corner` of the element. */
287
+ place(corner) {
288
+ this.root.dataset.corner = corner;
289
+ }
290
+ /** Show the meter and measure, or hide it and stop. */
291
+ show(on) {
292
+ if (on === this.shown) {
293
+ return;
294
+ }
295
+ this.shown = on;
296
+ this.root.hidden = !on;
297
+ this.counter.show(on);
298
+ if (on) {
299
+ this.reset();
300
+ }
301
+ this.tick();
302
+ }
303
+ /** A player begun, drawing with `gl`, or none playing: what was counted before is let go. */
304
+ attach(gl, playing) {
305
+ this.counter.attach(gl);
306
+ this.playing = playing;
307
+ this.reset();
308
+ this.tick();
309
+ }
310
+ /** The timer runs while the meter shows a player's figures; it shows them at once as it starts. */
311
+ tick() {
312
+ const run = this.shown && this.playing;
313
+ if (run && this.timer === undefined) {
314
+ this.timer = setInterval(this.update, EVERY);
315
+ }
316
+ else if (!run && this.timer !== undefined) {
317
+ clearInterval(this.timer);
318
+ this.timer = undefined;
319
+ }
320
+ if (this.shown) {
321
+ this.update();
322
+ }
323
+ }
324
+ reset() {
325
+ this.next = this.count = 0;
326
+ this.since = performance.now();
327
+ this.rate = 0;
328
+ this.counter.draws = this.counter.calls = 0;
329
+ this.draws = this.calls = this.drawnFrames = 0;
330
+ this.text("sub-draws", "–");
331
+ this.text("gl-calls", "–");
332
+ }
333
+ /** Each call of the player's loop, kept in the ring without allocating. */
334
+ heard = (stats) => {
335
+ const i = this.next;
336
+ this.next = i + 1 === KEPT ? 0 : i + 1;
337
+ if (this.count < KEPT) {
338
+ this.count++;
339
+ }
340
+ this.times[i] = stats.time;
341
+ this.frames[i] = stats.frames;
342
+ this.costs[i] = stats.frames > 0 || stats.drew ? stats.play + stats.draw : -1;
343
+ this.rate = stats.frameRate;
344
+ // What the context was asked since the last call belongs to the frame this one drew.
345
+ if (stats.drew && this.counter.calls > 0) {
346
+ this.draws += this.counter.draws;
347
+ this.calls += this.counter.calls;
348
+ this.drawnFrames++;
349
+ }
350
+ this.counter.draws = this.counter.calls = 0;
351
+ };
352
+ update = () => {
353
+ const now = performance.now();
354
+ const from = Math.max(now - SPAN, this.since);
355
+ let played = 0;
356
+ let working = 0;
357
+ // From the newest back, to the span's start.
358
+ for (let k = 0, i = this.next; k < this.count; k++) {
359
+ i = i === 0 ? KEPT - 1 : i - 1;
360
+ if (this.times[i] < from) {
361
+ break;
362
+ }
363
+ played += this.frames[i];
364
+ if (this.costs[i] >= 0) {
365
+ this.insert(working++, this.costs[i]);
366
+ }
367
+ }
368
+ const span = now - from;
369
+ const playing = this.playing && this.rate > 0;
370
+ this.text("fps", playing && span >= EVERY / 2
371
+ ? `${((played * 1000) / span).toFixed(1)} / ${rateText(this.rate)}`
372
+ : "–");
373
+ this.text("frame", playing && working > 0
374
+ ? `${median(this.sorted, working).toFixed(1)} ms, max ${this.sorted[working - 1].toFixed(1)}`
375
+ : "–");
376
+ // A still stage draws nothing: the last frame drawn stands.
377
+ if (this.drawnFrames > 0) {
378
+ this.text("sub-draws", String(Math.round(this.draws / this.drawnFrames)));
379
+ this.text("gl-calls", String(Math.round(this.calls / this.drawnFrames)));
380
+ }
381
+ const heap = performance.memory;
382
+ const heapRow = this.cells.get("heap")?.parentElement;
383
+ if (heapRow) {
384
+ heapRow.hidden = !heap;
385
+ }
386
+ if (heap) {
387
+ this.text("heap", megabytes(heap.usedJSHeapSize));
388
+ }
389
+ const wasm = this.memory();
390
+ this.text("codegen", wasm.codegen > 0 ? megabytes(wasm.codegen) : "–");
391
+ this.text("native", megabytes(wasm.native));
392
+ this.draws = this.calls = this.drawnFrames = 0;
393
+ };
394
+ text(figure, text) {
395
+ const cell = this.cells.get(figure);
396
+ if (cell && cell.textContent !== text) {
397
+ cell.textContent = text;
398
+ }
399
+ }
400
+ /** Put `cost` among the first `n` sorted, by insertion: a second's few hundred, twice a second. */
401
+ insert(n, cost) {
402
+ const sorted = this.sorted;
403
+ let j = n;
404
+ while (j > 0 && sorted[j - 1] > cost) {
405
+ sorted[j] = sorted[j - 1];
406
+ j--;
407
+ }
408
+ sorted[j] = cost;
409
+ }
410
+ }
411
+ function median(sorted, n) {
412
+ const middle = n >> 1;
413
+ return n % 2 === 1 ? sorted[middle] : (sorted[middle - 1] + sorted[middle]) / 2;
414
+ }
415
+ /** A frame rate as a SWF declares it, whole or to the hundredth: its 8.8 fixed point. */
416
+ function rateText(rate) {
417
+ return `${Number.isInteger(rate) ? rate : Number(rate.toFixed(2))} fps`;
418
+ }
419
+ function megabytes(bytes) {
420
+ return `${(bytes / MB).toFixed(bytes < 10 * MB ? 1 : 0)} MB`;
421
+ }
422
+ //# sourceMappingURL=meter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meter.js","sourceRoot":"","sources":["../src/meter.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,WAAW,GACtB,wEAAwE;IACxE,sEAAsE;IACtE,sFAAsF;IACtF,iFAAiF;IACjF,+BAA+B;IAC/B,sGAAsG;IACtG,gEAAgE;IAChE,gDAAgD;IAChD,0DAA0D;IAC1D,gFAAgF;IAChF,+FAA+F;IAC/F,sBAAsB;IACtB,oFAAoF;IACpF,uEAAuE;IACvE,oCAAoC;IACpC,4CAA4C;IAC5C,wDAAwD;IACxD,yDAAyD;IACzD,yDAAyD;IACzD,qCAAqC;IACrC,6FAA6F;IAC7F,6CAA6C;IAC7C,+FAA+F;IAC/F,0EAA0E,CAAC;AAE7E,oEAAoE;AACpE,MAAM,OAAO,GAAG;IACd,CAAC,KAAK,EAAE,KAAK,CAAC;IACd,CAAC,OAAO,EAAE,OAAO,CAAC;IAClB,CAAC,WAAW,EAAE,WAAW,C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AC,KAAK,CAAC;AAC/D,CAAC"}
@@ -10,6 +10,33 @@ export interface Look {
10
10
  /** The background the page gives, 0xRRGGBB, in place of the SWF's. */
11
11
  bgcolor: number | null;
12
12
  }
13
+ /**
14
+ * What the player did in one call of its loop, as a frame listener hears it
15
+ * (`Swf2esPlayerElement.frameListener`): a call each animation frame, or
16
+ * from the timer that plays a hidden page's frames.
17
+ */
18
+ export interface FrameStats {
19
+ /** The call's time, by performance.now()'s clock: the animation frame's, or the timer's. */
20
+ time: number;
21
+ /** The SWF's frames it played: none where the display's frame fell between two of the SWF's. */
22
+ frames: number;
23
+ /** The SWF's frame rate as it played them, which a script may change. */
24
+ frameRate: number;
25
+ /** The ms the frames took: their scripts, events, timeline and sound, the SWF's own work. */
26
+ play: number;
27
+ /**
28
+ * The ms the rest of the call took on the CPU where it drew: drawing the stage, the GPU's own
29
+ * work aside, and the little before it (the text input's focus kept, the samples chosen anew
30
+ * for a changed quality); 0 where it did not draw.
31
+ */
32
+ draw: number;
33
+ /** Whether it drew the stage: a coarse clock may time a short drawing as 0 ms. */
34
+ drew: boolean;
35
+ /** Whether it was an animation frame, which draws, rather than the timer, which never does. */
36
+ shown: boolean;
37
+ }
38
+ /** Hears what the player did in each call of its loop, given the same object each time. */
39
+ export type FrameListener = (stats: FrameStats) => void;
13
40
  export declare class Playback {
14
41
  private readonly box;
15
42
  private readonly player;
@@ -18,6 +45,14 @@ export declare class Playback {
18
45
  private readonly look;
19
46
  private readonly report;
20
47
  private readonly stage3D;
48
+ /**
49
+ * Told after every call of the loop, while set: one listener, which
50
+ * another replaces; unset, the loop measures nothing for it. Its time is
51
+ * not the player's: the frames' pacing counts only the frames' own.
52
+ */
53
+ onFrame: FrameListener | null;
54
+ /** What onFrame hears, filled anew for each call. */
55
+ private readonly stats;
21
56
  private frame;
22
57
  private last;
23
58
  /**
@@ -77,6 +112,8 @@ export declare class Playback {
77
112
  */
78
113
  private readonly idle;
79
114
  private step;
115
+ /** Tell `listener` of the call that began at `start`, its frames' part `this.busy`. */
116
+ private told;
80
117
  /**
81
118
  * Drawn by the stage's quality as a script or the page changes it:
82
119
  * Flash's low draws edges aliased and smooths no bitmap; medium, high and
@@ -1 +1 @@
1
- {"version":3,"file":"playback.d.ts","sourceRoot":"","sources":["../src/playback.ts"],"names":[],"mappings":"AAIA,OAAO,EAIL,KAAK,MAAM,EACX,KAAK,SAAS,EAEf,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAGL,KAAK,SAAS,EAIf,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,6EAA6E;AAC7E,MAAM,WAAW,IAAI;IACnB,KAAK,EAAE,SAAS,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,kFAAkF;IAClF,KAAK,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,qBAAa,QAAQ;IA+BjB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO;IApC1B,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,IAAI,CAAuB;IACnC;;;;OAIG;IACH,OAAO,CAAC,IAAI,CAAK;IACjB,OAAO,CAAC,KAAK,CAAM;IACnB,0GAA0G;IAC1G,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,GAAG,CAAK;IAChB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;IAC7C,4FAA4F;IAC5F,OAAO,CAAC,QAAQ,CAAC,SA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