@flighthq/displayobject-wgpu 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/dist/index.d.ts +29 -0
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +29 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/moduleMockTestHelper.d.ts +15 -0
  6. package/dist/moduleMockTestHelper.d.ts.map +1 -0
  7. package/dist/moduleMockTestHelper.js +25 -0
  8. package/dist/moduleMockTestHelper.js.map +1 -0
  9. package/dist/wgpuBitmap.d.ts +4 -0
  10. package/dist/wgpuBitmap.d.ts.map +1 -0
  11. package/dist/wgpuBitmap.js +80 -0
  12. package/dist/wgpuBitmap.js.map +1 -0
  13. package/dist/wgpuCache.d.ts +31 -0
  14. package/dist/wgpuCache.d.ts.map +1 -0
  15. package/dist/wgpuCache.js +232 -0
  16. package/dist/wgpuCache.js.map +1 -0
  17. package/dist/wgpuClip.d.ts +3 -0
  18. package/dist/wgpuClip.d.ts.map +1 -0
  19. package/dist/wgpuClip.js +44 -0
  20. package/dist/wgpuClip.js.map +1 -0
  21. package/dist/wgpuClipContours.d.ts +4 -0
  22. package/dist/wgpuClipContours.d.ts.map +1 -0
  23. package/dist/wgpuClipContours.js +174 -0
  24. package/dist/wgpuClipContours.js.map +1 -0
  25. package/dist/wgpuClipRectangle.d.ts +4 -0
  26. package/dist/wgpuClipRectangle.d.ts.map +1 -0
  27. package/dist/wgpuClipRectangle.js +80 -0
  28. package/dist/wgpuClipRectangle.js.map +1 -0
  29. package/dist/wgpuColorTransformMaterial.d.ts +5 -0
  30. package/dist/wgpuColorTransformMaterial.d.ts.map +1 -0
  31. package/dist/wgpuColorTransformMaterial.js +97 -0
  32. package/dist/wgpuColorTransformMaterial.js.map +1 -0
  33. package/dist/wgpuDefaultMaterial.d.ts +4 -0
  34. package/dist/wgpuDefaultMaterial.d.ts.map +1 -0
  35. package/dist/wgpuDefaultMaterial.js +46 -0
  36. package/dist/wgpuDefaultMaterial.js.map +1 -0
  37. package/dist/wgpuDisplayObject.d.ts +5 -0
  38. package/dist/wgpuDisplayObject.d.ts.map +1 -0
  39. package/dist/wgpuDisplayObject.js +41 -0
  40. package/dist/wgpuDisplayObject.js.map +1 -0
  41. package/dist/wgpuMaterials.d.ts +15 -0
  42. package/dist/wgpuMaterials.d.ts.map +1 -0
  43. package/dist/wgpuMaterials.js +34 -0
  44. package/dist/wgpuMaterials.js.map +1 -0
  45. package/dist/wgpuParticleEmitter.d.ts +4 -0
  46. package/dist/wgpuParticleEmitter.d.ts.map +1 -0
  47. package/dist/wgpuParticleEmitter.js +288 -0
  48. package/dist/wgpuParticleEmitter.js.map +1 -0
  49. package/dist/wgpuQuadBatch.d.ts +7 -0
  50. package/dist/wgpuQuadBatch.d.ts.map +1 -0
  51. package/dist/wgpuQuadBatch.js +85 -0
  52. package/dist/wgpuQuadBatch.js.map +1 -0
  53. package/dist/wgpuRegistration.d.ts +19 -0
  54. package/dist/wgpuRegistration.d.ts.map +1 -0
  55. package/dist/wgpuRegistration.js +53 -0
  56. package/dist/wgpuRegistration.js.map +1 -0
  57. package/dist/wgpuRenderStats.d.ts +20 -0
  58. package/dist/wgpuRenderStats.d.ts.map +1 -0
  59. package/dist/wgpuRenderStats.js +50 -0
  60. package/dist/wgpuRenderStats.js.map +1 -0
  61. package/dist/wgpuRendererData.d.ts +26 -0
  62. package/dist/wgpuRendererData.d.ts.map +1 -0
  63. package/dist/wgpuRendererData.js +29 -0
  64. package/dist/wgpuRendererData.js.map +1 -0
  65. package/dist/wgpuRichText.d.ts +9 -0
  66. package/dist/wgpuRichText.d.ts.map +1 -0
  67. package/dist/wgpuRichText.js +163 -0
  68. package/dist/wgpuRichText.js.map +1 -0
  69. package/dist/wgpuScale9Mapper.d.ts +3 -0
  70. package/dist/wgpuScale9Mapper.d.ts.map +1 -0
  71. package/dist/wgpuScale9Mapper.js +42 -0
  72. package/dist/wgpuScale9Mapper.js.map +1 -0
  73. package/dist/wgpuScale9Shape.d.ts +9 -0
  74. package/dist/wgpuScale9Shape.d.ts.map +1 -0
  75. package/dist/wgpuScale9Shape.js +123 -0
  76. package/dist/wgpuScale9Shape.js.map +1 -0
  77. package/dist/wgpuShape.d.ts +4 -0
  78. package/dist/wgpuShape.d.ts.map +1 -0
  79. package/dist/wgpuShape.js +157 -0
  80. package/dist/wgpuShape.js.map +1 -0
  81. package/dist/wgpuShapeMesh.d.ts +9 -0
  82. package/dist/wgpuShapeMesh.d.ts.map +1 -0
  83. package/dist/wgpuShapeMesh.js +204 -0
  84. package/dist/wgpuShapeMesh.js.map +1 -0
  85. package/dist/wgpuSprite.d.ts +3 -0
  86. package/dist/wgpuSprite.d.ts.map +1 -0
  87. package/dist/wgpuSprite.js +28 -0
  88. package/dist/wgpuSprite.js.map +1 -0
  89. package/dist/wgpuSpriteBatch.d.ts +18 -0
  90. package/dist/wgpuSpriteBatch.d.ts.map +1 -0
  91. package/dist/wgpuSpriteBatch.js +320 -0
  92. package/dist/wgpuSpriteBatch.js.map +1 -0
  93. package/dist/wgpuSpriteRenderer.d.ts +3 -0
  94. package/dist/wgpuSpriteRenderer.d.ts.map +1 -0
  95. package/dist/wgpuSpriteRenderer.js +51 -0
  96. package/dist/wgpuSpriteRenderer.js.map +1 -0
  97. package/dist/wgpuTextInput.d.ts +4 -0
  98. package/dist/wgpuTextInput.d.ts.map +1 -0
  99. package/dist/wgpuTextInput.js +44 -0
  100. package/dist/wgpuTextInput.js.map +1 -0
  101. package/dist/wgpuTextLabel.d.ts +4 -0
  102. package/dist/wgpuTextLabel.d.ts.map +1 -0
  103. package/dist/wgpuTextLabel.js +157 -0
  104. package/dist/wgpuTextLabel.js.map +1 -0
  105. package/dist/wgpuTilemap.d.ts +3 -0
  106. package/dist/wgpuTilemap.d.ts.map +1 -0
  107. package/dist/wgpuTilemap.js +76 -0
  108. package/dist/wgpuTilemap.js.map +1 -0
  109. package/dist/wgpuVelocity.d.ts +23 -0
  110. package/dist/wgpuVelocity.d.ts.map +1 -0
  111. package/dist/wgpuVelocity.js +365 -0
  112. package/dist/wgpuVelocity.js.map +1 -0
  113. package/dist/wgpuVideo.d.ts +6 -0
  114. package/dist/wgpuVideo.d.ts.map +1 -0
  115. package/dist/wgpuVideo.js +63 -0
  116. package/dist/wgpuVideo.js.map +1 -0
  117. package/package.json +52 -0
  118. package/src/wgpuBitmap.test.ts +40 -0
  119. package/src/wgpuCache.test.ts +230 -0
  120. package/src/wgpuClip.test.ts +15 -0
  121. package/src/wgpuClipContours.test.ts +101 -0
  122. package/src/wgpuClipRectangle.test.ts +45 -0
  123. package/src/wgpuColorTransformMaterial.test.ts +62 -0
  124. package/src/wgpuDefaultMaterial.test.ts +21 -0
  125. package/src/wgpuDisplayObject.test.ts +36 -0
  126. package/src/wgpuMaterials.test.ts +44 -0
  127. package/src/wgpuParticleEmitter.test.ts +34 -0
  128. package/src/wgpuQuadBatch.test.ts +69 -0
  129. package/src/wgpuRegistration.test.ts +115 -0
  130. package/src/wgpuRenderStats.test.ts +89 -0
  131. package/src/wgpuRendererData.test.ts +29 -0
  132. package/src/wgpuRichText.test.ts +100 -0
  133. package/src/wgpuScale9Mapper.test.ts +20 -0
  134. package/src/wgpuScale9Shape.test.ts +97 -0
  135. package/src/wgpuShape.test.ts +95 -0
  136. package/src/wgpuShapeMesh.test.ts +124 -0
  137. package/src/wgpuSprite.test.ts +19 -0
  138. package/src/wgpuSpriteBatch.test.ts +180 -0
  139. package/src/wgpuSpriteRenderer.test.ts +38 -0
  140. package/src/wgpuTextInput.test.ts +37 -0
  141. package/src/wgpuTextLabel.test.ts +113 -0
  142. package/src/wgpuTilemap.test.ts +47 -0
  143. package/src/wgpuVelocity.test.ts +147 -0
  144. package/src/wgpuVideo.test.ts +59 -0
@@ -0,0 +1,29 @@
1
+ export * from './wgpuBitmap';
2
+ export * from './wgpuCache';
3
+ export * from './wgpuClip';
4
+ export * from './wgpuClipContours';
5
+ export * from './wgpuClipRectangle';
6
+ export * from './wgpuColorTransformMaterial';
7
+ export * from './wgpuDefaultMaterial';
8
+ export * from './wgpuDisplayObject';
9
+ export * from './wgpuMaterials';
10
+ export * from './wgpuParticleEmitter';
11
+ export * from './wgpuQuadBatch';
12
+ export * from './wgpuRegistration';
13
+ export * from './wgpuRendererData';
14
+ export * from './wgpuRenderStats';
15
+ export * from './wgpuRichText';
16
+ export * from './wgpuScale9Mapper';
17
+ export * from './wgpuScale9Shape';
18
+ export * from './wgpuShape';
19
+ export * from './wgpuShapeMesh';
20
+ export * from './wgpuSprite';
21
+ export * from './wgpuSpriteBatch';
22
+ export * from './wgpuSpriteRenderer';
23
+ export * from './wgpuTextInput';
24
+ export * from './wgpuTextLabel';
25
+ export * from './wgpuTilemap';
26
+ export * from './wgpuVelocity';
27
+ export * from './wgpuVideo';
28
+ export { defaultCanvasBeginBitmapFill as defaultWgpuBeginBitmapFill, defaultCanvasBeginFill as defaultWgpuBeginFill, defaultCanvasBeginGradientFill as defaultWgpuBeginGradientFill, defaultCanvasCubicCurveTo as defaultWgpuCubicCurveTo, defaultCanvasCurveTo as defaultWgpuCurveTo, defaultCanvasDrawCircle as defaultWgpuDrawCircle, defaultCanvasDrawEllipse as defaultWgpuDrawEllipse, defaultCanvasDrawRectangle as defaultWgpuDrawRectangle, defaultCanvasDrawRoundRectangle as defaultWgpuDrawRoundRectangle, defaultCanvasEndFill as defaultWgpuEndFill, defaultCanvasLineStyle as defaultWgpuLineStyle, defaultCanvasLineTo as defaultWgpuLineTo, defaultCanvasMoveTo as defaultWgpuMoveTo, defaultCanvasShapeCommands as defaultWgpuShapeCommands, registerCanvasShapeCommands as registerWgpuShapeCommands, } from '@flighthq/displayobject-canvas';
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc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'./wgpuClipContours';
5
+ export * from './wgpuClipRectangle';
6
+ export * from './wgpuColorTransformMaterial';
7
+ export * from './wgpuDefaultMaterial';
8
+ export * from './wgpuDisplayObject';
9
+ export * from './wgpuMaterials';
10
+ export * from './wgpuParticleEmitter';
11
+ export * from './wgpuQuadBatch';
12
+ export * from './wgpuRegistration';
13
+ export * from './wgpuRendererData';
14
+ export * from './wgpuRenderStats';
15
+ export * from './wgpuRichText';
16
+ export * from './wgpuScale9Mapper';
17
+ export * from './wgpuScale9Shape';
18
+ export * from './wgpuShape';
19
+ export * from './wgpuShapeMesh';
20
+ export * from './wgpuSprite';
21
+ export * from './wgpuSpriteBatch';
22
+ export * from './wgpuSpriteRenderer';
23
+ export * from './wgpuTextInput';
24
+ export * from './wgpuTextLabel';
25
+ export * from './wgpuTilemap';
26
+ export * from './wgpuVelocity';
27
+ export * from './wgpuVideo';
28
+ export { defaultCanvasBeginBitmapFill as defaultWgpuBeginBitmapFill, defaultCanvasBeginFill as defaultWgpuBeginFill, defaultCanvasBeginGradientFill as defaultWgpuBeginGradientFill, defaultCanvasCubicCurveTo as defaultWgpuCubicCurveTo, defaultCanvasCurveTo as defaultWgpuCurveTo, defaultCanvasDrawCircle as defaultWgpuDrawCircle, defaultCanvasDrawEllipse as defaultWgpuDrawEllipse, defaultCanvasDrawRectangle as defaultWgpuDrawRectangle, defaultCanvasDrawRoundRectangle as defaultWgpuDrawRoundRectangle, defaultCanvasEndFill as defaultWgpuEndFill, defaultCanvasLineStyle as defaultWgpuLineStyle, defaultCanvasLineTo as defaultWgpuLineTo, defaultCanvasMoveTo as defaultWgpuMoveTo, defaultCanvasShapeCommands as defaultWgpuShapeCommands, registerCanvasShapeCommands as registerWgpuShapeCommands, } from '@flighthq/displayobject-canvas';
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,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+ * config uses. Call once at the top of a test file with every module id the file mocks, then apply
4
+ * the mocks and dynamically import the subject inside a beforeAll — both must stay in the test file
5
+ * so relative ids resolve against it. (This helper is colocated in the same package src, so the
6
+ * doUnmock ids passed here resolve to the same modules the test's doMock ids do.)
7
+ *
8
+ * It brackets the file with two vi.resetModules() calls. The first is registered here so it runs
9
+ * before the file's own beforeAll applies the mocks: it forces a subject a sibling already evaluated
10
+ * against the real modules to re-evaluate under the mocks (otherwise the dynamic import returns the
11
+ * cached, real-bound copy). The second, after unmocking, drops the mocked instances so a later file
12
+ * re-imports the real modules instead of the mock left in the shared registry.
13
+ */
14
+ export declare function scopeModuleMocks(mockedIds: readonly string[]): void;
15
+ //# sourceMappingURL=moduleMockTestHelper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moduleMockTestHelper.d.ts","sourceRoot":"","sources":["../src/moduleMockTestHelper.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAQnE"}
@@ -0,0 +1,25 @@
1
+ import { afterAll, beforeAll, vi } from 'vitest';
2
+ /**
3
+ * Makes vi.doMock-based module mocking safe under the shared (isolate:false) worker the root vitest
4
+ * config uses. Call once at the top of a test file with every module id the file mocks, then apply
5
+ * the mocks and dynamically import the subject inside a beforeAll — both must stay in the test file
6
+ * so relative ids resolve against it. (This helper is colocated in the same package src, so the
7
+ * doUnmock ids passed here resolve to the same modules the test's doMock ids do.)
8
+ *
9
+ * It brackets the file with two vi.resetModules() calls. The first is registered here so it runs
10
+ * before the file's own beforeAll applies the mocks: it forces a subject a sibling already evaluated
11
+ * against the real modules to re-evaluate under the mocks (otherwise the dynamic import returns the
12
+ * cached, real-bound copy). The second, after unmocking, drops the mocked instances so a later file
13
+ * re-imports the real modules instead of the mock left in the shared registry.
14
+ */
15
+ export function scopeModuleMocks(mockedIds) {
16
+ beforeAll(() => {
17
+ vi.resetModules();
18
+ });
19
+ afterAll(() => {
20
+ for (const id of mockedIds)
21
+ vi.doUnmock(id);
22
+ vi.resetModules();
23
+ });
24
+ }
25
+ //# sourceMappingURL=moduleMockTestHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moduleMockTestHelper.js","sourceRoot":"","sources":["../src/moduleMockTestHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAEjD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAA4B;IAC3D,SAAS,CAAC,GAAG,EAAE;QACb,EAAE,CAAC,YAAY,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;IACH,QAAQ,CAAC,GAAG,EAAE;QACZ,KAAK,MAAM,EAAE,IAAI,SAAS;YAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAC5C,EAAE,CAAC,YAAY,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { DisplayObjectRenderer, RenderProxy2D, WgpuRenderState } from '@flighthq/types';
2
+ export declare function drawWgpuBitmap(state: WgpuRenderState, renderProxy: RenderProxy2D): void;
3
+ export declare const defaultWgpuBitmapRenderer: DisplayObjectRenderer;
4
+ //# sourceMappingURL=wgpuBitmap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wgpuBitmap.d.ts","sourceRoot":"","sources":["../src/wgpuBitmap.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAU,qBAAqB,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAUrG,wBAAgB,cAAc,CAAC,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,GAAG,IAAI,CA2EvF;AAED,eAAO,MAAM,yBAAyB,EAAE,qBAIvC,CAAC"}
@@ -0,0 +1,80 @@
1
+ import { noopRendererData } from '@flighthq/render';
2
+ import { bindWgpuTexture } from '@flighthq/render-wgpu';
3
+ import { resolveWgpuMaterialRenderer } from '@flighthq/render-wgpu';
4
+ import { getWgpuRenderStateRuntime } from '@flighthq/render-wgpu';
5
+ import { resolveWgpuShader } from '@flighthq/render-wgpu';
6
+ import { BatchFormat } from '@flighthq/types';
7
+ import { ensureWgpuQuadBatchResources, flushWgpuSpriteBatch, packWgpuSpriteBatchMaterialInstance, prepareWgpuSpriteBatchWrite, } from './wgpuSpriteBatch';
8
+ export function drawWgpuBitmap(state, renderProxy) {
9
+ const runtime = getWgpuRenderStateRuntime(state);
10
+ if (runtime.renderPass === null)
11
+ return;
12
+ const source = renderProxy.source;
13
+ const imageSource = source.data.image;
14
+ if (imageSource === null || imageSource.source === null)
15
+ return;
16
+ // Custom per-node shader: flush pending batch to preserve painter's order, then draw immediately.
17
+ const shader = resolveWgpuShader(state, renderProxy);
18
+ if (shader !== null) {
19
+ flushWgpuSpriteBatch(state);
20
+ state.applyBlendMode?.(state, renderProxy.blendMode);
21
+ bindWgpuTexture(state, imageSource.source);
22
+ shader.bind(state, renderProxy);
23
+ return;
24
+ }
25
+ const material = renderProxy.material;
26
+ const materialRenderer = resolveWgpuMaterialRenderer(state, material);
27
+ if (materialRenderer === null)
28
+ return;
29
+ ensureWgpuQuadBatchResources(state);
30
+ const sr = source.data.sourceRectangle ?? null;
31
+ const iw = 1 / (imageSource.width || 1);
32
+ const ih = 1 / (imageSource.height || 1);
33
+ let w;
34
+ let h;
35
+ let u0;
36
+ let v0;
37
+ let u1;
38
+ let v1;
39
+ if (sr === null) {
40
+ w = imageSource.width;
41
+ h = imageSource.height;
42
+ u0 = 0;
43
+ v0 = 0;
44
+ u1 = 1;
45
+ v1 = 1;
46
+ }
47
+ else {
48
+ w = sr.width;
49
+ h = sr.height;
50
+ u0 = sr.x * iw;
51
+ v0 = sr.y * ih;
52
+ u1 = (sr.x + sr.width) * iw;
53
+ v1 = (sr.y + sr.height) * ih;
54
+ }
55
+ const startCount = runtime.spriteBatchCount;
56
+ const base = prepareWgpuSpriteBatchWrite(state, imageSource.source, renderProxy.blendMode, material, materialRenderer, 1);
57
+ const d = runtime.spriteBatchInstanceData;
58
+ const t = renderProxy.transform2D;
59
+ d[base] = t.a;
60
+ d[base + 1] = t.b;
61
+ d[base + 2] = t.c;
62
+ d[base + 3] = t.d;
63
+ d[base + 4] = t.tx;
64
+ d[base + 5] = t.ty;
65
+ d[base + 6] = w;
66
+ d[base + 7] = h;
67
+ d[base + 8] = u0;
68
+ d[base + 9] = v0;
69
+ d[base + 10] = u1;
70
+ d[base + 11] = v1;
71
+ d[base + 12] = renderProxy.alpha;
72
+ packWgpuSpriteBatchMaterialInstance(state, renderProxy.materialData, startCount);
73
+ runtime.spriteBatchCount++;
74
+ }
75
+ export const defaultWgpuBitmapRenderer = {
76
+ format: BatchFormat.Quad,
77
+ createData: noopRendererData,
78
+ submit: drawWgpuBitmap,
79
+ };
80
+ //# sourceMappingURL=wgpuBitmap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wgpuBitmap.js","sourceRoot":"","sources":["../src/wgpuBitmap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EACL,4BAA4B,EAC5B,oBAAoB,EACpB,mCAAmC,EACnC,2BAA2B,GAC5B,MAAM,mBAAmB,CAAC;AAE3B,MAAM,UAAU,cAAc,CAAC,KAAsB,EAAE,WAA0B;IAC/E,MAAM,OAAO,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAA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AAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;IACnB,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;IACnB,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IAChB,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IAChB,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IACjB,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IACjB,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC;IAClB,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC;IAClB,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC;IACjC,mCAAmC,CAAC,KAAK,EAAE,WAAW,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IACjF,OAAO,CAAC,gBAAgB,EAAE,CAAC;AAC7B,CAAC;AAED,MAAM,CAAC,MAAM,yBAAyB,GAA0B;IAC9D,MAAM,EAAE,WAAW,CAAC,IAAI;IACxB,UAAU,EAAE,gBAAgB;IAC5B,MAAM,EAAE,cAAc;CACvB,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { DisplayObject, DisplayObjectRenderer, RenderCache, RenderCacheRefreshOptions, WgpuRenderState, WgpuRenderTarget } from '@flighthq/types';
2
+ /**
3
+ * Creates an offscreen render state for baking render caches consumed by `screenState`.
4
+ *
5
+ * Wgpu textures and pipelines cannot cross GPU devices, so — unlike the canvas backend —
6
+ * this offscreen state must share the screen state's GPU device/context and every
7
+ * device-bound resource (pipelines, samplers, uniform ring buffer, the uploaded-texture
8
+ * cache). What it keeps separate is the scene-graph bookkeeping: its own render node map,
9
+ * adapter map, and frame counter, so baking neither substitutes a cache into itself nor
10
+ * disturbs the screen state's nodes.
11
+ */
12
+ export declare function createWgpuCacheState(screenState: WgpuRenderState): WgpuRenderState;
13
+ export declare function enableWgpuRenderCache(state: WgpuRenderState): void;
14
+ /**
15
+ * Allocates or resizes the texture `screenState` composites for `cache`, returning it so a
16
+ * caller can render custom content into it directly. For engine-baked content prefer
17
+ * refreshWgpuRenderCache.
18
+ */
19
+ export declare function ensureWgpuRenderCacheTarget(state: WgpuRenderState, cache: RenderCache, width: number, height: number): WgpuRenderTarget;
20
+ export declare function getWgpuRenderCacheTarget(state: WgpuRenderState, cache: RenderCache): WgpuRenderTarget | null;
21
+ /**
22
+ * Bakes `source`'s subtree into its cache target using the offscreen `cacheState`, then records
23
+ * the transform that places the result back in scene space. Returns whether a bake happened —
24
+ * the offscreen state's own dirtiness decides it (honoring its sceneGraphSyncPolicy), so this is
25
+ * cheap to call every frame. Because the bake runs on the shared GPU device, the screen state's
26
+ * cached GPU state is reset afterward so it re-establishes cleanly on its next draw.
27
+ */
28
+ export declare function refreshWgpuRenderCache(cacheState: WgpuRenderState, cache: RenderCache, source: DisplayObject, options?: Readonly<RenderCacheRefreshOptions>): boolean;
29
+ export declare function releaseWgpuRenderCache(state: WgpuRenderState, cache: RenderCache): void;
30
+ export declare const defaultWgpuRenderCacheRenderer: DisplayObjectRenderer;
31
+ //# sourceMappingURL=wgpuCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wgpuCache.d.ts","sourceRoot":"","sources":["../src/wgpuCache.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EACV,aAAa,EACb,qBAAqB,EAErB,WAAW,EACX,yBAAyB,EAEzB,eAAe,EACf,gBAAgB,EACjB,MAAM,iBAAiB,CAAC;AAMzB;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,eAAe,GAAG,eAAe,CAkFlF;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAElE;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,eAAe,EACtB,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,gBAAgB,CAUlB;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,WAAW,GAAG,gBAAgB,GAAG,IAAI,CAE5G;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,eAAe,EAC3B,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,aAAa,EACrB,OAAO,CAAC,EAAE,QAAQ,CAAC,yBAAyB,CAAC,GAC5C,OAAO,CAiET;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,CAOvF;AA0BD,eAAO,MAAM,8BAA8B,EAAE,qBAG5C,CAAC"}
@@ -0,0 +1,232 @@
1
+ import { createMatrix, createRectangle, multiplyMatrix } from '@flighthq/geometry';
2
+ import { computeNodeBoundsRectangle } from '@flighthq/node';
3
+ import { computeDisplayObjectRenderTargetTransform, computeRenderCacheTransform, computeRenderTargetSize, copyAllRenderersFromRenderState, createRenderState, getRenderProxyCache, noopRendererData, prepareDisplayObjectRender, registerRenderCacheRenderer, } from '@flighthq/render';
4
+ import { createWgpuRenderStateRuntime, getWgpuRenderStateRuntime } from '@flighthq/render-wgpu';
5
+ import { beginWgpuRenderTarget, createWgpuRenderTarget, destroyWgpuRenderTarget, drawWgpuRenderTargetResult, endWgpuRenderTarget, resizeWgpuRenderTarget, } from '@flighthq/render-wgpu';
6
+ import { EntityRuntimeKey } from '@flighthq/types';
7
+ import { renderWgpuDisplayObject } from './wgpuDisplayObject';
8
+ import { flushWgpuSpriteBatch } from './wgpuSpriteBatch';
9
+ /**
10
+ * Creates an offscreen render state for baking render caches consumed by `screenState`.
11
+ *
12
+ * Wgpu textures and pipelines cannot cross GPU devices, so — unlike the canvas backend —
13
+ * this offscreen state must share the screen state's GPU device/context and every
14
+ * device-bound resource (pipelines, samplers, uniform ring buffer, the uploaded-texture
15
+ * cache). What it keeps separate is the scene-graph bookkeeping: its own render node map,
16
+ * adapter map, and frame counter, so baking neither substitutes a cache into itself nor
17
+ * disturbs the screen state's nodes.
18
+ */
19
+ export function createWgpuCacheState(screenState) {
20
+ const screenRuntime = getWgpuRenderStateRuntime(screenState);
21
+ const cacheState = createRenderState({
22
+ allowSmoothing: screenState.allowSmoothing,
23
+ pixelRatio: screenState.pixelRatio,
24
+ renderTransform2D: createMatrix(),
25
+ roundPixels: screenState.roundPixels,
26
+ sceneGraphSyncPolicy: screenState.sceneGraphSyncPolicy,
27
+ });
28
+ // Attach the cache runtime before copying renderers: copyAllRenderersFromRenderState registers
29
+ // into the runtime's rendererMap, so the backend runtime must already be installed.
30
+ const cacheRuntime = createWgpuRenderStateRuntime();
31
+ cacheState[EntityRuntimeKey] = cacheRuntime;
32
+ copyAllRenderersFromRenderState(cacheState, screenState);
33
+ cacheState.applyBlendMode = screenState.applyBlendMode;
34
+ cacheState.canvas = screenState.canvas;
35
+ cacheState.context = screenState.context;
36
+ cacheState.device = screenState.device;
37
+ cacheState.format = screenState.format;
38
+ cacheRuntime.uniformBindGroupLayout = screenRuntime.uniformBindGroupLayout;
39
+ cacheRuntime.textureBindGroupLayout = screenRuntime.textureBindGroupLayout;
40
+ cacheRuntime.uniformBuffer = screenRuntime.uniformBuffer;
41
+ cacheRuntime.uniformData = screenRuntime.uniformData;
42
+ cacheRuntime.uniformDataU32 = screenRuntime.uniformDataU32;
43
+ cacheRuntime.uniformStride = screenRuntime.uniformStride;
44
+ cacheRuntime.uniformBindGroup = screenRuntime.uniformBindGroup;
45
+ cacheRuntime.matrixArray = screenRuntime.matrixArray;
46
+ cacheRuntime.pipelineCache = screenRuntime.pipelineCache;
47
+ cacheRuntime.linearSampler = screenRuntime.linearSampler;
48
+ cacheRuntime.nearestSampler = screenRuntime.nearestSampler;
49
+ cacheRuntime.textureCache = screenRuntime.textureCache;
50
+ cacheRuntime.defaultBitmapShader = screenRuntime.defaultBitmapShader;
51
+ cacheRuntime.colorTransformBitmapShader = screenRuntime.colorTransformBitmapShader;
52
+ cacheRuntime.particleInstanceBuffer = screenRuntime.particleInstanceBuffer;
53
+ cacheRuntime.particleInstanceData = screenRuntime.particleInstanceData;
54
+ cacheRuntime.particleInstanceCapacity = screenRuntime.particleInstanceCapacity;
55
+ // The baked subtree is recorded into the screen state's command encoder, so the cache
56
+ // state must share the live per-frame encoder/pass surfaces rather than its own.
57
+ cacheRuntime.commandEncoder = screenRuntime.commandEncoder;
58
+ cacheRuntime.renderPass = screenRuntime.renderPass;
59
+ cacheRuntime.canvasTextureView = screenRuntime.canvasTextureView;
60
+ cacheRuntime.canvasViewCleared = screenRuntime.canvasViewCleared;
61
+ cacheRuntime.depthStencilTexture = screenRuntime.depthStencilTexture;
62
+ cacheRuntime.depthStencilView = screenRuntime.depthStencilView;
63
+ cacheRuntime.depthStencilWidth = screenRuntime.depthStencilWidth;
64
+ cacheRuntime.depthStencilHeight = screenRuntime.depthStencilHeight;
65
+ cacheRuntime.materialRendererMap = screenRuntime.materialRendererMap;
66
+ cacheRuntime.uniformOffset = 0;
67
+ cacheRuntime.currentBlendMode = null;
68
+ cacheRuntime.currentMaskDepth = 0;
69
+ // Contour-clip pipelines can be lazily rebuilt against the cache's device; the active-clip stack must
70
+ // start empty so a cached subtree's clips don't reference the screen state's GPU buffers.
71
+ cacheRuntime.clipContourPipelines = undefined;
72
+ cacheRuntime.clipContourStack = [];
73
+ cacheRuntime.clipForms = [];
74
+ // The flat-color shape-fill pipelines can be lazily rebuilt against the (shared) device on first use.
75
+ cacheRuntime.shapeMeshPipelines = undefined;
76
+ cacheRuntime.spriteBatchBlendMode = null;
77
+ cacheRuntime.spriteBatchMaterial = null;
78
+ cacheRuntime.spriteBatchMaterialRenderer = null;
79
+ cacheRuntime.spriteBatchMaterialFloats = 0;
80
+ cacheRuntime.spriteBatchCount = 0;
81
+ cacheRuntime.spriteBatchInstanceData = new Float32Array(0);
82
+ cacheRuntime.spriteBatchMaterialData = new Float32Array(0);
83
+ cacheRuntime.spriteBatchTexture = null;
84
+ // The bake state owns its own buffer pool (its flushes record into the same frame, so they must
85
+ // not share slots with the screen's batch either).
86
+ cacheRuntime.spriteBatchBufferPool = [];
87
+ cacheRuntime.spriteBatchBufferCursor = 0;
88
+ cacheRuntime.maskWriteMode = false;
89
+ cacheRuntime.currentScissorRect = null;
90
+ cacheRuntime.scissorStack = [];
91
+ cacheRuntime.renderTargetViewport = null;
92
+ cacheRuntime.renderTargetStack = [];
93
+ _cacheStateScreen.set(cacheState, screenState);
94
+ return cacheState;
95
+ }
96
+ export function enableWgpuRenderCache(state) {
97
+ registerRenderCacheRenderer(state, defaultWgpuRenderCacheRenderer);
98
+ }
99
+ /**
100
+ * Allocates or resizes the texture `screenState` composites for `cache`, returning it so a
101
+ * caller can render custom content into it directly. For engine-baked content prefer
102
+ * refreshWgpuRenderCache.
103
+ */
104
+ export function ensureWgpuRenderCacheTarget(state, cache, width, height) {
105
+ const targets = getTargets(state);
106
+ let target = targets.get(cache);
107
+ if (target === undefined) {
108
+ target = createWgpuRenderTarget(state, width, height);
109
+ targets.set(cache, target);
110
+ }
111
+ else {
112
+ resizeWgpuRenderTarget(state, target, width, height);
113
+ }
114
+ return target;
115
+ }
116
+ export function getWgpuRenderCacheTarget(state, cache) {
117
+ return getTargets(state).get(cache) ?? null;
118
+ }
119
+ /**
120
+ * Bakes `source`'s subtree into its cache target using the offscreen `cacheState`, then records
121
+ * the transform that places the result back in scene space. Returns whether a bake happened —
122
+ * the offscreen state's own dirtiness decides it (honoring its sceneGraphSyncPolicy), so this is
123
+ * cheap to call every frame. Because the bake runs on the shared GPU device, the screen state's
124
+ * cached GPU state is reset afterward so it re-establishes cleanly on its next draw.
125
+ */
126
+ export function refreshWgpuRenderCache(cacheState, cache, source, options) {
127
+ const screenState = _cacheStateScreen.get(cacheState) ?? cacheState;
128
+ const cacheRuntime = getWgpuRenderStateRuntime(cacheState);
129
+ const screenRuntime = getWgpuRenderStateRuntime(screenState);
130
+ // The bake records into the screen state's live, per-frame command encoder and render pass.
131
+ // createWgpuCacheState captured those once at setup — stale now, since webgpu rebuilds them
132
+ // every frame — so sync them here. This requires refresh to run within a frame (after the
133
+ // encoder/pass have begun), unlike the immediate-mode Gl backend.
134
+ cacheRuntime.commandEncoder = screenRuntime.commandEncoder;
135
+ cacheRuntime.renderPass = screenRuntime.renderPass;
136
+ cacheRuntime.canvasTextureView = screenRuntime.canvasTextureView;
137
+ cacheRuntime.canvasViewCleared = screenRuntime.canvasViewCleared;
138
+ cacheRuntime.depthStencilTexture = screenRuntime.depthStencilTexture;
139
+ cacheRuntime.depthStencilView = screenRuntime.depthStencilView;
140
+ cacheRuntime.depthStencilWidth = screenRuntime.depthStencilWidth;
141
+ cacheRuntime.depthStencilHeight = screenRuntime.depthStencilHeight;
142
+ // The cache state shares the screen state's uniform ring buffer (createWgpuCacheState aliases
143
+ // uniformBuffer/uniformData). Continue from the screen's current cursor so the bake's draws claim
144
+ // a region the screen render won't overwrite — otherwise both start at 0, the later screen writes
145
+ // clobber the bake's uniforms, and the baked subtree draws with corrupted transforms.
146
+ cacheRuntime.uniformOffset = screenRuntime.uniformOffset;
147
+ const padding = options?.padding ?? 0;
148
+ const minWidth = options?.minWidth ?? 1;
149
+ const minHeight = options?.minHeight ?? 1;
150
+ computeNodeBoundsRectangle(_bounds, source, source);
151
+ const { width, height } = computeRenderTargetSize(_bounds, padding, minWidth, minHeight);
152
+ const existing = getWgpuRenderCacheTarget(screenState, cache);
153
+ const resized = existing === null || existing.width !== width || existing.height !== height;
154
+ const target = ensureWgpuRenderCacheTarget(screenState, cache, width, height);
155
+ computeDisplayObjectRenderTargetTransform(_renderTransform, source, _bounds, padding, padding);
156
+ computeRenderCacheTransform(cache.transform, _bounds, padding, padding);
157
+ // Wgpu render targets store content for a bottom-left UV origin (what drawWgpuRenderTargetResult's
158
+ // V-flip expects on composite), so bake with a Y-inverted render transform — unlike the Gl backend,
159
+ // whose framebuffer convention needs no inversion.
160
+ _yInvert.d = -1;
161
+ _yInvert.ty = target.height;
162
+ multiplyMatrix(_bakeTransform, _yInvert, _renderTransform);
163
+ // Reclaim the bake state's buffer pool from the start of this bake; the previous bake's submit
164
+ // has been queued, so its slots are safe to reuse.
165
+ cacheRuntime.spriteBatchBufferCursor = 0;
166
+ beginWgpuRenderTarget(cacheState, target, _bakeTransform);
167
+ const dirty = prepareDisplayObjectRender(cacheState, source);
168
+ if (dirty || resized) {
169
+ // The render-target pass begins with a 'clear' load op, so the target starts transparent.
170
+ renderWgpuDisplayObject(cacheState, source);
171
+ }
172
+ endWgpuRenderTarget(cacheState);
173
+ // endWgpuRenderTarget reopened a fresh canvas pass on the cache state — hand the live encoder
174
+ // and pass back to the screen state so its subsequent draws continue in the same frame.
175
+ screenRuntime.commandEncoder = cacheRuntime.commandEncoder;
176
+ screenRuntime.renderPass = cacheRuntime.renderPass;
177
+ screenRuntime.canvasTextureView = cacheRuntime.canvasTextureView;
178
+ screenRuntime.canvasViewCleared = cacheRuntime.canvasViewCleared;
179
+ screenRuntime.currentBlendMode = null;
180
+ // Advance the screen's cursor past the bake's uniform writes so its subsequent draws don't
181
+ // overwrite them in the shared ring buffer.
182
+ screenRuntime.uniformOffset = cacheRuntime.uniformOffset;
183
+ return dirty || resized;
184
+ }
185
+ export function releaseWgpuRenderCache(state, cache) {
186
+ const targets = getTargets(state);
187
+ const target = targets.get(cache);
188
+ if (target === undefined)
189
+ return;
190
+ // A WgpuRenderTarget owns GPU textures; GC will not free them.
191
+ destroyWgpuRenderTarget(state, target);
192
+ targets.delete(cache);
193
+ }
194
+ function drawWgpuRenderCache(state, renderProxy) {
195
+ const cache = getRenderProxyCache(state, renderProxy.source);
196
+ if (cache === null)
197
+ return;
198
+ const target = getTargets(state).get(cache);
199
+ if (target === undefined)
200
+ return;
201
+ // Drain pending batched geometry before the immediate composite quad. Like every other
202
+ // immediate-draw renderer (RichText, Video), this bypasses the sprite batch; without the flush the
203
+ // immediate quad interleaves with the un-flushed batch's instance buffer and bind-group state,
204
+ // corrupting the pending batch rather than merely reordering it.
205
+ flushWgpuSpriteBatch(state);
206
+ // renderProxy.transform2D already carries the cache placement transform (folded in by the
207
+ // adapter), so the target composites with an identity offset.
208
+ drawWgpuRenderTargetResult(state, renderProxy, target, _identity);
209
+ }
210
+ function getTargets(state) {
211
+ let targets = _renderCacheTargets.get(state);
212
+ if (targets === undefined) {
213
+ targets = new WeakMap();
214
+ _renderCacheTargets.set(state, targets);
215
+ }
216
+ return targets;
217
+ }
218
+ export const defaultWgpuRenderCacheRenderer = {
219
+ createData: noopRendererData,
220
+ submit: drawWgpuRenderCache,
221
+ };
222
+ // The screen state owns each cache's target, keyed by the handle, so one handle can be
223
+ // composited by several states without the handle carrying a backend resource.
224
+ const _renderCacheTargets = new WeakMap();
225
+ // Links an offscreen cache state back to the screen state whose targets it bakes into.
226
+ const _cacheStateScreen = new WeakMap();
227
+ const _bounds = createRectangle();
228
+ const _renderTransform = createMatrix();
229
+ const _bakeTransform = createMatrix();
230
+ const _yInvert = createMatrix();
231
+ const _identity = createMatrix();
232
+ //# sourceMappingURL=wgpuCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wgpuCache.js","sourceRoot":"","sources":["../src/wgpuCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACnF,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EACL,yCAAyC,EACzC,2BAA2B,EAC3B,uBAAuB,EACvB,+BAA+B,EAC/B,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,4BAA4B,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAChG,OAAO,EACL,qBAAqB,EACrB,sBAAs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,uFAAuF;AACvF,+EAA+E;AAC/E,MAAM,mBAAmB,GAAG,IAAI,OAAO,EAA2D,CAAC;AACnG,uFAAuF;AACvF,MAAM,iBAAiB,GAAG,IAAI,OAAO,EAAoC,CAAC;AAC1E,MAAM,OAAO,GAAG,eAAe,EAAE,CAAC;AAClC,MAAM,gBAAgB,GAAG,YAAY,EAAY,CAAC;AAClD,MAAM,cAAc,GAAG,YAAY,EAAY,CAAC;AAChD,MAAM,QAAQ,GAAG,YAAY,EAAY,CAAC;AAC1C,MAAM,SAAS,GAAG,YAAY,EAAY,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { WgpuRenderState } from '@flighthq/types';
2
+ export declare function enableWgpuClipSupport(state: WgpuRenderState): void;
3
+ //# sourceMappingURL=wgpuClip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wgpuClip.d.ts","sourceRoot":"","sources":["../src/wgpuClip.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAwD,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAO7G,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAElE"}
@@ -0,0 +1,44 @@
1
+ import { getWgpuRenderStateRuntime } from '@flighthq/render-wgpu';
2
+ import { popWgpuClipContours, pushWgpuClipContours } from './wgpuClipContours';
3
+ import { popWgpuClipRectangle, pushWgpuClipRectangle } from './wgpuClipRectangle';
4
+ // Masks RETIRED — a former mask is a path ClipRegion. Clip = scissor (rect) or stencil-then-cover
5
+ // (contour); independent gates that AND when nested. `runtime.clipForms` records each clip's form for unwind.
6
+ export function enableWgpuClipSupport(state) {
7
+ state.displayObjectClipHooks = webgpuClipHooks;
8
+ }
9
+ function popOneWgpuClip(state) {
10
+ const runtime = getWgpuRenderStateRuntime(state);
11
+ const form = runtime.clipForms.pop();
12
+ if (form === 'contour')
13
+ popWgpuClipContours(state);
14
+ else
15
+ popWgpuClipRectangle(state); // pops its own scissor stack; clipForms tracks the count
16
+ }
17
+ const webgpuClipHooks = {
18
+ finalize(state) {
19
+ const runtime = getWgpuRenderStateRuntime(state);
20
+ while (runtime.clipForms.length > 0)
21
+ popOneWgpuClip(state);
22
+ },
23
+ popClip(state, data, source) {
24
+ const runtime = getWgpuRenderStateRuntime(state);
25
+ const target = data.clipDepth - (source.clip != null ? 1 : 0);
26
+ while (runtime.clipForms.length > target)
27
+ popOneWgpuClip(state);
28
+ },
29
+ pushClip(state, data, source) {
30
+ const runtime = getWgpuRenderStateRuntime(state);
31
+ const clip = source.clip;
32
+ if (clip === null)
33
+ return;
34
+ if (clip.contours === null) {
35
+ pushWgpuClipRectangle(state, clip.rect, data.transform2D);
36
+ runtime.clipForms.push('rect');
37
+ }
38
+ else {
39
+ pushWgpuClipContours(state, clip.contours, clip.winding, data.transform2D);
40
+ runtime.clipForms.push('contour');
41
+ }
42
+ },
43
+ };
44
+ //# sourceMappingURL=wgpuClip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wgpuClip.js","sourceRoot":"","sources":["../src/wgpuClip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAElF,kGAAkG;AAClG,8GAA8G;AAC9G,MAAM,UAAU,qBAAqB,CAAC,KAAsB;IAC1D,KAAK,CAAC,sBAAsB,GAAG,eAAe,CAAC;AACjD,CAAC;AAED,SAAS,cAAc,CAAC,KAAsB;IAC5C,MAAM,OAAO,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;IACrC,IAAI,IAAI,KAAK,SAAS;QAAE,mBAAmB,CAAC,KAAK,CAAC,CAAC;;QAC9C,oBAAoB,CAAC,KAAK,CAA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CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Matrix, PathWinding, WgpuRenderState } from '@flighthq/types';
2
+ export declare function popWgpuClipContours(state: WgpuRenderState): void;
3
+ export declare function pushWgpuClipContours(state: WgpuRenderState, contours: readonly (readonly number[])[], winding: PathWinding, worldTransform: Readonly<Matrix>): void;
4
+ //# sourceMappingURL=wgpuClipContours.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wgpuClipContours.d.ts","sourceRoot":"","sources":["../src/wgpuClipContours.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAA4B,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAsCtG,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAsBhE;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,eAAe,EACtB,QAAQ,EAAE,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,EACxC,OAAO,EAAE,WAAW,EACpB,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,GAC/B,IAAI,CA+BN"}