@taole/giftstage 0.3.1 → 0.3.3

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.
@@ -85,186 +85,186 @@ void main() {\r
85
85
  vec4 c = texture(u_atlas, v_uv);\r
86
86
  fragColor = vec4(c.rgb * v_color.rgb * v_color.a, c.a * v_color.a);\r
87
87
  }\r
88
- `, RE = `#version 300 es
89
- precision highp float;
90
- precision highp int;
91
-
92
- /**
93
- * Table-aware SVGA instanced vertex stage.
94
- *
95
- * The frame table is a RGBA32F/NEAREST texture with three texels per
96
- * (sprite, frame) row:
97
- * texel 0 = layoutW, layoutH, a, b
98
- * texel 1 = c, d, tx, ty
99
- * texel 2 = alpha, 0, 0, 0
100
- *
101
- * Static sprite metadata is a second RGBA32F/NEAREST texture with two texels
102
- * per row:
103
- * texel 0 = atlas UV min.xy / max.xy
104
- * texel 1 = sourceSpriteIndex, atlasPage, flags, reserved
105
- *
106
- * One draw covers a single atlas page of one slot. \`gl_InstanceID\` selects a
107
- * metadata row (\`u_spriteBase + gl_InstanceID\`), so the only per-frame CPU
108
- * state is the slot transform/opacity/clip and the authoritative frame index.
109
- */
110
- layout(location = 0) in vec2 a_corner;
111
- // Optional Hybrid scheduling row. Direct draws leave these attributes disabled
112
- // and use the uniform slot state below.
113
- layout(location = 1) in vec4 a_instanceParent;
114
- layout(location = 2) in vec4 a_instanceTranslateOpacityFrame;
115
- layout(location = 3) in vec4 a_instanceClipRect;
116
- /** x=clipEnabled, y=metadataRow, z=atlasPage, w=present. */
117
- layout(location = 4) in vec4 a_instanceInfo;
118
-
119
- uniform mat4 u_projection;
120
- uniform highp sampler2D u_frameTable;
121
- uniform highp sampler2D u_spriteMetadata;
122
- /**
123
- * Canonical compact state (four RGBA32F texels / 16 floats):
124
- * affine; translate+opacity+frame; clip rect; clipEnabled+metadataBase+atlasPage+track+1.
125
- */
126
- uniform highp sampler2D u_slotStates;
127
- /** x = frameCount, y = spriteCount, z = texels per frame (3), w = default frame. */
128
- uniform ivec4 u_tableInfo;
129
- /** x/y = frame-table texture width/height in texels. */
130
- uniform ivec2 u_frameTableSize;
131
- /** x/y = sprite metadata texture width/height in texels. */
132
- uniform ivec2 u_spriteMetadataSize;
133
- uniform int u_spriteMetadataTexelsPerRow;
134
- uniform ivec2 u_slotStateSize;
135
- /** First static metadata row consumed by this slot/page draw. */
136
- uniform int u_spriteBase;
137
- /** Authoritative SVGA frame selected by RenderManager/PlaybackScope. */
138
- uniform int u_frameIndex;
139
- uniform vec4 u_parentAffine;
140
- uniform vec2 u_parentTranslate;
141
- uniform float u_slotOpacity;
142
- /** Atlas page for this draw; negative means metadata page filtering is disabled. */
143
- uniform int u_atlasPage;
144
- uniform vec4 u_clipRect;
145
- uniform float u_clipEnabled;
146
- /** WebGL's gl_FragCoord has a bottom-left origin; input clip rects are top-left. */
147
- uniform float u_canvasHeight;
148
- uniform float u_instanceStateEnabled;
149
- uniform float u_compactSlotStateEnabled;
150
- uniform int u_spritesPerSlot;
151
-
152
- out vec2 v_uv;
153
- out vec4 v_color;
154
- flat out vec4 v_clipRect;
155
- flat out float v_clipEnabled;
156
- out vec2 v_localPosition;
157
- flat out vec4 v_localClipRect;
158
- flat out float v_localClipEnabled;
159
-
160
- ivec2 texelCoord(int linearIndex, ivec2 textureSize) {
161
- int width = max(textureSize.x, 1);
162
- return ivec2(linearIndex - (linearIndex / width) * width, linearIndex / width);
163
- }
164
-
165
- void main() {
166
- int frameCount = max(u_tableInfo.x, 1);
167
- int spriteCount = max(u_tableInfo.y, 1);
168
- bool instanceState = u_instanceStateEnabled > 0.5;
169
- bool compactSlotState = u_compactSlotStateEnabled > 0.5;
170
- int spritesPerSlot = max(u_spritesPerSlot, 1);
171
- int slotStateIndex = gl_InstanceID / spritesPerSlot;
172
- int spriteWithinSlot = gl_InstanceID - slotStateIndex * spritesPerSlot;
173
- vec4 compactParent = vec4(0.0);
174
- vec4 compactTranslateOpacityFrame = vec4(0.0);
175
- vec4 compactClip = vec4(0.0);
176
- vec4 compactInfo = vec4(0.0);
177
- if (compactSlotState) {
178
- int compactBase = slotStateIndex * 4;
179
- compactParent = texelFetch(u_slotStates, texelCoord(compactBase, u_slotStateSize), 0);
180
- compactTranslateOpacityFrame = texelFetch(u_slotStates, texelCoord(compactBase + 1, u_slotStateSize), 0);
181
- compactClip = texelFetch(u_slotStates, texelCoord(compactBase + 2, u_slotStateSize), 0);
182
- compactInfo = texelFetch(u_slotStates, texelCoord(compactBase + 3, u_slotStateSize), 0);
183
- }
184
- int metadataRow = instanceState
185
- ? max(int(a_instanceInfo.y + 0.5), 0)
186
- : compactSlotState
187
- ? max(u_spriteBase + spriteWithinSlot, 0)
188
- : max(u_spriteBase + gl_InstanceID, 0);
189
- int metadataStride = max(u_spriteMetadataTexelsPerRow, 2);
190
- int metadataTexel = metadataRow * metadataStride;
191
- vec4 metadata0 = texelFetch(
192
- u_spriteMetadata,
193
- texelCoord(metadataTexel, u_spriteMetadataSize),
194
- 0
195
- );
196
- vec4 metadata1 = texelFetch(
197
- u_spriteMetadata,
198
- texelCoord(metadataTexel + 1, u_spriteMetadataSize),
199
- 0
200
- );
201
- vec4 metadata2 = metadataStride >= 3
202
- ? texelFetch(u_spriteMetadata, texelCoord(metadataTexel + 2, u_spriteMetadataSize), 0)
203
- : vec4(0.0);
204
- // Metadata carries the source sprite index so a page-specific range can
205
- // represent non-contiguous atlas pages. Its y component is the atlas page.
206
- int spriteIndex = clamp(int(max(metadata1.x, 0.0) + 0.5), 0, spriteCount - 1);
207
- int frameIndex = instanceState
208
- ? int(a_instanceTranslateOpacityFrame.w + 0.5)
209
- : compactSlotState
210
- ? int(compactTranslateOpacityFrame.w + 0.5)
211
- : u_frameIndex;
212
- if (frameIndex < 0) frameIndex = u_tableInfo.w;
213
- frameIndex = clamp(frameIndex, 0, frameCount - 1);
214
-
215
- int row = spriteIndex * frameCount + frameIndex;
216
- int frameTexel = row * u_tableInfo.z;
217
- vec4 frame0 = texelFetch(u_frameTable, texelCoord(frameTexel, u_frameTableSize), 0);
218
- vec4 frame1 = texelFetch(u_frameTable, texelCoord(frameTexel + 1, u_frameTableSize), 0);
219
- vec4 frame2 = texelFetch(u_frameTable, texelCoord(frameTexel + 2, u_frameTableSize), 0);
220
-
221
- float layoutW = frame0.x;
222
- float layoutH = frame0.y;
223
- vec2 local = vec2(
224
- frame0.z * layoutW * a_corner.x + frame1.x * layoutH * a_corner.y + frame1.z,
225
- frame0.w * layoutW * a_corner.x + frame1.y * layoutH * a_corner.y + frame1.w
226
- );
227
-
228
- vec4 parentAffine = instanceState
229
- ? a_instanceParent
230
- : compactSlotState ? compactParent : u_parentAffine;
231
- vec2 parentTranslate = instanceState
232
- ? a_instanceTranslateOpacityFrame.xy
233
- : compactSlotState ? compactTranslateOpacityFrame.xy : u_parentTranslate;
234
- float slotOpacity = instanceState
235
- ? a_instanceTranslateOpacityFrame.z
236
- : compactSlotState ? compactTranslateOpacityFrame.z : u_slotOpacity;
237
- int atlasPage = instanceState
238
- ? int(a_instanceInfo.z + 0.5)
239
- : compactSlotState
240
- ? (compactInfo.z < -0.5 ? -1 : int(compactInfo.z + 0.5))
241
- : u_atlasPage;
242
- vec4 clipRect = instanceState
243
- ? a_instanceClipRect
244
- : compactSlotState ? compactClip : u_clipRect;
245
- float clipEnabled = instanceState
246
- ? a_instanceInfo.x
247
- : compactSlotState ? compactInfo.x : u_clipEnabled;
248
- vec2 world = vec2(
249
- parentAffine.x * local.x + parentAffine.z * local.y + parentTranslate.x,
250
- parentAffine.y * local.x + parentAffine.w * local.y + parentTranslate.y
251
- );
252
-
253
- gl_Position = u_projection * vec4(world, 0.0, 1.0);
254
- v_uv = mix(metadata0.xy, metadata0.zw, a_corner);
255
- bool pageMatches = atlasPage < 0 || int(max(metadata1.y, 0.0) + 0.5) == atlasPage;
256
- int metadataFlags = int(max(metadata1.z, 0.0) + 0.5);
257
- bool metadataPresent = (metadataFlags & 1) == 0;
258
- float pageAlpha = pageMatches && metadataPresent ? 1.0 : 0.0;
259
- float effectiveAlpha = frame2.x * slotOpacity * pageAlpha;
260
- // Match the CPU reference's strict \`< 0.05\` visibility cutoff.
261
- v_color = vec4(1.0, 1.0, 1.0, effectiveAlpha >= 0.05 ? effectiveAlpha : 0.0);
262
- v_clipRect = clipRect;
263
- v_clipEnabled = clipEnabled;
264
- v_localPosition = vec2(layoutW * a_corner.x, layoutH * a_corner.y);
265
- v_localClipRect = metadata2;
266
- v_localClipEnabled = (metadataFlags & 2) != 0 ? 1.0 : 0.0;
267
- }
88
+ `, RE = `#version 300 es\r
89
+ precision highp float;\r
90
+ precision highp int;\r
91
+ \r
92
+ /**\r
93
+ * Table-aware SVGA instanced vertex stage.\r
94
+ *\r
95
+ * The frame table is a RGBA32F/NEAREST texture with three texels per\r
96
+ * (sprite, frame) row:\r
97
+ * texel 0 = layoutW, layoutH, a, b\r
98
+ * texel 1 = c, d, tx, ty\r
99
+ * texel 2 = alpha, 0, 0, 0\r
100
+ *\r
101
+ * Static sprite metadata is a second RGBA32F/NEAREST texture with two texels\r
102
+ * per row:\r
103
+ * texel 0 = atlas UV min.xy / max.xy\r
104
+ * texel 1 = sourceSpriteIndex, atlasPage, flags, reserved\r
105
+ *\r
106
+ * One draw covers a single atlas page of one slot. \`gl_InstanceID\` selects a\r
107
+ * metadata row (\`u_spriteBase + gl_InstanceID\`), so the only per-frame CPU\r
108
+ * state is the slot transform/opacity/clip and the authoritative frame index.\r
109
+ */\r
110
+ layout(location = 0) in vec2 a_corner;\r
111
+ // Optional Hybrid scheduling row. Direct draws leave these attributes disabled\r
112
+ // and use the uniform slot state below.\r
113
+ layout(location = 1) in vec4 a_instanceParent;\r
114
+ layout(location = 2) in vec4 a_instanceTranslateOpacityFrame;\r
115
+ layout(location = 3) in vec4 a_instanceClipRect;\r
116
+ /** x=clipEnabled, y=metadataRow, z=atlasPage, w=present. */\r
117
+ layout(location = 4) in vec4 a_instanceInfo;\r
118
+ \r
119
+ uniform mat4 u_projection;\r
120
+ uniform highp sampler2D u_frameTable;\r
121
+ uniform highp sampler2D u_spriteMetadata;\r
122
+ /**\r
123
+ * Canonical compact state (four RGBA32F texels / 16 floats):\r
124
+ * affine; translate+opacity+frame; clip rect; clipEnabled+metadataBase+atlasPage+track+1.\r
125
+ */\r
126
+ uniform highp sampler2D u_slotStates;\r
127
+ /** x = frameCount, y = spriteCount, z = texels per frame (3), w = default frame. */\r
128
+ uniform ivec4 u_tableInfo;\r
129
+ /** x/y = frame-table texture width/height in texels. */\r
130
+ uniform ivec2 u_frameTableSize;\r
131
+ /** x/y = sprite metadata texture width/height in texels. */\r
132
+ uniform ivec2 u_spriteMetadataSize;\r
133
+ uniform int u_spriteMetadataTexelsPerRow;\r
134
+ uniform ivec2 u_slotStateSize;\r
135
+ /** First static metadata row consumed by this slot/page draw. */\r
136
+ uniform int u_spriteBase;\r
137
+ /** Authoritative SVGA frame selected by RenderManager/PlaybackScope. */\r
138
+ uniform int u_frameIndex;\r
139
+ uniform vec4 u_parentAffine;\r
140
+ uniform vec2 u_parentTranslate;\r
141
+ uniform float u_slotOpacity;\r
142
+ /** Atlas page for this draw; negative means metadata page filtering is disabled. */\r
143
+ uniform int u_atlasPage;\r
144
+ uniform vec4 u_clipRect;\r
145
+ uniform float u_clipEnabled;\r
146
+ /** WebGL's gl_FragCoord has a bottom-left origin; input clip rects are top-left. */\r
147
+ uniform float u_canvasHeight;\r
148
+ uniform float u_instanceStateEnabled;\r
149
+ uniform float u_compactSlotStateEnabled;\r
150
+ uniform int u_spritesPerSlot;\r
151
+ \r
152
+ out vec2 v_uv;\r
153
+ out vec4 v_color;\r
154
+ flat out vec4 v_clipRect;\r
155
+ flat out float v_clipEnabled;\r
156
+ out vec2 v_localPosition;\r
157
+ flat out vec4 v_localClipRect;\r
158
+ flat out float v_localClipEnabled;\r
159
+ \r
160
+ ivec2 texelCoord(int linearIndex, ivec2 textureSize) {\r
161
+ int width = max(textureSize.x, 1);\r
162
+ return ivec2(linearIndex - (linearIndex / width) * width, linearIndex / width);\r
163
+ }\r
164
+ \r
165
+ void main() {\r
166
+ int frameCount = max(u_tableInfo.x, 1);\r
167
+ int spriteCount = max(u_tableInfo.y, 1);\r
168
+ bool instanceState = u_instanceStateEnabled > 0.5;\r
169
+ bool compactSlotState = u_compactSlotStateEnabled > 0.5;\r
170
+ int spritesPerSlot = max(u_spritesPerSlot, 1);\r
171
+ int slotStateIndex = gl_InstanceID / spritesPerSlot;\r
172
+ int spriteWithinSlot = gl_InstanceID - slotStateIndex * spritesPerSlot;\r
173
+ vec4 compactParent = vec4(0.0);\r
174
+ vec4 compactTranslateOpacityFrame = vec4(0.0);\r
175
+ vec4 compactClip = vec4(0.0);\r
176
+ vec4 compactInfo = vec4(0.0);\r
177
+ if (compactSlotState) {\r
178
+ int compactBase = slotStateIndex * 4;\r
179
+ compactParent = texelFetch(u_slotStates, texelCoord(compactBase, u_slotStateSize), 0);\r
180
+ compactTranslateOpacityFrame = texelFetch(u_slotStates, texelCoord(compactBase + 1, u_slotStateSize), 0);\r
181
+ compactClip = texelFetch(u_slotStates, texelCoord(compactBase + 2, u_slotStateSize), 0);\r
182
+ compactInfo = texelFetch(u_slotStates, texelCoord(compactBase + 3, u_slotStateSize), 0);\r
183
+ }\r
184
+ int metadataRow = instanceState\r
185
+ ? max(int(a_instanceInfo.y + 0.5), 0)\r
186
+ : compactSlotState\r
187
+ ? max(u_spriteBase + spriteWithinSlot, 0)\r
188
+ : max(u_spriteBase + gl_InstanceID, 0);\r
189
+ int metadataStride = max(u_spriteMetadataTexelsPerRow, 2);\r
190
+ int metadataTexel = metadataRow * metadataStride;\r
191
+ vec4 metadata0 = texelFetch(\r
192
+ u_spriteMetadata,\r
193
+ texelCoord(metadataTexel, u_spriteMetadataSize),\r
194
+ 0\r
195
+ );\r
196
+ vec4 metadata1 = texelFetch(\r
197
+ u_spriteMetadata,\r
198
+ texelCoord(metadataTexel + 1, u_spriteMetadataSize),\r
199
+ 0\r
200
+ );\r
201
+ vec4 metadata2 = metadataStride >= 3\r
202
+ ? texelFetch(u_spriteMetadata, texelCoord(metadataTexel + 2, u_spriteMetadataSize), 0)\r
203
+ : vec4(0.0);\r
204
+ // Metadata carries the source sprite index so a page-specific range can\r
205
+ // represent non-contiguous atlas pages. Its y component is the atlas page.\r
206
+ int spriteIndex = clamp(int(max(metadata1.x, 0.0) + 0.5), 0, spriteCount - 1);\r
207
+ int frameIndex = instanceState\r
208
+ ? int(a_instanceTranslateOpacityFrame.w + 0.5)\r
209
+ : compactSlotState\r
210
+ ? int(compactTranslateOpacityFrame.w + 0.5)\r
211
+ : u_frameIndex;\r
212
+ if (frameIndex < 0) frameIndex = u_tableInfo.w;\r
213
+ frameIndex = clamp(frameIndex, 0, frameCount - 1);\r
214
+ \r
215
+ int row = spriteIndex * frameCount + frameIndex;\r
216
+ int frameTexel = row * u_tableInfo.z;\r
217
+ vec4 frame0 = texelFetch(u_frameTable, texelCoord(frameTexel, u_frameTableSize), 0);\r
218
+ vec4 frame1 = texelFetch(u_frameTable, texelCoord(frameTexel + 1, u_frameTableSize), 0);\r
219
+ vec4 frame2 = texelFetch(u_frameTable, texelCoord(frameTexel + 2, u_frameTableSize), 0);\r
220
+ \r
221
+ float layoutW = frame0.x;\r
222
+ float layoutH = frame0.y;\r
223
+ vec2 local = vec2(\r
224
+ frame0.z * layoutW * a_corner.x + frame1.x * layoutH * a_corner.y + frame1.z,\r
225
+ frame0.w * layoutW * a_corner.x + frame1.y * layoutH * a_corner.y + frame1.w\r
226
+ );\r
227
+ \r
228
+ vec4 parentAffine = instanceState\r
229
+ ? a_instanceParent\r
230
+ : compactSlotState ? compactParent : u_parentAffine;\r
231
+ vec2 parentTranslate = instanceState\r
232
+ ? a_instanceTranslateOpacityFrame.xy\r
233
+ : compactSlotState ? compactTranslateOpacityFrame.xy : u_parentTranslate;\r
234
+ float slotOpacity = instanceState\r
235
+ ? a_instanceTranslateOpacityFrame.z\r
236
+ : compactSlotState ? compactTranslateOpacityFrame.z : u_slotOpacity;\r
237
+ int atlasPage = instanceState\r
238
+ ? int(a_instanceInfo.z + 0.5)\r
239
+ : compactSlotState\r
240
+ ? (compactInfo.z < -0.5 ? -1 : int(compactInfo.z + 0.5))\r
241
+ : u_atlasPage;\r
242
+ vec4 clipRect = instanceState\r
243
+ ? a_instanceClipRect\r
244
+ : compactSlotState ? compactClip : u_clipRect;\r
245
+ float clipEnabled = instanceState\r
246
+ ? a_instanceInfo.x\r
247
+ : compactSlotState ? compactInfo.x : u_clipEnabled;\r
248
+ vec2 world = vec2(\r
249
+ parentAffine.x * local.x + parentAffine.z * local.y + parentTranslate.x,\r
250
+ parentAffine.y * local.x + parentAffine.w * local.y + parentTranslate.y\r
251
+ );\r
252
+ \r
253
+ gl_Position = u_projection * vec4(world, 0.0, 1.0);\r
254
+ v_uv = mix(metadata0.xy, metadata0.zw, a_corner);\r
255
+ bool pageMatches = atlasPage < 0 || int(max(metadata1.y, 0.0) + 0.5) == atlasPage;\r
256
+ int metadataFlags = int(max(metadata1.z, 0.0) + 0.5);\r
257
+ bool metadataPresent = (metadataFlags & 1) == 0;\r
258
+ float pageAlpha = pageMatches && metadataPresent ? 1.0 : 0.0;\r
259
+ float effectiveAlpha = frame2.x * slotOpacity * pageAlpha;\r
260
+ // Match the CPU reference's strict \`< 0.05\` visibility cutoff.\r
261
+ v_color = vec4(1.0, 1.0, 1.0, effectiveAlpha >= 0.05 ? effectiveAlpha : 0.0);\r
262
+ v_clipRect = clipRect;\r
263
+ v_clipEnabled = clipEnabled;\r
264
+ v_localPosition = vec2(layoutW * a_corner.x, layoutH * a_corner.y);\r
265
+ v_localClipRect = metadata2;\r
266
+ v_localClipEnabled = (metadataFlags & 2) != 0 ? 1.0 : 0.0;\r
267
+ }\r
268
268
  `, uE = `#version 300 es
269
269
  precision highp float;
270
270
 
@@ -791,67 +791,67 @@ void main() {\r
791
791
  float coverage = 1.0 - smoothstep(0.45, 1.0, distanceToCenter);\r
792
792
  outColor = v_color * coverage;\r
793
793
  }\r
794
- `, TE = `#version 300 es
795
- precision highp float;
796
-
797
- layout(location = 0) in vec2 a_corner;
798
- layout(location = 1) in vec4 a_birthLifePosition;
799
- layout(location = 2) in vec4 a_velocityAcceleration;
800
- layout(location = 3) in vec4 a_scaleRotation;
801
- layout(location = 4) in vec4 a_color;
802
- layout(location = 5) in vec4 a_sizeAnchor;
803
- layout(location = 6) in vec4 a_uvRect;
804
-
805
- uniform mat4 u_projection;
806
- uniform float u_time;
807
- uniform float u_globalAlpha;
808
- uniform float u_sizeEnvelope;
809
- uniform float u_fadeMode;
810
- uniform vec2 u_cssScale;
811
-
812
- out vec2 v_uv;
813
- out vec4 v_modulation;
814
-
815
- void main() {
816
- float age = u_time - a_birthLifePosition.x;
817
- float life = max(a_birthLifePosition.y, 0.0001);
818
- bool alive = age >= 0.0 && age <= life;
819
- float safeAge = max(age, 0.0);
820
- vec2 position = a_birthLifePosition.zw
821
- + a_velocityAcceleration.xy * safeAge
822
- + 0.5 * a_velocityAcceleration.zw * safeAge * safeAge;
823
- float scale = max(0.04, a_scaleRotation.x + a_scaleRotation.y * safeAge) * u_sizeEnvelope;
824
- vec2 unitCorner = a_corner + 0.5;
825
- vec2 local = (unitCorner - a_sizeAnchor.zw) * a_sizeAnchor.xy * scale;
826
- float angle = a_scaleRotation.z + a_scaleRotation.w * safeAge;
827
- float c = cos(angle);
828
- float s = sin(angle);
829
- vec2 rotated = vec2(c * local.x - s * local.y, s * local.x + c * local.y);
830
- float progress = clamp(safeAge / life, 0.0, 1.0);
831
- float fade = u_fadeMode > 0.5
832
- ? min(safeAge / 0.04, 1.0) * pow(1.0 - progress, 0.78)
833
- : 1.0;
834
- if (!alive) {
835
- position = vec2(-100000.0);
836
- fade = 0.0;
837
- }
838
- gl_Position = u_projection * vec4((position + rotated) * u_cssScale, 0.0, 1.0);
839
- v_uv = mix(a_uvRect.xy, a_uvRect.zw, unitCorner);
840
- float alpha = a_color.a * fade * u_globalAlpha;
841
- v_modulation = vec4(a_color.rgb * alpha, alpha);
842
- }
843
- `, vE = `#version 300 es
844
- precision highp float;
845
-
846
- uniform sampler2D u_atlas;
847
- in vec2 v_uv;
848
- in vec4 v_modulation;
849
- out vec4 outColor;
850
-
851
- void main() {
852
- vec4 sampled = texture(u_atlas, v_uv);
853
- outColor = vec4(sampled.rgb * v_modulation.rgb, sampled.a * v_modulation.a);
854
- }
794
+ `, TE = `#version 300 es\r
795
+ precision highp float;\r
796
+ \r
797
+ layout(location = 0) in vec2 a_corner;\r
798
+ layout(location = 1) in vec4 a_birthLifePosition;\r
799
+ layout(location = 2) in vec4 a_velocityAcceleration;\r
800
+ layout(location = 3) in vec4 a_scaleRotation;\r
801
+ layout(location = 4) in vec4 a_color;\r
802
+ layout(location = 5) in vec4 a_sizeAnchor;\r
803
+ layout(location = 6) in vec4 a_uvRect;\r
804
+ \r
805
+ uniform mat4 u_projection;\r
806
+ uniform float u_time;\r
807
+ uniform float u_globalAlpha;\r
808
+ uniform float u_sizeEnvelope;\r
809
+ uniform float u_fadeMode;\r
810
+ uniform vec2 u_cssScale;\r
811
+ \r
812
+ out vec2 v_uv;\r
813
+ out vec4 v_modulation;\r
814
+ \r
815
+ void main() {\r
816
+ float age = u_time - a_birthLifePosition.x;\r
817
+ float life = max(a_birthLifePosition.y, 0.0001);\r
818
+ bool alive = age >= 0.0 && age <= life;\r
819
+ float safeAge = max(age, 0.0);\r
820
+ vec2 position = a_birthLifePosition.zw\r
821
+ + a_velocityAcceleration.xy * safeAge\r
822
+ + 0.5 * a_velocityAcceleration.zw * safeAge * safeAge;\r
823
+ float scale = max(0.04, a_scaleRotation.x + a_scaleRotation.y * safeAge) * u_sizeEnvelope;\r
824
+ vec2 unitCorner = a_corner + 0.5;\r
825
+ vec2 local = (unitCorner - a_sizeAnchor.zw) * a_sizeAnchor.xy * scale;\r
826
+ float angle = a_scaleRotation.z + a_scaleRotation.w * safeAge;\r
827
+ float c = cos(angle);\r
828
+ float s = sin(angle);\r
829
+ vec2 rotated = vec2(c * local.x - s * local.y, s * local.x + c * local.y);\r
830
+ float progress = clamp(safeAge / life, 0.0, 1.0);\r
831
+ float fade = u_fadeMode > 0.5\r
832
+ ? min(safeAge / 0.04, 1.0) * pow(1.0 - progress, 0.78)\r
833
+ : 1.0;\r
834
+ if (!alive) {\r
835
+ position = vec2(-100000.0);\r
836
+ fade = 0.0;\r
837
+ }\r
838
+ gl_Position = u_projection * vec4((position + rotated) * u_cssScale, 0.0, 1.0);\r
839
+ v_uv = mix(a_uvRect.xy, a_uvRect.zw, unitCorner);\r
840
+ float alpha = a_color.a * fade * u_globalAlpha;\r
841
+ v_modulation = vec4(a_color.rgb * alpha, alpha);\r
842
+ }\r
843
+ `, vE = `#version 300 es\r
844
+ precision highp float;\r
845
+ \r
846
+ uniform sampler2D u_atlas;\r
847
+ in vec2 v_uv;\r
848
+ in vec4 v_modulation;\r
849
+ out vec4 outColor;\r
850
+ \r
851
+ void main() {\r
852
+ vec4 sampled = texture(u_atlas, v_uv);\r
853
+ outColor = vec4(sampled.rgb * v_modulation.rgb, sampled.a * v_modulation.a);\r
854
+ }\r
855
855
  `, WE = `/** SVGA atlas variant for premultiplied RGBA atlas textures. */\r
856
856
  struct Uniforms {\r
857
857
  projection: mat4x4f,\r
@@ -1357,78 +1357,78 @@ fn fs(input: VOut) -> @location(0) vec4f {\r
1357
1357
  let coverage = 1.0 - smoothstep(0.45, 1.0, distanceToCenter);\r
1358
1358
  return input.color * coverage;\r
1359
1359
  }\r
1360
- `, gi = `struct Globals {
1361
- projection: mat4x4f,
1362
- }
1363
-
1364
- @group(0) @binding(0) var<uniform> globals: Globals;
1365
- @group(0) @binding(1) var<storage, read> instanceData: array<f32>;
1366
- @group(1) @binding(0) var atlasTexture: texture_2d<f32>;
1367
- @group(1) @binding(1) var atlasSampler: sampler;
1368
-
1369
- struct VIn {
1370
- @location(0) corner: vec2f,
1371
- }
1372
-
1373
- struct VOut {
1374
- @builtin(position) position: vec4f,
1375
- @location(0) uv: vec2f,
1376
- @location(1) modulation: vec4f,
1377
- }
1378
-
1379
- @vertex
1380
- fn vs(input: VIn, @builtin(instance_index) instance: u32) -> VOut {
1381
- let base = 8u + instance * 24u;
1382
- let birth = instanceData[base];
1383
- let life = max(instanceData[base + 1u], 0.0001);
1384
- let age = instanceData[0] - birth;
1385
- let safeAge = max(age, 0.0);
1386
- var position = vec2f(instanceData[base + 2u], instanceData[base + 3u])
1387
- + vec2f(instanceData[base + 4u], instanceData[base + 5u]) * safeAge
1388
- + 0.5 * vec2f(instanceData[base + 6u], instanceData[base + 7u]) * safeAge * safeAge;
1389
- let scale = max(0.04, instanceData[base + 8u] + instanceData[base + 9u] * safeAge)
1390
- * instanceData[2];
1391
- let unitCorner = input.corner + vec2f(0.5);
1392
- let anchor = vec2f(instanceData[base + 18u], instanceData[base + 19u]);
1393
- let spriteSize = vec2f(instanceData[base + 16u], instanceData[base + 17u]);
1394
- let local = (unitCorner - anchor) * spriteSize * scale;
1395
- let angle = instanceData[base + 10u] + instanceData[base + 11u] * safeAge;
1396
- let c = cos(angle);
1397
- let s = sin(angle);
1398
- let rotated = vec2f(c * local.x - s * local.y, s * local.x + c * local.y);
1399
- let progress = clamp(safeAge / life, 0.0, 1.0);
1400
- var fade = select(
1401
- 1.0,
1402
- min(safeAge / 0.04, 1.0) * pow(1.0 - progress, 0.78),
1403
- instanceData[3] > 0.5,
1404
- );
1405
- if (age < 0.0 || age > life) {
1406
- position = vec2f(-100000.0);
1407
- fade = 0.0;
1408
- }
1409
- let cssScale = vec2f(instanceData[4], instanceData[5]);
1410
- let alpha = instanceData[base + 15u] * fade * instanceData[1];
1411
- var output: VOut;
1412
- output.position = globals.projection * vec4f((position + rotated) * cssScale, 0.0, 1.0);
1413
- output.uv = mix(
1414
- vec2f(instanceData[base + 20u], instanceData[base + 21u]),
1415
- vec2f(instanceData[base + 22u], instanceData[base + 23u]),
1416
- unitCorner,
1417
- );
1418
- output.modulation = vec4f(
1419
- instanceData[base + 12u] * alpha,
1420
- instanceData[base + 13u] * alpha,
1421
- instanceData[base + 14u] * alpha,
1422
- alpha,
1423
- );
1424
- return output;
1425
- }
1426
-
1427
- @fragment
1428
- fn fs(input: VOut) -> @location(0) vec4f {
1429
- let sampled = textureSample(atlasTexture, atlasSampler, input.uv);
1430
- return vec4f(sampled.rgb * input.modulation.rgb, sampled.a * input.modulation.a);
1431
- }
1360
+ `, gi = `struct Globals {\r
1361
+ projection: mat4x4f,\r
1362
+ }\r
1363
+ \r
1364
+ @group(0) @binding(0) var<uniform> globals: Globals;\r
1365
+ @group(0) @binding(1) var<storage, read> instanceData: array<f32>;\r
1366
+ @group(1) @binding(0) var atlasTexture: texture_2d<f32>;\r
1367
+ @group(1) @binding(1) var atlasSampler: sampler;\r
1368
+ \r
1369
+ struct VIn {\r
1370
+ @location(0) corner: vec2f,\r
1371
+ }\r
1372
+ \r
1373
+ struct VOut {\r
1374
+ @builtin(position) position: vec4f,\r
1375
+ @location(0) uv: vec2f,\r
1376
+ @location(1) modulation: vec4f,\r
1377
+ }\r
1378
+ \r
1379
+ @vertex\r
1380
+ fn vs(input: VIn, @builtin(instance_index) instance: u32) -> VOut {\r
1381
+ let base = 8u + instance * 24u;\r
1382
+ let birth = instanceData[base];\r
1383
+ let life = max(instanceData[base + 1u], 0.0001);\r
1384
+ let age = instanceData[0] - birth;\r
1385
+ let safeAge = max(age, 0.0);\r
1386
+ var position = vec2f(instanceData[base + 2u], instanceData[base + 3u])\r
1387
+ + vec2f(instanceData[base + 4u], instanceData[base + 5u]) * safeAge\r
1388
+ + 0.5 * vec2f(instanceData[base + 6u], instanceData[base + 7u]) * safeAge * safeAge;\r
1389
+ let scale = max(0.04, instanceData[base + 8u] + instanceData[base + 9u] * safeAge)\r
1390
+ * instanceData[2];\r
1391
+ let unitCorner = input.corner + vec2f(0.5);\r
1392
+ let anchor = vec2f(instanceData[base + 18u], instanceData[base + 19u]);\r
1393
+ let spriteSize = vec2f(instanceData[base + 16u], instanceData[base + 17u]);\r
1394
+ let local = (unitCorner - anchor) * spriteSize * scale;\r
1395
+ let angle = instanceData[base + 10u] + instanceData[base + 11u] * safeAge;\r
1396
+ let c = cos(angle);\r
1397
+ let s = sin(angle);\r
1398
+ let rotated = vec2f(c * local.x - s * local.y, s * local.x + c * local.y);\r
1399
+ let progress = clamp(safeAge / life, 0.0, 1.0);\r
1400
+ var fade = select(\r
1401
+ 1.0,\r
1402
+ min(safeAge / 0.04, 1.0) * pow(1.0 - progress, 0.78),\r
1403
+ instanceData[3] > 0.5,\r
1404
+ );\r
1405
+ if (age < 0.0 || age > life) {\r
1406
+ position = vec2f(-100000.0);\r
1407
+ fade = 0.0;\r
1408
+ }\r
1409
+ let cssScale = vec2f(instanceData[4], instanceData[5]);\r
1410
+ let alpha = instanceData[base + 15u] * fade * instanceData[1];\r
1411
+ var output: VOut;\r
1412
+ output.position = globals.projection * vec4f((position + rotated) * cssScale, 0.0, 1.0);\r
1413
+ output.uv = mix(\r
1414
+ vec2f(instanceData[base + 20u], instanceData[base + 21u]),\r
1415
+ vec2f(instanceData[base + 22u], instanceData[base + 23u]),\r
1416
+ unitCorner,\r
1417
+ );\r
1418
+ output.modulation = vec4f(\r
1419
+ instanceData[base + 12u] * alpha,\r
1420
+ instanceData[base + 13u] * alpha,\r
1421
+ instanceData[base + 14u] * alpha,\r
1422
+ alpha,\r
1423
+ );\r
1424
+ return output;\r
1425
+ }\r
1426
+ \r
1427
+ @fragment\r
1428
+ fn fs(input: VOut) -> @location(0) vec4f {\r
1429
+ let sampled = textureSample(atlasTexture, atlasSampler, input.uv);\r
1430
+ return vec4f(sampled.rgb * input.modulation.rgb, sampled.a * input.modulation.a);\r
1431
+ }\r
1432
1432
  `, Ii = `struct Globals {\r
1433
1433
  projection: mat4x4f,\r
1434
1434
  }\r
@@ -1773,292 +1773,292 @@ fn applyMotionPoint(point: vec2f, center: vec2f, scale: vec2f, cosine: f32, sine
1773
1773
  svgaMotionInstancedPremul: Ii,
1774
1774
  svgaFrameTableShape: Bi,
1775
1775
  svgaFrameTableClipMask: Ci
1776
- }, Qi = `/// SVGA timeline/table variant for premultiplied RGBA atlas textures.
1777
- ///
1778
- /// The frame table and sprite metadata are resident storage buffers. A draw
1779
- /// submits one instance per sprite. Direct draws derive the sprite index from
1780
- /// the GPU instance index and only upload the slot/global uniform. Hybrid
1781
- /// draws can additionally bind compact CPU-precompiled scheduling rows that
1782
- /// omit the SVGA child matrix and alpha fetched from the frame table.
1783
- ///
1784
- /// Frame table: three vec4 values per (sprite, frame):
1785
- /// 0: layoutW, layoutH, a, b
1786
- /// 1: c, d, tx, ty
1787
- /// 2: alpha, reserved, reserved, reserved
1788
- ///
1789
- /// Sprite metadata: two vec4 values per draw sprite:
1790
- /// 0: atlas UV min.xy / max.xy
1791
- /// 1: source sprite index, atlas page, flags, reserved
1792
- ///
1793
- /// Uniform layout:
1794
- /// projection mat4x4f (64 bytes)
1795
- /// parentAffine vec4f (a, b, c, d)
1796
- /// translateOpacityFrame vec4f (tx, ty, opacity, frameIndex)
1797
- /// clipRect vec4f (top-left x0, y0, x1, y1)
1798
- /// drawInfo vec4u (metadataBase, drawSpriteCount, clipEnabled, trackIndex+1)
1799
- /// tableInfo vec4u (frameCount, spriteCount, vec4sPerFrame, 0)
1800
- /// batchInfo vec4u (spritesPerSlot, metadataVec4Stride, stateMode, 0)
1801
-
1802
- struct Globals {
1803
- projection: mat4x4f,
1804
- parentAffine: vec4f,
1805
- translateOpacityFrame: vec4f,
1806
- clipRect: vec4f,
1807
- drawInfo: vec4u,
1808
- tableInfo: vec4u,
1809
- batchInfo: vec4u,
1810
- }
1811
-
1812
- struct MotionGlobals {
1813
- timeMs: f32,
1814
- sampleIntervalMs: f32,
1815
- sampleCount: f32,
1816
- cssScaleX: f32,
1817
- cssScaleY: f32,
1818
- pad0: f32,
1819
- pad1: f32,
1820
- pad2: f32,
1821
- }
1822
-
1823
- @group(0) @binding(0) var<uniform> globals: Globals;
1824
- @group(0) @binding(1) var<storage, read> frameTable: array<vec4f>;
1825
- @group(0) @binding(2) var<storage, read> spriteMetadata: array<vec4f>;
1826
- @group(0) @binding(3) var<storage, read> motionData: array<f32>;
1827
- @group(0) @binding(4) var<uniform> motionGlobals: MotionGlobals;
1828
- // Canonical four-vec4 / 16-float slot row: affine; translate+opacity+frame;
1829
- // clip rect; clipEnabled+metadataBase+atlasPage+motionTrack+1.
1830
- // Optional Hybrid scheduling rows use this exact schema per draw instance.
1831
- // Direct draws bind a harmless dummy slice and leave drawInfo bit 1 clear.
1832
- @group(0) @binding(5) var<storage, read> hybridInstances: array<vec4f>;
1833
- @group(1) @binding(0) var atlasTex: texture_2d<f32>;
1834
- @group(1) @binding(1) var atlasSampler: sampler;
1835
-
1836
- struct VIn {
1837
- @location(0) corner: vec2f,
1838
- }
1839
-
1840
- struct VOut {
1841
- @builtin(position) pos: vec4f,
1842
- @location(0) uv: vec2f,
1843
- @location(1) color: vec4f,
1844
- @location(2) @interpolate(flat) clipRect: vec4f,
1845
- @location(3) @interpolate(flat) clipEnabled: f32,
1846
- @location(4) localPosition: vec2f,
1847
- @location(5) @interpolate(flat) localClipRect: vec4f,
1848
- @location(6) @interpolate(flat) localClipEnabled: f32,
1849
- }
1850
-
1851
- fn readFrameValue(index: u32) -> vec4f {
1852
- return frameTable[index];
1853
- }
1854
-
1855
- fn sampleMotion(track: u32, channel: u32) -> f32 {
1856
- let sampleCount = max(u32(motionGlobals.sampleCount), 1u);
1857
- let samplePosition = clamp(
1858
- motionGlobals.timeMs / max(motionGlobals.sampleIntervalMs, 0.001),
1859
- 0.0,
1860
- f32(sampleCount - 1u),
1861
- );
1862
- let left = u32(floor(samplePosition));
1863
- let right = min(sampleCount - 1u, left + 1u);
1864
- let trackBase = track * sampleCount * 8u;
1865
- let leftBase = trackBase + left * 8u;
1866
- let rightBase = trackBase + right * 8u;
1867
- let interpolate = left != right && motionData[leftBase + 7u] > 0.5 && channel < 6u;
1868
- if (!interpolate) {
1869
- return motionData[leftBase + channel];
1870
- }
1871
- let progress = samplePosition - f32(left);
1872
- return mix(motionData[leftBase + channel], motionData[rightBase + channel], progress);
1873
- }
1874
-
1875
- fn applyMotionPoint(
1876
- point: vec2f,
1877
- center: vec2f,
1878
- scale: vec2f,
1879
- cosine: f32,
1880
- sine: f32,
1881
- ) -> vec2f {
1882
- let scaled = point * scale;
1883
- return center + vec2f(
1884
- cosine * scaled.x - sine * scaled.y,
1885
- sine * scaled.x + cosine * scaled.y,
1886
- );
1887
- }
1888
-
1889
- @vertex
1890
- fn vs(input: VIn, @builtin(instance_index) instance: u32) -> VOut {
1891
- let safeInstance = min(instance, max(globals.drawInfo.y, 1u) - 1u);
1892
- let hybrid = (globals.drawInfo.z & 2u) != 0u;
1893
- let compactSlots = (globals.drawInfo.z & 4u) != 0u;
1894
- let spritesPerSlot = max(globals.batchInfo.x, 1u);
1895
- let slotStateIndex = select(safeInstance, safeInstance / spritesPerSlot, compactSlots);
1896
- let hybridBase = slotStateIndex * 4u;
1897
- var hybridParent = vec4f(0.0);
1898
- var hybridTranslateOpacityFrame = vec4f(0.0);
1899
- var hybridClip = vec4f(0.0);
1900
- var hybridInfo = vec4f(0.0);
1901
- if (hybrid || compactSlots) {
1902
- hybridParent = hybridInstances[hybridBase];
1903
- hybridTranslateOpacityFrame = hybridInstances[hybridBase + 1u];
1904
- hybridClip = hybridInstances[hybridBase + 2u];
1905
- hybridInfo = hybridInstances[hybridBase + 3u];
1906
- }
1907
- let spriteWithinSlot = select(safeInstance, safeInstance % spritesPerSlot, compactSlots);
1908
- let metadataIndex = select(
1909
- globals.drawInfo.x + spriteWithinSlot,
1910
- u32(max(hybridInfo.y, 0.0)),
1911
- hybrid,
1912
- );
1913
- let metadataStride = max(globals.batchInfo.y, 2u);
1914
- let metadataBase = metadataIndex * metadataStride;
1915
- let metadataUv = spriteMetadata[metadataBase];
1916
- let metadataSprite = spriteMetadata[metadataBase + 1u];
1917
- var metadataClip = vec4f(0.0);
1918
- if (metadataStride >= 3u) {
1919
- metadataClip = spriteMetadata[metadataBase + 2u];
1920
- }
1921
- let metadataPage = metadataSprite.y;
1922
- let metadataFlags = u32(max(metadataSprite.z, 0.0));
1923
- // The source sprite index is explicit so a page-specific metadata range
1924
- // can represent non-contiguous atlas pages without duplicating frame rows.
1925
- // A page mismatch is made transparent so an invalid plan cannot sample a
1926
- // sprite into the wrong atlas page.
1927
- let spriteIndex = u32(max(metadataSprite.x, 0.0));
1928
-
1929
- let frameCount = max(globals.tableInfo.x, 1u);
1930
- let spriteCount = max(globals.tableInfo.y, 1u);
1931
- let safeSprite = min(spriteIndex, spriteCount - 1u);
1932
- let selectedFrame = select(
1933
- globals.translateOpacityFrame.w,
1934
- hybridTranslateOpacityFrame.w,
1935
- hybrid || compactSlots,
1936
- );
1937
- let safeFrame = min(
1938
- u32(max(selectedFrame, 0.0)),
1939
- frameCount - 1u,
1940
- );
1941
- let tableBase = (safeSprite * frameCount + safeFrame) * globals.tableInfo.z;
1942
- let frame0 = readFrameValue(tableBase);
1943
- let frame1 = readFrameValue(tableBase + 1u);
1944
- let frame2 = readFrameValue(tableBase + 2u);
1945
-
1946
- let layoutW = frame0.x;
1947
- let layoutH = frame0.y;
1948
- let local = vec2f(
1949
- frame0.z * layoutW * input.corner.x + frame1.x * layoutH * input.corner.y + frame1.z,
1950
- frame0.w * layoutW * input.corner.x + frame1.y * layoutH * input.corner.y + frame1.w,
1951
- );
1952
-
1953
- let instanceSlotState = hybrid || compactSlots;
1954
- let parent = select(globals.parentAffine, hybridParent, instanceSlotState);
1955
- let parentTranslate = select(
1956
- globals.translateOpacityFrame.xy,
1957
- hybridTranslateOpacityFrame.xy,
1958
- instanceSlotState,
1959
- );
1960
- let parentLocal = vec2f(
1961
- parent.x * local.x + parent.z * local.y + parentTranslate.x,
1962
- parent.y * local.x + parent.w * local.y + parentTranslate.y,
1963
- );
1964
- let instanceTrack = u32(max(hybridInfo.w, 0.0));
1965
- let selectedTrack = select(globals.drawInfo.w, instanceTrack, compactSlots);
1966
- let hasParentMotion = selectedTrack > 0u;
1967
- var world = parentLocal;
1968
- var outerClip = select(globals.clipRect, hybridClip, instanceSlotState);
1969
- let outerClipEnabled = select(
1970
- f32(globals.drawInfo.z & 1u),
1971
- hybridInfo.x,
1972
- instanceSlotState,
1973
- );
1974
- var parentOpacity = select(
1975
- globals.translateOpacityFrame.z,
1976
- hybridTranslateOpacityFrame.z,
1977
- instanceSlotState,
1978
- );
1979
- if (hasParentMotion) {
1980
- let track = selectedTrack - 1u;
1981
- let scale = vec2f(sampleMotion(track, 2u), sampleMotion(track, 3u));
1982
- let angle = sampleMotion(track, 4u);
1983
- let cosine = cos(angle);
1984
- let sine = sin(angle);
1985
- let center = vec2f(
1986
- sampleMotion(track, 0u) * motionGlobals.cssScaleX,
1987
- sampleMotion(track, 1u) * motionGlobals.cssScaleY,
1988
- );
1989
- world = applyMotionPoint(parentLocal, center, scale, cosine, sine);
1990
- let clip0 = applyMotionPoint(outerClip.xy, center, scale, cosine, sine);
1991
- let clip1 = applyMotionPoint(vec2f(outerClip.z, outerClip.y), center, scale, cosine, sine);
1992
- let clip2 = applyMotionPoint(outerClip.zw, center, scale, cosine, sine);
1993
- let clip3 = applyMotionPoint(vec2f(outerClip.x, outerClip.w), center, scale, cosine, sine);
1994
- outerClip = vec4f(
1995
- min(min(clip0.x, clip1.x), min(clip2.x, clip3.x)),
1996
- min(min(clip0.y, clip1.y), min(clip2.y, clip3.y)),
1997
- max(max(clip0.x, clip1.x), max(clip2.x, clip3.x)),
1998
- max(max(clip0.y, clip1.y), max(clip2.y, clip3.y)),
1999
- );
2000
- let visible = sampleMotion(track, 6u);
2001
- parentOpacity = sampleMotion(track, 5u) * select(0.0, 1.0, visible > 0.5);
2002
- }
2003
-
2004
- var output: VOut;
2005
- output.pos = globals.projection * vec4f(world, 0.0, 1.0);
2006
- output.uv = mix(metadataUv.xy, metadataUv.zw, input.corner);
2007
- var pageMatchesValue = globals.tableInfo.w == 0xffffffffu ||
2008
- u32(max(metadataPage, 0.0)) == globals.tableInfo.w;
2009
- if (hybrid || compactSlots) {
2010
- pageMatchesValue = hybridInfo.z < -0.5 ||
2011
- i32(round(metadataPage)) == i32(round(hybridInfo.z));
2012
- }
2013
- let pageMatches = select(
2014
- 0.0,
2015
- 1.0,
2016
- pageMatchesValue,
2017
- );
2018
- let metadataPresent = select(1.0, 0.0, (metadataFlags & 1u) != 0u);
2019
- // Keep the table path's visibility cutoff identical to the CPU reference
2020
- // renderer: rows below 0.05 are culled before issuing meaningful color.
2021
- // Exactly 0.05 remains visible (the reference uses a strict \`< 0.05\` test).
2022
- let effectiveAlpha = frame2.x * parentOpacity * pageMatches * metadataPresent;
2023
- let visibleAlpha = select(0.0, effectiveAlpha, effectiveAlpha >= 0.05);
2024
- output.color = vec4f(visibleAlpha);
2025
- output.clipRect = outerClip;
2026
- output.clipEnabled = outerClipEnabled;
2027
- output.localPosition = vec2f(layoutW * input.corner.x, layoutH * input.corner.y);
2028
- output.localClipRect = metadataClip;
2029
- output.localClipEnabled = select(0.0, 1.0, (metadataFlags & 2u) != 0u);
2030
- return output;
2031
- }
2032
-
2033
- @fragment
2034
- fn fs(input: VOut) -> @location(0) vec4f {
2035
- if (input.color.a < 0.05) {
2036
- discard;
2037
- }
2038
- if (input.clipEnabled > 0.5) {
2039
- if (
2040
- input.pos.x < input.clipRect.x ||
2041
- input.pos.y < input.clipRect.y ||
2042
- input.pos.x >= input.clipRect.z ||
2043
- input.pos.y >= input.clipRect.w
2044
- ) {
2045
- discard;
2046
- }
2047
- }
2048
- if (
2049
- input.localClipEnabled > 0.5 &&
2050
- (
2051
- input.localPosition.x < input.localClipRect.x ||
2052
- input.localPosition.y < input.localClipRect.y ||
2053
- input.localPosition.x >= input.localClipRect.z ||
2054
- input.localPosition.y >= input.localClipRect.w
2055
- )
2056
- ) {
2057
- discard;
2058
- }
2059
- let color = textureSample(atlasTex, atlasSampler, input.uv);
2060
- return vec4f(color.rgb * input.color.a, color.a * input.color.a);
2061
- }
1776
+ }, Qi = `/// SVGA timeline/table variant for premultiplied RGBA atlas textures.\r
1777
+ ///\r
1778
+ /// The frame table and sprite metadata are resident storage buffers. A draw\r
1779
+ /// submits one instance per sprite. Direct draws derive the sprite index from\r
1780
+ /// the GPU instance index and only upload the slot/global uniform. Hybrid\r
1781
+ /// draws can additionally bind compact CPU-precompiled scheduling rows that\r
1782
+ /// omit the SVGA child matrix and alpha fetched from the frame table.\r
1783
+ ///\r
1784
+ /// Frame table: three vec4 values per (sprite, frame):\r
1785
+ /// 0: layoutW, layoutH, a, b\r
1786
+ /// 1: c, d, tx, ty\r
1787
+ /// 2: alpha, reserved, reserved, reserved\r
1788
+ ///\r
1789
+ /// Sprite metadata: two vec4 values per draw sprite:\r
1790
+ /// 0: atlas UV min.xy / max.xy\r
1791
+ /// 1: source sprite index, atlas page, flags, reserved\r
1792
+ ///\r
1793
+ /// Uniform layout:\r
1794
+ /// projection mat4x4f (64 bytes)\r
1795
+ /// parentAffine vec4f (a, b, c, d)\r
1796
+ /// translateOpacityFrame vec4f (tx, ty, opacity, frameIndex)\r
1797
+ /// clipRect vec4f (top-left x0, y0, x1, y1)\r
1798
+ /// drawInfo vec4u (metadataBase, drawSpriteCount, clipEnabled, trackIndex+1)\r
1799
+ /// tableInfo vec4u (frameCount, spriteCount, vec4sPerFrame, 0)\r
1800
+ /// batchInfo vec4u (spritesPerSlot, metadataVec4Stride, stateMode, 0)\r
1801
+ \r
1802
+ struct Globals {\r
1803
+ projection: mat4x4f,\r
1804
+ parentAffine: vec4f,\r
1805
+ translateOpacityFrame: vec4f,\r
1806
+ clipRect: vec4f,\r
1807
+ drawInfo: vec4u,\r
1808
+ tableInfo: vec4u,\r
1809
+ batchInfo: vec4u,\r
1810
+ }\r
1811
+ \r
1812
+ struct MotionGlobals {\r
1813
+ timeMs: f32,\r
1814
+ sampleIntervalMs: f32,\r
1815
+ sampleCount: f32,\r
1816
+ cssScaleX: f32,\r
1817
+ cssScaleY: f32,\r
1818
+ pad0: f32,\r
1819
+ pad1: f32,\r
1820
+ pad2: f32,\r
1821
+ }\r
1822
+ \r
1823
+ @group(0) @binding(0) var<uniform> globals: Globals;\r
1824
+ @group(0) @binding(1) var<storage, read> frameTable: array<vec4f>;\r
1825
+ @group(0) @binding(2) var<storage, read> spriteMetadata: array<vec4f>;\r
1826
+ @group(0) @binding(3) var<storage, read> motionData: array<f32>;\r
1827
+ @group(0) @binding(4) var<uniform> motionGlobals: MotionGlobals;\r
1828
+ // Canonical four-vec4 / 16-float slot row: affine; translate+opacity+frame;\r
1829
+ // clip rect; clipEnabled+metadataBase+atlasPage+motionTrack+1.\r
1830
+ // Optional Hybrid scheduling rows use this exact schema per draw instance.\r
1831
+ // Direct draws bind a harmless dummy slice and leave drawInfo bit 1 clear.\r
1832
+ @group(0) @binding(5) var<storage, read> hybridInstances: array<vec4f>;\r
1833
+ @group(1) @binding(0) var atlasTex: texture_2d<f32>;\r
1834
+ @group(1) @binding(1) var atlasSampler: sampler;\r
1835
+ \r
1836
+ struct VIn {\r
1837
+ @location(0) corner: vec2f,\r
1838
+ }\r
1839
+ \r
1840
+ struct VOut {\r
1841
+ @builtin(position) pos: vec4f,\r
1842
+ @location(0) uv: vec2f,\r
1843
+ @location(1) color: vec4f,\r
1844
+ @location(2) @interpolate(flat) clipRect: vec4f,\r
1845
+ @location(3) @interpolate(flat) clipEnabled: f32,\r
1846
+ @location(4) localPosition: vec2f,\r
1847
+ @location(5) @interpolate(flat) localClipRect: vec4f,\r
1848
+ @location(6) @interpolate(flat) localClipEnabled: f32,\r
1849
+ }\r
1850
+ \r
1851
+ fn readFrameValue(index: u32) -> vec4f {\r
1852
+ return frameTable[index];\r
1853
+ }\r
1854
+ \r
1855
+ fn sampleMotion(track: u32, channel: u32) -> f32 {\r
1856
+ let sampleCount = max(u32(motionGlobals.sampleCount), 1u);\r
1857
+ let samplePosition = clamp(\r
1858
+ motionGlobals.timeMs / max(motionGlobals.sampleIntervalMs, 0.001),\r
1859
+ 0.0,\r
1860
+ f32(sampleCount - 1u),\r
1861
+ );\r
1862
+ let left = u32(floor(samplePosition));\r
1863
+ let right = min(sampleCount - 1u, left + 1u);\r
1864
+ let trackBase = track * sampleCount * 8u;\r
1865
+ let leftBase = trackBase + left * 8u;\r
1866
+ let rightBase = trackBase + right * 8u;\r
1867
+ let interpolate = left != right && motionData[leftBase + 7u] > 0.5 && channel < 6u;\r
1868
+ if (!interpolate) {\r
1869
+ return motionData[leftBase + channel];\r
1870
+ }\r
1871
+ let progress = samplePosition - f32(left);\r
1872
+ return mix(motionData[leftBase + channel], motionData[rightBase + channel], progress);\r
1873
+ }\r
1874
+ \r
1875
+ fn applyMotionPoint(\r
1876
+ point: vec2f,\r
1877
+ center: vec2f,\r
1878
+ scale: vec2f,\r
1879
+ cosine: f32,\r
1880
+ sine: f32,\r
1881
+ ) -> vec2f {\r
1882
+ let scaled = point * scale;\r
1883
+ return center + vec2f(\r
1884
+ cosine * scaled.x - sine * scaled.y,\r
1885
+ sine * scaled.x + cosine * scaled.y,\r
1886
+ );\r
1887
+ }\r
1888
+ \r
1889
+ @vertex\r
1890
+ fn vs(input: VIn, @builtin(instance_index) instance: u32) -> VOut {\r
1891
+ let safeInstance = min(instance, max(globals.drawInfo.y, 1u) - 1u);\r
1892
+ let hybrid = (globals.drawInfo.z & 2u) != 0u;\r
1893
+ let compactSlots = (globals.drawInfo.z & 4u) != 0u;\r
1894
+ let spritesPerSlot = max(globals.batchInfo.x, 1u);\r
1895
+ let slotStateIndex = select(safeInstance, safeInstance / spritesPerSlot, compactSlots);\r
1896
+ let hybridBase = slotStateIndex * 4u;\r
1897
+ var hybridParent = vec4f(0.0);\r
1898
+ var hybridTranslateOpacityFrame = vec4f(0.0);\r
1899
+ var hybridClip = vec4f(0.0);\r
1900
+ var hybridInfo = vec4f(0.0);\r
1901
+ if (hybrid || compactSlots) {\r
1902
+ hybridParent = hybridInstances[hybridBase];\r
1903
+ hybridTranslateOpacityFrame = hybridInstances[hybridBase + 1u];\r
1904
+ hybridClip = hybridInstances[hybridBase + 2u];\r
1905
+ hybridInfo = hybridInstances[hybridBase + 3u];\r
1906
+ }\r
1907
+ let spriteWithinSlot = select(safeInstance, safeInstance % spritesPerSlot, compactSlots);\r
1908
+ let metadataIndex = select(\r
1909
+ globals.drawInfo.x + spriteWithinSlot,\r
1910
+ u32(max(hybridInfo.y, 0.0)),\r
1911
+ hybrid,\r
1912
+ );\r
1913
+ let metadataStride = max(globals.batchInfo.y, 2u);\r
1914
+ let metadataBase = metadataIndex * metadataStride;\r
1915
+ let metadataUv = spriteMetadata[metadataBase];\r
1916
+ let metadataSprite = spriteMetadata[metadataBase + 1u];\r
1917
+ var metadataClip = vec4f(0.0);\r
1918
+ if (metadataStride >= 3u) {\r
1919
+ metadataClip = spriteMetadata[metadataBase + 2u];\r
1920
+ }\r
1921
+ let metadataPage = metadataSprite.y;\r
1922
+ let metadataFlags = u32(max(metadataSprite.z, 0.0));\r
1923
+ // The source sprite index is explicit so a page-specific metadata range\r
1924
+ // can represent non-contiguous atlas pages without duplicating frame rows.\r
1925
+ // A page mismatch is made transparent so an invalid plan cannot sample a\r
1926
+ // sprite into the wrong atlas page.\r
1927
+ let spriteIndex = u32(max(metadataSprite.x, 0.0));\r
1928
+ \r
1929
+ let frameCount = max(globals.tableInfo.x, 1u);\r
1930
+ let spriteCount = max(globals.tableInfo.y, 1u);\r
1931
+ let safeSprite = min(spriteIndex, spriteCount - 1u);\r
1932
+ let selectedFrame = select(\r
1933
+ globals.translateOpacityFrame.w,\r
1934
+ hybridTranslateOpacityFrame.w,\r
1935
+ hybrid || compactSlots,\r
1936
+ );\r
1937
+ let safeFrame = min(\r
1938
+ u32(max(selectedFrame, 0.0)),\r
1939
+ frameCount - 1u,\r
1940
+ );\r
1941
+ let tableBase = (safeSprite * frameCount + safeFrame) * globals.tableInfo.z;\r
1942
+ let frame0 = readFrameValue(tableBase);\r
1943
+ let frame1 = readFrameValue(tableBase + 1u);\r
1944
+ let frame2 = readFrameValue(tableBase + 2u);\r
1945
+ \r
1946
+ let layoutW = frame0.x;\r
1947
+ let layoutH = frame0.y;\r
1948
+ let local = vec2f(\r
1949
+ frame0.z * layoutW * input.corner.x + frame1.x * layoutH * input.corner.y + frame1.z,\r
1950
+ frame0.w * layoutW * input.corner.x + frame1.y * layoutH * input.corner.y + frame1.w,\r
1951
+ );\r
1952
+ \r
1953
+ let instanceSlotState = hybrid || compactSlots;\r
1954
+ let parent = select(globals.parentAffine, hybridParent, instanceSlotState);\r
1955
+ let parentTranslate = select(\r
1956
+ globals.translateOpacityFrame.xy,\r
1957
+ hybridTranslateOpacityFrame.xy,\r
1958
+ instanceSlotState,\r
1959
+ );\r
1960
+ let parentLocal = vec2f(\r
1961
+ parent.x * local.x + parent.z * local.y + parentTranslate.x,\r
1962
+ parent.y * local.x + parent.w * local.y + parentTranslate.y,\r
1963
+ );\r
1964
+ let instanceTrack = u32(max(hybridInfo.w, 0.0));\r
1965
+ let selectedTrack = select(globals.drawInfo.w, instanceTrack, compactSlots);\r
1966
+ let hasParentMotion = selectedTrack > 0u;\r
1967
+ var world = parentLocal;\r
1968
+ var outerClip = select(globals.clipRect, hybridClip, instanceSlotState);\r
1969
+ let outerClipEnabled = select(\r
1970
+ f32(globals.drawInfo.z & 1u),\r
1971
+ hybridInfo.x,\r
1972
+ instanceSlotState,\r
1973
+ );\r
1974
+ var parentOpacity = select(\r
1975
+ globals.translateOpacityFrame.z,\r
1976
+ hybridTranslateOpacityFrame.z,\r
1977
+ instanceSlotState,\r
1978
+ );\r
1979
+ if (hasParentMotion) {\r
1980
+ let track = selectedTrack - 1u;\r
1981
+ let scale = vec2f(sampleMotion(track, 2u), sampleMotion(track, 3u));\r
1982
+ let angle = sampleMotion(track, 4u);\r
1983
+ let cosine = cos(angle);\r
1984
+ let sine = sin(angle);\r
1985
+ let center = vec2f(\r
1986
+ sampleMotion(track, 0u) * motionGlobals.cssScaleX,\r
1987
+ sampleMotion(track, 1u) * motionGlobals.cssScaleY,\r
1988
+ );\r
1989
+ world = applyMotionPoint(parentLocal, center, scale, cosine, sine);\r
1990
+ let clip0 = applyMotionPoint(outerClip.xy, center, scale, cosine, sine);\r
1991
+ let clip1 = applyMotionPoint(vec2f(outerClip.z, outerClip.y), center, scale, cosine, sine);\r
1992
+ let clip2 = applyMotionPoint(outerClip.zw, center, scale, cosine, sine);\r
1993
+ let clip3 = applyMotionPoint(vec2f(outerClip.x, outerClip.w), center, scale, cosine, sine);\r
1994
+ outerClip = vec4f(\r
1995
+ min(min(clip0.x, clip1.x), min(clip2.x, clip3.x)),\r
1996
+ min(min(clip0.y, clip1.y), min(clip2.y, clip3.y)),\r
1997
+ max(max(clip0.x, clip1.x), max(clip2.x, clip3.x)),\r
1998
+ max(max(clip0.y, clip1.y), max(clip2.y, clip3.y)),\r
1999
+ );\r
2000
+ let visible = sampleMotion(track, 6u);\r
2001
+ parentOpacity = sampleMotion(track, 5u) * select(0.0, 1.0, visible > 0.5);\r
2002
+ }\r
2003
+ \r
2004
+ var output: VOut;\r
2005
+ output.pos = globals.projection * vec4f(world, 0.0, 1.0);\r
2006
+ output.uv = mix(metadataUv.xy, metadataUv.zw, input.corner);\r
2007
+ var pageMatchesValue = globals.tableInfo.w == 0xffffffffu ||\r
2008
+ u32(max(metadataPage, 0.0)) == globals.tableInfo.w;\r
2009
+ if (hybrid || compactSlots) {\r
2010
+ pageMatchesValue = hybridInfo.z < -0.5 ||\r
2011
+ i32(round(metadataPage)) == i32(round(hybridInfo.z));\r
2012
+ }\r
2013
+ let pageMatches = select(\r
2014
+ 0.0,\r
2015
+ 1.0,\r
2016
+ pageMatchesValue,\r
2017
+ );\r
2018
+ let metadataPresent = select(1.0, 0.0, (metadataFlags & 1u) != 0u);\r
2019
+ // Keep the table path's visibility cutoff identical to the CPU reference\r
2020
+ // renderer: rows below 0.05 are culled before issuing meaningful color.\r
2021
+ // Exactly 0.05 remains visible (the reference uses a strict \`< 0.05\` test).\r
2022
+ let effectiveAlpha = frame2.x * parentOpacity * pageMatches * metadataPresent;\r
2023
+ let visibleAlpha = select(0.0, effectiveAlpha, effectiveAlpha >= 0.05);\r
2024
+ output.color = vec4f(visibleAlpha);\r
2025
+ output.clipRect = outerClip;\r
2026
+ output.clipEnabled = outerClipEnabled;\r
2027
+ output.localPosition = vec2f(layoutW * input.corner.x, layoutH * input.corner.y);\r
2028
+ output.localClipRect = metadataClip;\r
2029
+ output.localClipEnabled = select(0.0, 1.0, (metadataFlags & 2u) != 0u);\r
2030
+ return output;\r
2031
+ }\r
2032
+ \r
2033
+ @fragment\r
2034
+ fn fs(input: VOut) -> @location(0) vec4f {\r
2035
+ if (input.color.a < 0.05) {\r
2036
+ discard;\r
2037
+ }\r
2038
+ if (input.clipEnabled > 0.5) {\r
2039
+ if (\r
2040
+ input.pos.x < input.clipRect.x ||\r
2041
+ input.pos.y < input.clipRect.y ||\r
2042
+ input.pos.x >= input.clipRect.z ||\r
2043
+ input.pos.y >= input.clipRect.w\r
2044
+ ) {\r
2045
+ discard;\r
2046
+ }\r
2047
+ }\r
2048
+ if (\r
2049
+ input.localClipEnabled > 0.5 &&\r
2050
+ (\r
2051
+ input.localPosition.x < input.localClipRect.x ||\r
2052
+ input.localPosition.y < input.localClipRect.y ||\r
2053
+ input.localPosition.x >= input.localClipRect.z ||\r
2054
+ input.localPosition.y >= input.localClipRect.w\r
2055
+ )\r
2056
+ ) {\r
2057
+ discard;\r
2058
+ }\r
2059
+ let color = textureSample(atlasTex, atlasSampler, input.uv);\r
2060
+ return vec4f(color.rgb * input.color.a, color.a * input.color.a);\r
2061
+ }\r
2062
2062
  `, tg = Object.freeze({
2063
2063
  submitted: !0
2064
2064
  });
@@ -3932,12 +3932,12 @@ const hg = class CA {
3932
3932
  rA,
3933
3933
  this.storageBindOffsetAlign
3934
3934
  ), this.writeInstancedStorageShadow(QA, UA, rA), this.performanceSVGADynamicUploadWrites++, this.performanceSVGADynamicUploadBytes += rA, x && BA >= 0 && (this.svgaCompactSlotStateUploadId = BA, this.svgaCompactSlotStateStorageBase = QA, this.svgaCompactSlotStateByteLength = rA));
3935
- const V = A.motionTrackIndex, YA = A.motionTrackBuffer, kA = A.motionTrackGlobalsBuffer, W = YA ? this.buffers.get(YA.id) : null, pA = kA ? this.buffers.get(kA.id) : null, LA = Math.floor((D = A.motionTrackSampleCount) != null ? D : 0), ag = Math.floor(V != null ? V : -1), OA = (ag + 1) * LA * 8 * 4, KA = ag >= 0 && LA >= 1 && (W == null ? void 0 : W.usage) === "storage" && (pA == null ? void 0 : pA.usage) === "uniform" && W.buffer.size >= OA && pA.buffer.size >= 32, qA = A.stencil === "test" ? "test" : A.stencil === "write" ? "write" : A.stencil === "clear" ? "clear" : this.frameUsesStencil ? "pass" : "none", sA = l ? this.ensureSVGAFrameTableMeshPipeline(
3935
+ const V = A.motionTrackIndex, YA = A.motionTrackBuffer, kA = A.motionTrackGlobalsBuffer, W = YA ? this.buffers.get(YA.id) : null, pA = kA ? this.buffers.get(kA.id) : null, LA = Math.floor((D = A.motionTrackSampleCount) != null ? D : 0), ag = Math.floor(V != null ? V : -1), OA = (ag + 1) * LA * 8 * 4, KA = ag >= 0 && LA >= 1 && (W == null ? void 0 : W.usage) === "storage" && (pA == null ? void 0 : pA.usage) === "uniform" && W.buffer.size >= OA && pA.buffer.size >= 32, TA = A.stencil === "test" ? "test" : A.stencil === "write" ? "write" : A.stencil === "clear" ? "clear" : this.frameUsesStencil ? "pass" : "none", sA = l ? this.ensureSVGAFrameTableMeshPipeline(
3936
3936
  A.shader,
3937
- qA
3938
- ) : this.ensureSVGAFrameTablePipeline(qA === "test" ? "test" : qA === "pass" ? "pass" : "none");
3937
+ TA
3938
+ ) : this.ensureSVGAFrameTablePipeline(TA === "test" ? "test" : TA === "pass" ? "pass" : "none");
3939
3939
  this.lastDrawPipeline !== sA.pipeline && (w.setPipeline(sA.pipeline), this.lastDrawPipeline = sA.pipeline, this.lastInstancedTextureBindGroup = null);
3940
- const L = qA === "test" || qA === "write" ? 1 : 0;
3940
+ const L = TA === "test" || TA === "write" ? 1 : 0;
3941
3941
  this.frameUsesStencil && this.lastStencilRef !== L && (w.setStencilReference(L), this.lastStencilRef = L);
3942
3942
  const EA = A.uniforms.u_projection;
3943
3943
  if (!(EA instanceof Float32Array) || EA.length < 16) return;
@@ -4007,20 +4007,20 @@ const hg = class CA {
4007
4007
  }), this.instancedTextureBindGroupCache.set(eA, tA)), w.setBindGroup(1, tA), this.lastVertexBufferId !== A.vertexBuffer.id && (w.setVertexBuffer(0, Bg.buffer), this.lastVertexBufferId = A.vertexBuffer.id), this.lastIndexBufferId !== A.indexBuffer.id && (w.setIndexBuffer(AA.buffer, "uint32"), this.lastIndexBufferId = A.indexBuffer.id), w.drawIndexed(A.indexCount, F, 0, 0, 0), this.recordSubmittedDraw();
4008
4008
  }
4009
4009
  resolveSVGAFrameTableSlotUniform(A, g, I) {
4010
- var B, Q, E, i, e, t, a, o, s, n, r, h, c, D, w, l, F, d, y, G, f, u, R, M, N, S, Y, U, k, m, J, q, _, Z, x, X, v, gA, UA, yA, rA, BA, Ig, QA, V, YA, kA, W, pA, LA, ag, OA, KA, qA, sA;
4010
+ var B, Q, E, i, e, t, a, o, s, n, r, h, c, D, w, l, F, d, y, G, f, u, R, M, N, S, Y, U, k, m, J, q, _, Z, x, X, v, gA, UA, yA, rA, BA, Ig, QA, V, YA, kA, W, pA, LA, ag, OA, KA, TA, sA;
4011
4011
  const L = (Q = (B = A.svgaFrameTableSlotState) != null ? B : A.svgaSlotState) != null ? Q : A.uniforms.u_svgaSlotState instanceof Float32Array ? A.uniforms.u_svgaSlotState : A.uniforms.u_slotState instanceof Float32Array ? A.uniforms.u_slotState : null, EA = A.uniforms.u_transform, Bg = A.uniforms.u_clipRect, AA = A.svgaFrameTableParentAffine, DA = A.svgaFrameTableParentTranslate, IA = A.svgaFrameTableClipRect, pg = A.svgaFrameIndex != null || A.svgaFrameTableFrameIndex != null || A.frameTableFrameIndex != null, Kg = A.svgaFrameTableOpacity != null || typeof A.uniforms.u_opacity == "number", Cg = A.uniforms.u_projection;
4012
4012
  if (!(Cg instanceof Float32Array) || Cg.length < 16) return null;
4013
- let GA = 1, fA = 0, dA = 0, iA = 1, eA = 0, tA = 0, hA = (E = A.svgaFrameTableOpacity) != null ? E : typeof A.uniforms.u_opacity == "number" ? A.uniforms.u_opacity : 1, aA = (t = (e = (i = A.svgaFrameIndex) != null ? i : A.svgaFrameTableFrameIndex) != null ? e : A.frameTableFrameIndex) != null ? t : 0, nA = 0, RA = 0, uA = this.canvas.width, TA = this.canvas.height, Qg = 0, Wg = (a = A.svgaFrameTableAtlasPage) != null ? a : -1, PA = (h = (r = (n = (s = (o = A.svgaFrameTableMetadataBase) != null ? o : A.svgaFrameTableSpriteBase) != null ? s : A.frameTableSpriteBase) != null ? n : A.svgaSpriteMetadataBase) != null ? r : A.svgaSpriteBase) != null ? h : 0;
4013
+ let GA = 1, fA = 0, dA = 0, iA = 1, eA = 0, tA = 0, hA = (E = A.svgaFrameTableOpacity) != null ? E : typeof A.uniforms.u_opacity == "number" ? A.uniforms.u_opacity : 1, aA = (t = (e = (i = A.svgaFrameIndex) != null ? i : A.svgaFrameTableFrameIndex) != null ? e : A.frameTableFrameIndex) != null ? t : 0, nA = 0, RA = 0, uA = this.canvas.width, vA = this.canvas.height, Qg = 0, Wg = (a = A.svgaFrameTableAtlasPage) != null ? a : -1, PA = (h = (r = (n = (s = (o = A.svgaFrameTableMetadataBase) != null ? o : A.svgaFrameTableSpriteBase) != null ? s : A.frameTableSpriteBase) != null ? n : A.svgaSpriteMetadataBase) != null ? r : A.svgaSpriteBase) != null ? h : 0;
4014
4014
  if (AA && AA.length >= 4)
4015
- GA = (c = AA[0]) != null ? c : GA, fA = (D = AA[1]) != null ? D : fA, dA = (w = AA[2]) != null ? w : dA, iA = (l = AA[3]) != null ? l : iA, DA && DA.length >= 2 && (eA = (F = DA[0]) != null ? F : eA, tA = (d = DA[1]) != null ? d : tA), IA && IA.length >= 4 && (nA = (y = IA[0]) != null ? y : nA, RA = (G = IA[1]) != null ? G : RA, uA = (f = IA[2]) != null ? f : uA, TA = (u = IA[3]) != null ? u : TA, Qg = 1);
4015
+ GA = (c = AA[0]) != null ? c : GA, fA = (D = AA[1]) != null ? D : fA, dA = (w = AA[2]) != null ? w : dA, iA = (l = AA[3]) != null ? l : iA, DA && DA.length >= 2 && (eA = (F = DA[0]) != null ? F : eA, tA = (d = DA[1]) != null ? d : tA), IA && IA.length >= 4 && (nA = (y = IA[0]) != null ? y : nA, RA = (G = IA[1]) != null ? G : RA, uA = (f = IA[2]) != null ? f : uA, vA = (u = IA[3]) != null ? u : vA, Qg = 1);
4016
4016
  else if (L && L.length >= 13)
4017
- GA = (R = L[0]) != null ? R : GA, fA = (M = L[1]) != null ? M : fA, dA = (N = L[2]) != null ? N : dA, iA = (S = L[3]) != null ? S : iA, eA = (Y = L[4]) != null ? Y : eA, tA = (U = L[5]) != null ? U : tA, Kg || (hA = (k = L[6]) != null ? k : hA), pg || (aA = (m = L[7]) != null ? m : aA), nA = (J = L[8]) != null ? J : nA, RA = (q = L[9]) != null ? q : RA, uA = (_ = L[10]) != null ? _ : uA, TA = (Z = L[11]) != null ? Z : TA, Qg = ((x = L[12]) != null ? x : 0) > 0.5 ? 1 : 0, A.svgaFrameTableMetadataBase == null && A.svgaFrameTableSpriteBase == null && A.frameTableSpriteBase == null && A.svgaSpriteMetadataBase == null && A.svgaSpriteBase == null && L.length >= 14 && (PA = (X = L[13]) != null ? X : PA);
4017
+ GA = (R = L[0]) != null ? R : GA, fA = (M = L[1]) != null ? M : fA, dA = (N = L[2]) != null ? N : dA, iA = (S = L[3]) != null ? S : iA, eA = (Y = L[4]) != null ? Y : eA, tA = (U = L[5]) != null ? U : tA, Kg || (hA = (k = L[6]) != null ? k : hA), pg || (aA = (m = L[7]) != null ? m : aA), nA = (J = L[8]) != null ? J : nA, RA = (q = L[9]) != null ? q : RA, uA = (_ = L[10]) != null ? _ : uA, vA = (Z = L[11]) != null ? Z : vA, Qg = ((x = L[12]) != null ? x : 0) > 0.5 ? 1 : 0, A.svgaFrameTableMetadataBase == null && A.svgaFrameTableSpriteBase == null && A.frameTableSpriteBase == null && A.svgaSpriteMetadataBase == null && A.svgaSpriteBase == null && L.length >= 14 && (PA = (X = L[13]) != null ? X : PA);
4018
4018
  else if (EA instanceof Float32Array && EA.length >= 16) {
4019
4019
  GA = (v = EA[0]) != null ? v : GA, fA = (gA = EA[1]) != null ? gA : fA, dA = (UA = EA[4]) != null ? UA : dA, iA = (yA = EA[5]) != null ? yA : iA, eA = (rA = EA[12]) != null ? rA : eA, tA = (BA = EA[13]) != null ? BA : tA;
4020
4020
  const _g = Bg instanceof Float32Array && Bg.length >= 4 ? Bg : IA;
4021
- _g && _g.length >= 4 && (nA = (Ig = _g[0]) != null ? Ig : nA, RA = (QA = _g[1]) != null ? QA : RA, uA = (V = _g[2]) != null ? V : uA, TA = (YA = _g[3]) != null ? YA : TA, Qg = typeof A.uniforms.u_clipEnabled == "number" ? A.uniforms.u_clipEnabled > 0.5 ? 1 : 0 : 1);
4021
+ _g && _g.length >= 4 && (nA = (Ig = _g[0]) != null ? Ig : nA, RA = (QA = _g[1]) != null ? QA : RA, uA = (V = _g[2]) != null ? V : uA, vA = (YA = _g[3]) != null ? YA : vA, Qg = typeof A.uniforms.u_clipEnabled == "number" ? A.uniforms.u_clipEnabled > 0.5 ? 1 : 0 : 1);
4022
4022
  }
4023
- return AA && L && L.length >= 13 && (DA || (eA = (kA = L[4]) != null ? kA : eA, tA = (W = L[5]) != null ? W : tA), Kg || (hA = (pA = L[6]) != null ? pA : hA), pg || (aA = (LA = L[7]) != null ? LA : aA), IA || (nA = (ag = L[8]) != null ? ag : nA, RA = (OA = L[9]) != null ? OA : RA, uA = (KA = L[10]) != null ? KA : uA, TA = (qA = L[11]) != null ? qA : TA, Qg = ((sA = L[12]) != null ? sA : 0) > 0.5 ? 1 : 0)), Number.isFinite(hA) || (hA = 1), Number.isFinite(aA) || (aA = 0), Number.isFinite(PA) || (PA = 0), Number.isFinite(Wg) || (Wg = -1), aA = Math.max(0, Math.min(I - 1, Math.floor(aA))), PA = Math.max(0, Math.floor(PA)), ![GA, fA, dA, iA, eA, tA, hA].every(Number.isFinite) || g < 1 ? null : {
4023
+ return AA && L && L.length >= 13 && (DA || (eA = (kA = L[4]) != null ? kA : eA, tA = (W = L[5]) != null ? W : tA), Kg || (hA = (pA = L[6]) != null ? pA : hA), pg || (aA = (LA = L[7]) != null ? LA : aA), IA || (nA = (ag = L[8]) != null ? ag : nA, RA = (OA = L[9]) != null ? OA : RA, uA = (KA = L[10]) != null ? KA : uA, vA = (TA = L[11]) != null ? TA : vA, Qg = ((sA = L[12]) != null ? sA : 0) > 0.5 ? 1 : 0)), Number.isFinite(hA) || (hA = 1), Number.isFinite(aA) || (aA = 0), Number.isFinite(PA) || (PA = 0), Number.isFinite(Wg) || (Wg = -1), aA = Math.max(0, Math.min(I - 1, Math.floor(aA))), PA = Math.max(0, Math.floor(PA)), ![GA, fA, dA, iA, eA, tA, hA].every(Number.isFinite) || g < 1 ? null : {
4024
4024
  parentA: GA,
4025
4025
  parentB: fA,
4026
4026
  parentC: dA,
@@ -4032,7 +4032,7 @@ const hg = class CA {
4032
4032
  clipX0: nA,
4033
4033
  clipY0: RA,
4034
4034
  clipX1: uA,
4035
- clipY1: TA,
4035
+ clipY1: vA,
4036
4036
  clipEnabled: Qg,
4037
4037
  metadataBase: PA,
4038
4038
  atlasPage: Math.max(-1, Math.floor(Wg))
@@ -4234,7 +4234,7 @@ function dC(C, A, g) {
4234
4234
  }
4235
4235
  return I;
4236
4236
  }
4237
- function vA(C, A, g) {
4237
+ function WA(C, A, g) {
4238
4238
  const I = dC(C, C.VERTEX_SHADER, A), B = dC(C, C.FRAGMENT_SHADER, g), Q = C.createProgram();
4239
4239
  if (!Q)
4240
4240
  throw C.deleteShader(I), C.deleteShader(B), new Error("Failed to create program");
@@ -4263,7 +4263,7 @@ function pI(C) {
4263
4263
  return typeof A.displayHeight == "number" && A.displayHeight > 0 ? A.displayHeight : typeof A.codedHeight == "number" && A.codedHeight > 0 ? A.codedHeight : typeof A.videoHeight == "number" && A.videoHeight > 0 ? A.videoHeight : typeof A.naturalHeight == "number" && A.naturalHeight > 0 ? A.naturalHeight : typeof A.height == "number" && A.height > 0 ? A.height : 0;
4264
4264
  }
4265
4265
  var si = Object.defineProperty, ni = (C, A, g) => A in C ? si(C, A, { enumerable: !0, configurable: !0, writable: !0, value: g }) : C[A] = g, H = (C, A, g) => ni(C, typeof A != "symbol" ? A + "" : A, g);
4266
- const vI = "svga-frame-table-instanced-premul", uC = 8, ri = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]), hi = new Float32Array([1, 1]), SA = class xA {
4266
+ const vI = "svga-frame-table-instanced-premul", uC = 8, ri = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]), hi = new Float32Array([1, 1]), SA = class bA {
4267
4267
  constructor(A, g = !0) {
4268
4268
  H(this, "type", "webgl2"), H(this, "supportsAtomicFrameReplay", !0), H(this, "canvas"), H(this, "maxTextureSize", 4096), H(this, "antialias"), H(this, "gl"), H(this, "nextId", 1), H(this, "buffers", /* @__PURE__ */ new Map()), H(this, "textures", /* @__PURE__ */ new Map()), H(this, "frameTables", /* @__PURE__ */ new Map()), H(this, "ownedFrameTableMetadataIds", /* @__PURE__ */ new Set()), H(this, "programs", /* @__PURE__ */ new Map()), H(this, "vertexArrays", /* @__PURE__ */ new Map()), H(this, "cachedDrawProgram", null), H(this, "cachedTex0Id", null), H(this, "cachedFrameTableId", null), H(this, "cachedFrameMetadataId", null), H(this, "cachedProjectionRef", null), H(this, "cachedProjectionShader", null), H(this, "videoUploadCanvas", null), H(this, "videoUploadCtx", null), H(this, "videoElementPreferCanvasBridge", oi()), H(this, "videoElementDirectUploadValidated", !1), H(this, "maxVertexTextureImageUnits", 0), H(this, "svgaFrameTableSupported", !1), H(this, "instancedSvgaInstanceGLBuffer", null), H(this, "svgaSlotStateTexture", null), H(this, "svgaSlotStateTextureWidth", 0), H(this, "svgaSlotStateTextureHeight", 0), H(this, "svgaSlotStateUploadScratch", new Float32Array(0)), H(this, "svgaSlotStateUploadId", -1), H(this, "svgaTableInfoScratch", new Int32Array(4)), H(this, "svgaTableSizeScratch", new Int32Array(2)), H(this, "svgaMetadataSizeScratch", new Int32Array(2)), H(this, "instancedClipMaskGLBuffer", null), H(this, "instancedAlphaInstanceGLBuffer", null), H(this, "performanceBufferWrites", 0), H(this, "performanceBufferWriteBytes", 0), H(this, "performanceStorageBufferWrites", 0), H(this, "performanceStorageBufferWriteBytes", 0), H(this, "performanceSubmittedDrawCalls", 0), H(this, "performanceRejectedDrawCalls", 0), H(this, "performanceSVGADynamicUploadWrites", 0), H(this, "performanceSVGADynamicUploadBytes", 0), H(this, "runtimeSubmittedDrawCalls", 0), H(this, "runtimeRejectedDrawCalls", 0), H(this, "currentDrawResult", $(
4269
4269
  "invalid-command",
@@ -4322,19 +4322,19 @@ const vI = "svga-frame-table-instanced-premul", uC = 8, ri = new Float32Array([1
4322
4322
  this.currentDrawRecorded = !0, this.currentDrawResult.submitted && (this.currentDrawResult = $("invalid-command", "WebGL2 draw was rejected")), this.performanceRejectedDrawCalls++, this.runtimeRejectedDrawCalls++;
4323
4323
  }
4324
4324
  initPrograms() {
4325
- const A = this.gl, g = vA(A, P.svgaBatchPremul.vert, P.svgaBatchPremul.frag);
4325
+ const A = this.gl, g = WA(A, P.svgaBatchPremul.vert, P.svgaBatchPremul.frag);
4326
4326
  this.programs.set(
4327
4327
  "svga-batch-premul",
4328
4328
  this.makeProgramEntry(g, { transform: !0, opacity: !0 })
4329
4329
  ), this.bindProgramSamplers(g, { u_atlas: 0 });
4330
- const I = vA(
4330
+ const I = WA(
4331
4331
  A,
4332
4332
  P.svgaInstancedPremul.vert,
4333
4333
  P.svgaInstancedPremul.frag
4334
4334
  );
4335
4335
  if (this.programs.set("svga-instanced-premul", this.makeProgramEntry(I)), this.bindProgramSamplers(I, { u_atlas: 0 }), this.maxVertexTextureImageUnits >= 2 && this.maxTextureSize >= 3)
4336
4336
  try {
4337
- const n = vA(
4337
+ const n = WA(
4338
4338
  A,
4339
4339
  P.svgaFrameTableInstancedPremul.vert,
4340
4340
  P.svgaFrameTableInstancedPremul.frag
@@ -4369,7 +4369,7 @@ const vI = "svga-frame-table-instanced-premul", uC = 8, ri = new Float32Array([1
4369
4369
  u_spriteMetadata: 2,
4370
4370
  u_slotStates: 3
4371
4371
  });
4372
- const r = vA(
4372
+ const r = WA(
4373
4373
  A,
4374
4374
  P.svgaFrameTableShape.vert,
4375
4375
  P.svgaFrameTableShape.frag
@@ -4393,7 +4393,7 @@ const vI = "svga-frame-table-instanced-premul", uC = 8, ri = new Float32Array([1
4393
4393
  compactSlotStateEnabled: !0
4394
4394
  })
4395
4395
  ), this.bindProgramSamplers(r, { u_frameTable: 0, u_slotStates: 3 });
4396
- const h = vA(
4396
+ const h = WA(
4397
4397
  A,
4398
4398
  P.svgaFrameTableClipMask.vert,
4399
4399
  P.svgaFrameTableClipMask.frag
@@ -4419,7 +4419,7 @@ const vI = "svga-frame-table-instanced-premul", uC = 8, ri = new Float32Array([1
4419
4419
  } catch (n) {
4420
4420
  this.svgaFrameTableSupported = !1, console.warn("[WebGL2] SVGA frame-table shader unavailable; using CPU reference path.", n);
4421
4421
  }
4422
- const B = vA(A, P.vap.vert, P.vap.frag);
4422
+ const B = WA(A, P.vap.vert, P.vap.frag);
4423
4423
  this.programs.set(
4424
4424
  "vap",
4425
4425
  this.makeProgramEntry(B, {
@@ -4429,12 +4429,12 @@ const vI = "svga-frame-table-instanced-premul", uC = 8, ri = new Float32Array([1
4429
4429
  rgbPremultiplied: !0
4430
4430
  })
4431
4431
  ), this.bindProgramSamplers(B, { u_video: 0 });
4432
- const Q = vA(A, P.vapMixOverlay.vert, P.vapMixOverlay.frag);
4432
+ const Q = WA(A, P.vapMixOverlay.vert, P.vapMixOverlay.frag);
4433
4433
  this.programs.set(
4434
4434
  "vap-mix-overlay",
4435
4435
  this.makeProgramEntry(Q, { transform: !0, atlasRemap: !0, opacity: !0 })
4436
4436
  ), this.bindProgramSamplers(Q, { u_resource: 0, u_video: 1 });
4437
- const E = vA(A, P.alphaVideo.vert, P.alphaVideo.frag);
4437
+ const E = WA(A, P.alphaVideo.vert, P.alphaVideo.frag);
4438
4438
  this.programs.set(
4439
4439
  "alpha-video",
4440
4440
  this.makeProgramEntry(E, {
@@ -4444,28 +4444,28 @@ const vI = "svga-frame-table-instanced-premul", uC = 8, ri = new Float32Array([1
4444
4444
  rgbPremultiplied: !0
4445
4445
  })
4446
4446
  ), this.bindProgramSamplers(E, { u_video: 0 });
4447
- const i = vA(A, P.rgbaTextured.vert, P.rgbaTextured.frag);
4447
+ const i = WA(A, P.rgbaTextured.vert, P.rgbaTextured.frag);
4448
4448
  this.programs.set(
4449
4449
  "rgba-textured",
4450
4450
  this.makeProgramEntry(i, { transform: !0, atlasRemap: !0, opacity: !0 })
4451
4451
  ), this.bindProgramSamplers(i, { u_video: 0 });
4452
- const e = vA(
4452
+ const e = WA(
4453
4453
  A,
4454
4454
  P.alphaVideoInstanced.vert,
4455
4455
  P.alphaVideoInstanced.frag
4456
4456
  );
4457
4457
  this.programs.set("alpha-video-instanced", this.makeProgramEntry(e)), this.bindProgramSamplers(e, { u_video: 0 });
4458
- const t = vA(A, P.vapInstanced.vert, P.vapInstanced.frag);
4458
+ const t = WA(A, P.vapInstanced.vert, P.vapInstanced.frag);
4459
4459
  this.programs.set("vap-instanced", this.makeProgramEntry(t)), this.bindProgramSamplers(t, { u_video: 0 });
4460
- const a = vA(A, P.clipMask.vert, P.clipMask.frag);
4460
+ const a = WA(A, P.clipMask.vert, P.clipMask.frag);
4461
4461
  this.programs.set("clip-mask", this.makeProgramEntry(a, { transform: !0 }));
4462
- const o = vA(
4462
+ const o = WA(
4463
4463
  A,
4464
4464
  P.clipMaskInstanced.vert,
4465
4465
  P.clipMaskInstanced.frag
4466
4466
  );
4467
4467
  this.programs.set("clip-mask-instanced", this.makeProgramEntry(o));
4468
- const s = vA(
4468
+ const s = WA(
4469
4469
  A,
4470
4470
  P.particleInstanced.vert,
4471
4471
  P.particleInstanced.frag
@@ -4475,7 +4475,7 @@ const vI = "svga-frame-table-instanced-premul", uC = 8, ri = new Float32Array([1
4475
4475
  ensureParticleSpriteProgram() {
4476
4476
  let A = this.programs.get("particle-sprite-instanced");
4477
4477
  if (A) return A;
4478
- const g = vA(
4478
+ const g = WA(
4479
4479
  this.gl,
4480
4480
  P.particleSpriteInstanced.vert,
4481
4481
  P.particleSpriteInstanced.frag
@@ -5081,7 +5081,7 @@ const vI = "svga-frame-table-instanced-premul", uC = 8, ri = new Float32Array([1
5081
5081
  if (!this.instancedSvgaInstanceGLBuffer) {
5082
5082
  const g = A.createBuffer();
5083
5083
  if (!g) throw new Error("createBuffer failed");
5084
- A.bindVertexArray(null), A.bindBuffer(A.ARRAY_BUFFER, g), A.bufferData(A.ARRAY_BUFFER, xA.INST_SVGA_GL_BYTES, A.DYNAMIC_DRAW), this.instancedSvgaInstanceGLBuffer = g;
5084
+ A.bindVertexArray(null), A.bindBuffer(A.ARRAY_BUFFER, g), A.bufferData(A.ARRAY_BUFFER, bA.INST_SVGA_GL_BYTES, A.DYNAMIC_DRAW), this.instancedSvgaInstanceGLBuffer = g;
5085
5085
  }
5086
5086
  return this.instancedSvgaInstanceGLBuffer;
5087
5087
  }
@@ -5099,19 +5099,19 @@ const vI = "svga-frame-table-instanced-premul", uC = 8, ri = new Float32Array([1
5099
5099
  return e !== t.length && (this.svgaSlotStateUploadScratch.length < e && (this.svgaSlotStateUploadScratch = new Float32Array(e)), this.svgaSlotStateUploadScratch.fill(0, 0, e), this.svgaSlotStateUploadScratch.set(t), a = this.svgaSlotStateUploadScratch.subarray(0, e)), B.texSubImage2D(B.TEXTURE_2D, 0, 0, 0, E, i, B.RGBA, B.FLOAT, a, 0), this.performanceSVGADynamicUploadWrites++, this.performanceSVGADynamicUploadBytes += g * $A * Float32Array.BYTES_PER_ELEMENT, this.svgaSlotStateUploadId = I, { width: E, height: i };
5100
5100
  }
5101
5101
  resolveSVGAFrameTableSlotState(A, g) {
5102
- var I, B, Q, E, i, e, t, a, o, s, n, r, h, c, D, w, l, F, d, y, G, f, u, R, M, N, S, Y, U, k, m, J, q, _, Z, x, X, v, gA, UA, yA, rA, BA, Ig, QA, V, YA, kA, W, pA, LA, ag, OA, KA, qA;
5102
+ var I, B, Q, E, i, e, t, a, o, s, n, r, h, c, D, w, l, F, d, y, G, f, u, R, M, N, S, Y, U, k, m, J, q, _, Z, x, X, v, gA, UA, yA, rA, BA, Ig, QA, V, YA, kA, W, pA, LA, ag, OA, KA, TA;
5103
5103
  const sA = A.uniforms, L = (B = (I = A.svgaFrameTableSlotState) != null ? I : A.svgaSlotState) != null ? B : sA.u_svgaSlotState instanceof Float32Array ? sA.u_svgaSlotState : sA.u_slotState instanceof Float32Array ? sA.u_slotState : null, EA = sA.u_transform, Bg = sA.u_clipRect, AA = A.svgaFrameTableParentAffine, DA = A.svgaFrameTableParentTranslate, IA = A.svgaFrameTableClipRect, pg = A.svgaFrameIndex != null || A.svgaFrameTableFrameIndex != null || A.frameTableFrameIndex != null, Kg = A.svgaFrameTableOpacity != null || typeof sA.u_opacity == "number";
5104
- let Cg = 1, GA = 0, fA = 0, dA = 1, iA = 0, eA = 0, tA = (Q = A.svgaFrameTableOpacity) != null ? Q : typeof sA.u_opacity == "number" ? sA.u_opacity : 1, hA = (e = (i = (E = A.svgaFrameIndex) != null ? E : A.svgaFrameTableFrameIndex) != null ? i : A.frameTableFrameIndex) != null ? e : 0, aA = 0, nA = 0, RA = this.canvas.width, uA = this.canvas.height, TA = 0, Qg = (n = (s = (o = (a = (t = A.svgaFrameTableMetadataBase) != null ? t : A.svgaFrameTableSpriteBase) != null ? a : A.frameTableSpriteBase) != null ? o : A.svgaSpriteMetadataBase) != null ? s : A.svgaSpriteBase) != null ? n : 0, Wg = (r = A.svgaFrameTableAtlasPage) != null ? r : -1;
5104
+ let Cg = 1, GA = 0, fA = 0, dA = 1, iA = 0, eA = 0, tA = (Q = A.svgaFrameTableOpacity) != null ? Q : typeof sA.u_opacity == "number" ? sA.u_opacity : 1, hA = (e = (i = (E = A.svgaFrameIndex) != null ? E : A.svgaFrameTableFrameIndex) != null ? i : A.frameTableFrameIndex) != null ? e : 0, aA = 0, nA = 0, RA = this.canvas.width, uA = this.canvas.height, vA = 0, Qg = (n = (s = (o = (a = (t = A.svgaFrameTableMetadataBase) != null ? t : A.svgaFrameTableSpriteBase) != null ? a : A.frameTableSpriteBase) != null ? o : A.svgaSpriteMetadataBase) != null ? s : A.svgaSpriteBase) != null ? n : 0, Wg = (r = A.svgaFrameTableAtlasPage) != null ? r : -1;
5105
5105
  if (AA && AA.length >= 4)
5106
- Cg = (h = AA[0]) != null ? h : Cg, GA = (c = AA[1]) != null ? c : GA, fA = (D = AA[2]) != null ? D : fA, dA = (w = AA[3]) != null ? w : dA, DA && DA.length >= 2 && (iA = (l = DA[0]) != null ? l : iA, eA = (F = DA[1]) != null ? F : eA), IA && IA.length >= 4 && (aA = (d = IA[0]) != null ? d : aA, nA = (y = IA[1]) != null ? y : nA, RA = (G = IA[2]) != null ? G : RA, uA = (f = IA[3]) != null ? f : uA, TA = 1);
5106
+ Cg = (h = AA[0]) != null ? h : Cg, GA = (c = AA[1]) != null ? c : GA, fA = (D = AA[2]) != null ? D : fA, dA = (w = AA[3]) != null ? w : dA, DA && DA.length >= 2 && (iA = (l = DA[0]) != null ? l : iA, eA = (F = DA[1]) != null ? F : eA), IA && IA.length >= 4 && (aA = (d = IA[0]) != null ? d : aA, nA = (y = IA[1]) != null ? y : nA, RA = (G = IA[2]) != null ? G : RA, uA = (f = IA[3]) != null ? f : uA, vA = 1);
5107
5107
  else if (L && L.length >= 13)
5108
- Cg = (u = L[0]) != null ? u : Cg, GA = (R = L[1]) != null ? R : GA, fA = (M = L[2]) != null ? M : fA, dA = (N = L[3]) != null ? N : dA, iA = (S = L[4]) != null ? S : iA, eA = (Y = L[5]) != null ? Y : eA, Kg || (tA = (U = L[6]) != null ? U : tA), pg || (hA = (k = L[7]) != null ? k : hA), aA = (m = L[8]) != null ? m : aA, nA = (J = L[9]) != null ? J : nA, RA = (q = L[10]) != null ? q : RA, uA = (_ = L[11]) != null ? _ : uA, TA = ((Z = L[12]) != null ? Z : 0) > 0.5 ? 1 : 0, A.svgaFrameTableMetadataBase == null && A.svgaFrameTableSpriteBase == null && A.frameTableSpriteBase == null && A.svgaSpriteMetadataBase == null && A.svgaSpriteBase == null && L.length >= 14 && (Qg = (x = L[13]) != null ? x : Qg);
5108
+ Cg = (u = L[0]) != null ? u : Cg, GA = (R = L[1]) != null ? R : GA, fA = (M = L[2]) != null ? M : fA, dA = (N = L[3]) != null ? N : dA, iA = (S = L[4]) != null ? S : iA, eA = (Y = L[5]) != null ? Y : eA, Kg || (tA = (U = L[6]) != null ? U : tA), pg || (hA = (k = L[7]) != null ? k : hA), aA = (m = L[8]) != null ? m : aA, nA = (J = L[9]) != null ? J : nA, RA = (q = L[10]) != null ? q : RA, uA = (_ = L[11]) != null ? _ : uA, vA = ((Z = L[12]) != null ? Z : 0) > 0.5 ? 1 : 0, A.svgaFrameTableMetadataBase == null && A.svgaFrameTableSpriteBase == null && A.frameTableSpriteBase == null && A.svgaSpriteMetadataBase == null && A.svgaSpriteBase == null && L.length >= 14 && (Qg = (x = L[13]) != null ? x : Qg);
5109
5109
  else if (EA instanceof Float32Array && EA.length >= 16) {
5110
5110
  Cg = (X = EA[0]) != null ? X : Cg, GA = (v = EA[1]) != null ? v : GA, fA = (gA = EA[4]) != null ? gA : fA, dA = (UA = EA[5]) != null ? UA : dA, iA = (yA = EA[12]) != null ? yA : iA, eA = (rA = EA[13]) != null ? rA : eA;
5111
5111
  const PA = Bg instanceof Float32Array && Bg.length >= 4 ? Bg : IA;
5112
- PA && PA.length >= 4 && (aA = (BA = PA[0]) != null ? BA : aA, nA = (Ig = PA[1]) != null ? Ig : nA, RA = (QA = PA[2]) != null ? QA : RA, uA = (V = PA[3]) != null ? V : uA, TA = typeof sA.u_clipEnabled == "number" ? sA.u_clipEnabled > 0.5 ? 1 : 0 : 1);
5112
+ PA && PA.length >= 4 && (aA = (BA = PA[0]) != null ? BA : aA, nA = (Ig = PA[1]) != null ? Ig : nA, RA = (QA = PA[2]) != null ? QA : RA, uA = (V = PA[3]) != null ? V : uA, vA = typeof sA.u_clipEnabled == "number" ? sA.u_clipEnabled > 0.5 ? 1 : 0 : 1);
5113
5113
  }
5114
- return AA && L && L.length >= 13 && (DA || (iA = (YA = L[4]) != null ? YA : iA, eA = (kA = L[5]) != null ? kA : eA), Kg || (tA = (W = L[6]) != null ? W : tA), pg || (hA = (pA = L[7]) != null ? pA : hA), IA || (aA = (LA = L[8]) != null ? LA : aA, nA = (ag = L[9]) != null ? ag : nA, RA = (OA = L[10]) != null ? OA : RA, uA = (KA = L[11]) != null ? KA : uA, TA = ((qA = L[12]) != null ? qA : 0) > 0.5 ? 1 : 0)), Number.isFinite(tA) || (tA = 1), Number.isFinite(hA) || (hA = 0), Number.isFinite(Qg) || (Qg = 0), Number.isFinite(Wg) || (Wg = -1), hA = Math.max(0, Math.min(Math.max(1, g) - 1, Math.floor(hA))), Qg = Math.max(0, Math.floor(Qg)), [Cg, GA, fA, dA, iA, eA, tA, aA, nA, RA, uA].every(Number.isFinite) ? {
5114
+ return AA && L && L.length >= 13 && (DA || (iA = (YA = L[4]) != null ? YA : iA, eA = (kA = L[5]) != null ? kA : eA), Kg || (tA = (W = L[6]) != null ? W : tA), pg || (hA = (pA = L[7]) != null ? pA : hA), IA || (aA = (LA = L[8]) != null ? LA : aA, nA = (ag = L[9]) != null ? ag : nA, RA = (OA = L[10]) != null ? OA : RA, uA = (KA = L[11]) != null ? KA : uA, vA = ((TA = L[12]) != null ? TA : 0) > 0.5 ? 1 : 0)), Number.isFinite(tA) || (tA = 1), Number.isFinite(hA) || (hA = 0), Number.isFinite(Qg) || (Qg = 0), Number.isFinite(Wg) || (Wg = -1), hA = Math.max(0, Math.min(Math.max(1, g) - 1, Math.floor(hA))), Qg = Math.max(0, Math.floor(Qg)), [Cg, GA, fA, dA, iA, eA, tA, aA, nA, RA, uA].every(Number.isFinite) ? {
5115
5115
  parentA: Cg,
5116
5116
  parentB: GA,
5117
5117
  parentC: fA,
@@ -5124,7 +5124,7 @@ const vI = "svga-frame-table-instanced-premul", uC = 8, ri = new Float32Array([1
5124
5124
  clipY0: nA,
5125
5125
  clipX1: RA,
5126
5126
  clipY1: uA,
5127
- clipEnabled: TA,
5127
+ clipEnabled: vA,
5128
5128
  metadataBase: Qg,
5129
5129
  atlasPage: Math.max(-1, Math.floor(Wg))
5130
5130
  } : null;
@@ -5213,12 +5213,12 @@ const vI = "svga-frame-table-instanced-premul", uC = 8, ri = new Float32Array([1
5213
5213
  this.applyProjectionUniform(W, kA, A.uniforms.u_projection);
5214
5214
  const KA = this.svgaTableInfoScratch;
5215
5215
  KA[0] = q, KA[1] = _, KA[2] = 3, KA[3] = 0;
5216
- const qA = this.svgaTableSizeScratch;
5217
- qA[0] = Y.width, qA[1] = Y.height;
5216
+ const TA = this.svgaTableSizeScratch;
5217
+ TA[0] = Y.width, TA[1] = Y.height;
5218
5218
  const sA = this.svgaMetadataSizeScratch;
5219
5219
  sA[0] = k.width, sA[1] = k.height;
5220
5220
  const L = R;
5221
- if (W.tableInfoLoc && ((F = L.uniform4iv) == null || F.call(L, W.tableInfoLoc, KA)), W.frameTableSizeLoc && ((d = L.uniform2iv) == null || d.call(L, W.frameTableSizeLoc, qA)), W.spriteMetadataSizeLoc && ((y = L.uniform2iv) == null || y.call(L, W.spriteMetadataSizeLoc, sA)), W.spriteMetadataStrideLoc && R.uniform1i(W.spriteMetadataStrideLoc, QA), W.spriteBaseLoc && R.uniform1i(W.spriteBaseLoc, V.metadataBase), W.frameIndexLoc && R.uniform1i(W.frameIndexLoc, V.frameIndex), W.parentAffineLoc && R.uniform4f(W.parentAffineLoc, V.parentA, V.parentB, V.parentC, V.parentD), W.parentTranslateLoc && R.uniform2f(W.parentTranslateLoc, V.tx, V.ty), W.slotOpacityLoc && R.uniform1f(W.slotOpacityLoc, V.opacity), W.atlasPageLoc && R.uniform1i(W.atlasPageLoc, V.atlasPage), W.clipRectLoc && R.uniform4f(W.clipRectLoc, V.clipX0, V.clipY0, V.clipX1, V.clipY1), W.clipEnabledLoc && R.uniform1f(W.clipEnabledLoc, V.clipEnabled), W.canvasHeightLoc && R.uniform1f(W.canvasHeightLoc, this.canvas.height), W.instanceStateEnabledLoc && R.uniform1f(W.instanceStateEnabledLoc, yA ? 1 : 0), W.compactSlotStateEnabledLoc && R.uniform1f(W.compactSlotStateEnabledLoc, UA ? 1 : 0), W.spritesPerSlotLoc && R.uniform1i(W.spritesPerSlotLoc, UA ? gA : 1), W.slotStateSizeLoc) {
5221
+ if (W.tableInfoLoc && ((F = L.uniform4iv) == null || F.call(L, W.tableInfoLoc, KA)), W.frameTableSizeLoc && ((d = L.uniform2iv) == null || d.call(L, W.frameTableSizeLoc, TA)), W.spriteMetadataSizeLoc && ((y = L.uniform2iv) == null || y.call(L, W.spriteMetadataSizeLoc, sA)), W.spriteMetadataStrideLoc && R.uniform1i(W.spriteMetadataStrideLoc, QA), W.spriteBaseLoc && R.uniform1i(W.spriteBaseLoc, V.metadataBase), W.frameIndexLoc && R.uniform1i(W.frameIndexLoc, V.frameIndex), W.parentAffineLoc && R.uniform4f(W.parentAffineLoc, V.parentA, V.parentB, V.parentC, V.parentD), W.parentTranslateLoc && R.uniform2f(W.parentTranslateLoc, V.tx, V.ty), W.slotOpacityLoc && R.uniform1f(W.slotOpacityLoc, V.opacity), W.atlasPageLoc && R.uniform1i(W.atlasPageLoc, V.atlasPage), W.clipRectLoc && R.uniform4f(W.clipRectLoc, V.clipX0, V.clipY0, V.clipX1, V.clipY1), W.clipEnabledLoc && R.uniform1f(W.clipEnabledLoc, V.clipEnabled), W.canvasHeightLoc && R.uniform1f(W.canvasHeightLoc, this.canvas.height), W.instanceStateEnabledLoc && R.uniform1f(W.instanceStateEnabledLoc, yA ? 1 : 0), W.compactSlotStateEnabledLoc && R.uniform1f(W.compactSlotStateEnabledLoc, UA ? 1 : 0), W.spritesPerSlotLoc && R.uniform1i(W.spritesPerSlotLoc, UA ? gA : 1), W.slotStateSizeLoc) {
5222
5222
  const AA = new Int32Array([
5223
5223
  (G = OA == null ? void 0 : OA.width) != null ? G : 1,
5224
5224
  (f = OA == null ? void 0 : OA.height) != null ? f : 1
@@ -5340,8 +5340,8 @@ const vI = "svga-frame-table-instanced-premul", uC = 8, ri = new Float32Array([1
5340
5340
  drawInstancedSvgaGL(A) {
5341
5341
  var g, I;
5342
5342
  const B = this.gl, Q = (g = A.instanceCount) != null ? g : 0, E = A.instanceData;
5343
- if (Q < 1 || !E || E.length < Q * xA.INST_SVGA_GL_FLOATS) return;
5344
- if (Q > xA.INST_SVGA_GL_MAX) {
5343
+ if (Q < 1 || !E || E.length < Q * bA.INST_SVGA_GL_FLOATS) return;
5344
+ if (Q > bA.INST_SVGA_GL_MAX) {
5345
5345
  console.warn("[WebGL2] svga-instanced-premul: instanceCount exceeds max", Q);
5346
5346
  return;
5347
5347
  }
@@ -5360,8 +5360,8 @@ const vI = "svga-frame-table-instanced-premul", uC = 8, ri = new Float32Array([1
5360
5360
  const a = this.buffers.get(A.vertexBuffer.id), o = this.buffers.get(A.indexBuffer.id);
5361
5361
  if (!a || !o) return;
5362
5362
  const s = this.ensureInstancedSvgaInstanceBuffer();
5363
- if (B.bindBuffer(B.ARRAY_BUFFER, s), B.bufferSubData(B.ARRAY_BUFFER, 0, E, 0, Q * xA.INST_SVGA_GL_FLOATS), this.performanceSVGADynamicUploadWrites++, this.performanceSVGADynamicUploadBytes += Q * xA.INST_SVGA_GL_FLOATS * Float32Array.BYTES_PER_ELEMENT, this.bindCachedVertexArray(e, A.vertexBuffer.id, A.indexBuffer.id)) {
5364
- const n = xA.INST_SVGA_GL_STRIDE;
5363
+ if (B.bindBuffer(B.ARRAY_BUFFER, s), B.bufferSubData(B.ARRAY_BUFFER, 0, E, 0, Q * bA.INST_SVGA_GL_FLOATS), this.performanceSVGADynamicUploadWrites++, this.performanceSVGADynamicUploadBytes += Q * bA.INST_SVGA_GL_FLOATS * Float32Array.BYTES_PER_ELEMENT, this.bindCachedVertexArray(e, A.vertexBuffer.id, A.indexBuffer.id)) {
5364
+ const n = bA.INST_SVGA_GL_STRIDE;
5365
5365
  B.bindBuffer(B.ARRAY_BUFFER, s), B.enableVertexAttribArray(1), B.vertexAttribPointer(1, 4, B.FLOAT, !1, n, 0), B.vertexAttribDivisor(1, 1), B.enableVertexAttribArray(2), B.vertexAttribPointer(2, 3, B.FLOAT, !1, n, 16), B.vertexAttribDivisor(2, 1), B.enableVertexAttribArray(3), B.vertexAttribPointer(3, 4, B.FLOAT, !1, n, 28), B.vertexAttribDivisor(3, 1), B.enableVertexAttribArray(4), B.vertexAttribIPointer(4, 2, B.UNSIGNED_INT, n, 44), B.vertexAttribDivisor(4, 1), B.bindBuffer(B.ARRAY_BUFFER, a.buffer), B.enableVertexAttribArray(0), B.vertexAttribPointer(0, 2, B.FLOAT, !1, 8, 0), B.vertexAttribDivisor(0, 0), B.bindBuffer(B.ELEMENT_ARRAY_BUFFER, o.buffer);
5366
5366
  }
5367
5367
  B.drawElementsInstanced(B.TRIANGLES, A.indexCount, B.UNSIGNED_INT, 0, Q), this.recordSubmittedDraw(), i !== "none" && (B.disable(B.STENCIL_TEST), B.colorMask(!0, !0, !0, !0));
@@ -5373,7 +5373,7 @@ const vI = "svga-frame-table-instanced-premul", uC = 8, ri = new Float32Array([1
5373
5373
  if (!g) throw new Error("createBuffer failed");
5374
5374
  A.bindVertexArray(null), A.bindBuffer(A.ARRAY_BUFFER, g), A.bufferData(
5375
5375
  A.ARRAY_BUFFER,
5376
- xA.INST_CLIP_MASK_GL_BYTES,
5376
+ bA.INST_CLIP_MASK_GL_BYTES,
5377
5377
  A.DYNAMIC_DRAW
5378
5378
  ), this.instancedClipMaskGLBuffer = g;
5379
5379
  }
@@ -5382,9 +5382,9 @@ const vI = "svga-frame-table-instanced-premul", uC = 8, ri = new Float32Array([1
5382
5382
  drawInstancedClipMaskGL(A) {
5383
5383
  var g, I;
5384
5384
  const B = this.gl, Q = (g = A.instanceCount) != null ? g : 0, E = A.instanceData;
5385
- if (Q < 1 || !E || E.length < Q * xA.INST_CLIP_MASK_GL_FLOATS)
5385
+ if (Q < 1 || !E || E.length < Q * bA.INST_CLIP_MASK_GL_FLOATS)
5386
5386
  return;
5387
- if (Q > xA.INST_CLIP_MASK_GL_MAX) {
5387
+ if (Q > bA.INST_CLIP_MASK_GL_MAX) {
5388
5388
  console.warn(
5389
5389
  "[WebGL2] clip-mask-instanced: instanceCount exceeds max",
5390
5390
  Q
@@ -5403,9 +5403,9 @@ const vI = "svga-frame-table-instanced-premul", uC = 8, ri = new Float32Array([1
5403
5403
  0,
5404
5404
  E,
5405
5405
  0,
5406
- Q * xA.INST_CLIP_MASK_GL_FLOATS
5406
+ Q * bA.INST_CLIP_MASK_GL_FLOATS
5407
5407
  ), this.bindCachedVertexArray(i, A.vertexBuffer.id, A.indexBuffer.id)) {
5408
- const n = xA.INST_CLIP_MASK_GL_STRIDE;
5408
+ const n = bA.INST_CLIP_MASK_GL_STRIDE;
5409
5409
  B.bindBuffer(B.ARRAY_BUFFER, s), B.enableVertexAttribArray(1), B.vertexAttribPointer(1, 4, B.FLOAT, !1, n, 0), B.vertexAttribDivisor(1, 1), B.enableVertexAttribArray(2), B.vertexAttribPointer(2, 2, B.FLOAT, !1, n, 16), B.vertexAttribDivisor(2, 1), B.bindBuffer(B.ARRAY_BUFFER, t.buffer), B.enableVertexAttribArray(0), B.vertexAttribPointer(0, 2, B.FLOAT, !1, 8, 0), B.vertexAttribDivisor(0, 0), B.bindBuffer(B.ELEMENT_ARRAY_BUFFER, a.buffer);
5410
5410
  }
5411
5411
  B.drawElementsInstanced(
@@ -5421,7 +5421,7 @@ const vI = "svga-frame-table-instanced-premul", uC = 8, ri = new Float32Array([1
5421
5421
  if (!this.instancedAlphaInstanceGLBuffer) {
5422
5422
  const g = A.createBuffer();
5423
5423
  if (!g) throw new Error("createBuffer failed");
5424
- A.bindVertexArray(null), A.bindBuffer(A.ARRAY_BUFFER, g), A.bufferData(A.ARRAY_BUFFER, xA.INST_ALPHA_GL_BYTES, A.DYNAMIC_DRAW), this.instancedAlphaInstanceGLBuffer = g;
5424
+ A.bindVertexArray(null), A.bindBuffer(A.ARRAY_BUFFER, g), A.bufferData(A.ARRAY_BUFFER, bA.INST_ALPHA_GL_BYTES, A.DYNAMIC_DRAW), this.instancedAlphaInstanceGLBuffer = g;
5425
5425
  }
5426
5426
  return this.instancedAlphaInstanceGLBuffer;
5427
5427
  }
@@ -5429,7 +5429,7 @@ const vI = "svga-frame-table-instanced-premul", uC = 8, ri = new Float32Array([1
5429
5429
  var g;
5430
5430
  const I = this.gl, B = (g = A.instanceCount) != null ? g : 0, Q = A.instanceData;
5431
5431
  if (B < 1 || !Q || Q.length < B * 12) return;
5432
- if (B > xA.INST_ALPHA_GL_MAX) {
5432
+ if (B > bA.INST_ALPHA_GL_MAX) {
5433
5433
  console.warn("[WebGL2] alpha-video-instanced: instanceCount exceeds max", B);
5434
5434
  return;
5435
5435
  }
@@ -5464,7 +5464,7 @@ const vI = "svga-frame-table-instanced-premul", uC = 8, ri = new Float32Array([1
5464
5464
  if (!this.instancedVapInstanceGLBuffer) {
5465
5465
  const g = A.createBuffer();
5466
5466
  if (!g) throw new Error("createBuffer failed");
5467
- A.bindVertexArray(null), A.bindBuffer(A.ARRAY_BUFFER, g), A.bufferData(A.ARRAY_BUFFER, xA.INST_VAP_GL_BYTES, A.DYNAMIC_DRAW), this.instancedVapInstanceGLBuffer = g;
5467
+ A.bindVertexArray(null), A.bindBuffer(A.ARRAY_BUFFER, g), A.bufferData(A.ARRAY_BUFFER, bA.INST_VAP_GL_BYTES, A.DYNAMIC_DRAW), this.instancedVapInstanceGLBuffer = g;
5468
5468
  }
5469
5469
  return this.instancedVapInstanceGLBuffer;
5470
5470
  }
@@ -5472,7 +5472,7 @@ const vI = "svga-frame-table-instanced-premul", uC = 8, ri = new Float32Array([1
5472
5472
  var g;
5473
5473
  const I = this.gl, B = (g = A.instanceCount) != null ? g : 0, Q = A.instanceData;
5474
5474
  if (B < 1 || !Q || Q.length < B * 32) return;
5475
- if (B > xA.INST_VAP_GL_MAX) {
5475
+ if (B > bA.INST_VAP_GL_MAX) {
5476
5476
  console.warn("[WebGL2] vap-instanced: instanceCount exceeds max", B);
5477
5477
  return;
5478
5478
  }
@@ -6120,32 +6120,32 @@ function fB(C, A, g) {
6120
6120
  return E;
6121
6121
  }
6122
6122
  function Ni(C, A, g) {
6123
- const I = UC(C, z.__wbindgen_malloc), B = bA;
6124
- var Q = UC(A, z.__wbindgen_malloc), E = bA, i = JQ(g, z.__wbindgen_malloc), e = bA;
6123
+ const I = UC(C, z.__wbindgen_malloc), B = qA;
6124
+ var Q = UC(A, z.__wbindgen_malloc), E = qA, i = JQ(g, z.__wbindgen_malloc), e = qA;
6125
6125
  return z.build_batch_vertices(I, B, Q, E, A, i, e, g) >>> 0;
6126
6126
  }
6127
6127
  function Ui(C) {
6128
- const A = yB(C, z.__wbindgen_malloc), g = bA, I = z.decode_svga(A, g);
6128
+ const A = yB(C, z.__wbindgen_malloc), g = qA, I = z.decode_svga(A, g);
6129
6129
  if (I[2])
6130
6130
  throw KI(I[1]);
6131
6131
  return KI(I[0]);
6132
6132
  }
6133
6133
  function ki(C) {
6134
- const A = yB(C, z.__wbindgen_malloc), g = bA, I = z.decode_svga_payload(A, g);
6134
+ const A = yB(C, z.__wbindgen_malloc), g = qA, I = z.decode_svga_payload(A, g);
6135
6135
  if (I[3])
6136
6136
  throw KI(I[2]);
6137
6137
  var B = FB(I[0], I[1]).slice();
6138
6138
  return z.__wbindgen_free(I[0], I[1] * 1, 1), B;
6139
6139
  }
6140
6140
  function Yi(C) {
6141
- const A = yB(C, z.__wbindgen_malloc), g = bA, I = z.decode_svga_payload_profiled(A, g);
6141
+ const A = yB(C, z.__wbindgen_malloc), g = qA, I = z.decode_svga_payload_profiled(A, g);
6142
6142
  if (I[3])
6143
6143
  throw KI(I[2]);
6144
6144
  var B = FB(I[0], I[1]).slice();
6145
6145
  return z.__wbindgen_free(I[0], I[1] * 1, 1), B;
6146
6146
  }
6147
6147
  function pi(C) {
6148
- const A = yB(C, z.__wbindgen_malloc), g = bA, I = z.inflate(A, g);
6148
+ const A = yB(C, z.__wbindgen_malloc), g = qA, I = z.inflate(A, g);
6149
6149
  if (I[3])
6150
6150
  throw KI(I[2]);
6151
6151
  var B = FB(I[0], I[1]).slice();
@@ -6158,7 +6158,7 @@ function Ki() {
6158
6158
  return z.take_svga_payload_profile();
6159
6159
  }
6160
6160
  function mi(C, A) {
6161
- const g = xi(C, z.__wbindgen_malloc), I = bA, B = JQ(A, z.__wbindgen_malloc), Q = bA, E = z.triangulate_clip_polygons(g, I, B, Q);
6161
+ const g = xi(C, z.__wbindgen_malloc), I = qA, B = JQ(A, z.__wbindgen_malloc), Q = qA, E = z.triangulate_clip_polygons(g, I, B, Q);
6162
6162
  var i = Ji(E[0], E[1]).slice();
6163
6163
  return z.__wbindgen_free(E[0], E[1] * 4, 4), i;
6164
6164
  }
@@ -6171,7 +6171,7 @@ function KQ() {
6171
6171
  return Error(MB(A, g));
6172
6172
  },
6173
6173
  __wbg_String_8564e559799eccda: function(A, g) {
6174
- const I = String(g), B = bi(I, z.__wbindgen_malloc, z.__wbindgen_realloc), Q = bA;
6174
+ const I = String(g), B = bi(I, z.__wbindgen_malloc, z.__wbindgen_realloc), Q = qA;
6175
6175
  NC().setInt32(A + 4, Q, !0), NC().setInt32(A + 0, B, !0);
6176
6176
  },
6177
6177
  __wbg___wbindgen_copy_to_typed_array_a4db337751e0b328: function(A, g, I) {
@@ -6251,24 +6251,24 @@ function iI() {
6251
6251
  }
6252
6252
  function JQ(C, A) {
6253
6253
  const g = A(C.length * 4, 4) >>> 0;
6254
- return mQ().set(C, g / 4), bA = C.length, g;
6254
+ return mQ().set(C, g / 4), qA = C.length, g;
6255
6255
  }
6256
6256
  function yB(C, A) {
6257
6257
  const g = A(C.length * 1, 1) >>> 0;
6258
- return iI().set(C, g / 1), bA = C.length, g;
6258
+ return iI().set(C, g / 1), qA = C.length, g;
6259
6259
  }
6260
6260
  function UC(C, A) {
6261
6261
  const g = A(C.length * 4, 4) >>> 0;
6262
- return Li().set(C, g / 4), bA = C.length, g;
6262
+ return Li().set(C, g / 4), qA = C.length, g;
6263
6263
  }
6264
6264
  function xi(C, A) {
6265
6265
  const g = A(C.length * 8, 8) >>> 0;
6266
- return Hi().set(C, g / 8), bA = C.length, g;
6266
+ return Hi().set(C, g / 8), qA = C.length, g;
6267
6267
  }
6268
6268
  function bi(C, A, g) {
6269
6269
  if (g === void 0) {
6270
6270
  const i = dI.encode(C), e = A(i.length, 1) >>> 0;
6271
- return iI().subarray(e, e + i.length).set(i), bA = i.length, e;
6271
+ return iI().subarray(e, e + i.length).set(i), qA = i.length, e;
6272
6272
  }
6273
6273
  let I = C.length, B = A(I, 1) >>> 0;
6274
6274
  const Q = iI();
@@ -6283,7 +6283,7 @@ function bi(C, A, g) {
6283
6283
  const i = iI().subarray(B + E, B + I), e = dI.encodeInto(C, i);
6284
6284
  E += e.written, B = g(B, I, E, 1) >>> 0;
6285
6285
  }
6286
- return bA = E, B;
6286
+ return qA = E, B;
6287
6287
  }
6288
6288
  function KI(C) {
6289
6289
  const A = z.__wbindgen_externrefs.get(C);
@@ -6304,7 +6304,7 @@ const dI = new TextEncoder();
6304
6304
  written: g.length
6305
6305
  };
6306
6306
  });
6307
- let bA = 0, z;
6307
+ let qA = 0, z;
6308
6308
  function LQ(C, A) {
6309
6309
  return z = C.exports, Zg = null, DI = null, lI = null, wI = null, FI = null, z.__wbindgen_start(), z;
6310
6310
  }
@@ -11112,10 +11112,10 @@ function hI(C, A, g, I = { left: 0, right: 0, top: 0, bottom: 0 }) {
11112
11112
  const [B, Q, E, i] = C;
11113
11113
  return I.left = B / A, I.right = (B + E) / A, I.top = (g - Q) / g, I.bottom = (g - Q - i) / g, I;
11114
11114
  }
11115
- var lt = Object.defineProperty, wt = (C, A, g) => A in C ? lt(C, A, { enumerable: !0, configurable: !0, writable: !0, value: g }) : C[A] = g, WA = (C, A, g) => wt(C, typeof A != "symbol" ? A + "" : A, g);
11115
+ var lt = Object.defineProperty, wt = (C, A, g) => A in C ? lt(C, A, { enumerable: !0, configurable: !0, writable: !0, value: g }) : C[A] = g, VA = (C, A, g) => wt(C, typeof A != "symbol" ? A + "" : A, g);
11116
11116
  class jQ {
11117
11117
  constructor(A) {
11118
- WA(this, "onFrameAvailable"), WA(this, "frameInfo", /* @__PURE__ */ new Map()), WA(this, "pending", /* @__PURE__ */ new Set()), WA(this, "lastHandle", /* @__PURE__ */ new Map()), WA(this, "started", /* @__PURE__ */ new Set()), WA(this, "firstUploaded", /* @__PURE__ */ new Set()), WA(this, "forceTimeFallback", /* @__PURE__ */ new Set()), WA(this, "lastArmAt", /* @__PURE__ */ new Map()), WA(this, "lastCallbackAt", /* @__PURE__ */ new Map()), WA(this, "lastProgressAt", /* @__PURE__ */ new Map()), WA(this, "lastRecoveryAt", /* @__PURE__ */ new Map()), WA(this, "stallLogged", /* @__PURE__ */ new Set()), WA(this, "stagnationLogged", /* @__PURE__ */ new Set()), WA(this, "lastTimeFallback", /* @__PURE__ */ new Map()), WA(this, "healthTimers", /* @__PURE__ */ new Map()), this.onFrameAvailable = A;
11118
+ VA(this, "onFrameAvailable"), VA(this, "frameInfo", /* @__PURE__ */ new Map()), VA(this, "pending", /* @__PURE__ */ new Set()), VA(this, "lastHandle", /* @__PURE__ */ new Map()), VA(this, "started", /* @__PURE__ */ new Set()), VA(this, "firstUploaded", /* @__PURE__ */ new Set()), VA(this, "forceTimeFallback", /* @__PURE__ */ new Set()), VA(this, "lastArmAt", /* @__PURE__ */ new Map()), VA(this, "lastCallbackAt", /* @__PURE__ */ new Map()), VA(this, "lastProgressAt", /* @__PURE__ */ new Map()), VA(this, "lastRecoveryAt", /* @__PURE__ */ new Map()), VA(this, "stallLogged", /* @__PURE__ */ new Set()), VA(this, "stagnationLogged", /* @__PURE__ */ new Set()), VA(this, "lastTimeFallback", /* @__PURE__ */ new Map()), VA(this, "healthTimers", /* @__PURE__ */ new Map()), this.onFrameAvailable = A;
11119
11119
  }
11120
11120
  /**
11121
11121
  * Returns true when `updateTexture` should run for this slot: first time, or a new decoded frame was signaled.
@@ -17052,18 +17052,18 @@ async function I(t, e, n, o, s) {
17052
17052
  }
17053
17053
  function v(t, e, n, o, s, i) {
17054
17054
  if (n.w <= 0 || n.h <= 0 || i <= 0) return;
17055
- const l = Math.max(1, Math.floor(i * 0.5)), a = n.x, c = n.y, h = n.w, r = n.h, f = Math.min(l, a), u = Math.min(l, c), d = Math.min(l, o - (a + h)), w = Math.min(l, s - (c + r)), H = e.imageSmoothingEnabled;
17056
- e.imageSmoothingEnabled = !1, f > 0 && e.drawImage(t, a, c, 1, r, a - f, c, f, r), d > 0 && e.drawImage(t, a + h - 1, c, 1, r, a + h, c, d, r), u > 0 && e.drawImage(t, a, c, h, 1, a, c - u, h, u), w > 0 && e.drawImage(t, a, c + r - 1, h, 1, a, c + r, h, w), f > 0 && u > 0 && e.drawImage(t, a, c, 1, 1, a - f, c - u, f, u), d > 0 && u > 0 && e.drawImage(t, a + h - 1, c, 1, 1, a + h, c - u, d, u), f > 0 && w > 0 && e.drawImage(t, a, c + r - 1, 1, 1, a - f, c + r, f, w), d > 0 && w > 0 && e.drawImage(t, a + h - 1, c + r - 1, 1, 1, a + h, c + r, d, w), e.imageSmoothingEnabled = H;
17055
+ const l = Math.max(1, Math.floor(i * 0.5)), a = n.x, c = n.y, h = n.w, r = n.h, f = Math.min(l, a), u = Math.min(l, c), w = Math.min(l, o - (a + h)), d = Math.min(l, s - (c + r)), H = e.imageSmoothingEnabled;
17056
+ e.imageSmoothingEnabled = !1, f > 0 && e.drawImage(t, a, c, 1, r, a - f, c, f, r), w > 0 && e.drawImage(t, a + h - 1, c, 1, r, a + h, c, w, r), u > 0 && e.drawImage(t, a, c, h, 1, a, c - u, h, u), d > 0 && e.drawImage(t, a, c + r - 1, h, 1, a, c + r, h, d), f > 0 && u > 0 && e.drawImage(t, a, c, 1, 1, a - f, c - u, f, u), w > 0 && u > 0 && e.drawImage(t, a + h - 1, c, 1, 1, a + h, c - u, w, u), f > 0 && d > 0 && e.drawImage(t, a, c + r - 1, 1, 1, a - f, c + r, f, d), w > 0 && d > 0 && e.drawImage(t, a + h - 1, c + r - 1, 1, 1, a + h, c + r, w, d), e.imageSmoothingEnabled = H;
17057
17057
  }
17058
17058
  var E = Object.defineProperty, C = (t, e, n) => e in t ? E(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, M = (t, e, n) => C(t, typeof e != "symbol" ? e + "" : e, n);
17059
17059
  function g() {
17060
17060
  return typeof performance != "undefined" ? performance.now() : Date.now();
17061
17061
  }
17062
- function S(t) {
17062
+ function A(t) {
17063
17063
  const e = t != null ? t : 4;
17064
17064
  return Number.isFinite(e) ? Math.max(1, Math.min(8, e)) : 4;
17065
17065
  }
17066
- class T {
17066
+ class S {
17067
17067
  constructor(e = 4) {
17068
17068
  this.maxSliceMs = e, M(this, "sliceStartedAt", g());
17069
17069
  }
@@ -17071,7 +17071,7 @@ class T {
17071
17071
  g() - this.sliceStartedAt < this.maxSliceMs || (await new Promise((e) => setTimeout(e, 0)), this.sliceStartedAt = g());
17072
17072
  }
17073
17073
  }
17074
- class A {
17074
+ class T {
17075
17075
  constructor() {
17076
17076
  M(this, "running", !1), M(this, "tasks", []);
17077
17077
  }
@@ -17090,7 +17090,7 @@ class A {
17090
17090
  }
17091
17091
  }
17092
17092
  }
17093
- const m = self, Y = new A();
17093
+ const m = self, Y = new T();
17094
17094
  async function _(t, e, n, o) {
17095
17095
  const s = new OffscreenCanvas(t.atlasW, t.atlasH), i = s.getContext("2d");
17096
17096
  if (!i) throw new Error("Atlas worker: 2d context unavailable");
@@ -17127,7 +17127,7 @@ async function X(t, e) {
17127
17127
  }
17128
17128
  async function $(t) {
17129
17129
  var e;
17130
- const n = [], o = new T(S(t.workerTimeSliceMs));
17130
+ const n = [], o = new S(A(t.workerTimeSliceMs));
17131
17131
  try {
17132
17132
  if (typeof OffscreenCanvas == "undefined")
17133
17133
  throw new Error("OffscreenCanvas unavailable in atlas worker");
@@ -17154,7 +17154,7 @@ async function $(t) {
17154
17154
  for (const r of l) {
17155
17155
  const f = await _(r, s, t.padding, o);
17156
17156
  t.captureEncodedPng && c.push(B(f));
17157
- const u = f.transferToImageBitmap();
17157
+ const u = await createImageBitmap(f, { premultiplyAlpha: "premultiply" });
17158
17158
  a.push({
17159
17159
  width: r.atlasW,
17160
17160
  height: r.atlasH,
@@ -17202,7 +17202,7 @@ m.onmessage = (t) => {
17202
17202
  const e = t.data;
17203
17203
  !e || e.type !== "build-svga-atlas" || Y.push(() => $(e));
17204
17204
  };
17205
- //# sourceMappingURL=svga-atlas-worker-B7n5WXUn.js.map
17205
+ //# sourceMappingURL=svga-atlas-worker-CkVFsaPa.js.map
17206
17206
  `, lQ = typeof self != "undefined" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", sE], { type: "text/javascript;charset=utf-8" });
17207
17207
  function no(C) {
17208
17208
  let A;
@@ -17318,7 +17318,7 @@ function ho() {
17318
17318
  return NI;
17319
17319
  }
17320
17320
  function nE() {
17321
- return typeof Worker != "undefined" && UQ() && typeof OffscreenCanvas.prototype.transferToImageBitmap == "function";
17321
+ return typeof Worker != "undefined" && UQ() && typeof createImageBitmap == "function";
17322
17322
  }
17323
17323
  async function co(C, A) {
17324
17324
  if (!nE())
@@ -17524,7 +17524,8 @@ async function yo(C, A, g, I, B) {
17524
17524
  width: o.width,
17525
17525
  height: o.height,
17526
17526
  filter: "linear",
17527
- premultiplyAlpha: !0
17527
+ premultiplyAlpha: !0,
17528
+ sourcePremultiplied: !0
17528
17529
  });
17529
17530
  try {
17530
17531
  o.bitmap.close();
@@ -18967,10 +18968,10 @@ class _B {
18967
18968
  this._released || (this._released = !0, this.gpuGlobalsBuffer && ((A = this.backend) == null || A.deleteBuffer(this.gpuGlobalsBuffer)), this.table.release());
18968
18969
  }
18969
18970
  }
18970
- var ls = Object.defineProperty, ws = (C, A, g) => A in C ? ls(C, A, { enumerable: !0, configurable: !0, writable: !0, value: g }) : C[A] = g, VA = (C, A, g) => ws(C, typeof A != "symbol" ? A + "" : A, g);
18971
+ var ls = Object.defineProperty, ws = (C, A, g) => A in C ? ls(C, A, { enumerable: !0, configurable: !0, writable: !0, value: g }) : C[A] = g, xA = (C, A, g) => ws(C, typeof A != "symbol" ? A + "" : A, g);
18971
18972
  class Fs {
18972
18973
  constructor(A, g = `scope-${xQ()}`) {
18973
- VA(this, "id"), VA(this, "host"), VA(this, "controller", new AbortController()), VA(this, "gifts", /* @__PURE__ */ new Map()), VA(this, "tracks", /* @__PURE__ */ new Set()), VA(this, "bindings", /* @__PURE__ */ new Set()), VA(this, "particleBatches", /* @__PURE__ */ new Set()), VA(this, "particleBatchGroups", /* @__PURE__ */ new Set()), VA(this, "frameListeners", /* @__PURE__ */ new Set()), VA(this, "finishListeners", /* @__PURE__ */ new Set()), VA(this, "unregisterController"), VA(this, "_state", "idle"), VA(this, "_currentTimeMs", 0), VA(this, "durationMs", 0), VA(this, "lastTickAtMs", 0), this.host = A, this.id = g, this.unregisterController = A.registerFrameController(this);
18974
+ xA(this, "id"), xA(this, "host"), xA(this, "controller", new AbortController()), xA(this, "gifts", /* @__PURE__ */ new Map()), xA(this, "tracks", /* @__PURE__ */ new Set()), xA(this, "bindings", /* @__PURE__ */ new Set()), xA(this, "particleBatches", /* @__PURE__ */ new Set()), xA(this, "particleBatchGroups", /* @__PURE__ */ new Set()), xA(this, "frameListeners", /* @__PURE__ */ new Set()), xA(this, "finishListeners", /* @__PURE__ */ new Set()), xA(this, "unregisterController"), xA(this, "_state", "idle"), xA(this, "_currentTimeMs", 0), xA(this, "durationMs", 0), xA(this, "lastTickAtMs", 0), xA(this, "playbackRevision", 0), this.host = A, this.id = g, this.unregisterController = A.registerFrameController(this);
18974
18975
  }
18975
18976
  get signal() {
18976
18977
  return this.controller.signal;
@@ -18999,7 +19000,11 @@ class Fs {
18999
19000
  createMotionTrack(A) {
19000
19001
  this.assertAlive();
19001
19002
  const g = new _B(this.host.backend, A);
19002
- return this.tracks.add(g), g;
19003
+ this.tracks.add(g);
19004
+ const I = g.release.bind(g);
19005
+ return g.release = () => {
19006
+ I(), this.tracks.delete(g);
19007
+ }, g;
19003
19008
  }
19004
19009
  createParticleBatch(A) {
19005
19010
  this.assertAlive();
@@ -19053,47 +19058,48 @@ class Fs {
19053
19058
  }
19054
19059
  start(A) {
19055
19060
  var g;
19056
- this.assertAlive(), this.durationMs = Math.max(0, A.durationMs), this._currentTimeMs = Math.max(0, Math.min(this.durationMs, (g = A.fromMs) != null ? g : 0)), this.lastTickAtMs = performance.now(), this._state = "playing";
19061
+ this.assertAlive(), this.playbackRevision++, this.durationMs = Math.max(0, A.durationMs), this._currentTimeMs = Math.max(0, Math.min(this.durationMs, (g = A.fromMs) != null ? g : 0)), this.lastTickAtMs = performance.now(), this._state = "playing";
19057
19062
  for (const I of this.gifts.values()) I.resume();
19058
19063
  this.applyMediaTime(this._currentTimeMs, !0, !0), this.applyAll(this._currentTimeMs), this.applyParticleTime(this._currentTimeMs), this.host.invalidate(!0);
19059
19064
  }
19060
19065
  pause() {
19061
19066
  if (this._state === "playing") {
19062
- this._state = "paused";
19067
+ this.playbackRevision++, this._state = "paused";
19063
19068
  for (const A of this.gifts.values()) A.pause();
19064
19069
  }
19065
19070
  }
19066
19071
  resume() {
19067
19072
  if (this._state === "paused") {
19068
- this.lastTickAtMs = performance.now(), this._state = "playing";
19073
+ this.playbackRevision++, this.lastTickAtMs = performance.now(), this._state = "playing";
19069
19074
  for (const A of this.gifts.values()) A.resume();
19070
19075
  this.applyMediaTime(this._currentTimeMs, !1, !0), this.host.invalidate(!0);
19071
19076
  }
19072
19077
  }
19073
19078
  seek(A) {
19074
- this.assertAlive(), this._currentTimeMs = Math.max(0, Math.min(this.durationMs, A)), this._state === "playing" && (this.lastTickAtMs = performance.now()), this.applyAll(this._currentTimeMs), this.applyParticleTime(this._currentTimeMs), this.applyMediaTime(this._currentTimeMs, !1, !0), this.emitFrame(0), this.host.invalidate();
19079
+ this.assertAlive(), this.playbackRevision++, this._currentTimeMs = Math.max(0, Math.min(this.durationMs, A)), this._state === "playing" && (this.lastTickAtMs = performance.now()), this.applyAll(this._currentTimeMs), this.applyParticleTime(this._currentTimeMs), this.applyMediaTime(this._currentTimeMs, !1, !0), this.emitFrame(0), this.host.invalidate();
19075
19080
  }
19076
19081
  stop() {
19077
19082
  if (!(this._state === "destroyed" || this._state === "stopped")) {
19078
- this._state = "stopped";
19083
+ this.playbackRevision++, this._state = "stopped";
19079
19084
  for (const A of this.gifts.values()) A.pause();
19080
19085
  this.host.invalidate();
19081
19086
  }
19082
19087
  }
19083
19088
  tick(A, g) {
19084
19089
  if (this._state !== "playing") return !1;
19085
- const I = Math.max(0, g), B = this.lastTickAtMs > 0 ? Math.max(0, A - this.lastTickAtMs) : I, Q = Math.min(I, B);
19086
- if (this.lastTickAtMs = A, this._currentTimeMs = Math.min(this.durationMs, this._currentTimeMs + Q), this.applyAll(this._currentTimeMs), this.applyParticleTime(this._currentTimeMs), this.applyMediaTime(this._currentTimeMs), this.emitFrame(Q), this._currentTimeMs >= this.durationMs) {
19090
+ const I = this.playbackRevision, B = Math.max(0, g), Q = this.lastTickAtMs > 0 ? Math.max(0, A - this.lastTickAtMs) : B, E = Math.min(B, Q);
19091
+ if (this.lastTickAtMs = A, this._currentTimeMs = Math.min(this.durationMs, this._currentTimeMs + E), this.applyAll(this._currentTimeMs), this.applyParticleTime(this._currentTimeMs), this.applyMediaTime(this._currentTimeMs), I !== this.playbackRevision || (this.emitFrame(E), I !== this.playbackRevision)) return !0;
19092
+ if (this._currentTimeMs >= this.durationMs) {
19087
19093
  this._state = "stopped";
19088
- for (const E of this.gifts.values()) E.pause();
19089
- for (const E of this.finishListeners) E();
19094
+ for (const i of this.gifts.values()) i.pause();
19095
+ for (const i of this.finishListeners) i();
19090
19096
  }
19091
19097
  return !0;
19092
19098
  }
19093
19099
  destroy() {
19094
19100
  var A;
19095
19101
  if (this._state !== "destroyed") {
19096
- this._state = "destroyed", this.controller.abort(), (A = this.unregisterController) == null || A.call(this), this.unregisterController = null;
19102
+ this.playbackRevision++, this._state = "destroyed", this.controller.abort(), (A = this.unregisterController) == null || A.call(this), this.unregisterController = null;
19097
19103
  for (const g of this.bindings) this.bindings.delete(g);
19098
19104
  for (const g of this.gifts.values()) this.host.removeGift(g.id);
19099
19105
  this.gifts.clear();
@@ -21277,11 +21283,27 @@ const Fg = class zA {
21277
21283
  preload: (e, t, a) => this.preload(e, t, a),
21278
21284
  createParticleAtlas: async (e) => {
21279
21285
  const t = await this.createParticleAtlas(e);
21280
- return I.add(t), t;
21286
+ I.add(t);
21287
+ const a = t.destroy.bind(t);
21288
+ return t.destroy = () => {
21289
+ try {
21290
+ a();
21291
+ } finally {
21292
+ I.delete(t);
21293
+ }
21294
+ }, t;
21281
21295
  },
21282
21296
  createPlaybackScope: (e) => {
21283
21297
  const t = this.createPlaybackScope(e);
21284
- return g.add(t), t;
21298
+ g.add(t);
21299
+ const a = t.destroy.bind(t);
21300
+ return t.destroy = () => {
21301
+ try {
21302
+ a();
21303
+ } finally {
21304
+ g.delete(t);
21305
+ }
21306
+ }, t;
21285
21307
  }
21286
21308
  }, Q = await A.setup(B);
21287
21309
  let E = !1;