@swf2es/render 0.1.34 → 0.1.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/commands.d.ts +11 -2
  2. package/dist/commands.d.ts.map +1 -1
  3. package/dist/commands.js +36 -6
  4. package/dist/commands.js.map +1 -1
  5. package/dist/geometry.d.ts +62 -5
  6. package/dist/geometry.d.ts.map +1 -1
  7. package/dist/geometry.js +100 -17
  8. package/dist/geometry.js.map +1 -1
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +1 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/measure.d.ts.map +1 -1
  14. package/dist/measure.js +118 -61
  15. package/dist/measure.js.map +1 -1
  16. package/dist/plan.js +4 -4
  17. package/dist/plan.js.map +1 -1
  18. package/dist/rows.d.ts +4 -0
  19. package/dist/rows.d.ts.map +1 -1
  20. package/dist/rows.js +59 -10
  21. package/dist/rows.js.map +1 -1
  22. package/dist/scene.d.ts.map +1 -1
  23. package/dist/scene.js +37 -5
  24. package/dist/scene.js.map +1 -1
  25. package/dist/webgl/atlas.d.ts +83 -18
  26. package/dist/webgl/atlas.d.ts.map +1 -1
  27. package/dist/webgl/atlas.js +271 -110
  28. package/dist/webgl/atlas.js.map +1 -1
  29. package/dist/webgl/backend.d.ts +5 -3
  30. package/dist/webgl/backend.d.ts.map +1 -1
  31. package/dist/webgl/backend.js +9 -9
  32. package/dist/webgl/backend.js.map +1 -1
  33. package/dist/webgl/batches.d.ts +36 -11
  34. package/dist/webgl/batches.d.ts.map +1 -1
  35. package/dist/webgl/batches.js +94 -51
  36. package/dist/webgl/batches.js.map +1 -1
  37. package/dist/webgl/draws.js +2 -2
  38. package/dist/webgl/draws.js.map +1 -1
  39. package/package.json +2 -2
  40. package/src/commands.ts +48 -6
  41. package/src/geometry.ts +109 -19
  42. package/src/index.ts +1 -0
  43. package/src/measure.ts +132 -68
  44. package/src/plan.ts +4 -4
  45. package/src/rows.ts +62 -19
  46. package/src/scene.ts +41 -5
  47. package/src/webgl/atlas.ts +321 -120
  48. package/src/webgl/backend.ts +9 -9
  49. package/src/webgl/batches.ts +108 -57
  50. package/src/webgl/draws.ts +2 -2
package/src/scene.ts CHANGED
@@ -145,6 +145,12 @@ export const NO_WHOLE = 0;
145
145
  export const WHOLE_SMOOTH = 1;
146
146
  export const WHOLE_ALIASED = 2;
147
147
 
148
+ /**
149
+ * Draws of a span from which SceneList.appendDraws copies its columns
150
+ * through views: below it, copying by index costs less than making them.
151
+ */
152
+ const SPAN_VIEW_DRAWS = 64;
153
+
148
154
  /**
149
155
  * A frame's drawing in order: each entry a geometry drawn under a row with
150
156
  * a blend mode, and the texture it samples (-1 for none) and how. Boundaries
@@ -226,20 +232,50 @@ export class SceneList {
226
232
 
227
233
  const kinds = from.kind;
228
234
  const rows = from.row;
235
+ const kind = this.kind;
229
236
  const row = this.row;
237
+ if (end - first >= SPAN_VIEW_DRAWS) {
238
+ // A long span's other columns through views, which copy them much faster than by index.
239
+ for (let e = first, to = at; e < end; e++, to++) {
240
+ if (kinds[e] !== DRAW) {
241
+ throw new Error(`entry ${e} of a span is no draw, which a span cannot move`);
242
+ }
243
+
244
+ kind[to] = DRAW;
245
+ row[to] = rows[e] + rowShift;
246
+ }
247
+
248
+ this.geometry.set(from.geometry.subarray(first, end), at);
249
+ this.blend.set(from.blend.subarray(first, end), at);
250
+ this.texture.set(from.texture.subarray(first, end), at);
251
+ this.sampler.set(from.sampler.subarray(first, end), at);
252
+ this.length = length;
253
+ return;
254
+ }
255
+
256
+ // Column by column, by index: a view of each to copy whole was most of what a frame of
257
+ // spans allocated, most spans being short.
258
+ const geometries = from.geometry;
259
+ const blends = from.blend;
260
+ const textures = from.texture;
261
+ const samplers = from.sampler;
262
+ const geometry = this.geometry;
263
+ const blend = this.blend;
264
+ const texture = this.texture;
265
+ const sampler = this.sampler;
230
266
  for (let e = first, to = at; e < end; e++, to++) {
231
267
  if (kinds[e] !== DRAW) {
232
268
  throw new Error(`entry ${e} of a span is no draw, which a span cannot move`);
233
269
  }
234
270
 
271
+ kind[to] = DRAW;
235
272
  row[to] = rows[e] + rowShift;
273
+ geometry[to] = geometries[e];
274
+ blend[to] = blends[e];
275
+ texture[to] = textures[e];
276
+ sampler[to] = samplers[e];
236
277
  }
237
278
 
238
- this.kind.fill(DRAW, at, length);
239
- this.geometry.set(from.geometry.subarray(first, end), at);
240
- this.blend.set(from.blend.subarray(first, end), at);
241
- this.texture.set(from.texture.subarray(first, end), at);
242
- this.sampler.set(from.sampler.subarray(first, end), at);
243
279
  this.length = length;
244
280
  }
245
281