@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/webgl/draws.ts
CHANGED
|
@@ -22,6 +22,7 @@ import type { GpuTextures } from "./gpu-textures.js";
|
|
|
22
22
|
import type { KernelHost, KernelPrograms } from "./kernels.js";
|
|
23
23
|
import {
|
|
24
24
|
BACK_UNIT,
|
|
25
|
+
BELOW_STEP,
|
|
25
26
|
blendFillFragment,
|
|
26
27
|
FILL_SLOT,
|
|
27
28
|
FILL_TEXTURES,
|
|
@@ -556,11 +557,13 @@ export class Draws {
|
|
|
556
557
|
/**
|
|
557
558
|
* Entry `i`, blendable, drawn onto the target bound in blend mode `mode`,
|
|
558
559
|
* a layer drawn for its blend mode alone where `fresh` (SceneList.fresh),
|
|
560
|
+
* what is below read as `below` says there (SceneList.below),
|
|
559
561
|
* coloured by its layer's row `layerRow` (or -1), where the masks pushed
|
|
560
562
|
* pass: GL's blending computing add, screen and, where it does not
|
|
561
563
|
* `reads` below, multiply, the program the rest from the copy of what is
|
|
562
|
-
* below (Compositor.
|
|
563
|
-
*
|
|
564
|
+
* below (Compositor.copyBoxes, made for it or shared with the blends
|
|
565
|
+
* drawn direct before it: Backdrops), whose texel at a fragment is
|
|
566
|
+
* (`backX`, `backY`) short of it.
|
|
564
567
|
*/
|
|
565
568
|
drawBlended(
|
|
566
569
|
scene: SceneList,
|
|
@@ -568,6 +571,7 @@ export class Draws {
|
|
|
568
571
|
mode: number,
|
|
569
572
|
reads: boolean,
|
|
570
573
|
fresh: boolean | undefined,
|
|
574
|
+
below: number,
|
|
571
575
|
layerRow: number,
|
|
572
576
|
backX: number,
|
|
573
577
|
backY: number,
|
|
@@ -579,7 +583,10 @@ export class Draws {
|
|
|
579
583
|
gl.uniform4fv(this.blendViewLocation, this.view);
|
|
580
584
|
gl.uniform1f(this.blendUnitLocation, this.unit);
|
|
581
585
|
// Its pixel alone where GL's blending computes the mode (readsBelow).
|
|
582
|
-
gl.uniform1i(
|
|
586
|
+
gl.uniform1i(
|
|
587
|
+
this.blendModeLocation,
|
|
588
|
+
(reads ? mode : NORMAL) + (fresh ? FRESH : 0) + below * BELOW_STEP,
|
|
589
|
+
);
|
|
583
590
|
gl.uniform1i(this.blendLayerRowLocation, layerRow);
|
|
584
591
|
gl.uniform2i(this.blendBackLocation, backX, backY);
|
|
585
592
|
this.gatherRun(scene, i, i + 1, false);
|
package/src/webgl/holds.ts
CHANGED
|
@@ -4,6 +4,9 @@ import {
|
|
|
4
4
|
HELD,
|
|
5
5
|
HOLD_POP,
|
|
6
6
|
HOLD_PUSH,
|
|
7
|
+
operandBelow,
|
|
8
|
+
operandMode,
|
|
9
|
+
operandSolid,
|
|
7
10
|
RUN,
|
|
8
11
|
STENCIL_POP,
|
|
9
12
|
STENCIL_PUSH,
|
|
@@ -545,8 +548,11 @@ export class HeldLayers {
|
|
|
545
548
|
state.stencil(null);
|
|
546
549
|
}
|
|
547
550
|
|
|
548
|
-
/**
|
|
549
|
-
|
|
551
|
+
/**
|
|
552
|
+
* Held output `held` composited onto `under`, bound, in blend mode and
|
|
553
|
+
* below `operand` (modeWithBelow), coloured by `row`.
|
|
554
|
+
*/
|
|
555
|
+
compositeHeld(held: number, under: Open, operand: number, row: number): void {
|
|
550
556
|
const hold = this.holds[held];
|
|
551
557
|
const result = hold.result;
|
|
552
558
|
if (!result) {
|
|
@@ -561,7 +567,9 @@ export class HeldLayers {
|
|
|
561
567
|
open.height = hold.height;
|
|
562
568
|
open.ox = result.x;
|
|
563
569
|
open.oy = result.y;
|
|
564
|
-
|
|
570
|
+
open.below = operandBelow(operand);
|
|
571
|
+
open.solid = operandSolid(operand);
|
|
572
|
+
this.compositor.compositeLayer(open, under, operandMode(operand), row);
|
|
565
573
|
}
|
|
566
574
|
|
|
567
575
|
/**
|
package/src/webgl/programs.ts
CHANGED
|
@@ -3,6 +3,9 @@ import { ROWS_A_LINE } from "../rows.js";
|
|
|
3
3
|
import {
|
|
4
4
|
ADD,
|
|
5
5
|
ALPHA,
|
|
6
|
+
BELOW_CLEARED,
|
|
7
|
+
BELOW_INVERTED,
|
|
8
|
+
BELOW_SUBTRACTED,
|
|
6
9
|
DARKEN,
|
|
7
10
|
DIFFERENCE,
|
|
8
11
|
ERASE,
|
|
@@ -574,6 +577,19 @@ const layerColor = (row: string) => ` if (${row} >= 0 && front.a > 0.0) {
|
|
|
574
577
|
*/
|
|
575
578
|
export const FRESH = 64;
|
|
576
579
|
|
|
580
|
+
/**
|
|
581
|
+
* Added to a composite's uMode where the layer is the bitmap of its
|
|
582
|
+
* filters (SceneList.solids), whose clear pixels BLEND_FRONT draws as it
|
|
583
|
+
* draws the rest.
|
|
584
|
+
*/
|
|
585
|
+
export const SOLID_FRONT = 128;
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* What a blend program's uMode has, times this, for how it reads what is
|
|
589
|
+
* below it in a layer drawn for its blend mode alone (SceneList.below).
|
|
590
|
+
*/
|
|
591
|
+
export const BELOW_STEP = 256;
|
|
592
|
+
|
|
577
593
|
/** A composited layer's pixel, `front`, coloured by its row's colour transform where it has one (uRow not -1). */
|
|
578
594
|
export const LAYER_COLOR = layerColor("uRow");
|
|
579
595
|
|
|
@@ -594,11 +610,21 @@ export const LAYER_COLOR = layerColor("uRow");
|
|
|
594
610
|
* formulas, so they mark it DRAWN_CLEAR, clear but for a red no
|
|
595
611
|
* premultiplied colour has, which the formulas read as clear and
|
|
596
612
|
* compositeFragment drops, as Flash's premultiplied pixels of no alpha
|
|
597
|
-
* have no colour.
|
|
613
|
+
* have no colour. What is drawn over a pixel so drawn as it is reads it as
|
|
614
|
+
* the mode would have left it over nothing, which the planner works out
|
|
615
|
+
* where it can (uMode / BELOW_STEP, SceneList.below): an invert's as white,
|
|
616
|
+
* a subtract's as black, an erase's or alpha's as clear, at its alpha, in
|
|
617
|
+
* any mode, normal too, for which GL's blending cannot read it. Where
|
|
618
|
+
* `front` is clear the pixel keeps what it holds, and alpha leaves it be,
|
|
619
|
+
* as Flash draws a shape, but not where `front` is the bitmap of a display
|
|
620
|
+
* object's filters (SOLID_FRONT added to uMode): adl draws that bitmap's
|
|
621
|
+
* clear pixels as it does the rest.
|
|
598
622
|
*/
|
|
599
623
|
const BLEND_FRONT = ` int mode = uMode & ${FRESH - 1};
|
|
600
|
-
bool fresh = uMode
|
|
601
|
-
|
|
624
|
+
bool fresh = (uMode & ${FRESH}) != 0;
|
|
625
|
+
bool solid = (uMode & ${SOLID_FRONT}) != 0;
|
|
626
|
+
int below = uMode / ${BELOW_STEP};
|
|
627
|
+
if (below == 0 && (mode == ${NORMAL} || mode == ${LAYER} || mode == ${SCREEN} || mode == ${ADD})) {
|
|
602
628
|
finalColor = front;
|
|
603
629
|
return;
|
|
604
630
|
}
|
|
@@ -609,8 +635,17 @@ const BLEND_FRONT = ` int mode = uMode & ${FRESH - 1};
|
|
|
609
635
|
return;
|
|
610
636
|
}
|
|
611
637
|
|
|
612
|
-
if (
|
|
638
|
+
if (below != 0 && front.a == 0.0 && !solid) {
|
|
639
|
+
finalColor = back;
|
|
640
|
+
return;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
if (back.a == 0.0 || below == ${BELOW_CLEARED}) {
|
|
613
644
|
back = vec4(0.0);
|
|
645
|
+
} else if (below == ${BELOW_INVERTED}) {
|
|
646
|
+
back = vec4(back.a);
|
|
647
|
+
} else if (below == ${BELOW_SUBTRACTED}) {
|
|
648
|
+
back = vec4(0.0, 0.0, 0.0, back.a);
|
|
614
649
|
}
|
|
615
650
|
|
|
616
651
|
vec3 cb = straight(back);
|
|
@@ -623,6 +658,12 @@ const BLEND_FRONT = ` int mode = uMode & ${FRESH - 1};
|
|
|
623
658
|
case ${DIFFERENCE}: b = abs(cb - cf); break;
|
|
624
659
|
case ${OVERLAY}: b = hardlight(cf, cb); break;
|
|
625
660
|
case ${HARDLIGHT}: b = hardlight(cb, cf); break;
|
|
661
|
+
case ${ADD}:
|
|
662
|
+
finalColor = min(front + back, 1.0);
|
|
663
|
+
return;
|
|
664
|
+
case ${SCREEN}:
|
|
665
|
+
finalColor = front + back * (1.0 - front);
|
|
666
|
+
return;
|
|
626
667
|
case ${SUBTRACT}:
|
|
627
668
|
finalColor = vec4(max(back.rgb - front.rgb, 0.0), min(front.a + back.a, 1.0));
|
|
628
669
|
return;
|
|
@@ -633,7 +674,7 @@ const BLEND_FRONT = ` int mode = uMode & ${FRESH - 1};
|
|
|
633
674
|
);
|
|
634
675
|
return;
|
|
635
676
|
case ${ALPHA}:
|
|
636
|
-
finalColor = drawn(front.a > 0.0 ? back * front.a : back, fresh);
|
|
677
|
+
finalColor = drawn(front.a > 0.0 || solid ? back * front.a : back, fresh);
|
|
637
678
|
return;
|
|
638
679
|
case ${ERASE}:
|
|
639
680
|
finalColor = drawn(back * (1.0 - front.a), fresh);
|
package/src/webgl/targets.ts
CHANGED
|
@@ -145,6 +145,10 @@ export interface Open {
|
|
|
145
145
|
opaque?: boolean;
|
|
146
146
|
/** Whether it is a layer drawn for its blend mode alone (SceneList.fresh). */
|
|
147
147
|
fresh?: boolean;
|
|
148
|
+
/** How it reads what is below it in a layer drawn for its blend mode alone (SceneList.below). */
|
|
149
|
+
below?: number;
|
|
150
|
+
/** Whether it is the bitmap of its filters, its clear pixels drawn (SceneList.solids). */
|
|
151
|
+
solid?: boolean;
|
|
148
152
|
}
|
|
149
153
|
|
|
150
154
|
/** A whole layer's object from params `p` from `at` (plan.ts, layerParams): null for none. */
|