@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
@@ -34,11 +34,17 @@ export declare class Draws {
34
34
  private readonly batches;
35
35
  private readonly gpu;
36
36
  private readonly pool;
37
- /** The fill program, and where it takes its row, view and Flash's pixels a stage pixel. */
38
- program: WebGLProgram;
39
- private rowLocation;
40
- private viewLocation;
41
- private fillUnitLocation;
37
+ /**
38
+ * The fill program; the radial one, linked as a run of a radial
39
+ * gradient's fill first needs it, from radialPending, begun with the rest;
40
+ * and the one in use.
41
+ */
42
+ private plain;
43
+ private radial;
44
+ private radialPending;
45
+ private fill;
46
+ /** Views given (drawInto), which a fill program is told as it is next used. */
47
+ private views;
42
48
  /**
43
49
  * The stage fill program (stageFillFragment), for fills that sample the
44
50
  * stage's pixel (Place.stage), each drawn alone: linked as one is first
@@ -51,18 +57,15 @@ export declare class Draws {
51
57
  private stageUnitLocation;
52
58
  private stageLocation;
53
59
  /**
54
- * The fill program that blends a fill straight onto what is below it
55
- * (drawBlended), a draw a call, and where it takes what the fill program
56
- * does and the blend's mode, its layer's row and where the copy of what
57
- * is below lies.
60
+ * The fill programs that blend a fill straight onto what is below it
61
+ * (drawBlended), a draw a call, taking what the fill program does and the
62
+ * blend's mode, its layer's row and where the copy of what is below lies:
63
+ * the plain one, and the radial one for a radial gradient's fill, linked
64
+ * as one is first drawn from radialBlendPending, begun with the rest.
58
65
  */
59
- private blendProgram;
60
- private blendRowLocation;
61
- private blendViewLocation;
62
- private blendUnitLocation;
63
- private blendModeLocation;
64
- private blendLayerRowLocation;
65
- private blendBackLocation;
66
+ private blend;
67
+ private radialBlend;
68
+ private radialBlendPending;
66
69
  /** WEBGL_multi_draw, which draws a run of fills alike a call (drawEntries), where there is. */
67
70
  private multi;
68
71
  /**
@@ -72,9 +75,6 @@ export declare class Draws {
72
75
  merging: boolean;
73
76
  /** Avoid the dynamically indexed uniform table used in the Intel GPU hang reproducer. */
74
77
  private runTable;
75
- private runBaseLocation;
76
- /** The table start the fill program was told last (uRunBase), -1 for none. */
77
- private runBase;
78
78
  private runTableHeight;
79
79
  private runTableMost;
80
80
  private tableRows;
@@ -134,11 +134,6 @@ export declare class Draws {
134
134
  private glyphTable;
135
135
  /** Flash's pixels a stage pixel: the target's pixels a stage pixel over those a pixel of Flash's. */
136
136
  private unit;
137
- /**
138
- * The row a fill drawn alone (without WEBGL_multi_draw) last told the fill
139
- * program, so that it is not told again; -1 for none (forgetRow).
140
- */
141
- private lastRow;
142
137
  /** Each shader fill's fragment shader by its entry in the frame's filters, for the generation it is of. */
143
138
  private readonly fillShaders;
144
139
  /** A shader fill's program as it is linked: its rows' unit. */
@@ -154,6 +149,20 @@ export declare class Draws {
154
149
  kernels: KernelPrograms);
155
150
  /** The fill, mesh and glyph programs made, as the context comes or comes back. */
156
151
  setUp(textureMost: number): void;
152
+ /**
153
+ * Blend program `program` linked, made the current program: its samplers
154
+ * told their units, its uniforms found. The radial one is so made as it is
155
+ * first drawn with, which changes the current program in the middle of
156
+ * drawBlended, before drawBlended makes it current itself.
157
+ */
158
+ private blendProgram;
159
+ /**
160
+ * The radial blend program, linked as first drawn with: from
161
+ * radialBlendPending, or begun again where its link failed, as radialFill.
162
+ */
163
+ private radialBlendProgram;
164
+ /** Fill program `program` linked, in use: its samplers told their units, its uniforms found. */
165
+ private fillProgram;
157
166
  /**
158
167
  * Upload before any draws, so that updating a run cannot stall earlier
159
168
  * draws reading it: the run table, with WEBGL_multi_draw, and the merged
@@ -168,10 +177,21 @@ export declare class Draws {
168
177
  * down in a layer. The fill program takes the view.
169
178
  */
170
179
  drawInto(open: Open, target: Target): void;
171
- /** The row the fill program was told forgotten, so that the next fill tells it again. */
180
+ /** The row the fill programs were told forgotten, so that the next fill tells it again. */
172
181
  forgetRow(): void;
173
- /** The fill program and rows bound; each run selects its vertex array. */
174
- useFill(): void;
182
+ /**
183
+ * The fill program, or with `radial` the radial one, by default the one
184
+ * last used, so that a run of one kind after another switches programs
185
+ * once, and rows bound, the program told the view where it has not been;
186
+ * each run selects its vertex array.
187
+ */
188
+ useFill(radial?: boolean): void;
189
+ /**
190
+ * The radial fill program, linked as first asked for: from radialPending,
191
+ * or begun again where its link failed and the frame was conceded without
192
+ * a setUp (LinkLosses), as endProgram deletes a program it cannot link.
193
+ */
194
+ private radialFill;
175
195
  /** Entries `first` up to `end` drawn as fills, where the masks pushed pass. */
176
196
  drawRun(scene: SceneList, first: number, end: number, command: number): void;
177
197
  /**
@@ -207,7 +227,7 @@ export declare class Draws {
207
227
  maskBy(masks: Masks): void;
208
228
  /** The draws at `scene`'s entries from `first` up to `end`; for the stencil alone, untextured. */
209
229
  drawEntries(scene: SceneList, first: number, end: number, stencil: boolean, command: number): void;
210
- /** The fill program told where its run starts in the run table, if it was told another. */
230
+ /** The fill program in use told where its run starts in the run table, if it was told another. */
211
231
  private tellRunBase;
212
232
  /**
213
233
  * The fills from entry `i` on that one call draws, as many as fit its
@@ -227,7 +247,8 @@ export declare class Draws {
227
247
  * The slot (FILL_SLOT) of the unit texture `id` is sampled from so in the
228
248
  * run: the one it was left on, else one the run has not taken, an empty
229
249
  * one first, so that a texture stays where it is from run to run; 0 when
230
- * the run has taken all.
250
+ * the run has taken all. Line textures (Textures.addLine), all one texture
251
+ * here, share a unit.
231
252
  */
232
253
  private runSlot;
233
254
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"draws.d.ts","sourceRoot":"","sources":["../../src/webgl/draws.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,OAAO,EAAe,MAAM,0BAA0B,CAAC;AAC/F,OAAO,EAAE,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;OAUG;IACH,WAAW,CACT,KAAK,EAAE,SAAS,EAChB,CAAC,EAAE,MAAM,EACT,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,OAAO,GAAG,SAAS,EAC1B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACZ,IAAI,CA4BN;IAED;;;;;;OAMG;IACH,QAAQ,CACN,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,MAAM,GACd,IAAI,CAeN;IAED,6EAA6E;IAC7E,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAGzB;IAED,kGAAkG;IAClG,WAAW,CACT,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,IAAI,CAoIN;IAED,kGAAkG;IAClG,OAAO,CAAC,WAAW;IAQnB;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,SAAS;IA4EjB;;;;;;OAMG;IACH,OAAO,CAAC,OAAO;IAoCf;;;;OAIG;IACH,OAAO,CAAC,SAAS;IA8CjB;;;;;OAKG;IACH,OAAO,CAAC,UAAU;IAgClB;;;;OAIG;IACH,OAAO,CAAC,QAAQ;IAiDhB;;;;OAIG;IACH,OAAO,CAAC,UAAU;IA+BlB,0GAA0G;IAC1G,OAAO,CAAC,UAAU;IAqBlB,gEAAgE;IAChE,OAAO,IAAI,IAAI,CA+Bd;CACF"}
@@ -1,13 +1,18 @@
1
- import { beginProgram, endProgram, linkProgram } from "@swf2es/context3d/device";
1
+ import { beginProgram, endProgram, linkProgram, } from "@swf2es/context3d/device";
2
2
  import { RUN, STENCIL_POP, STENCIL_PUSH } from "../commands.js";
3
3
  import { FILL_SHADER } from "../filters.js";
4
4
  import { fillKernel, kernelImagesFit } from "../kernel-shaders.js";
5
- import { CLAMP, DRAW, MESH, MIRROR, NORMAL, PLANE, REPEAT, SHADED, SMOOTH, SNAP, } from "../scene.js";
5
+ import { CLAMP, DRAW, MESH, MIRROR, NORMAL, PLANE, RADIAL_FILL, REPEAT, SHADED, SMOOTH, SNAP, } from "../scene.js";
6
6
  import { gathered } from "./atlas.js";
7
7
  import { FillBatches } from "./batches.js";
8
8
  import { setModeBlend } from "./composite.js";
9
- import { BACK_UNIT, BELOW_STEP, blendFillFragment, FILL_SLOT, FILL_TEXTURES, FILL_UNIT, FRESH, fillFragment, fillVertex, glyphsFragment, glyphsVertex, MERGED_UNIT, meshFragment, meshVertex, OUTLINE_UNIT, RUN_MOST, RUN_UNIT, SNAP_BIT, stageFillFragment, TABLE_UNIT, TEXTURE_UNIT, } from "./programs.js";
9
+ import { BACK_UNIT, BELOW_STEP, blendFillFragment, FILL_SLOT, FILL_TEXTURES, FILL_UNIT, FRESH, fillFragment, fillVertex, glyphsFragment, glyphsVertex, MERGED_UNIT, meshFragment, meshVertex, OUTLINE_UNIT, RUN_MOST, RUN_UNIT, radialBlendFillFragment, radialFillFragment, SNAP_BIT, stageFillFragment, TABLE_UNIT, TEXTURE_UNIT, } from "./programs.js";
10
10
  import { framebufferOf } from "./targets.js";
11
+ /**
12
+ * A bit of a run's units (runUnits) above theirs: one of its fills is a
13
+ * radial gradient's (RADIAL_FILL), which the radial fill program draws.
14
+ */
15
+ const RADIAL_RUN = 1 << 30;
11
16
  /** Last entry, table start, draws, units, batch start/count, then each unit's texture and sampling. */
12
17
  const RUN_STRIDE = 6 + FILL_TEXTURES * 2;
13
18
  /**
@@ -37,11 +42,17 @@ export class Draws {
37
42
  batches;
38
43
  gpu;
39
44
  pool;
40
- /** The fill program, and where it takes its row, view and Flash's pixels a stage pixel. */
41
- program;
42
- rowLocation = null;
43
- viewLocation = null;
44
- fillUnitLocation = null;
45
+ /**
46
+ * The fill program; the radial one, linked as a run of a radial
47
+ * gradient's fill first needs it, from radialPending, begun with the rest;
48
+ * and the one in use.
49
+ */
50
+ plain;
51
+ radial = null;
52
+ radialPending = null;
53
+ fill;
54
+ /** Views given (drawInto), which a fill program is told as it is next used. */
55
+ views = 0;
45
56
  /**
46
57
  * The stage fill program (stageFillFragment), for fills that sample the
47
58
  * stage's pixel (Place.stage), each drawn alone: linked as one is first
@@ -54,18 +65,15 @@ export class Draws {
54
65
  stageUnitLocation = null;
55
66
  stageLocation = null;
56
67
  /**
57
- * The fill program that blends a fill straight onto what is below it
58
- * (drawBlended), a draw a call, and where it takes what the fill program
59
- * does and the blend's mode, its layer's row and where the copy of what
60
- * is below lies.
68
+ * The fill programs that blend a fill straight onto what is below it
69
+ * (drawBlended), a draw a call, taking what the fill program does and the
70
+ * blend's mode, its layer's row and where the copy of what is below lies:
71
+ * the plain one, and the radial one for a radial gradient's fill, linked
72
+ * as one is first drawn from radialBlendPending, begun with the rest.
61
73
  */
62
- blendProgram;
63
- blendRowLocation = null;
64
- blendViewLocation = null;
65
- blendUnitLocation = null;
66
- blendModeLocation = null;
67
- blendLayerRowLocation = null;
68
- blendBackLocation = null;
74
+ blend;
75
+ radialBlend = null;
76
+ radialBlendPending = null;
69
77
  /** WEBGL_multi_draw, which draws a run of fills alike a call (drawEntries), where there is. */
70
78
  multi = null;
71
79
  /**
@@ -75,9 +83,6 @@ export class Draws {
75
83
  merging = true;
76
84
  /** Avoid the dynamically indexed uniform table used in the Intel GPU hang reproducer. */
77
85
  runTable = null;
78
- runBaseLocation = null;
79
- /** The table start the fill program was told last (uRunBase), -1 for none. */
80
- runBase = -1;
81
86
  runTableHeight = 0;
82
87
  runTableMost = 0;
83
88
  tableRows = new Int32Array(RUN_MOST);
@@ -137,11 +142,6 @@ export class Draws {
137
142
  glyphTable = -1;
138
143
  /** Flash's pixels a stage pixel: the target's pixels a stage pixel over those a pixel of Flash's. */
139
144
  unit = 1;
140
- /**
141
- * The row a fill drawn alone (without WEBGL_multi_draw) last told the fill
142
- * program, so that it is not told again; -1 for none (forgetRow).
143
- */
144
- lastRow = -1;
145
145
  /** Each shader fill's fragment shader by its entry in the frame's filters, for the generation it is of. */
146
146
  fillShaders = new Map();
147
147
  /** A shader fill's program as it is linked: its rows' unit. */
@@ -171,11 +171,12 @@ export class Draws {
171
171
  // All begun before any is asked after, so that a driver that compiles on threads of its own
172
172
  // (KHR_parallel_shader_compile) compiles them at once.
173
173
  const fill = beginProgram(gl, fillVertex(this.multi !== null, true), fillFragment);
174
- const blend = beginProgram(gl, fillVertex(false), blendFillFragment);
174
+ const blend = beginProgram(gl, fillVertex(false, false), blendFillFragment);
175
175
  const mesh = beginProgram(gl, meshVertex, meshFragment);
176
176
  const glyphs = beginProgram(gl, glyphsVertex, glyphsFragment);
177
+ let program;
177
178
  try {
178
- this.program = endProgram(gl, fill);
179
+ program = endProgram(gl, fill);
179
180
  }
180
181
  catch (e) {
181
182
  // Not where the context is flagged lost, whose every link fails.
@@ -184,40 +185,28 @@ export class Draws {
184
185
  }
185
186
  // An extension offered whose shader directive the compiler refuses: runs merged alone.
186
187
  this.multi = null;
187
- this.program = linkProgram(gl, fillVertex(false, true), fillFragment);
188
- }
188
+ program = linkProgram(gl, fillVertex(false, true), fillFragment);
189
+ }
190
+ // Begun once the extension is known to compile, compiled while the rest are linked.
191
+ this.radialPending = beginProgram(gl, fillVertex(this.multi !== null, true, false, true), radialFillFragment);
192
+ this.radial = null;
193
+ this.radialBlendPending = beginProgram(gl, fillVertex(false, false, false, true), radialBlendFillFragment);
194
+ this.radialBlend = null;
195
+ this.views = 0;
189
196
  this.unitIds.fill(-1);
190
- this.rowLocation = gl.getUniformLocation(this.program, "uRow");
191
- this.viewLocation = gl.getUniformLocation(this.program, "uView");
192
197
  // The context's own, gone with it, or not made yet.
193
198
  this.stageProgram = null;
194
- this.state.useProgram(this.program);
195
- gl.uniform1i(gl.getUniformLocation(this.program, "uRows"), 0);
196
- gl.uniform1iv(gl.getUniformLocation(this.program, "uTextures"), Array.from({ length: FILL_TEXTURES }, (_, k) => FILL_UNIT + k));
197
199
  this.runTable = null;
198
200
  this.runTableHeight = 0;
199
201
  this.runTableMost = textureMost;
200
202
  this.prepared = false;
201
- this.runBaseLocation = gl.getUniformLocation(this.program, "uRunBase");
202
- this.runBase = -1;
203
203
  this.batches.setUp(textureMost);
204
- gl.uniform1i(gl.getUniformLocation(this.program, "uMergedRows"), MERGED_UNIT);
205
204
  if (this.multi) {
206
205
  this.sizeRunTable(1);
207
- gl.uniform1i(gl.getUniformLocation(this.program, "uRunTable"), RUN_UNIT);
208
- }
209
- this.fillUnitLocation = gl.getUniformLocation(this.program, "uUnit");
210
- this.blendProgram = endProgram(gl, blend);
211
- this.blendRowLocation = gl.getUniformLocation(this.blendProgram, "uRow");
212
- this.blendViewLocation = gl.getUniformLocation(this.blendProgram, "uView");
213
- this.blendUnitLocation = gl.getUniformLocation(this.blendProgram, "uUnit");
214
- this.blendModeLocation = gl.getUniformLocation(this.blendProgram, "uMode");
215
- this.blendLayerRowLocation = gl.getUniformLocation(this.blendProgram, "uLayerRow");
216
- this.blendBackLocation = gl.getUniformLocation(this.blendProgram, "uBackOffset");
217
- this.state.useProgram(this.blendProgram);
218
- gl.uniform1i(gl.getUniformLocation(this.blendProgram, "uRows"), 0);
219
- gl.uniform1i(gl.getUniformLocation(this.blendProgram, "uBack"), BACK_UNIT);
220
- gl.uniform1iv(gl.getUniformLocation(this.blendProgram, "uTextures"), Array.from({ length: FILL_TEXTURES }, (_, k) => FILL_UNIT + k));
206
+ }
207
+ this.plain = this.fillProgram(program);
208
+ this.fill = this.plain;
209
+ this.blend = this.blendProgram(endProgram(gl, blend));
221
210
  this.mesh = endProgram(gl, mesh);
222
211
  this.meshRowLocation = gl.getUniformLocation(this.mesh, "uRow");
223
212
  this.meshViewLocation = gl.getUniformLocation(this.mesh, "uView");
@@ -241,7 +230,62 @@ export class Draws {
241
230
  this.glyphStale = true;
242
231
  this.glyphRow = -1;
243
232
  this.glyphTable = -1;
244
- this.lastRow = -1;
233
+ }
234
+ /**
235
+ * Blend program `program` linked, made the current program: its samplers
236
+ * told their units, its uniforms found. The radial one is so made as it is
237
+ * first drawn with, which changes the current program in the middle of
238
+ * drawBlended, before drawBlended makes it current itself.
239
+ */
240
+ blendProgram(program) {
241
+ const gl = this.gl;
242
+ this.state.useProgram(program);
243
+ gl.uniform1i(gl.getUniformLocation(program, "uRows"), 0);
244
+ gl.uniform1i(gl.getUniformLocation(program, "uBack"), BACK_UNIT);
245
+ gl.uniform1iv(gl.getUniformLocation(program, "uTextures"), Array.from({ length: FILL_TEXTURES }, (_, k) => FILL_UNIT + k));
246
+ return {
247
+ program,
248
+ row: gl.getUniformLocation(program, "uRow"),
249
+ view: gl.getUniformLocation(program, "uView"),
250
+ unit: gl.getUniformLocation(program, "uUnit"),
251
+ mode: gl.getUniformLocation(program, "uMode"),
252
+ layerRow: gl.getUniformLocation(program, "uLayerRow"),
253
+ back: gl.getUniformLocation(program, "uBackOffset"),
254
+ };
255
+ }
256
+ /**
257
+ * The radial blend program, linked as first drawn with: from
258
+ * radialBlendPending, or begun again where its link failed, as radialFill.
259
+ */
260
+ radialBlendProgram() {
261
+ if (!this.radialBlend) {
262
+ const pending = this.radialBlendPending ??
263
+ beginProgram(this.gl, fillVertex(false, false, false, true), radialBlendFillFragment);
264
+ this.radialBlendPending = null;
265
+ this.radialBlend = this.blendProgram(endProgram(this.gl, pending));
266
+ }
267
+ return this.radialBlend;
268
+ }
269
+ /** Fill program `program` linked, in use: its samplers told their units, its uniforms found. */
270
+ fillProgram(program) {
271
+ const gl = this.gl;
272
+ this.state.useProgram(program);
273
+ gl.uniform1i(gl.getUniformLocation(program, "uRows"), 0);
274
+ gl.uniform1iv(gl.getUniformLocation(program, "uTextures"), Array.from({ length: FILL_TEXTURES }, (_, k) => FILL_UNIT + k));
275
+ gl.uniform1i(gl.getUniformLocation(program, "uMergedRows"), MERGED_UNIT);
276
+ if (this.multi) {
277
+ gl.uniform1i(gl.getUniformLocation(program, "uRunTable"), RUN_UNIT);
278
+ }
279
+ return {
280
+ program,
281
+ row: gl.getUniformLocation(program, "uRow"),
282
+ view: gl.getUniformLocation(program, "uView"),
283
+ unit: gl.getUniformLocation(program, "uUnit"),
284
+ runBase: gl.getUniformLocation(program, "uRunBase"),
285
+ lastRow: -1,
286
+ base: -1,
287
+ viewed: -1,
288
+ };
245
289
  }
246
290
  /**
247
291
  * Upload before any draws, so that updating a run cannot stall earlier
@@ -370,20 +414,17 @@ export class Draws {
370
414
  * down in a layer. The fill program takes the view.
371
415
  */
372
416
  drawInto(open, target) {
373
- const gl = this.gl;
374
417
  const state = this.state;
375
418
  const ox = open.ox ?? 0;
376
419
  const oy = open.oy ?? 0;
377
420
  state.bindFramebuffer(framebufferOf(open));
378
421
  state.viewport(ox, oy, open.width, open.height);
379
- state.useProgram(this.program);
380
422
  const down = open.layer ? 1 : -1;
381
423
  const view = this.view;
382
424
  view[0] = (2 * target.scale) / open.width;
383
425
  view[1] = (down * 2 * target.scale) / open.height;
384
426
  view[2] = -1 + (2 * (target.x - open.x)) / open.width;
385
427
  view[3] = -down * (1 - (2 * (target.y - open.y)) / open.height);
386
- gl.uniform4fv(this.viewLocation, view);
387
428
  // A layer's rows run down from its corner; the canvas' up from its bottom.
388
429
  const frag = this.frag;
389
430
  frag[0] = open.x - target.x - ox;
@@ -396,19 +437,50 @@ export class Draws {
396
437
  stage[2] = down;
397
438
  stage[3] = 1 / target.scale;
398
439
  this.unit = target.scale / target.pixel;
399
- gl.uniform1f(this.fillUnitLocation, this.unit);
440
+ this.views++;
441
+ this.useFill();
400
442
  this.stageStale = true;
401
443
  this.meshStale = true;
402
444
  this.glyphStale = true;
403
445
  }
404
- /** The row the fill program was told forgotten, so that the next fill tells it again. */
446
+ /** The row the fill programs were told forgotten, so that the next fill tells it again. */
405
447
  forgetRow() {
406
- this.lastRow = -1;
448
+ this.plain.lastRow = -1;
449
+ if (this.radial) {
450
+ this.radial.lastRow = -1;
451
+ }
407
452
  }
408
- /** The fill program and rows bound; each run selects its vertex array. */
409
- useFill() {
410
- this.state.useProgram(this.program);
453
+ /**
454
+ * The fill program, or with `radial` the radial one, by default the one
455
+ * last used, so that a run of one kind after another switches programs
456
+ * once, and rows bound, the program told the view where it has not been;
457
+ * each run selects its vertex array.
458
+ */
459
+ useFill(radial = this.fill === this.radial) {
460
+ const fill = radial ? this.radialFill() : this.plain;
461
+ const gl = this.gl;
462
+ this.fill = fill;
463
+ this.state.useProgram(fill.program);
411
464
  this.state.bindTexture(0, this.gpu.rowsTexture);
465
+ if (fill.viewed !== this.views) {
466
+ fill.viewed = this.views;
467
+ gl.uniform4fv(fill.view, this.view);
468
+ gl.uniform1f(fill.unit, this.unit);
469
+ }
470
+ }
471
+ /**
472
+ * The radial fill program, linked as first asked for: from radialPending,
473
+ * or begun again where its link failed and the frame was conceded without
474
+ * a setUp (LinkLosses), as endProgram deletes a program it cannot link.
475
+ */
476
+ radialFill() {
477
+ if (!this.radial) {
478
+ const pending = this.radialPending ??
479
+ beginProgram(this.gl, fillVertex(this.multi !== null, true, false, true), radialFillFragment);
480
+ this.radialPending = null;
481
+ this.radial = this.fillProgram(endProgram(this.gl, pending));
482
+ }
483
+ return this.radial;
412
484
  }
413
485
  /** Entries `first` up to `end` drawn as fills, where the masks pushed pass. */
414
486
  drawRun(scene, first, end, command) {
@@ -448,14 +520,15 @@ export class Draws {
448
520
  drawBlended(scene, i, mode, reads, fresh, below, layerRow, backX, backY) {
449
521
  const gl = this.gl;
450
522
  const state = this.state;
451
- state.useProgram(this.blendProgram);
523
+ const blend = scene.sampler[i] & RADIAL_FILL ? this.radialBlendProgram() : this.blend;
524
+ state.useProgram(blend.program);
452
525
  state.bindTexture(0, this.gpu.rowsTexture);
453
- gl.uniform4fv(this.blendViewLocation, this.view);
454
- gl.uniform1f(this.blendUnitLocation, this.unit);
526
+ gl.uniform4fv(blend.view, this.view);
527
+ gl.uniform1f(blend.unit, this.unit);
455
528
  // Its pixel alone where GL's blending computes the mode (readsBelow).
456
- gl.uniform1i(this.blendModeLocation, (reads ? mode : NORMAL) + (fresh ? FRESH : 0) + below * BELOW_STEP);
457
- gl.uniform1i(this.blendLayerRowLocation, layerRow);
458
- gl.uniform2i(this.blendBackLocation, backX, backY);
529
+ gl.uniform1i(blend.mode, (reads ? mode : NORMAL) + (fresh ? FRESH : 0) + below * BELOW_STEP);
530
+ gl.uniform1i(blend.layerRow, layerRow);
531
+ gl.uniform2i(blend.back, backX, backY);
459
532
  this.gatherRun(scene, i, i + 1, false);
460
533
  if (this.runCount === 0) {
461
534
  return;
@@ -467,7 +540,7 @@ export class Draws {
467
540
  state.bindSampler(FILL_UNIT + k, this.gpu.sampler(this.unitSampling[k]));
468
541
  }
469
542
  }
470
- gl.uniform1i(this.blendRowLocation, this.runRows[0]);
543
+ gl.uniform1i(blend.row, this.runRows[0]);
471
544
  setModeBlend(gl, state, reads ? -1 : mode);
472
545
  gl.drawElements(gl.TRIANGLES, this.runCounts[0], gl.UNSIGNED_INT, this.runOffsets[0]);
473
546
  }
@@ -534,10 +607,6 @@ export class Draws {
534
607
  other = this.drawStage(scene, i) || other;
535
608
  continue;
536
609
  }
537
- if (other) {
538
- this.useFill();
539
- other = false;
540
- }
541
610
  let base = 0;
542
611
  let draws;
543
612
  let units;
@@ -561,6 +630,12 @@ export class Draws {
561
630
  if (draws === 0) {
562
631
  continue;
563
632
  }
633
+ // A mask's coverage by either.
634
+ const radial = stencil ? this.fill === this.radial : (units & RADIAL_RUN) !== 0;
635
+ if (other || radial !== (this.fill === this.radial)) {
636
+ this.useFill(radial);
637
+ other = false;
638
+ }
564
639
  for (let k = 0; k < FILL_TEXTURES; k++) {
565
640
  if (units & (1 << k)) {
566
641
  const id = this.prepared ? this.runs[bindings + k * 2] : this.unitIds[k];
@@ -583,10 +658,11 @@ export class Draws {
583
658
  const rows = this.prepared ? this.tableRows : this.runRows;
584
659
  const counts = this.prepared ? this.tableCounts : this.runCounts;
585
660
  const offsets = this.prepared ? this.tableOffsets : this.runOffsets;
661
+ const fill = this.fill;
586
662
  for (let k = base; k < base + draws; k++) {
587
- if (rows[k] !== this.lastRow) {
588
- this.lastRow = rows[k];
589
- gl.uniform1i(this.rowLocation, this.lastRow);
663
+ if (rows[k] !== fill.lastRow) {
664
+ fill.lastRow = rows[k];
665
+ gl.uniform1i(fill.row, fill.lastRow);
590
666
  }
591
667
  gl.drawElements(gl.TRIANGLES, counts[k], gl.UNSIGNED_INT, offsets[k]);
592
668
  }
@@ -605,11 +681,12 @@ export class Draws {
605
681
  this.useFill();
606
682
  }
607
683
  }
608
- /** The fill program told where its run starts in the run table, if it was told another. */
684
+ /** The fill program in use told where its run starts in the run table, if it was told another. */
609
685
  tellRunBase(base) {
610
- if (base !== this.runBase) {
611
- this.runBase = base;
612
- this.gl.uniform1i(this.runBaseLocation, base);
686
+ const fill = this.fill;
687
+ if (base !== fill.base) {
688
+ fill.base = base;
689
+ this.gl.uniform1i(fill.runBase, base);
613
690
  }
614
691
  }
615
692
  /**
@@ -671,6 +748,9 @@ export class Draws {
671
748
  break;
672
749
  }
673
750
  }
751
+ if (!stencil && scene.sampler[j] & RADIAL_FILL) {
752
+ this.runUnits |= RADIAL_RUN;
753
+ }
674
754
  this.runCounts[draws] = place.indices;
675
755
  this.runPlaces[draws] = place;
676
756
  // A short-lived geometry drawn more than once keeps its arrays (atlas.ts, settle).
@@ -689,11 +769,16 @@ export class Draws {
689
769
  * The slot (FILL_SLOT) of the unit texture `id` is sampled from so in the
690
770
  * run: the one it was left on, else one the run has not taken, an empty
691
771
  * one first, so that a texture stays where it is from run to run; 0 when
692
- * the run has taken all.
772
+ * the run has taken all. Line textures (Textures.addLine), all one texture
773
+ * here, share a unit.
693
774
  */
694
775
  runSlot(id, sampling) {
776
+ const textures = this.gpu.textures;
777
+ const texture = textures[id];
695
778
  for (let k = 0; k < FILL_TEXTURES; k++) {
696
- if (this.unitIds[k] === id && this.unitSampling[k] === sampling) {
779
+ const at = this.unitIds[k];
780
+ if ((at === id || (at >= 0 && textures[at] === texture)) &&
781
+ this.unitSampling[k] === sampling) {
697
782
  this.runUnits |= 1 << k;
698
783
  return k + 1;
699
784
  }
@@ -731,7 +816,7 @@ export class Draws {
731
816
  const state = this.state;
732
817
  if (!this.stageProgram) {
733
818
  // A link that fails is given up on as the fill program's would be (WebGLBackend.gaveUp).
734
- const program = linkProgram(gl, fillVertex(false, false, true), stageFillFragment);
819
+ const program = linkProgram(gl, fillVertex(false, false, true, true), stageFillFragment);
735
820
  this.stageProgram = program;
736
821
  this.stageRowLocation = gl.getUniformLocation(program, "uRow");
737
822
  this.stageViewLocation = gl.getUniformLocation(program, "uView");
@@ -897,7 +982,22 @@ export class Draws {
897
982
  this.runTable = null;
898
983
  }
899
984
  const gl = this.gl;
900
- gl.deleteProgram(this.program);
985
+ gl.deleteProgram(this.plain.program);
986
+ gl.deleteProgram(this.radial?.program ?? null);
987
+ if (this.radialPending) {
988
+ gl.deleteProgram(this.radialPending.program);
989
+ gl.deleteShader(this.radialPending.vertex);
990
+ gl.deleteShader(this.radialPending.fragment);
991
+ this.radialPending = null;
992
+ }
993
+ gl.deleteProgram(this.blend.program);
994
+ gl.deleteProgram(this.radialBlend?.program ?? null);
995
+ if (this.radialBlendPending) {
996
+ gl.deleteProgram(this.radialBlendPending.program);
997
+ gl.deleteShader(this.radialBlendPending.vertex);
998
+ gl.deleteShader(this.radialBlendPending.fragment);
999
+ this.radialBlendPending = null;
1000
+ }
901
1001
  gl.deleteProgram(this.stageProgram);
902
1002
  gl.deleteProgram(this.mesh);
903
1003
  gl.deleteProgram(this.glyphProgram);