@swf2es/render 0.1.33 → 0.1.35
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/commands.d.ts +11 -2
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +36 -6
- package/dist/commands.js.map +1 -1
- package/dist/geometry.d.ts +62 -5
- package/dist/geometry.d.ts.map +1 -1
- package/dist/geometry.js +100 -17
- package/dist/geometry.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/measure.d.ts.map +1 -1
- package/dist/measure.js +118 -61
- package/dist/measure.js.map +1 -1
- package/dist/plan.js +4 -4
- package/dist/plan.js.map +1 -1
- package/dist/registry.d.ts +4 -0
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +8 -0
- package/dist/registry.js.map +1 -1
- package/dist/rows.d.ts +8 -0
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +78 -9
- package/dist/rows.js.map +1 -1
- package/dist/scene.d.ts +13 -0
- package/dist/scene.d.ts.map +1 -1
- package/dist/scene.js +73 -0
- package/dist/scene.js.map +1 -1
- package/dist/spans.d.ts +27 -0
- package/dist/spans.d.ts.map +1 -0
- package/dist/spans.js +146 -0
- package/dist/spans.js.map +1 -0
- package/dist/webgl/atlas.d.ts +83 -18
- package/dist/webgl/atlas.d.ts.map +1 -1
- package/dist/webgl/atlas.js +271 -110
- package/dist/webgl/atlas.js.map +1 -1
- package/dist/webgl/backend.d.ts +5 -3
- package/dist/webgl/backend.d.ts.map +1 -1
- package/dist/webgl/backend.js +9 -9
- package/dist/webgl/backend.js.map +1 -1
- package/dist/webgl/batches.d.ts +36 -11
- package/dist/webgl/batches.d.ts.map +1 -1
- package/dist/webgl/batches.js +94 -51
- package/dist/webgl/batches.js.map +1 -1
- package/dist/webgl/draws.js +2 -2
- package/dist/webgl/draws.js.map +1 -1
- package/package.json +2 -2
- package/src/commands.ts +48 -6
- package/src/geometry.ts +109 -19
- package/src/index.ts +2 -0
- package/src/measure.ts +132 -68
- package/src/plan.ts +4 -4
- package/src/registry.ts +10 -0
- package/src/rows.ts +85 -18
- package/src/scene.ts +82 -0
- package/src/spans.ts +223 -0
- package/src/webgl/atlas.ts +321 -120
- package/src/webgl/backend.ts +9 -9
- package/src/webgl/batches.ts +108 -57
- package/src/webgl/draws.ts +2 -2
package/src/rows.ts
CHANGED
|
@@ -6,6 +6,11 @@
|
|
|
6
6
|
export const ROW_FLOATS = 16;
|
|
7
7
|
/** Rows a line of the rows' texture. */
|
|
8
8
|
export const ROWS_A_LINE = 256;
|
|
9
|
+
/**
|
|
10
|
+
* Floats of a span from which Rows.append copies through a view: below
|
|
11
|
+
* it, copying by index costs less than making the view.
|
|
12
|
+
*/
|
|
13
|
+
const SPAN_VIEW_FLOATS = 4 * ROW_FLOATS;
|
|
9
14
|
|
|
10
15
|
/** The rows of a frame's draws, written in order and uploaded together. */
|
|
11
16
|
export class Rows {
|
|
@@ -17,25 +22,75 @@ export class Rows {
|
|
|
17
22
|
this.count = 0;
|
|
18
23
|
}
|
|
19
24
|
|
|
25
|
+
/** The rows from `count` on taken off, as rows written only to be compared are. */
|
|
26
|
+
truncate(count: number): void {
|
|
27
|
+
this.count = count;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Rows `first` to `end` of `from` written after these, as they were: the index of the first. */
|
|
31
|
+
append(from: Rows, first: number, end: number): number {
|
|
32
|
+
const row = this.count;
|
|
33
|
+
this.count += end - first;
|
|
34
|
+
if (this.count * ROW_FLOATS > this.data.length) {
|
|
35
|
+
let length = this.data.length * 2;
|
|
36
|
+
while (this.count * ROW_FLOATS > length) {
|
|
37
|
+
length *= 2;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const grown = new Float32Array(length);
|
|
41
|
+
grown.set(this.data.subarray(0, row * ROW_FLOATS));
|
|
42
|
+
this.data = grown;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// A short span by index, as a view to copy from would be an allocation each span; a long one
|
|
46
|
+
// through the view, which copies it much faster.
|
|
47
|
+
const source = from.data;
|
|
48
|
+
const data = this.data;
|
|
49
|
+
const start = first * ROW_FLOATS;
|
|
50
|
+
const last = end * ROW_FLOATS;
|
|
51
|
+
if (last - start < SPAN_VIEW_FLOATS) {
|
|
52
|
+
for (let i = start, to = row * ROW_FLOATS; i < last; i++, to++) {
|
|
53
|
+
data[to] = source[i];
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
data.set(source.subarray(start, last), row * ROW_FLOATS);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return row;
|
|
60
|
+
}
|
|
61
|
+
|
|
20
62
|
/**
|
|
21
63
|
* A row for the transform at `places[at]`, a b c d tx ty: numbers a
|
|
22
64
|
* caller keeps in a typed array, so that none are boxed passing them.
|
|
23
65
|
*/
|
|
24
66
|
addPlaced(places: Float64Array, at: number, ct: ColorRow | null): number {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
67
|
+
// Written here, not passed to add, which would box them where it is not inlined.
|
|
68
|
+
const row = this.next();
|
|
69
|
+
const out = this.data;
|
|
70
|
+
const to = row * ROW_FLOATS;
|
|
71
|
+
out[to] = places[at];
|
|
72
|
+
out[to + 1] = places[at + 1];
|
|
73
|
+
out[to + 2] = places[at + 2];
|
|
74
|
+
out[to + 3] = places[at + 3];
|
|
75
|
+
out[to + 4] = places[at + 4];
|
|
76
|
+
out[to + 5] = places[at + 5];
|
|
77
|
+
this.color(to, ct);
|
|
78
|
+
return row;
|
|
34
79
|
}
|
|
35
80
|
|
|
36
81
|
/** A row for the translation of the transform at `places[at]` alone. */
|
|
37
82
|
addTranslated(places: Float64Array, at: number, ct: ColorRow | null): number {
|
|
38
|
-
|
|
83
|
+
const row = this.next();
|
|
84
|
+
const out = this.data;
|
|
85
|
+
const to = row * ROW_FLOATS;
|
|
86
|
+
out[to] = 1;
|
|
87
|
+
out[to + 1] = 0;
|
|
88
|
+
out[to + 2] = 0;
|
|
89
|
+
out[to + 3] = 1;
|
|
90
|
+
out[to + 4] = places[at + 4];
|
|
91
|
+
out[to + 5] = places[at + 5];
|
|
92
|
+
this.color(to, ct);
|
|
93
|
+
return row;
|
|
39
94
|
}
|
|
40
95
|
|
|
41
96
|
/**
|
|
@@ -51,13 +106,7 @@ export class Rows {
|
|
|
51
106
|
ty: number,
|
|
52
107
|
ct: ColorRow | null,
|
|
53
108
|
): number {
|
|
54
|
-
const row = this.
|
|
55
|
-
if (this.count * ROW_FLOATS > this.data.length) {
|
|
56
|
-
const grown = new Float32Array(this.data.length * 2);
|
|
57
|
-
grown.set(this.data);
|
|
58
|
-
this.data = grown;
|
|
59
|
-
}
|
|
60
|
-
|
|
109
|
+
const row = this.next();
|
|
61
110
|
const out = this.data;
|
|
62
111
|
const at = row * ROW_FLOATS;
|
|
63
112
|
out[at] = a;
|
|
@@ -66,6 +115,25 @@ export class Rows {
|
|
|
66
115
|
out[at + 3] = d;
|
|
67
116
|
out[at + 4] = tx;
|
|
68
117
|
out[at + 5] = ty;
|
|
118
|
+
this.color(at, ct);
|
|
119
|
+
return row;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** A row taken, the store grown for it: its index. */
|
|
123
|
+
private next(): number {
|
|
124
|
+
const row = this.count++;
|
|
125
|
+
if (this.count * ROW_FLOATS > this.data.length) {
|
|
126
|
+
const grown = new Float32Array(this.data.length * 2);
|
|
127
|
+
grown.set(this.data);
|
|
128
|
+
this.data = grown;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return row;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** The row at `data[at]` coloured by `ct`, or by nothing where it is null. */
|
|
135
|
+
private color(at: number, ct: ColorRow | null): void {
|
|
136
|
+
const out = this.data;
|
|
69
137
|
out[at + 6] = 0;
|
|
70
138
|
out[at + 7] = 0;
|
|
71
139
|
out[at + 8] = ct ? ct.rMul : 1;
|
|
@@ -76,7 +144,6 @@ export class Rows {
|
|
|
76
144
|
out[at + 13] = ct ? ct.gAdd / 255 : 0;
|
|
77
145
|
out[at + 14] = ct ? ct.bAdd / 255 : 0;
|
|
78
146
|
out[at + 15] = ct ? ct.aAdd / 255 : 0;
|
|
79
|
-
return row;
|
|
80
147
|
}
|
|
81
148
|
}
|
|
82
149
|
|
package/src/scene.ts
CHANGED
|
@@ -145,6 +145,12 @@ export const NO_WHOLE = 0;
|
|
|
145
145
|
export const WHOLE_SMOOTH = 1;
|
|
146
146
|
export const WHOLE_ALIASED = 2;
|
|
147
147
|
|
|
148
|
+
/**
|
|
149
|
+
* Draws of a span from which SceneList.appendDraws copies its columns
|
|
150
|
+
* through views: below it, copying by index costs less than making them.
|
|
151
|
+
*/
|
|
152
|
+
const SPAN_VIEW_DRAWS = 64;
|
|
153
|
+
|
|
148
154
|
/**
|
|
149
155
|
* A frame's drawing in order: each entry a geometry drawn under a row with
|
|
150
156
|
* a blend mode, and the texture it samples (-1 for none) and how. Boundaries
|
|
@@ -206,6 +212,82 @@ export class SceneList {
|
|
|
206
212
|
this.push(DRAW, geometry, row, blend, texture, sampler);
|
|
207
213
|
}
|
|
208
214
|
|
|
215
|
+
/**
|
|
216
|
+
* Entries `first` to `end` of `from`, draws alone, written after these as
|
|
217
|
+
* they were, each naming its row `rowShift` on: a span a frame before
|
|
218
|
+
* wrote, its rows put elsewhere (docs/renderer.md, "Spans"). A boundary
|
|
219
|
+
* names layers and draws by number, which a span does not move yet.
|
|
220
|
+
*/
|
|
221
|
+
appendDraws(from: SceneList, first: number, end: number, rowShift: number): void {
|
|
222
|
+
const at = this.length;
|
|
223
|
+
const length = at + end - first;
|
|
224
|
+
while (length > this.geometry.length) {
|
|
225
|
+
this.geometry = grow(this.geometry);
|
|
226
|
+
this.row = grow(this.row);
|
|
227
|
+
this.blend = grow(this.blend);
|
|
228
|
+
this.texture = grow(this.texture);
|
|
229
|
+
this.sampler = grow(this.sampler);
|
|
230
|
+
this.kind = grow(this.kind);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const kinds = from.kind;
|
|
234
|
+
const rows = from.row;
|
|
235
|
+
const kind = this.kind;
|
|
236
|
+
const row = this.row;
|
|
237
|
+
if (end - first >= SPAN_VIEW_DRAWS) {
|
|
238
|
+
// A long span's other columns through views, which copy them much faster than by index.
|
|
239
|
+
for (let e = first, to = at; e < end; e++, to++) {
|
|
240
|
+
if (kinds[e] !== DRAW) {
|
|
241
|
+
throw new Error(`entry ${e} of a span is no draw, which a span cannot move`);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
kind[to] = DRAW;
|
|
245
|
+
row[to] = rows[e] + rowShift;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
this.geometry.set(from.geometry.subarray(first, end), at);
|
|
249
|
+
this.blend.set(from.blend.subarray(first, end), at);
|
|
250
|
+
this.texture.set(from.texture.subarray(first, end), at);
|
|
251
|
+
this.sampler.set(from.sampler.subarray(first, end), at);
|
|
252
|
+
this.length = length;
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// Column by column, by index: a view of each to copy whole was most of what a frame of
|
|
257
|
+
// spans allocated, most spans being short.
|
|
258
|
+
const geometries = from.geometry;
|
|
259
|
+
const blends = from.blend;
|
|
260
|
+
const textures = from.texture;
|
|
261
|
+
const samplers = from.sampler;
|
|
262
|
+
const geometry = this.geometry;
|
|
263
|
+
const blend = this.blend;
|
|
264
|
+
const texture = this.texture;
|
|
265
|
+
const sampler = this.sampler;
|
|
266
|
+
for (let e = first, to = at; e < end; e++, to++) {
|
|
267
|
+
if (kinds[e] !== DRAW) {
|
|
268
|
+
throw new Error(`entry ${e} of a span is no draw, which a span cannot move`);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
kind[to] = DRAW;
|
|
272
|
+
row[to] = rows[e] + rowShift;
|
|
273
|
+
geometry[to] = geometries[e];
|
|
274
|
+
blend[to] = blends[e];
|
|
275
|
+
texture[to] = textures[e];
|
|
276
|
+
sampler[to] = samplers[e];
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
this.length = length;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* The entries from `length` on taken off, as draws written only to be
|
|
284
|
+
* compared are: draws alone, as a layer begun among them would stay
|
|
285
|
+
* counted.
|
|
286
|
+
*/
|
|
287
|
+
truncate(length: number): void {
|
|
288
|
+
this.length = length;
|
|
289
|
+
}
|
|
290
|
+
|
|
209
291
|
/**
|
|
210
292
|
* A layer begun, padded for its filters (or -1), over whole units as
|
|
211
293
|
* `whole` says (wholes), drawn as a layer whatever it holds where
|
package/src/spans.ts
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
// Spans of a scene list compared (docs/renderer.md, "Spans"): the view's
|
|
2
|
+
// checked mode walks what a span it kept from a frame before stands for,
|
|
3
|
+
// and has this say, entry for entry and row for row, where the two differ.
|
|
4
|
+
import { ROW_FLOATS, type Rows } from "./rows.js";
|
|
5
|
+
import {
|
|
6
|
+
BLEND_NAMES,
|
|
7
|
+
DRAW,
|
|
8
|
+
KEPT,
|
|
9
|
+
LAYER_BEGIN,
|
|
10
|
+
LAYER_END,
|
|
11
|
+
MASK_BEGIN,
|
|
12
|
+
MASK_POP,
|
|
13
|
+
MASK_USE,
|
|
14
|
+
type SceneList,
|
|
15
|
+
} from "./scene.js";
|
|
16
|
+
|
|
17
|
+
/** A stretch of a scene list's entries, and of the rows they name, that one subtree wrote. */
|
|
18
|
+
export interface Span {
|
|
19
|
+
first: number;
|
|
20
|
+
end: number;
|
|
21
|
+
rowsFirst: number;
|
|
22
|
+
rowsEnd: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** A row's floats by name (rows.ts), the two after the translation unused. */
|
|
26
|
+
const ROW_NAMES = [
|
|
27
|
+
"a",
|
|
28
|
+
"b",
|
|
29
|
+
"c",
|
|
30
|
+
"d",
|
|
31
|
+
"tx",
|
|
32
|
+
"ty",
|
|
33
|
+
"pad 6",
|
|
34
|
+
"pad 7",
|
|
35
|
+
"rMul",
|
|
36
|
+
"gMul",
|
|
37
|
+
"bMul",
|
|
38
|
+
"aMul",
|
|
39
|
+
"rAdd",
|
|
40
|
+
"gAdd",
|
|
41
|
+
"bAdd",
|
|
42
|
+
"aAdd",
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
const KIND_NAMES: Record<number, string> = {
|
|
46
|
+
[DRAW]: "draw",
|
|
47
|
+
[MASK_BEGIN]: "mask begin",
|
|
48
|
+
[MASK_USE]: "mask use",
|
|
49
|
+
[MASK_POP]: "mask pop",
|
|
50
|
+
[LAYER_BEGIN]: "layer begin",
|
|
51
|
+
[LAYER_END]: "layer end",
|
|
52
|
+
[KEPT]: "kept layer",
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/** Whether two floats differ, NaN equal to itself, as the same sums make it. */
|
|
56
|
+
function differ(x: number, y: number): boolean {
|
|
57
|
+
return x !== y && !(Number.isNaN(x) && Number.isNaN(y));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Entry `e` of `scene` in words, its row from `rowsFirst` as the span counts it. */
|
|
61
|
+
function entry(scene: SceneList, e: number, rowsFirst: number): string {
|
|
62
|
+
const kind = scene.kind[e];
|
|
63
|
+
const row = scene.row[e];
|
|
64
|
+
const blend = scene.blend[e];
|
|
65
|
+
return `${KIND_NAMES[kind] ?? `kind ${kind}`} of geometry ${scene.geometry[e]}, row ${
|
|
66
|
+
kind === DRAW ? `${row - rowsFirst} of the span` : row
|
|
67
|
+
}, blend ${BLEND_NAMES[blend] ?? blend}, texture ${scene.texture[e]}, sampler ${scene.sampler[e]}`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Whether entry `i` of span `a` and of span `b` differ, their rows counted from each span's first. */
|
|
71
|
+
function entriesDiffer(
|
|
72
|
+
aScene: SceneList,
|
|
73
|
+
i: number,
|
|
74
|
+
a: Span,
|
|
75
|
+
bScene: SceneList,
|
|
76
|
+
j: number,
|
|
77
|
+
b: Span,
|
|
78
|
+
): boolean {
|
|
79
|
+
const kind = aScene.kind[i];
|
|
80
|
+
return (
|
|
81
|
+
kind !== bScene.kind[j] ||
|
|
82
|
+
aScene.geometry[i] !== bScene.geometry[j] ||
|
|
83
|
+
(kind === DRAW
|
|
84
|
+
? aScene.row[i] - a.rowsFirst !== bScene.row[j] - b.rowsFirst
|
|
85
|
+
: aScene.row[i] !== bScene.row[j]) ||
|
|
86
|
+
aScene.blend[i] !== bScene.blend[j] ||
|
|
87
|
+
aScene.texture[i] !== bScene.texture[j] ||
|
|
88
|
+
aScene.sampler[i] !== bScene.sampler[j]
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The first entry and the first row, counted from each span's first, at
|
|
94
|
+
* which spans `a` and `b` differ, or -1 for none; past the shorter's end
|
|
95
|
+
* where only their lengths do.
|
|
96
|
+
*/
|
|
97
|
+
export function firstDifference(
|
|
98
|
+
aScene: SceneList,
|
|
99
|
+
aRows: Rows,
|
|
100
|
+
a: Span,
|
|
101
|
+
bScene: SceneList,
|
|
102
|
+
bRows: Rows,
|
|
103
|
+
b: Span,
|
|
104
|
+
): { entry: number; row: number } {
|
|
105
|
+
const entries = Math.min(a.end - a.first, b.end - b.first);
|
|
106
|
+
let entry = a.end - a.first === b.end - b.first ? -1 : entries;
|
|
107
|
+
for (let k = 0; k < entries; k++) {
|
|
108
|
+
if (entriesDiffer(aScene, a.first + k, a, bScene, b.first + k, b)) {
|
|
109
|
+
entry = k;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const rows = Math.min(a.rowsEnd - a.rowsFirst, b.rowsEnd - b.rowsFirst);
|
|
115
|
+
let row = a.rowsEnd - a.rowsFirst === b.rowsEnd - b.rowsFirst ? -1 : rows;
|
|
116
|
+
for (let k = 0; k < rows && (row < 0 || k < row); k++) {
|
|
117
|
+
const i = (a.rowsFirst + k) * ROW_FLOATS;
|
|
118
|
+
const j = (b.rowsFirst + k) * ROW_FLOATS;
|
|
119
|
+
for (let f = 0; f < ROW_FLOATS; f++) {
|
|
120
|
+
if (differ(aRows.data[i + f], bRows.data[j + f])) {
|
|
121
|
+
row = k;
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (row === k) {
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return { entry, row };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Where span `b` of `bScene` and `bRows` draws otherwise than span `a` of
|
|
136
|
+
* `aScene` and `aRows`, in words that name each by `aName` and `bName`:
|
|
137
|
+
* their lengths, their first entry and first row that differ, each in full,
|
|
138
|
+
* and how many do; null where they are alike, entry for entry and row for
|
|
139
|
+
* row. A draw's row is compared as the span counts it, from its first.
|
|
140
|
+
*/
|
|
141
|
+
export function spanDifference(
|
|
142
|
+
aName: string,
|
|
143
|
+
aScene: SceneList,
|
|
144
|
+
aRows: Rows,
|
|
145
|
+
a: Span,
|
|
146
|
+
bName: string,
|
|
147
|
+
bScene: SceneList,
|
|
148
|
+
bRows: Rows,
|
|
149
|
+
b: Span,
|
|
150
|
+
): string | null {
|
|
151
|
+
const entries = a.end - a.first;
|
|
152
|
+
const rows = a.rowsEnd - a.rowsFirst;
|
|
153
|
+
const bEntries = b.end - b.first;
|
|
154
|
+
const bRowCount = b.rowsEnd - b.rowsFirst;
|
|
155
|
+
const told: string[] = [];
|
|
156
|
+
if (entries !== bEntries || rows !== bRowCount) {
|
|
157
|
+
told.push(
|
|
158
|
+
`${aName} has ${entries} entries and ${rows} rows, ${bName} ${bEntries} entries and ${bRowCount} rows`,
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
let firstEntry = -1;
|
|
163
|
+
let entriesOff = 0;
|
|
164
|
+
for (let k = 0; k < Math.min(entries, bEntries); k++) {
|
|
165
|
+
if (entriesDiffer(aScene, a.first + k, a, bScene, b.first + k, b)) {
|
|
166
|
+
entriesOff++;
|
|
167
|
+
if (firstEntry < 0) {
|
|
168
|
+
firstEntry = k;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (firstEntry >= 0) {
|
|
174
|
+
told.push(
|
|
175
|
+
`entry ${firstEntry} of the span (scene entry ${a.first + firstEntry} and ${
|
|
176
|
+
b.first + firstEntry
|
|
177
|
+
}) is a ${entry(aScene, a.first + firstEntry, a.rowsFirst)} in ${aName}, a ${entry(
|
|
178
|
+
bScene,
|
|
179
|
+
b.first + firstEntry,
|
|
180
|
+
b.rowsFirst,
|
|
181
|
+
)} in ${bName}; ${entriesOff} of ${Math.min(entries, bEntries)} entries differ`,
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
let firstRow = -1;
|
|
186
|
+
let rowsOff = 0;
|
|
187
|
+
const fields: string[] = [];
|
|
188
|
+
const aData = aRows.data;
|
|
189
|
+
const bData = bRows.data;
|
|
190
|
+
for (let k = 0; k < Math.min(rows, bRowCount); k++) {
|
|
191
|
+
const i = (a.rowsFirst + k) * ROW_FLOATS;
|
|
192
|
+
const j = (b.rowsFirst + k) * ROW_FLOATS;
|
|
193
|
+
let off = false;
|
|
194
|
+
for (let f = 0; f < ROW_FLOATS; f++) {
|
|
195
|
+
if (differ(aData[i + f], bData[j + f])) {
|
|
196
|
+
off = true;
|
|
197
|
+
if (firstRow < 0) {
|
|
198
|
+
fields.push(`${ROW_NAMES[f]} ${aData[i + f]} against ${bData[j + f]}`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (off) {
|
|
204
|
+
rowsOff++;
|
|
205
|
+
if (firstRow < 0) {
|
|
206
|
+
firstRow = k;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (firstRow >= 0) {
|
|
212
|
+
told.push(
|
|
213
|
+
`row ${firstRow} of the span (row ${a.rowsFirst + firstRow} and ${
|
|
214
|
+
b.rowsFirst + firstRow
|
|
215
|
+
}) has ${fields.join(", ")} in ${aName} and ${bName}; ${rowsOff} of ${Math.min(
|
|
216
|
+
rows,
|
|
217
|
+
bRowCount,
|
|
218
|
+
)} rows differ`,
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return told.length > 0 ? told.join("; ") : null;
|
|
223
|
+
}
|