@swf2es/render 0.1.43 → 0.1.45

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.
Files changed (54) hide show
  1. package/dist/filter-shaders.d.ts +2 -2
  2. package/dist/filter-shaders.d.ts.map +1 -1
  3. package/dist/filter-shaders.js +7 -4
  4. package/dist/filter-shaders.js.map +1 -1
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +1 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/registry.d.ts +12 -0
  10. package/dist/registry.d.ts.map +1 -1
  11. package/dist/registry.js +19 -0
  12. package/dist/registry.js.map +1 -1
  13. package/dist/rows.d.ts +28 -1
  14. package/dist/rows.d.ts.map +1 -1
  15. package/dist/rows.js +32 -1
  16. package/dist/rows.js.map +1 -1
  17. package/dist/scene.d.ts +6 -0
  18. package/dist/scene.d.ts.map +1 -1
  19. package/dist/scene.js +6 -0
  20. package/dist/scene.js.map +1 -1
  21. package/dist/spans.js +2 -2
  22. package/dist/spans.js.map +1 -1
  23. package/dist/textures.d.ts +33 -0
  24. package/dist/textures.d.ts.map +1 -1
  25. package/dist/textures.js +67 -14
  26. package/dist/textures.js.map +1 -1
  27. package/dist/webgl/backend.d.ts +15 -3
  28. package/dist/webgl/backend.d.ts.map +1 -1
  29. package/dist/webgl/backend.js +63 -14
  30. package/dist/webgl/backend.js.map +1 -1
  31. package/dist/webgl/draws.d.ts +50 -29
  32. package/dist/webgl/draws.d.ts.map +1 -1
  33. package/dist/webgl/draws.js +185 -85
  34. package/dist/webgl/draws.js.map +1 -1
  35. package/dist/webgl/gpu-textures.d.ts +16 -1
  36. package/dist/webgl/gpu-textures.d.ts.map +1 -1
  37. package/dist/webgl/gpu-textures.js +61 -3
  38. package/dist/webgl/gpu-textures.js.map +1 -1
  39. package/dist/webgl/programs.d.ts +40 -9
  40. package/dist/webgl/programs.d.ts.map +1 -1
  41. package/dist/webgl/programs.js +111 -18
  42. package/dist/webgl/programs.js.map +1 -1
  43. package/package.json +2 -2
  44. package/src/filter-shaders.ts +7 -4
  45. package/src/index.ts +1 -0
  46. package/src/registry.ts +21 -0
  47. package/src/rows.ts +34 -1
  48. package/src/scene.ts +6 -0
  49. package/src/spans.ts +2 -2
  50. package/src/textures.ts +85 -14
  51. package/src/webgl/backend.ts +73 -15
  52. package/src/webgl/draws.ts +252 -91
  53. package/src/webgl/gpu-textures.ts +91 -4
  54. package/src/webgl/programs.ts +124 -18
@@ -1,5 +1,5 @@
1
1
  import { TARGET_TEXEL } from "../geometry.js";
2
- import { ROWS_A_LINE } from "../rows.js";
2
+ import { RADIAL, RADIAL_LEAST_STEP, ROWS_A_LINE } from "../rows.js";
3
3
  import { ADD, ALPHA, BELOW_CLEARED, BELOW_INVERTED, BELOW_SUBTRACTED, DARKEN, DIFFERENCE, ERASE, HARDLIGHT, INVERT, LAYER, LIGHTEN, MULTIPLY, NORMAL, OVERLAY, SCREEN, SUBTRACT, } from "../scene.js";
4
4
  /** Texels a row (ROW_FLOATS over four). */
5
5
  export const ROW_TEXELS = 4;
@@ -82,11 +82,15 @@ if (FILL_TEXTURES >= STAGE_TEXEL) {
82
82
  * `multi`, a merged fill's vertices carry as aDraw where its packed row is
83
83
  * in uMergedRows, which the stream keeps for its copy, so that the row
84
84
  * changes from frame to frame where the vertices need not; the atlas leaves
85
- * that attribute disabled and negative. With `stage`, the stage fill
86
- * program's (stageFillFragment), a texel of TARGET_TEXEL or below samples
87
- * the stage's pixel under the fragment instead.
85
+ * that attribute disabled and negative. A row's line (Rows.line) puts the
86
+ * texel on that line of its texture. With `radial`, a radial gradient's
87
+ * row (Rows.radial) passes on its focal point and its ramp's line in
88
+ * vRadial, the texel its square's place, which the fragment takes to the
89
+ * ramp (radialFillFragment). With `stage`, the stage fill program's
90
+ * (stageFillFragment), a texel of TARGET_TEXEL or below samples the
91
+ * stage's pixel under the fragment instead.
88
92
  */
89
- export const fillVertex = (multi, merged = multi, stage = false) => `#version 300 es
93
+ export const fillVertex = (multi, merged = multi, stage = false, radial = false) => `#version 300 es
90
94
  ${multi ? "#extension GL_ANGLE_multi_draw : require" : ""}
91
95
  precision highp float;
92
96
  layout(location = ${POSITION_AT}) in vec2 aPosition;
@@ -102,6 +106,7 @@ out vec2 vTexel;
102
106
  flat out vec4 vMul;
103
107
  flat out vec4 vAdd;
104
108
  flat out int vSlot;
109
+ ${radial ? "flat out vec3 vRadial;" : ""}
105
110
 
106
111
  void main(void) {
107
112
  int draw = ${merged ? `aDraw >= 0 ? texelFetch(uMergedRows, ivec2(aDraw & ${MERGED_LINE - 1}, aDraw >> ${Math.log2(MERGED_LINE)}), 0).r : ` : ""}${multi ? `texelFetch(uRunTable, ivec2((uRunBase + gl_DrawID) & ${RUN_MOST - 1}, (uRunBase + gl_DrawID) >> ${Math.log2(RUN_MOST)}), 0).r` : "uRow"};
@@ -119,12 +124,23 @@ void main(void) {
119
124
 
120
125
  gl_Position = vec4(p * uView.xy + uView.zw, 0.0, 1.0);
121
126
  vColor = aColor;
127
+ // A ramp kept as a line of a texture of many (Rows.line) is read on that line's centre, a
128
+ // texture of its own on its middle${radial ? "; a radial gradient's, at the place the fragment finds" : ""}.
129
+ ${radial
130
+ ? ` // Its x the least the place is read at, the middle of the row's least entry: above 0, which
131
+ // tells the fragment to take its place to the ramp.
132
+ bool radial = t.w > 0.0;
133
+ float least = floor((t.w - ${(RADIAL - 1).toFixed(1)}) / ${RADIAL_LEAST_STEP.toFixed(1)});
134
+ float focal = t.w - ${RADIAL.toFixed(1)} - least * ${RADIAL_LEAST_STEP.toFixed(1)};
135
+ vRadial = radial ? vec3(least + 0.5, focal, t.z > 0.0 ? t.z : 0.5) : vec3(0.0);
136
+ vec2 texel = !radial && t.z > 0.0 ? vec2(aTexel.x, t.z) : aTexel;`
137
+ : " vec2 texel = t.z > 0.0 ? vec2(aTexel.x, t.z) : aTexel;"}
122
138
  ${stage
123
139
  ? ` // The fragment finds the stage's pixel from its place (STAGE_TEXEL in vSlot).
124
140
  bool onStage = aTexel.x <= ${TARGET_TEXEL / 2};
125
- vTexel = onStage ? p : aTexel;
141
+ vTexel = onStage ? p : texel;
126
142
  vSlot |= onStage ? ${STAGE_TEXEL} : 0;`
127
- : " vTexel = aTexel;"}
143
+ : " vTexel = texel;"}
128
144
  }
129
145
  `;
130
146
  /**
@@ -138,20 +154,65 @@ ${stage
138
154
  const slotTexel = Array.from({ length: FILL_TEXTURES }, (_, k) => ` case ${k + 1}:
139
155
  t = textureLod(uTextures[${k}], at / vec2(textureSize(uTextures[${k}], 0)), 0.0);
140
156
  break;`).join("\n");
157
+ /** Texels a gradient's ramp has across, its line's (Textures.addLine) or a texture's of its own. */
158
+ const RAMP_TEXELS = 256;
159
+ /**
160
+ * Where p, in the gradient square's place (a unit its radius), lies out
161
+ * from the focal point (f, 0) to the circle along the ray through it, as
162
+ * display/gradients.ts's radialPlace finds it: 0 at the focus, 1 on the
163
+ * circle; on a focus off the centre 1, the last stop, and on the centre of
164
+ * one centred 0, which the row's least entry raises (Rows.radial: 8 for a
165
+ * padded one). 1 / s where the ray f + s d meets the circle, in whichever
166
+ * of its two forms subtracts nothing, as a float's few digits would lose a
167
+ * focus near the circle's. A point so far out that its square overflows,
168
+ * as a matrix all but collapsed puts one, is as far out as it is across.
169
+ */
170
+ export const radialPlace = `float radialPlace(vec2 p, float f) {
171
+ vec2 d = vec2(p.x - f, p.y);
172
+ float across = max(abs(d.x), abs(d.y));
173
+ if (across > 1e18) {
174
+ return across;
175
+ }
176
+
177
+ float dd = dot(d, d);
178
+ if (dd < 1e-12) {
179
+ return f != 0.0 ? 1.0 : 0.0;
180
+ }
181
+
182
+ float fd = f * d.x;
183
+ float k = 1.0 - f * f;
184
+ float root = sqrt(max(fd * fd + dd * k, 0.0));
185
+ if (fd <= 0.0) {
186
+ float den = root - fd;
187
+ return den > 0.0 ? dd / den : 1.0;
188
+ }
189
+
190
+ return k > 0.0 ? (root + fd) / k : 1.0;
191
+ }`;
192
+ /** A radial gradient's texel moved to its ramp's entry at the fragment's place (radialPlace). */
193
+ const radialAt = ` if (vRadial.x > 0.0) {
194
+ // Rounded to the nearest entry, as Flash reads a radial's ramp (radialIndex).
195
+ float entry = radialPlace(vTexel, vRadial.y) * ${RAMP_TEXELS.toFixed(1)} + 0.5;
196
+ at = vec2(max(entry, vRadial.x), vRadial.z);
197
+ }
198
+ `;
141
199
  /**
142
200
  * Flash's colour transform on the straight colour, clamped, then
143
201
  * premultiplied for blending: the vertex' colour, or with a texture the
144
202
  * texel's (premultiplied in the texture) times it, as the colour batcher
145
- * did, a clear texel staying clear. With `stage`, the stage fill program's
146
- * (stageFillFragment).
203
+ * did, a clear texel staying clear. With `radial`, a radial gradient's
204
+ * texel is its ramp's at the fragment's place (radialPlace), each pixel's
205
+ * own as Flash finds it (radialFillFragment). With `stage`, the stage fill
206
+ * program's (stageFillFragment).
147
207
  */
148
- const fillFragmentOf = (stage) => `#version 300 es
208
+ const fillFragmentOf = (stage, radial) => `#version 300 es
149
209
  precision highp float;
150
210
  in vec4 vColor;
151
211
  in vec2 vTexel;
152
212
  flat in vec4 vMul;
153
213
  flat in vec4 vAdd;
154
214
  flat in int vSlot;
215
+ ${radial ? "flat in vec3 vRadial;" : ""}
155
216
  uniform sampler2D uTextures[${FILL_TEXTURES}];
156
217
  ${stage ? "uniform vec4 uStage;\n" : ""}out vec4 finalColor;
157
218
 
@@ -175,10 +236,14 @@ ${slotTexel}
175
236
  return t;
176
237
  }
177
238
 
239
+ ${radial ? radialPlace : ""}
240
+
178
241
  void main(void) {
179
242
  vec4 straight = vColor;
180
243
  if (${stage ? `(vSlot & ${STAGE_TEXEL - 1})` : "vSlot"} != 0) {
181
- vec4 t = texel(vTexel);
244
+ vec2 at = vTexel;
245
+ ${radial ? radialAt : ""}
246
+ vec4 t = texel(at);
182
247
  if (t.a == 0.0) {
183
248
  finalColor = vec4(0.0);
184
249
  return;
@@ -191,8 +256,20 @@ void main(void) {
191
256
  finalColor = vec4(c.rgb * c.a, c.a);
192
257
  }
193
258
  `;
194
- /** The fill program's fragment shader, which every fill draws with but those of stageFillFragment. */
195
- export const fillFragment = fillFragmentOf(false);
259
+ /**
260
+ * The fill program's fragment shader, which every fill draws with but a
261
+ * radial gradient's (radialFillFragment) and those of stageFillFragment.
262
+ * A program of its own: in it, the radial gradient's path, though no fill
263
+ * took it, made a frame of plain fills take Intel's GPUs some tenth as long
264
+ * again (bench.ts --shapes 2000, Iris Xe).
265
+ */
266
+ export const fillFragment = fillFragmentOf(false, false);
267
+ /**
268
+ * The radial fill program's, for runs of fills one of which is a radial
269
+ * gradient's (RADIAL_FILL): every fill as fillFragment draws it, and a radial
270
+ * gradient's texel at the fragment's place.
271
+ */
272
+ export const radialFillFragment = fillFragmentOf(false, true);
196
273
  /**
197
274
  * The stage fill program's, for a fill some of whose texels are the
198
275
  * stage's pixel (TARGET_TEXEL, Place.stage), drawn alone: the stage's
@@ -202,7 +279,7 @@ export const fillFragment = fillFragmentOf(false);
202
279
  * its own: in the fill program, that path, though no fill took it, made a
203
280
  * frame of plain fills take Intel's GPUs over half as long again.
204
281
  */
205
- export const stageFillFragment = fillFragmentOf(true);
282
+ export const stageFillFragment = fillFragmentOf(true, true);
206
283
  /**
207
284
  * drawTriangles' textured triangles (MESH), placed as fills are, their u
208
285
  * and v carried times their depth t, and t, which the GPU interpolates
@@ -683,16 +760,18 @@ ${BLEND_FRONT}}
683
760
  /**
684
761
  * A fill drawn straight onto what is below it in a blend mode, where its
685
762
  * layer would hold it alone (a flat fill, GeometryData.flat): its pixel as
686
- * fillFragment has it, then as compositeFragment composites its layer's,
687
- * coloured by the layer's row (uLayerRow, -1 for none) and blended by uMode.
763
+ * fillFragment, or with `radial` radialFillFragment, has it, then as
764
+ * compositeFragment composites its layer's, coloured by the layer's row
765
+ * (uLayerRow, -1 for none) and blended by uMode.
688
766
  */
689
- export const blendFillFragment = `#version 300 es
767
+ const blendFillFragmentOf = (radial) => `#version 300 es
690
768
  precision highp float;
691
769
  in vec4 vColor;
692
770
  in vec2 vTexel;
693
771
  flat in vec4 vMul;
694
772
  flat in vec4 vAdd;
695
773
  flat in int vSlot;
774
+ ${radial ? "flat in vec3 vRadial;" : ""}
696
775
  uniform sampler2D uTextures[${FILL_TEXTURES}];
697
776
  uniform sampler2D uBack;
698
777
  uniform highp sampler2D uRows;
@@ -711,12 +790,16 @@ ${slotTexel}
711
790
  return t;
712
791
  }
713
792
 
793
+ ${radial ? radialPlace : ""}
794
+
714
795
  void main(void) {
715
796
  vec4 front = vec4(0.0);
716
797
  vec4 fill = vColor;
717
798
  bool clear = false;
718
799
  if (vSlot != 0) {
719
- vec4 t = texel(vTexel);
800
+ vec2 at = vTexel;
801
+ ${radial ? radialAt : ""}
802
+ vec4 t = texel(at);
720
803
  clear = t.a == 0.0;
721
804
  fill = clear ? fill : vec4(t.rgb / t.a * vColor.rgb, t.a * vColor.a);
722
805
  }
@@ -729,4 +812,14 @@ void main(void) {
729
812
  ${layerColor("uLayerRow")}
730
813
  ${BLEND_FRONT}}
731
814
  `;
815
+ /**
816
+ * The blend program's fragment shader, for every fill drawn straight in a
817
+ * blend mode but a radial gradient's (radialBlendFillFragment). A program of
818
+ * its own, as fillFragment is: the radial path in it, though no fill took
819
+ * it, made SwiftShader's frames of 500 shapes in blend modes 3 % longer
820
+ * (bench.ts --blends 500).
821
+ */
822
+ export const blendFillFragment = blendFillFragmentOf(false);
823
+ /** The radial blend program's, for a radial gradient's fill drawn straight in a blend mode. */
824
+ export const radialBlendFillFragment = blendFillFragmentOf(true);
732
825
  //# sourceMappingURL=programs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"programs.js","sourceRoot":"","sources":["../../src/webgl/programs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EACL,GAAG,EACH,KAAK,EACL,aAAa,EACb,cAAc,EACd,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;;;;;;EAQzB,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;;;;;;;;;;;EAWtB,UAAU,CAAC,WAAW,CAAC;EACvB,WAAW;CACZ,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;AAE5D,+FAA+F;AAC/F,MAAM,CAAC,MAAM,uBAAuB,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swf2es/render",
3
- "version": "0.1.43",
3
+ "version": "0.1.45",
4
4
  "description": "swf2es's own renderer: a scene list, a planner and a WebGL 2 backend (docs/renderer.md)",
5
5
  "keywords": [
6
6
  "swf",
@@ -33,6 +33,6 @@
33
33
  "src"
34
34
  ],
35
35
  "dependencies": {
36
- "@swf2es/context3d": "0.1.43"
36
+ "@swf2es/context3d": "0.1.45"
37
37
  }
38
38
  }
@@ -72,7 +72,7 @@ void main(void) {
72
72
  /**
73
73
  * A glow or a shadow: the input's blurred alpha (uBlurred), from `uOffset`
74
74
  * texels back for a shadow, times strength and alpha, in its colour; behind
75
- * the object, or inside it for an inner one; the object kept, or not.
75
+ * the object, or atop it for an inner one; the object kept, or not.
76
76
  */
77
77
  export const GLOW = `in vec2 vTextureCoord;
78
78
  out vec4 finalColor;
@@ -92,10 +92,13 @@ void main(void) {
92
92
  float a = texture(uBlurred, (vTextureCoord - uOffset * uInputSize.zw) * uBlurredScale).a;
93
93
  vec4 c;
94
94
  if (uInner > 0.5) {
95
- float g = clamp((1.0 - a) * uStrength, 0.0, 1.0) * uAlpha * src.a;
95
+ float raw = clamp((1.0 - a) * uStrength, 0.0, 1.0) * uAlpha;
96
+ float g = raw * src.a;
96
97
  vec4 glow = vec4(uColor * g, g);
97
- // A shadow that hides its object leaves the inner shadow alone, as knocked out (adl).
98
- c = uKnockout > 0.5 || uHide > 0.5 ? glow : glow + src * (1.0 - g);
98
+ // A shadow that hides its object leaves the inner shadow alone, as knocked out (adl). Kept, the
99
+ // object's straight colour gives way by the glow's own alpha, not that times the object's, and
100
+ // keeps its alpha: over a half-transparent object a full glow is its colour alone (adl).
101
+ c = uKnockout > 0.5 || uHide > 0.5 ? glow : glow + src * (1.0 - raw);
99
102
  } else {
100
103
  float g = clamp(a * uStrength, 0.0, 1.0) * uAlpha;
101
104
  vec4 glow = vec4(uColor * g, g);
package/src/index.ts CHANGED
@@ -86,6 +86,7 @@ export {
86
86
  NORMAL,
87
87
  OVERLAY,
88
88
  PLANE,
89
+ RADIAL_FILL,
89
90
  REPEAT,
90
91
  SCREEN,
91
92
  SceneList,
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/rows.ts CHANGED
@@ -1,9 +1,21 @@
1
1
  /**
2
2
  * Floats a row: an object's transform on the stage and its colour
3
3
  * transform, four texels of a float texture. The linear part; the
4
- * translation; the multipliers; the offsets, over 255.
4
+ * translation, then the line its draws read their texture on (line), or 0,
5
+ * and a radial gradient's focal point (radial), or 0; the multipliers; the
6
+ * offsets, over 255.
5
7
  */
6
8
  export const ROW_FLOATS = 16;
9
+ /**
10
+ * What a radial gradient's row (radial) adds to its focal point in the
11
+ * translation's last float: 0 there is any other draw's.
12
+ */
13
+ export const RADIAL = 2;
14
+ /**
15
+ * What it adds for each entry its ramp is read no lower than (radial's
16
+ * `least`): wider than a focal point's span, so that each is told apart.
17
+ */
18
+ export const RADIAL_LEAST_STEP = 4;
7
19
  /** Rows a line of the rows' texture. */
8
20
  export const ROWS_A_LINE = 256;
9
21
  /**
@@ -119,6 +131,27 @@ export class Rows {
119
131
  return row;
120
132
  }
121
133
 
134
+ /**
135
+ * Row `row`'s draws read their texture on its line `line` alone, whatever
136
+ * their texels' v: a ramp kept as a line of a texture of many, so that
137
+ * instances whose ramps differ need not each take a texture of their own,
138
+ * each of which takes one of the fill program's slots and ends a run as
139
+ * they run out.
140
+ */
141
+ line(row: number, line: number): void {
142
+ this.data[row * ROW_FLOATS + 6] = line + 0.5;
143
+ }
144
+
145
+ /**
146
+ * Row `row`'s draws are a radial gradient's, their texels its square's
147
+ * place (a unit its radius), from which the fill program finds each
148
+ * fragment's place on the ramp, out from `focal` on the x axis (-1 to 1),
149
+ * read no lower than entry `least`.
150
+ */
151
+ radial(row: number, focal: number, least = 0): void {
152
+ this.data[row * ROW_FLOATS + 7] = focal + RADIAL + least * RADIAL_LEAST_STEP;
153
+ }
154
+
122
155
  /** A row taken, the store grown for it: its index. */
123
156
  private next(): number {
124
157
  const row = this.count++;
package/src/scene.ts CHANGED
@@ -146,6 +146,12 @@ export const SNAP = 32;
146
146
  * draws one.
147
147
  */
148
148
  export const SHADED = 64;
149
+ /**
150
+ * A radial gradient's draw, whose row says so (Rows.radial): drawn by a
151
+ * fill program that finds each fragment's place on its ramp, which the
152
+ * plain fill program leaves out (webgl/programs.ts, radialFillFragment).
153
+ */
154
+ export const RADIAL_FILL = 128;
149
155
 
150
156
  /**
151
157
  * Which pixels a filtered layer's object covers (SceneList.wholes): those
package/src/spans.ts CHANGED
@@ -22,7 +22,7 @@ export interface Span {
22
22
  rowsEnd: number;
23
23
  }
24
24
 
25
- /** A row's floats by name (rows.ts), the two after the translation unused. */
25
+ /** A row's floats by name (rows.ts): the line after the translation (Rows.line), one unused. */
26
26
  const ROW_NAMES = [
27
27
  "a",
28
28
  "b",
@@ -30,7 +30,7 @@ const ROW_NAMES = [
30
30
  "d",
31
31
  "tx",
32
32
  "ty",
33
- "pad 6",
33
+ "line",
34
34
  "pad 7",
35
35
  "rMul",
36
36
  "gMul",
package/src/textures.ts CHANGED
@@ -18,8 +18,20 @@ export interface TextureData {
18
18
  fill: number | null;
19
19
  /** Host image, interpreted only by the backend; core has no DOM dependency. */
20
20
  source?: object | null;
21
+ /** Its line of the lines' texture where it is a line (addLine). */
22
+ line?: number;
21
23
  }
22
24
 
25
+ /**
26
+ * Texels a line texture has (addLine): a gradient's ramp's, 256 across. The
27
+ * lines' texture is as wide, so that a ramp wraps across it as across a
28
+ * texture of its own.
29
+ */
30
+ export const LINE_TEXELS = 256;
31
+
32
+ /** The most lines there are at once: the lines' texture's height, which every WebGL 2 allows. */
33
+ const LINES_MOST = 2048;
34
+
23
35
  /**
24
36
  * How many frames a texture keeps the bytes it was last set from without
25
37
  * being set again, and spare bytes wait for another texture: a texture set
@@ -60,6 +72,9 @@ export class Textures extends Registry {
60
72
  private readonly lent = new WeakSet<Uint8Array>();
61
73
  /** Added or set again since the backend last took them. */
62
74
  pending: number[] = [];
75
+ /** Lines let go of, to give again, and how many have been given (addLine). */
76
+ private readonly freeLines: number[] = [];
77
+ private lineTop = 0;
63
78
 
64
79
  /**
65
80
  * `length` bytes to fill and add or set a texture from: those texture `id`
@@ -97,6 +112,36 @@ export class Textures extends Registry {
97
112
  return handle;
98
113
  }
99
114
 
115
+ /**
116
+ * A texture of `pixels`, LINE_TEXELS by 1, kept by the backend as a line of
117
+ * one texture of many (lineOf): drawn on that line by its row (Rows.line),
118
+ * all of them take one of the fill program's slots, and those a frame
119
+ * added or set are uploaded together, where many textures of their own, as
120
+ * a gradient's ramps under many colour transforms are, each took a slot,
121
+ * ending a run as they ran out, and an upload. Null where there are as
122
+ * many lines as there may be. It is set again as any other, at its size.
123
+ */
124
+ addLine(pixels: Uint8Array, idle = IDLE_FRAMES): TextureHandle | null {
125
+ const line = this.freeLines.pop() ?? (this.lineTop < LINES_MOST ? this.lineTop++ : -1);
126
+ if (line < 0) {
127
+ return null;
128
+ }
129
+
130
+ const handle = this.add(LINE_TEXELS, 1, pixels, idle);
131
+ (this.data[handle.id] as TextureData).line = line;
132
+ return handle;
133
+ }
134
+
135
+ /** `id`'s line of the lines' texture, or -1 for a texture of its own. */
136
+ lineOf(id: number): number {
137
+ return this.data[id]?.line ?? -1;
138
+ }
139
+
140
+ /** How many lines the lines' texture has room for at least: those given, the free among them. */
141
+ get lines(): number {
142
+ return this.lineTop;
143
+ }
144
+
100
145
  /**
101
146
  * A texture every texel of which is `pixel`, premultiplied ARGB, as a
102
147
  * BitmapData is made: cleared to it on the GPU, with no bytes to fill
@@ -116,20 +161,17 @@ export class Textures extends Registry {
116
161
  * let go of after as many undrawn frames where that is fewer.
117
162
  */
118
163
  set(id: number, width: number, height: number, pixels: Uint8Array, idle?: number): void {
119
- const data = this.data[id];
120
- if (data) {
121
- data.width = width;
122
- data.height = height;
123
- data.pixels = pixels;
124
- data.source = null;
125
- data.fill = null;
126
- this.keep(id, pixels);
127
- this.changing[id] = true;
128
- this.pending.push(id);
129
- if (idle !== undefined) {
130
- this.idleWithin(id, idle);
131
- }
132
- }
164
+ this.setAs(id, width, height, pixels, idle, true);
165
+ }
166
+
167
+ /**
168
+ * As set, for pixels made anew whole each time, as a gradient's are for
169
+ * each colour transform taken into its stops: their bytes are spared once
170
+ * uploaded, as an added texture's are, not kept for KEEP_FRAMES, so that
171
+ * textures refilled every frame hold no more than the spare bytes' cap.
172
+ */
173
+ refill(id: number, width: number, height: number, pixels: Uint8Array, idle?: number): void {
174
+ this.setAs(id, width, height, pixels, idle, false);
133
175
  }
134
176
 
135
177
  /** A host image uploaded directly, without making a CPU copy for the renderer. */
@@ -191,6 +233,11 @@ export class Textures extends Registry {
191
233
  }
192
234
 
193
235
  protected override dropped(id: number): void {
236
+ const line = this.data[id]?.line;
237
+ if (line !== undefined) {
238
+ this.freeLines.push(line);
239
+ }
240
+
194
241
  this.data[id] = null;
195
242
  const bytes = this.kept[id];
196
243
  this.kept[id] = null;
@@ -199,6 +246,30 @@ export class Textures extends Registry {
199
246
  }
200
247
  }
201
248
 
249
+ private setAs(
250
+ id: number,
251
+ width: number,
252
+ height: number,
253
+ pixels: Uint8Array,
254
+ idle: number | undefined,
255
+ changing: boolean,
256
+ ): void {
257
+ const data = this.data[id];
258
+ if (data) {
259
+ data.width = width;
260
+ data.height = height;
261
+ data.pixels = pixels;
262
+ data.source = null;
263
+ data.fill = null;
264
+ this.keep(id, pixels);
265
+ this.changing[id] = changing;
266
+ this.pending.push(id);
267
+ if (idle !== undefined) {
268
+ this.idleWithin(id, idle);
269
+ }
270
+ }
271
+ }
272
+
202
273
  /** `pixels` kept for `id` where `bytes` lent them; those it kept before spared. */
203
274
  private keep(id: number, pixels: Uint8Array | Float32Array | null): void {
204
275
  const before = this.kept[id];