@swf2es/render 0.1.42 → 0.1.44
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 +26 -5
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +42 -5
- package/dist/commands.js.map +1 -1
- package/dist/filter-shaders.d.ts +2 -2
- package/dist/filter-shaders.d.ts.map +1 -1
- package/dist/filter-shaders.js +7 -4
- package/dist/filter-shaders.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/measure.d.ts +7 -2
- package/dist/measure.d.ts.map +1 -1
- package/dist/measure.js +189 -5
- package/dist/measure.js.map +1 -1
- package/dist/plan.d.ts.map +1 -1
- package/dist/plan.js +8 -4
- package/dist/plan.js.map +1 -1
- package/dist/registry.d.ts +12 -0
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +19 -0
- package/dist/registry.js.map +1 -1
- package/dist/scene.d.ts +35 -4
- package/dist/scene.d.ts.map +1 -1
- package/dist/scene.js +41 -4
- package/dist/scene.js.map +1 -1
- package/dist/webgl/backdrops.d.ts +60 -0
- package/dist/webgl/backdrops.d.ts.map +1 -0
- package/dist/webgl/backdrops.js +130 -0
- package/dist/webgl/backdrops.js.map +1 -0
- package/dist/webgl/backend.d.ts +31 -1
- package/dist/webgl/backend.d.ts.map +1 -1
- package/dist/webgl/backend.js +140 -31
- package/dist/webgl/backend.js.map +1 -1
- package/dist/webgl/composite.d.ts +29 -2
- package/dist/webgl/composite.d.ts.map +1 -1
- package/dist/webgl/composite.js +96 -27
- package/dist/webgl/composite.js.map +1 -1
- package/dist/webgl/draws.d.ts +5 -3
- package/dist/webgl/draws.d.ts.map +1 -1
- package/dist/webgl/draws.js +7 -5
- package/dist/webgl/draws.js.map +1 -1
- package/dist/webgl/holds.d.ts +5 -2
- package/dist/webgl/holds.d.ts.map +1 -1
- package/dist/webgl/holds.js +9 -4
- package/dist/webgl/holds.js.map +1 -1
- package/dist/webgl/programs.d.ts +11 -0
- package/dist/webgl/programs.d.ts.map +1 -1
- package/dist/webgl/programs.js +42 -6
- package/dist/webgl/programs.js.map +1 -1
- package/dist/webgl/targets.d.ts +4 -0
- package/dist/webgl/targets.d.ts.map +1 -1
- package/dist/webgl/targets.js.map +1 -1
- package/package.json +2 -2
- package/src/commands.ts +47 -5
- package/src/filter-shaders.ts +7 -4
- package/src/index.ts +9 -0
- package/src/measure.ts +247 -2
- package/src/plan.ts +24 -4
- package/src/registry.ts +21 -0
- package/src/scene.ts +42 -3
- package/src/webgl/backdrops.ts +150 -0
- package/src/webgl/backend.ts +175 -34
- package/src/webgl/composite.ts +120 -48
- package/src/webgl/draws.ts +10 -3
- package/src/webgl/holds.ts +11 -3
- package/src/webgl/programs.ts +46 -5
- package/src/webgl/targets.ts +4 -0
package/src/measure.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import type { Geometries } from "./geometry.js";
|
|
2
2
|
import { ROW_FLOATS, type Rows } from "./rows.js";
|
|
3
3
|
import {
|
|
4
|
+
ALPHA,
|
|
4
5
|
ALPHA_MASK,
|
|
6
|
+
BELOW_CLEARED,
|
|
7
|
+
BELOW_INVERTED,
|
|
8
|
+
BELOW_SUBTRACTED,
|
|
5
9
|
DRAW,
|
|
10
|
+
ERASE,
|
|
11
|
+
INVERT,
|
|
6
12
|
KEPT,
|
|
13
|
+
KERNEL,
|
|
7
14
|
LAYER_BEGIN,
|
|
8
15
|
LAYER_END,
|
|
9
16
|
MASK_BEGIN,
|
|
@@ -11,6 +18,7 @@ import {
|
|
|
11
18
|
MASK_USE,
|
|
12
19
|
NO_WHOLE,
|
|
13
20
|
type SceneList,
|
|
21
|
+
SUBTRACT,
|
|
14
22
|
WHOLE_ALIASED,
|
|
15
23
|
} from "./scene.js";
|
|
16
24
|
|
|
@@ -94,6 +102,26 @@ let open = new Int32Array(16);
|
|
|
94
102
|
let openTop = 0;
|
|
95
103
|
// drawnArea's area as it is measured.
|
|
96
104
|
const drawn = new Float64Array(4);
|
|
105
|
+
// A draw's own area, as a fresh layer's items take it.
|
|
106
|
+
const own = new Float64Array(4);
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* What each open fresh layer has had drawn in it, in order (belowOf): five
|
|
110
|
+
* numbers an item, the whole pixels it may touch, least x and y and past
|
|
111
|
+
* the greatest, then what a pixel it alone drew reads as (BELOW_INVERTED
|
|
112
|
+
* and the rest, 0 for as it is stored).
|
|
113
|
+
*/
|
|
114
|
+
let items = new Float64Array(80);
|
|
115
|
+
let itemTop = 0;
|
|
116
|
+
// Where each open layer's items begin, as `open`.
|
|
117
|
+
let itemFrom = new Int32Array(16);
|
|
118
|
+
// The most items a layer keeps apart, past which they are taken as one drawn as it is stored.
|
|
119
|
+
const MOST_ITEMS = 32;
|
|
120
|
+
// Pixels an item is taken to reach past its box each way, as layers are: a snapped vertex may lie
|
|
121
|
+
// a part of a pixel past it, and a sample there may make two items share the pixel.
|
|
122
|
+
const ITEM_SLACK = 1;
|
|
123
|
+
// How deep in a mask's own draws, which draw nothing, the walk is.
|
|
124
|
+
let maskDraws = 0;
|
|
97
125
|
|
|
98
126
|
/**
|
|
99
127
|
* Each layer's rectangle of the target (SceneList.layerRect), from what is
|
|
@@ -123,6 +151,8 @@ export function measureLayers(
|
|
|
123
151
|
clips.top = 0;
|
|
124
152
|
cuts.top = 0;
|
|
125
153
|
openTop = 0;
|
|
154
|
+
itemTop = 0;
|
|
155
|
+
maskDraws = 0;
|
|
126
156
|
areas.pushEmpty();
|
|
127
157
|
const k = target.scale;
|
|
128
158
|
const box = geometries.box;
|
|
@@ -131,20 +161,38 @@ export function measureLayers(
|
|
|
131
161
|
for (let i = 0; i < scene.length; i++) {
|
|
132
162
|
switch (scene.kind[i]) {
|
|
133
163
|
case DRAW:
|
|
134
|
-
|
|
164
|
+
if (maskDraws === 0 && openTop > 0 && scene.fresh[open[openTop - 1]] === 1) {
|
|
165
|
+
own[0] = Number.POSITIVE_INFINITY;
|
|
166
|
+
own[1] = Number.POSITIVE_INFINITY;
|
|
167
|
+
own[2] = Number.NEGATIVE_INFINITY;
|
|
168
|
+
own[3] = Number.NEGATIVE_INFINITY;
|
|
169
|
+
placeDraw(scene, i, box, m, k, own, 4);
|
|
170
|
+
if (own[2] >= own[0] && own[3] >= own[1]) {
|
|
171
|
+
unionTop(own[0], own[1], own[2], own[3]);
|
|
172
|
+
addItem(itemFrom[openTop - 1], own[0], own[1], own[2], own[3], 0);
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
placeDraw(scene, i, box, m, k, areas.data, areas.top);
|
|
176
|
+
}
|
|
177
|
+
|
|
135
178
|
break;
|
|
136
179
|
|
|
137
180
|
case MASK_BEGIN:
|
|
138
181
|
// The mask's own draws, measured apart.
|
|
139
182
|
areas.pushEmpty();
|
|
183
|
+
maskDraws++;
|
|
140
184
|
break;
|
|
141
185
|
case LAYER_BEGIN:
|
|
142
186
|
if (openTop === open.length) {
|
|
143
187
|
const grown = new Int32Array(open.length * 2);
|
|
144
188
|
grown.set(open);
|
|
145
189
|
open = grown;
|
|
190
|
+
const from = new Int32Array(itemFrom.length * 2);
|
|
191
|
+
from.set(itemFrom);
|
|
192
|
+
itemFrom = from;
|
|
146
193
|
}
|
|
147
194
|
|
|
195
|
+
itemFrom[openTop] = itemTop;
|
|
148
196
|
open[openTop++] = scene.geometry[i];
|
|
149
197
|
areas.pushEmpty();
|
|
150
198
|
cuts.push(
|
|
@@ -158,6 +206,7 @@ export function measureLayers(
|
|
|
158
206
|
// The mask's draws clip what follows, measured apart till it pops.
|
|
159
207
|
areas.moveTop(clips);
|
|
160
208
|
areas.pushEmpty();
|
|
209
|
+
maskDraws--;
|
|
161
210
|
break;
|
|
162
211
|
case MASK_POP: {
|
|
163
212
|
const a = areas.data;
|
|
@@ -180,7 +229,9 @@ export function measureLayers(
|
|
|
180
229
|
case LAYER_END: {
|
|
181
230
|
const a = areas.data;
|
|
182
231
|
const n = areas.top;
|
|
232
|
+
itemTop = itemFrom[openTop - 1];
|
|
183
233
|
const layer = open[--openTop];
|
|
234
|
+
const parent = openTop > 0 ? open[openTop - 1] : -1;
|
|
184
235
|
const pad = scene.pads[layer];
|
|
185
236
|
const cut = cuts.data;
|
|
186
237
|
const c = cuts.top - 4;
|
|
@@ -189,6 +240,21 @@ export function measureLayers(
|
|
|
189
240
|
const top = Math.max(0, Math.floor(a[n - 3]) - 1, cut[c + 1]);
|
|
190
241
|
const right = Math.min(target.width, Math.ceil(a[n - 2]) + 1, cut[c + 2]);
|
|
191
242
|
const bottom = Math.min(target.height, Math.ceil(a[n - 1]) + 1, cut[c + 3]);
|
|
243
|
+
if (parent >= 0) {
|
|
244
|
+
const x0 = Math.floor(a[n - 4]);
|
|
245
|
+
const y0 = Math.floor(a[n - 3]);
|
|
246
|
+
belowOf(
|
|
247
|
+
scene,
|
|
248
|
+
scene.geometry[i],
|
|
249
|
+
layer,
|
|
250
|
+
parent,
|
|
251
|
+
x0,
|
|
252
|
+
y0,
|
|
253
|
+
Math.ceil(a[n - 2]) - x0,
|
|
254
|
+
Math.ceil(a[n - 1]) - y0,
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
192
258
|
areas.top = n - 4;
|
|
193
259
|
cuts.top = c;
|
|
194
260
|
if (scene.geometry[i] === ALPHA_MASK) {
|
|
@@ -234,6 +300,7 @@ export function measureLayers(
|
|
|
234
300
|
layer * 4,
|
|
235
301
|
scene.wholes[layer],
|
|
236
302
|
scene.objects,
|
|
303
|
+
scene.solids[layer] === 1,
|
|
237
304
|
);
|
|
238
305
|
areas.top = n - 4;
|
|
239
306
|
const r = scene.layers;
|
|
@@ -242,6 +309,10 @@ export function measureLayers(
|
|
|
242
309
|
unionTop(r[at], r[at + 1], r[at] + r[at + 2], r[at + 1] + r[at + 3]);
|
|
243
310
|
}
|
|
244
311
|
|
|
312
|
+
if (parent >= 0) {
|
|
313
|
+
belowOf(scene, scene.geometry[i], layer, parent, r[at], r[at + 1], r[at + 2], r[at + 3]);
|
|
314
|
+
}
|
|
315
|
+
|
|
245
316
|
break;
|
|
246
317
|
}
|
|
247
318
|
|
|
@@ -251,6 +322,19 @@ export function measureLayers(
|
|
|
251
322
|
const at = scene.geometry[i] * 4;
|
|
252
323
|
if (r[at + 2] > 0 && r[at + 3] > 0) {
|
|
253
324
|
unionTop(r[at], r[at + 1], r[at] + r[at + 2], r[at + 1] + r[at + 3]);
|
|
325
|
+
if (openTop > 0) {
|
|
326
|
+
const layer = scene.geometry[i];
|
|
327
|
+
belowOf(
|
|
328
|
+
scene,
|
|
329
|
+
scene.blend[i],
|
|
330
|
+
layer,
|
|
331
|
+
open[openTop - 1],
|
|
332
|
+
r[at],
|
|
333
|
+
r[at + 1],
|
|
334
|
+
r[at + 2],
|
|
335
|
+
r[at + 3],
|
|
336
|
+
);
|
|
337
|
+
}
|
|
254
338
|
}
|
|
255
339
|
|
|
256
340
|
break;
|
|
@@ -268,7 +352,12 @@ export function measureLayers(
|
|
|
268
352
|
* padded; nothing where it has no size then; its edges snapped to the
|
|
269
353
|
* pixels they lie on. Into `out` from `to`: x, y, width, height, of no
|
|
270
354
|
* size for nothing. A whole layer's object, uncut, goes into `objects` at
|
|
271
|
-
* `to` too (SceneList.objects).
|
|
355
|
+
* `to` too (SceneList.objects). The bitmap of a display object's filters
|
|
356
|
+
* (`solid`, SceneList.solids) starts on the stage pixel its object's left
|
|
357
|
+
* edge lies on and is as many pixels wide as the object, rounded up, as
|
|
358
|
+
* adl's is: a square of 10 at x + 0.3 covers x to x + 10, one of 10.9 at x
|
|
359
|
+
* covers x to x + 11. Padded by the reach, a pixel at least, its edge
|
|
360
|
+
* texels are clear, which the filters' clamped reads take past it.
|
|
272
361
|
*/
|
|
273
362
|
export function filteredRect(
|
|
274
363
|
area: ArrayLike<number>,
|
|
@@ -279,6 +368,7 @@ export function filteredRect(
|
|
|
279
368
|
to: number,
|
|
280
369
|
whole = NO_WHOLE,
|
|
281
370
|
objects: Float64Array | null = null,
|
|
371
|
+
solid = false,
|
|
282
372
|
): void {
|
|
283
373
|
const res = target.resolution;
|
|
284
374
|
let x0 = area[at] / res;
|
|
@@ -319,6 +409,17 @@ export function filteredRect(
|
|
|
319
409
|
y0 = Math.max(oy0, 0) / res - pad;
|
|
320
410
|
x1 = Math.min(ox1, target.width) / res + pad;
|
|
321
411
|
y1 = Math.min(oy1, target.height) / res + pad;
|
|
412
|
+
} else if (solid) {
|
|
413
|
+
// In stage pixels, whatever the stage's scale; cut to the target only after.
|
|
414
|
+
const k = target.scale;
|
|
415
|
+
const sx = Math.floor(area[at] / k + TEXEL_SNAP);
|
|
416
|
+
const sy = Math.floor(area[at + 1] / k + TEXEL_SNAP);
|
|
417
|
+
const sw = Math.ceil((area[at + 2] - area[at]) / k - TEXEL_SNAP);
|
|
418
|
+
const sh = Math.ceil((area[at + 3] - area[at + 1]) / k - TEXEL_SNAP);
|
|
419
|
+
x0 = Math.max(sx * k, 0) / res - pad;
|
|
420
|
+
y0 = Math.max(sy * k, 0) / res - pad;
|
|
421
|
+
x1 = Math.min((sx + sw) * k, target.width) / res + pad;
|
|
422
|
+
y1 = Math.min((sy + sh) * k, target.height) / res + pad;
|
|
322
423
|
} else {
|
|
323
424
|
// Each edge moved in alone, as Bounds.fitBounds does: an area off the target turns inside out,
|
|
324
425
|
// and its padding may yet give it a size.
|
|
@@ -453,6 +554,150 @@ function placeDraw(
|
|
|
453
554
|
stack[n - 1] = Math.max(stack[n - 1], ty + Math.max(b * x0, b * x1) + Math.max(d * y0, d * y1));
|
|
454
555
|
}
|
|
455
556
|
|
|
557
|
+
/**
|
|
558
|
+
* How what is drawn in mode `mode` over a fresh layer's pixel nothing drew
|
|
559
|
+
* reads to what is drawn over it later (SceneList.below).
|
|
560
|
+
*/
|
|
561
|
+
function itemReads(mode: number): number {
|
|
562
|
+
switch (mode) {
|
|
563
|
+
case INVERT:
|
|
564
|
+
return BELOW_INVERTED;
|
|
565
|
+
case SUBTRACT:
|
|
566
|
+
return BELOW_SUBTRACTED;
|
|
567
|
+
case ERASE:
|
|
568
|
+
case ALPHA:
|
|
569
|
+
return BELOW_CLEARED;
|
|
570
|
+
default:
|
|
571
|
+
return 0;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* An item drawn into the open fresh layer whose items begin at `from`, the
|
|
577
|
+
* last, over the area from `left`, `top` to `right`, `bottom` in target
|
|
578
|
+
* pixels, read as `reads` says (itemReads): taken in with the last where
|
|
579
|
+
* both read as they are stored, as only items that read otherwise tell
|
|
580
|
+
* blends anything (belowOf); all its items taken as one so read past
|
|
581
|
+
* MOST_ITEMS.
|
|
582
|
+
*/
|
|
583
|
+
function addItem(
|
|
584
|
+
from: number,
|
|
585
|
+
left: number,
|
|
586
|
+
top: number,
|
|
587
|
+
right: number,
|
|
588
|
+
bottom: number,
|
|
589
|
+
reads: number,
|
|
590
|
+
): void {
|
|
591
|
+
if (!(right > left && bottom > top)) {
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
const x0 = Math.floor(left) - ITEM_SLACK;
|
|
596
|
+
const y0 = Math.floor(top) - ITEM_SLACK;
|
|
597
|
+
const x1 = Math.ceil(right) + ITEM_SLACK;
|
|
598
|
+
const y1 = Math.ceil(bottom) + ITEM_SLACK;
|
|
599
|
+
const last = itemTop - 5;
|
|
600
|
+
if (reads === 0 && last >= from && items[last + 4] === 0) {
|
|
601
|
+
items[last] = Math.min(items[last], x0);
|
|
602
|
+
items[last + 1] = Math.min(items[last + 1], y0);
|
|
603
|
+
items[last + 2] = Math.max(items[last + 2], x1);
|
|
604
|
+
items[last + 3] = Math.max(items[last + 3], y1);
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
if (itemTop - from >= MOST_ITEMS * 5) {
|
|
609
|
+
for (let at = from + 5; at < itemTop; at += 5) {
|
|
610
|
+
items[from] = Math.min(items[from], items[at]);
|
|
611
|
+
items[from + 1] = Math.min(items[from + 1], items[at + 1]);
|
|
612
|
+
items[from + 2] = Math.max(items[from + 2], items[at + 2]);
|
|
613
|
+
items[from + 3] = Math.max(items[from + 3], items[at + 3]);
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
items[from + 4] = 0;
|
|
617
|
+
itemTop = from + 5;
|
|
618
|
+
addItem(from, left, top, right, bottom, 0);
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
if (itemTop + 5 > items.length) {
|
|
623
|
+
const grown = new Float64Array(items.length * 2);
|
|
624
|
+
grown.set(items);
|
|
625
|
+
items = grown;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
items[itemTop] = x0;
|
|
629
|
+
items[itemTop + 1] = y0;
|
|
630
|
+
items[itemTop + 2] = x1;
|
|
631
|
+
items[itemTop + 3] = y1;
|
|
632
|
+
items[itemTop + 4] = reads;
|
|
633
|
+
itemTop += 5;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* The layer `layer`, of blend mode `mode`, ended or a kept output's, in
|
|
638
|
+
* layer `parent`, over the whole pixels from `x`, `y`, `width` by `height`
|
|
639
|
+
* that it may touch: where `parent` is fresh, how what lies under it there
|
|
640
|
+
* reads (SceneList.below), and it an item of `parent`'s. adl shows a pixel
|
|
641
|
+
* one object alone drew in a fresh layer as the object is, but blends what
|
|
642
|
+
* is drawn over it later with what the object's mode would have left over
|
|
643
|
+
* nothing. A pixel's own colour cannot tell which, so a blend is told from
|
|
644
|
+
* what was drawn before it: where all under it are of one mode that reads
|
|
645
|
+
* otherwise than it is stored, and none of them meets another there, each
|
|
646
|
+
* pixel under it that was drawn was drawn by one of them alone. Anything
|
|
647
|
+
* else under it, and it reads them as they are stored.
|
|
648
|
+
*/
|
|
649
|
+
function belowOf(
|
|
650
|
+
scene: SceneList,
|
|
651
|
+
mode: number,
|
|
652
|
+
layer: number,
|
|
653
|
+
parent: number,
|
|
654
|
+
x0: number,
|
|
655
|
+
y0: number,
|
|
656
|
+
width: number,
|
|
657
|
+
height: number,
|
|
658
|
+
): void {
|
|
659
|
+
if (scene.fresh[parent] !== 1 || mode === ALPHA_MASK || !(width > 0 && height > 0)) {
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
const x1 = x0 + width;
|
|
664
|
+
const y1 = y0 + height;
|
|
665
|
+
const from = itemFrom[openTop - 1];
|
|
666
|
+
let reads = 0;
|
|
667
|
+
if (mode < KERNEL) {
|
|
668
|
+
for (let a = from; a < itemTop; a += 5) {
|
|
669
|
+
if (!(items[a] < x1 && x0 < items[a + 2] && items[a + 1] < y1 && y0 < items[a + 3])) {
|
|
670
|
+
continue;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
if (items[a + 4] === 0 || (reads !== 0 && items[a + 4] !== reads)) {
|
|
674
|
+
reads = 0;
|
|
675
|
+
break;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
reads = items[a + 4];
|
|
679
|
+
for (let b = from; b < a; b += 5) {
|
|
680
|
+
if (
|
|
681
|
+
items[b + 4] !== 0 &&
|
|
682
|
+
Math.max(items[a], items[b], x0) < Math.min(items[a + 2], items[b + 2], x1) &&
|
|
683
|
+
Math.max(items[a + 1], items[b + 1], y0) < Math.min(items[a + 3], items[b + 3], y1)
|
|
684
|
+
) {
|
|
685
|
+
reads = -1;
|
|
686
|
+
break;
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
if (reads < 0) {
|
|
691
|
+
reads = 0;
|
|
692
|
+
break;
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
scene.below[layer] = reads;
|
|
698
|
+
addItem(from, x0, y0, x1, y1, itemReads(mode));
|
|
699
|
+
}
|
|
700
|
+
|
|
456
701
|
/** The open area on top grown to take in the rectangle. */
|
|
457
702
|
function unionTop(left: number, top: number, right: number, bottom: number): void {
|
|
458
703
|
const a = areas.data;
|
package/src/plan.ts
CHANGED
|
@@ -6,8 +6,11 @@ import {
|
|
|
6
6
|
HELD,
|
|
7
7
|
HOLD_POP,
|
|
8
8
|
HOLD_PUSH,
|
|
9
|
+
LAYER_FILTERED,
|
|
9
10
|
LAYER_POP,
|
|
10
11
|
LAYER_PUSH,
|
|
12
|
+
LAYER_SOLID,
|
|
13
|
+
modeWithBelow,
|
|
11
14
|
RUN,
|
|
12
15
|
STENCIL_POP,
|
|
13
16
|
STENCIL_PUSH,
|
|
@@ -135,7 +138,16 @@ function emit(scene: SceneList, from: number, to: number, out: Commands, stage:
|
|
|
135
138
|
close(i);
|
|
136
139
|
if (heldAt[i] >= 0) {
|
|
137
140
|
const end = layerEnd(scene, i);
|
|
138
|
-
out.push(
|
|
141
|
+
out.push(
|
|
142
|
+
HELD,
|
|
143
|
+
heldAt[i],
|
|
144
|
+
modeWithBelow(
|
|
145
|
+
scene.geometry[end],
|
|
146
|
+
scene.below[scene.geometry[i]],
|
|
147
|
+
scene.solids[scene.geometry[i]] === 1,
|
|
148
|
+
),
|
|
149
|
+
scene.row[end],
|
|
150
|
+
);
|
|
139
151
|
if (stage) {
|
|
140
152
|
noteClearing(out, scene.geometry[end]);
|
|
141
153
|
}
|
|
@@ -156,8 +168,12 @@ function emit(scene: SceneList, from: number, to: number, out: Commands, stage:
|
|
|
156
168
|
out.push(
|
|
157
169
|
LAYER_PUSH,
|
|
158
170
|
layerParams(out, scene, scene.geometry[i]),
|
|
159
|
-
scene.pads[scene.geometry[i]] >= 0
|
|
160
|
-
|
|
171
|
+
scene.pads[scene.geometry[i]] >= 0
|
|
172
|
+
? LAYER_FILTERED | (scene.solids[scene.geometry[i]] ? LAYER_SOLID : 0)
|
|
173
|
+
: scene.groups[scene.geometry[i]]
|
|
174
|
+
? 2
|
|
175
|
+
: 0,
|
|
176
|
+
scene.fresh[scene.geometry[i]] | (scene.below[scene.geometry[i]] << 1),
|
|
161
177
|
);
|
|
162
178
|
break;
|
|
163
179
|
}
|
|
@@ -178,7 +194,11 @@ function emit(scene: SceneList, from: number, to: number, out: Commands, stage:
|
|
|
178
194
|
out.push(
|
|
179
195
|
COMPOSITE,
|
|
180
196
|
out.param5(r[at], r[at + 1], r[at + 2], r[at + 3], scene.texture[i]),
|
|
181
|
-
|
|
197
|
+
modeWithBelow(
|
|
198
|
+
scene.blend[i],
|
|
199
|
+
scene.below[scene.geometry[i]],
|
|
200
|
+
scene.solids[scene.geometry[i]] === 1,
|
|
201
|
+
),
|
|
182
202
|
scene.row[i],
|
|
183
203
|
);
|
|
184
204
|
noteClearing(out, scene.blend[i]);
|
package/src/registry.ts
CHANGED
|
@@ -13,12 +13,16 @@ export interface Handle {
|
|
|
13
13
|
export class Registry {
|
|
14
14
|
private readonly generations: number[] = [];
|
|
15
15
|
private readonly usedAt: number[] = [];
|
|
16
|
+
/** The run each id was last used in (executed). */
|
|
17
|
+
private readonly usedRun: number[] = [];
|
|
16
18
|
private readonly idleFrames: number[] = [];
|
|
17
19
|
private readonly held: boolean[] = [];
|
|
18
20
|
private readonly free: number[] = [];
|
|
19
21
|
/** Removed since the backend last took them. */
|
|
20
22
|
removed: number[] = [];
|
|
21
23
|
frame = 0;
|
|
24
|
+
/** How many times what was named has been drawn: a frame, or a pass drawn alone. */
|
|
25
|
+
private run = 0;
|
|
22
26
|
|
|
23
27
|
/** A new id, removed once unused for `idle` frames. */
|
|
24
28
|
protected hold(idle: number): Handle {
|
|
@@ -26,6 +30,7 @@ export class Registry {
|
|
|
26
30
|
this.held[id] = true;
|
|
27
31
|
this.generations[id] = (this.generations[id] ?? 0) + 1;
|
|
28
32
|
this.usedAt[id] = this.frame;
|
|
33
|
+
this.usedRun[id] = this.run;
|
|
29
34
|
this.idleFrames[id] = idle;
|
|
30
35
|
return { id, generation: this.generations[id] };
|
|
31
36
|
}
|
|
@@ -86,6 +91,21 @@ export class Registry {
|
|
|
86
91
|
/** `id` used this frame. */
|
|
87
92
|
use(id: number): void {
|
|
88
93
|
this.usedAt[id] = this.frame;
|
|
94
|
+
this.usedRun[id] = this.run;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Whether `id` was used since what was named was last drawn: a draw not
|
|
99
|
+
* yet executed may name it. Frames end it, and passes drawn alone between
|
|
100
|
+
* them (executed), which a page drawing no frames, hidden, may run on.
|
|
101
|
+
*/
|
|
102
|
+
usedSinceDrawn(id: number): boolean {
|
|
103
|
+
return this.usedRun[id] === this.run;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** What was named drawn by a pass alone, outside any frame (usedSinceDrawn). */
|
|
107
|
+
executed(): void {
|
|
108
|
+
this.run++;
|
|
89
109
|
}
|
|
90
110
|
|
|
91
111
|
remove(id: number): void {
|
|
@@ -116,5 +136,6 @@ export class Registry {
|
|
|
116
136
|
}
|
|
117
137
|
|
|
118
138
|
this.frame++;
|
|
139
|
+
this.run++;
|
|
119
140
|
}
|
|
120
141
|
}
|
package/src/scene.ts
CHANGED
|
@@ -22,6 +22,18 @@ export const HARDLIGHT = 13;
|
|
|
22
22
|
* alone takes it, never a draw or a kept layer, whose modes are bytes.
|
|
23
23
|
*/
|
|
24
24
|
export const KERNEL = 14;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* In a layer drawn for its blend mode alone (SceneList.fresh), adl shows a
|
|
28
|
+
* pixel one object alone drew as that object is, in any mode, but what is
|
|
29
|
+
* drawn over it later reads it as the object's mode would have left it over
|
|
30
|
+
* nothing: an invert's as white (BELOW_INVERTED), a subtract's as black
|
|
31
|
+
* (BELOW_SUBTRACTED), an erase's or alpha's as clear (BELOW_CLEARED), each
|
|
32
|
+
* at the object's alpha. SceneList.below.
|
|
33
|
+
*/
|
|
34
|
+
export const BELOW_INVERTED = 1;
|
|
35
|
+
export const BELOW_SUBTRACTED = 2;
|
|
36
|
+
export const BELOW_CLEARED = 3;
|
|
25
37
|
/**
|
|
26
38
|
* Not Flash's: an alpha mask's layer composited onto the unfiltered layer
|
|
27
39
|
* that ends after it, the layer of what it masks, keeping only what the
|
|
@@ -191,6 +203,21 @@ export class SceneList {
|
|
|
191
203
|
* (programs.ts, BLEND_FRONT).
|
|
192
204
|
*/
|
|
193
205
|
fresh = new Uint8Array(16);
|
|
206
|
+
/**
|
|
207
|
+
* How a layer in a fresh one reads the pixels below it there, where all
|
|
208
|
+
* that lies under it there are blends each alone on its pixels and in one
|
|
209
|
+
* of the modes whose pixel adl reads otherwise than it shows it
|
|
210
|
+
* (BELOW_INVERTED and the rest, measureLayers); else 0, as it is stored.
|
|
211
|
+
*/
|
|
212
|
+
below = new Uint8Array(16);
|
|
213
|
+
/**
|
|
214
|
+
* Whether each filtered layer, or kept output, covers the bitmap Flash
|
|
215
|
+
* draws its object's filters into, as their padding is that bitmap's on
|
|
216
|
+
* every side: its clear pixels are then that bitmap's, which an alpha
|
|
217
|
+
* blend clears what is below by and a blend over a fresh layer reads it
|
|
218
|
+
* through (programs.ts, BLEND_FRONT), as it does a pixel it draws.
|
|
219
|
+
*/
|
|
220
|
+
solids = new Uint8Array(16);
|
|
194
221
|
/**
|
|
195
222
|
* Each whole layer's object, Flash's bitmap of it, uncut by the target:
|
|
196
223
|
* x, y, width and height in target pixels, as measureLayers finds it.
|
|
@@ -313,7 +340,8 @@ export class SceneList {
|
|
|
313
340
|
|
|
314
341
|
/**
|
|
315
342
|
* Kept output `keep` composited again over the rectangle x y width height
|
|
316
|
-
* of the target, in blend mode `mode`, coloured by `row
|
|
343
|
+
* of the target, in blend mode `mode`, coloured by `row`, the bitmap of
|
|
344
|
+
* its filters where `solid` (solids).
|
|
317
345
|
*/
|
|
318
346
|
keptLayer(
|
|
319
347
|
keep: number,
|
|
@@ -323,8 +351,10 @@ export class SceneList {
|
|
|
323
351
|
y: number,
|
|
324
352
|
width: number,
|
|
325
353
|
height: number,
|
|
354
|
+
solid = false,
|
|
326
355
|
): void {
|
|
327
356
|
const layer = this.newLayer(-1, keep);
|
|
357
|
+
this.solids[layer] = solid ? 1 : 0;
|
|
328
358
|
this.layerRect(layer, x, y, width, height);
|
|
329
359
|
this.push(KEPT, layer, row, mode, keep, 0);
|
|
330
360
|
}
|
|
@@ -337,6 +367,8 @@ export class SceneList {
|
|
|
337
367
|
this.wholes = grow(this.wholes);
|
|
338
368
|
this.groups = grow(this.groups);
|
|
339
369
|
this.fresh = grow(this.fresh);
|
|
370
|
+
this.below = grow(this.below);
|
|
371
|
+
this.solids = grow(this.solids);
|
|
340
372
|
const objects = new Float64Array(this.objects.length * 2);
|
|
341
373
|
objects.set(this.objects);
|
|
342
374
|
this.objects = objects;
|
|
@@ -351,15 +383,22 @@ export class SceneList {
|
|
|
351
383
|
this.wholes[layer] = NO_WHOLE;
|
|
352
384
|
this.groups[layer] = 0;
|
|
353
385
|
this.fresh[layer] = 0;
|
|
386
|
+
this.below[layer] = 0;
|
|
387
|
+
this.solids[layer] = 0;
|
|
354
388
|
this.keeps[layer] = keep;
|
|
355
389
|
this.parents[layer] = this.open.at(-1) ?? -1;
|
|
356
390
|
this.layerRect(layer, 0, 0, 0, 0);
|
|
357
391
|
return layer;
|
|
358
392
|
}
|
|
359
393
|
|
|
360
|
-
/**
|
|
361
|
-
|
|
394
|
+
/**
|
|
395
|
+
* Filtered layer `layer` padded by `padding` after all, as its filters
|
|
396
|
+
* were fitted once it was drawn, the bitmap of its filters where `solid`
|
|
397
|
+
* (solids).
|
|
398
|
+
*/
|
|
399
|
+
padLayer(layer: number, padding: number, solid = false): void {
|
|
362
400
|
this.pads[layer] = padding;
|
|
401
|
+
this.solids[layer] = solid ? 1 : 0;
|
|
363
402
|
}
|
|
364
403
|
|
|
365
404
|
/** The layer begun last ended: filtered by `chain` (or -1), composited in `mode`, coloured by `row`. */
|