@swf2es/render 0.0.0-stage → 0.1.0

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 (143) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +17 -2
  3. package/dist/commands.d.ts +67 -0
  4. package/dist/commands.d.ts.map +1 -0
  5. package/dist/commands.js +93 -0
  6. package/dist/commands.js.map +1 -0
  7. package/dist/filter-plan.d.ts +110 -0
  8. package/dist/filter-plan.d.ts.map +1 -0
  9. package/dist/filter-plan.js +480 -0
  10. package/dist/filter-plan.js.map +1 -0
  11. package/dist/filter-shaders.d.ts +63 -0
  12. package/dist/filter-shaders.d.ts.map +1 -0
  13. package/dist/filter-shaders.js +350 -0
  14. package/dist/filter-shaders.js.map +1 -0
  15. package/dist/filters.d.ts +107 -0
  16. package/dist/filters.d.ts.map +1 -0
  17. package/dist/filters.js +187 -0
  18. package/dist/filters.js.map +1 -0
  19. package/dist/geometry.d.ts +83 -0
  20. package/dist/geometry.d.ts.map +1 -0
  21. package/dist/geometry.js +93 -0
  22. package/dist/geometry.js.map +1 -0
  23. package/dist/index.d.ts +11 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +13 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/keeps.d.ts +17 -0
  28. package/dist/keeps.d.ts.map +1 -0
  29. package/dist/keeps.js +17 -0
  30. package/dist/keeps.js.map +1 -0
  31. package/dist/kernel-shaders.d.ts +74 -0
  32. package/dist/kernel-shaders.d.ts.map +1 -0
  33. package/dist/kernel-shaders.js +323 -0
  34. package/dist/kernel-shaders.js.map +1 -0
  35. package/dist/measure.d.ts +56 -0
  36. package/dist/measure.d.ts.map +1 -0
  37. package/dist/measure.js +287 -0
  38. package/dist/measure.js.map +1 -0
  39. package/dist/plan.d.ts +14 -0
  40. package/dist/plan.d.ts.map +1 -0
  41. package/dist/plan.js +247 -0
  42. package/dist/plan.js.map +1 -0
  43. package/dist/registry.d.ts +49 -0
  44. package/dist/registry.d.ts.map +1 -0
  45. package/dist/registry.js +87 -0
  46. package/dist/registry.js.map +1 -0
  47. package/dist/rows.d.ts +39 -0
  48. package/dist/rows.d.ts.map +1 -0
  49. package/dist/rows.js +60 -0
  50. package/dist/rows.js.map +1 -0
  51. package/dist/scene.d.ts +179 -0
  52. package/dist/scene.d.ts.map +1 -0
  53. package/dist/scene.js +265 -0
  54. package/dist/scene.js.map +1 -0
  55. package/dist/shelves.d.ts +23 -0
  56. package/dist/shelves.d.ts.map +1 -0
  57. package/dist/shelves.js +63 -0
  58. package/dist/shelves.js.map +1 -0
  59. package/dist/textures.d.ts +72 -0
  60. package/dist/textures.d.ts.map +1 -0
  61. package/dist/textures.js +160 -0
  62. package/dist/textures.js.map +1 -0
  63. package/dist/webgl/atlas.d.ts +63 -0
  64. package/dist/webgl/atlas.d.ts.map +1 -0
  65. package/dist/webgl/atlas.js +328 -0
  66. package/dist/webgl/atlas.js.map +1 -0
  67. package/dist/webgl/backend.d.ts +141 -0
  68. package/dist/webgl/backend.d.ts.map +1 -0
  69. package/dist/webgl/backend.js +659 -0
  70. package/dist/webgl/backend.js.map +1 -0
  71. package/dist/webgl/composite.d.ts +101 -0
  72. package/dist/webgl/composite.d.ts.map +1 -0
  73. package/dist/webgl/composite.js +293 -0
  74. package/dist/webgl/composite.js.map +1 -0
  75. package/dist/webgl/draws.d.ts +213 -0
  76. package/dist/webgl/draws.d.ts.map +1 -0
  77. package/dist/webgl/draws.js +714 -0
  78. package/dist/webgl/draws.js.map +1 -0
  79. package/dist/webgl/filters.d.ts +107 -0
  80. package/dist/webgl/filters.d.ts.map +1 -0
  81. package/dist/webgl/filters.js +351 -0
  82. package/dist/webgl/filters.js.map +1 -0
  83. package/dist/webgl/gpu-textures.d.ts +44 -0
  84. package/dist/webgl/gpu-textures.d.ts.map +1 -0
  85. package/dist/webgl/gpu-textures.js +178 -0
  86. package/dist/webgl/gpu-textures.js.map +1 -0
  87. package/dist/webgl/holds.d.ts +97 -0
  88. package/dist/webgl/holds.d.ts.map +1 -0
  89. package/dist/webgl/holds.js +453 -0
  90. package/dist/webgl/holds.js.map +1 -0
  91. package/dist/webgl/index.d.ts +2 -0
  92. package/dist/webgl/index.d.ts.map +1 -0
  93. package/dist/webgl/index.js +4 -0
  94. package/dist/webgl/index.js.map +1 -0
  95. package/dist/webgl/kernels.d.ts +64 -0
  96. package/dist/webgl/kernels.d.ts.map +1 -0
  97. package/dist/webgl/kernels.js +160 -0
  98. package/dist/webgl/kernels.js.map +1 -0
  99. package/dist/webgl/pool.d.ts +71 -0
  100. package/dist/webgl/pool.d.ts.map +1 -0
  101. package/dist/webgl/pool.js +192 -0
  102. package/dist/webgl/pool.js.map +1 -0
  103. package/dist/webgl/programs.d.ts +130 -0
  104. package/dist/webgl/programs.d.ts.map +1 -0
  105. package/dist/webgl/programs.js +582 -0
  106. package/dist/webgl/programs.js.map +1 -0
  107. package/dist/webgl/stage.d.ts +67 -0
  108. package/dist/webgl/stage.d.ts.map +1 -0
  109. package/dist/webgl/stage.js +173 -0
  110. package/dist/webgl/stage.js.map +1 -0
  111. package/dist/webgl/targets.d.ts +172 -0
  112. package/dist/webgl/targets.d.ts.map +1 -0
  113. package/dist/webgl/targets.js +323 -0
  114. package/dist/webgl/targets.js.map +1 -0
  115. package/package.json +35 -3
  116. package/src/commands.ts +98 -0
  117. package/src/filter-plan.ts +755 -0
  118. package/src/filter-shaders.ts +360 -0
  119. package/src/filters.ts +220 -0
  120. package/src/geometry.ts +143 -0
  121. package/src/index.ts +87 -0
  122. package/src/keeps.ts +21 -0
  123. package/src/kernel-shaders.ts +375 -0
  124. package/src/measure.ts +400 -0
  125. package/src/plan.ts +331 -0
  126. package/src/registry.ts +105 -0
  127. package/src/rows.ts +93 -0
  128. package/src/scene.ts +297 -0
  129. package/src/shelves.ts +70 -0
  130. package/src/textures.ts +198 -0
  131. package/src/webgl/atlas.ts +370 -0
  132. package/src/webgl/backend.ts +973 -0
  133. package/src/webgl/composite.ts +372 -0
  134. package/src/webgl/draws.ts +902 -0
  135. package/src/webgl/filters.ts +502 -0
  136. package/src/webgl/gpu-textures.ts +253 -0
  137. package/src/webgl/holds.ts +624 -0
  138. package/src/webgl/index.ts +3 -0
  139. package/src/webgl/kernels.ts +205 -0
  140. package/src/webgl/pool.ts +245 -0
  141. package/src/webgl/programs.ts +620 -0
  142. package/src/webgl/stage.ts +214 -0
  143. package/src/webgl/targets.ts +464 -0
@@ -0,0 +1,141 @@
1
+ import { GlState } from "@swf2es/context3d/device";
2
+ import { type Commands } from "../commands.js";
3
+ import type { Filters } from "../filters.js";
4
+ import type { Geometries } from "../geometry.js";
5
+ import type { Keeps } from "../keeps.js";
6
+ import type { Rows } from "../rows.js";
7
+ import { type SceneList } from "../scene.js";
8
+ import type { Textures } from "../textures.js";
9
+ import { type Layer, type Target } from "./targets.js";
10
+ export type { Target } from "./targets.js";
11
+ export declare class WebGLBackend {
12
+ readonly gl: WebGL2RenderingContext;
13
+ readonly state: GlState;
14
+ private readonly pool;
15
+ private readonly stage;
16
+ private readonly gpu;
17
+ private readonly atlas;
18
+ private readonly compositor;
19
+ private readonly draws;
20
+ private readonly holds;
21
+ /** Pixel Bender kernels' programs, which the filters, the compositor and the draws share. */
22
+ private readonly kernels;
23
+ /** The filters' passes, their programs made as first run. */
24
+ private filters;
25
+ /** The layers drawn into now, innermost last. */
26
+ private layers;
27
+ /** The frame's filters being drawn, whose chains blend shaders' modes name (KERNEL). */
28
+ private frameFilters;
29
+ /**
30
+ * Samples a pixel the stage and its layers are drawn with, 1 for none:
31
+ * Flash's anti-aliasing by the quality, as the host sets it.
32
+ */
33
+ samples: number;
34
+ /** The masks pushed on the target drawn into now (execute). */
35
+ private readonly masks;
36
+ /** A layer's rectangle, as blendDirect reads it. */
37
+ private readonly rect;
38
+ /** The mask counts of the targets below the layers drawn into now, two numbers each. */
39
+ private readonly below;
40
+ /** The program `compositeOver` draws with, linked as first used; null till then and after a lost context. */
41
+ private overProgram;
42
+ /** Framebuffers onto registry textures, drawn into or read, by texture id, with the texture they were made for. */
43
+ private textureFramebuffers;
44
+ constructor(gl: WebGL2RenderingContext);
45
+ /**
46
+ * The context came back after it was lost: everything made again, every
47
+ * geometry copied in again from the registry's arrays. The textures were
48
+ * lost with it, which their owners add again (Textures.lost).
49
+ */
50
+ restore(geometries: Geometries): void;
51
+ /** Programs, buffers and textures made, as the context comes or comes back. */
52
+ private setUp;
53
+ /**
54
+ * Draw a frame: what the geometries added and removed first, then the
55
+ * rows, then the commands; onto the canvas, or into `root`, a layer the
56
+ * target's size, as BitmapData.draw's frames go.
57
+ */
58
+ execute(commands: Commands, scene: SceneList, rows: Rows, geometries: Geometries, textures: Textures, filters: Filters, keeps: Keeps, target: Target, root?: Layer | null): void;
59
+ /**
60
+ * A frame drawn into a layer `samples` times the size of a `width` by
61
+ * `height` bitmap a side, as `execute` draws, then halved till a sample a
62
+ * pixel, and read back: premultiplied RGBA bytes, a row at a time from
63
+ * the top, as BitmapData.draw takes them.
64
+ */
65
+ snapshot(commands: Commands, scene: SceneList, rows: Rows, geometries: Geometries, textures: Textures, filters: Filters, keeps: Keeps, target: Target, width: number, height: number, samples: number): Uint8Array;
66
+ /**
67
+ * BitmapData.draw on the GPU: the commands drawn as `snapshot` draws
68
+ * them, into a layer of their own (the object may show the texture
69
+ * itself), then over texture `id` of the registry at (x, y), as Flash's
70
+ * store composites source over (compositeOver), where it stays: nothing
71
+ * is read back; `opaque` for an opaque store's texture. Pending
72
+ * textures, the one drawn into among them, are uploaded first. Whether
73
+ * it was drawn; not on a lost context or without the texture.
74
+ */
75
+ drawIntoTexture(commands: Commands, scene: SceneList, rows: Rows, geometries: Geometries, textures: Textures, filters: Filters, keeps: Keeps, target: Target, width: number, height: number, samples: number, id: number, x: number, y: number, opaque: boolean): boolean;
76
+ /**
77
+ * `layer`'s first `width` by `height` texels over those of `into` at
78
+ * (x, y), as Flash's store composites source over, a channel at a time
79
+ * on whole bytes: s + ((d * (256 - sa)) >> 8), at most 255, a source of
80
+ * alpha 255 put as it is and one of 0 leaving what was there; an opaque
81
+ * store's alpha 255 after. GL's own blending rounds where Flash floors,
82
+ * a level apart: the destination's rectangle is copied into a layer of
83
+ * its own first, and both read exactly.
84
+ */
85
+ private compositeOver;
86
+ /** compositeOver's program, linked as first asked for. */
87
+ private overProgramMade;
88
+ /**
89
+ * Texture `id`'s `width` by `height` texels read back, premultiplied RGBA
90
+ * row by row; null on a lost context or without the texture.
91
+ */
92
+ readTexture(id: number, width: number, height: number): Uint8Array | null;
93
+ /**
94
+ * Texture `id`'s `width` by `height` texels at (x, y) cleared to `pixel`,
95
+ * premultiplied ARGB, which comes back exactly; false on a lost context
96
+ * or without the texture.
97
+ */
98
+ fillTexture(textures: Textures, id: number, x: number, y: number, width: number, height: number, pixel: number): boolean;
99
+ /**
100
+ * Texture `from`'s `width` by `height` texels at (x, y) copied to (dx, dy)
101
+ * of texture `to`, replacing what was there: as a memmove where they are
102
+ * one texture, through a layer of its own, as a texture copied into
103
+ * itself is GL's feedback loop. Pending textures are uploaded first.
104
+ * False on a lost context or without either texture.
105
+ */
106
+ copyTexture(textures: Textures, from: number, x: number, y: number, width: number, height: number, to: number, dx: number, dy: number): boolean;
107
+ /** `width` by `height` texels at (x, y) of `from` blitted to (dx, dy) of `to`, the state cache's binding `to` after. */
108
+ private blit;
109
+ /** A framebuffer onto texture `id`, made as first asked for; null for an id of no texture. */
110
+ private textureFramebuffer;
111
+ /**
112
+ * A 3D object's bitmap drawn (PLANE): the commands, as `execute` draws
113
+ * them, into a layer `samples` times the size of a `width` by `height`
114
+ * bitmap a side, halved till a sample a texel, and kept as kept output
115
+ * `keep` (Keeps), the one kept before given back. Called as the frame is
116
+ * walked, before its own commands are drawn, which composite it.
117
+ */
118
+ drawPlane(keep: number, commands: Commands, scene: SceneList, rows: Rows, geometries: Geometries, textures: Textures, filters: Filters, keeps: Keeps, target: Target, width: number, height: number, samples: number): void;
119
+ /**
120
+ * The commands drawn, as `execute` draws them, into a layer `samples`
121
+ * times the size of a `width` by `height` bitmap a side, halved till a
122
+ * sample a pixel: the layer, its first `width` by `height` the bitmap.
123
+ */
124
+ private drawSampled;
125
+ /** Advanced text's outlines uploaded (GpuTextures.uploadOutlines). */
126
+ uploadOutlines(data: Float32Array, count: number, epoch: number): void;
127
+ /** What the backend made on the context, deleted. */
128
+ destroy(): void;
129
+ /**
130
+ * The layer pushed at command `k` drawn straight onto the target below,
131
+ * if it may be: unfiltered and not kept, one run of a flat fill alone
132
+ * (Draws.blendable) drawn normally in it, and a mode whose blend of the
133
+ * fill pixel by pixel, its edges covering the pixels in part, is that
134
+ * of the layer's pixels covered alike, as each is linear in what covers it
135
+ * (add short of its sums' clamp); its colour on the quad's. A layer and its
136
+ * resolve and composite left out, what reads what is below copies it as
137
+ * the composite would. Whether it was.
138
+ */
139
+ private blendDirect;
140
+ }
141
+ //# sourceMappingURL=backend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../../src/webgl/backend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAe,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAGL,KAAK,QAAQ,EAUd,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAWL,KAAK,SAAS,EACf,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAU/C,OAAO,EAAE,KAAK,KAAK,EAAuB,KAAK,MAAM,EAAc,MAAM,cAAc,CAAC;AAExF,YAAY,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAoE3C,qBAAa,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