@flighthq/render-gl 0.2.1-next.841.373388f → 0.3.0-next.1032.e2b99fc

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 (113) hide show
  1. package/dist/contract.d.ts +25 -0
  2. package/dist/contract.d.ts.map +1 -0
  3. package/dist/contract.js +25 -0
  4. package/dist/contract.js.map +1 -0
  5. package/dist/enableGlRenderTextureGuards.d.ts +4 -0
  6. package/dist/enableGlRenderTextureGuards.d.ts.map +1 -0
  7. package/dist/enableGlRenderTextureGuards.js +34 -0
  8. package/dist/enableGlRenderTextureGuards.js.map +1 -0
  9. package/dist/glBackground.d.ts +1 -1
  10. package/dist/glBackground.d.ts.map +1 -1
  11. package/dist/glBackground.js +2 -2
  12. package/dist/glBackground.js.map +1 -1
  13. package/dist/glCompressedTexture.d.ts +1 -1
  14. package/dist/glCompressedTexture.d.ts.map +1 -1
  15. package/dist/glCompressedTexture.js +8 -13
  16. package/dist/glCompressedTexture.js.map +1 -1
  17. package/dist/glDraw.d.ts +6 -3
  18. package/dist/glDraw.d.ts.map +1 -1
  19. package/dist/glDraw.js +94 -107
  20. package/dist/glDraw.js.map +1 -1
  21. package/dist/glExternalTexture.d.ts +4 -0
  22. package/dist/glExternalTexture.d.ts.map +1 -0
  23. package/dist/glExternalTexture.js +41 -0
  24. package/dist/glExternalTexture.js.map +1 -0
  25. package/dist/glFullscreenPass.d.ts +1 -1
  26. package/dist/glFullscreenPass.d.ts.map +1 -1
  27. package/dist/glFullscreenPass.js +2 -2
  28. package/dist/glFullscreenPass.js.map +1 -1
  29. package/dist/glLinearToSrgbPass.d.ts +1 -1
  30. package/dist/glLinearToSrgbPass.d.ts.map +1 -1
  31. package/dist/glMaterialRegistry.d.ts +1 -1
  32. package/dist/glMaterialRegistry.d.ts.map +1 -1
  33. package/dist/glMaterialRegistry.js +3 -3
  34. package/dist/glMaterialRegistry.js.map +1 -1
  35. package/dist/glPresentRenderTarget.d.ts +1 -1
  36. package/dist/glPresentRenderTarget.d.ts.map +1 -1
  37. package/dist/glReadback.d.ts +1 -1
  38. package/dist/glReadback.d.ts.map +1 -1
  39. package/dist/glRenderPass.d.ts +2 -2
  40. package/dist/glRenderPass.d.ts.map +1 -1
  41. package/dist/glRenderPass.js +136 -22
  42. package/dist/glRenderPass.js.map +1 -1
  43. package/dist/glRenderState.d.ts +1 -1
  44. package/dist/glRenderState.d.ts.map +1 -1
  45. package/dist/glRenderState.js +30 -27
  46. package/dist/glRenderState.js.map +1 -1
  47. package/dist/glRenderStateBracket.d.ts +5 -0
  48. package/dist/glRenderStateBracket.d.ts.map +1 -0
  49. package/dist/glRenderStateBracket.js +111 -0
  50. package/dist/glRenderStateBracket.js.map +1 -0
  51. package/dist/glRenderTarget.d.ts +1 -1
  52. package/dist/glRenderTarget.d.ts.map +1 -1
  53. package/dist/glRenderTarget.js +26 -10
  54. package/dist/glRenderTarget.js.map +1 -1
  55. package/dist/glRenderTargetPool.d.ts +1 -1
  56. package/dist/glRenderTargetPool.d.ts.map +1 -1
  57. package/dist/glRenderTargetPool.js.map +1 -1
  58. package/dist/glRenderTexture.d.ts +13 -0
  59. package/dist/glRenderTexture.d.ts.map +1 -0
  60. package/dist/glRenderTexture.js +109 -0
  61. package/dist/glRenderTexture.js.map +1 -0
  62. package/dist/glShader.d.ts +2 -2
  63. package/dist/glShader.d.ts.map +1 -1
  64. package/dist/glShaderBinding.d.ts +2 -2
  65. package/dist/glShaderBinding.d.ts.map +1 -1
  66. package/dist/glShaderBinding.js +2 -2
  67. package/dist/glShaderBinding.js.map +1 -1
  68. package/dist/glShaderRegistry.d.ts +2 -2
  69. package/dist/glShaderRegistry.d.ts.map +1 -1
  70. package/dist/glSkinPaletteTexture.d.ts +1 -1
  71. package/dist/glSkinPaletteTexture.d.ts.map +1 -1
  72. package/dist/glTestHelper.d.ts +2 -2
  73. package/dist/glTestHelper.d.ts.map +1 -1
  74. package/dist/glTestHelper.js +16 -13
  75. package/dist/glTestHelper.js.map +1 -1
  76. package/dist/glTextureResolver.d.ts +9 -0
  77. package/dist/glTextureResolver.d.ts.map +1 -0
  78. package/dist/glTextureResolver.js +68 -0
  79. package/dist/glTextureResolver.js.map +1 -0
  80. package/dist/glTextureUpload.d.ts +1 -1
  81. package/dist/glTextureUpload.d.ts.map +1 -1
  82. package/dist/glTextureUpload.js +3 -9
  83. package/dist/glTextureUpload.js.map +1 -1
  84. package/dist/glTextureVideoUpload.d.ts +2 -2
  85. package/dist/glTextureVideoUpload.d.ts.map +1 -1
  86. package/dist/glTextureVideoUpload.js +10 -10
  87. package/dist/glTextureVideoUpload.js.map +1 -1
  88. package/dist/index.d.ts +1 -19
  89. package/dist/index.d.ts.map +1 -1
  90. package/dist/index.js +1 -19
  91. package/dist/index.js.map +1 -1
  92. package/package.json +11 -5
  93. package/src/enableGlRenderTextureGuards.test.ts +22 -0
  94. package/src/glBackground.test.ts +10 -1
  95. package/src/glCompressedTexture.test.ts +7 -17
  96. package/src/glDraw.test.ts +130 -79
  97. package/src/glExternalTexture.test.ts +30 -0
  98. package/src/glFullscreenPass.test.ts +4 -4
  99. package/src/glLinearToSrgbPass.test.ts +1 -1
  100. package/src/glMaterialRegistry.test.ts +4 -4
  101. package/src/glPresentRenderTarget.test.ts +1 -1
  102. package/src/glReadback.test.ts +1 -1
  103. package/src/glRenderPass.test.ts +145 -6
  104. package/src/glRenderState.test.ts +2 -2
  105. package/src/glRenderStateBracket.test.ts +319 -0
  106. package/src/glRenderTarget.test.ts +61 -3
  107. package/src/glRenderTexture.test.ts +252 -0
  108. package/src/glShader.test.ts +25 -25
  109. package/src/glShaderBinding.test.ts +2 -2
  110. package/src/glSkinPaletteTexture.test.ts +1 -1
  111. package/src/glTextureResolver.test.ts +182 -0
  112. package/src/glTextureUpload.test.ts +2 -10
  113. package/src/glTextureVideoUpload.test.ts +15 -15
@@ -1,4 +1,4 @@
1
- import type { GlRenderState } from '@flighthq/types';
2
- import type { GlBitmapShader } from '@flighthq/types';
1
+ import type { GlRenderState } from '@flighthq/types/contract';
2
+ import type { GlBitmapShader } from '@flighthq/types/contract';
3
3
  export declare function registerGlBitmapShader(state: GlRenderState, shader: GlBitmapShader): void;
4
4
  //# sourceMappingURL=glShaderRegistry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"glShaderRegistry.d.ts","sourceRoot":"","sources":["../src/glShaderRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAItD,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAGzF"}
1
+ {"version":3,"file":"glShaderRegistry.d.ts","sourceRoot":"","sources":["../src/glShaderRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAI/D,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAGzF"}
@@ -1,4 +1,4 @@
1
- import type { GlSkinPaletteTexture } from '@flighthq/types';
1
+ import type { GlSkinPaletteTexture } from '@flighthq/types/contract';
2
2
  export declare function createGlSkinPaletteTexture(gl: WebGL2RenderingContext): GlSkinPaletteTexture;
3
3
  export declare function destroyGlSkinPaletteTexture(gl: WebGL2RenderingContext, palette: Readonly<GlSkinPaletteTexture>): void;
4
4
  export declare function uploadGlSkinPaletteTexture(gl: WebGL2RenderingContext, palette: GlSkinPaletteTexture, jointMatrices: Readonly<Float32Array>, jointCount: number): void;
@@ -1 +1 @@
1
- {"version":3,"file":"glSkinPaletteTexture.d.ts","sourceRoot":"","sources":["../src/glSkinPaletteTexture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAY5D,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,sBAAsB,GAAG,oBAAoB,CAE3F;AAID,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,sBAAsB,EAAE,OAAO,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GAAG,IAAI,CAErH;AAQD,wBAAgB,0BAA0B,CACxC,EAAE,EAAE,sBAAsB,EAC1B,OAAO,EAAE,oBAAoB,EAC7B,aAAa,EAAE,QAAQ,CAAC,YAAY,CAAC,EACrC,UAAU,EAAE,MAAM,GACjB,IAAI,CAiBN"}
1
+ {"version":3,"file":"glSkinPaletteTexture.d.ts","sourceRoot":"","sources":["../src/glSkinPaletteTexture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAYrE,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,sBAAsB,GAAG,oBAAoB,CAE3F;AAID,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,sBAAsB,EAAE,OAAO,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GAAG,IAAI,CAErH;AAQD,wBAAgB,0BAA0B,CACxC,EAAE,EAAE,sBAAsB,EAC1B,OAAO,EAAE,oBAAoB,EAC7B,aAAa,EAAE,QAAQ,CAAC,YAAY,CAAC,EACrC,UAAU,EAAE,MAAM,GACjB,IAAI,CAiBN"}
@@ -1,5 +1,5 @@
1
- import type { GlRenderState } from '@flighthq/types';
2
- import type { GlShaderLocations } from '@flighthq/types';
1
+ import type { GlRenderState } from '@flighthq/types/contract';
2
+ import type { GlShaderLocations } from '@flighthq/types/contract';
3
3
  export declare function createGlState(options?: {
4
4
  allowSmoothing?: boolean;
5
5
  backgroundColorRgba?: number[];
@@ -1 +1 @@
1
- {"version":3,"file":"glTestHelper.d.ts","sourceRoot":"","sources":["../src/glTestHelper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAwB,MAAM,iBAAiB,CAAC;AAE3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAIzD,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE;IAAE,cAAc,CAAC,EAAE,OAAO,CAAC;IAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG;IACrG,KAAK,EAAE,aAAa,CAAC;IACrB,EAAE,EAAE,sBAAsB,CAAC;IAC3B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,SAAS,EAAE,iBAAiB,CAAC;CAC9B,CAmDA;AAKD,wBAAgB,MAAM,IAAI,sBAAsB,CAG/C;AAED,wBAAgB,aAAa,IAAI,iBAAiB,CAYjD"}
1
+ {"version":3,"file":"glTestHelper.d.ts","sourceRoot":"","sources":["../src/glTestHelper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAwB,MAAM,0BAA0B,CAAC;AAEpF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAIlE,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE;IAAE,cAAc,CAAC,EAAE,OAAO,CAAC;IAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG;IACrG,KAAK,EAAE,aAAa,CAAC;IACrB,EAAE,EAAE,sBAAsB,CAAC;IAC3B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,SAAS,EAAE,iBAAiB,CAAC;CAC9B,CAsDA;AAKD,wBAAgB,MAAM,IAAI,sBAAsB,CAG/C;AAED,wBAAgB,aAAa,IAAI,iBAAiB,CAYjD"}
@@ -1,5 +1,5 @@
1
- import { createRenderState } from '@flighthq/render';
2
- import { EntityRuntimeKey } from '@flighthq/types';
1
+ import { createRenderState } from '@flighthq/render/contract';
2
+ import { EntityRuntimeKey } from '@flighthq/types/contract';
3
3
  import { createGlRenderStateRuntime } from './glRenderState';
4
4
  export function createGlState(options) {
5
5
  const canvas = document.createElement('canvas');
@@ -28,10 +28,11 @@ export function createGlState(options) {
28
28
  currentScissorRect: null,
29
29
  currentTexture: null,
30
30
  currentTextureStraightAlpha: false,
31
+ flushPendingDraws: null,
31
32
  renderTargetViewport: null,
32
33
  textureCache: new WeakMap(),
33
- imageResourcePremultipliedTextureCache: new WeakMap(),
34
- imageResourceStraightTextureCache: new WeakMap(),
34
+ imageBackingPremultipliedTextureCache: new WeakMap(),
35
+ imageBackingStraightTextureCache: new WeakMap(),
35
36
  shaderLoc,
36
37
  defaultBitmapShader: { locations: shaderLoc, program: shaderLoc.program, bind: vi.fn() },
37
38
  quadVertexBuffer: {},
@@ -40,12 +41,14 @@ export function createGlState(options) {
40
41
  matrixArray: new Float32Array(9),
41
42
  scissorStack: [],
42
43
  clipForms: [],
43
- spriteBatchBlendMode: null,
44
- spriteBatchCount: 0,
45
- spriteBatchInstanceBuffer: null,
46
- spriteBatchInstanceData: new Float32Array(13 * 256),
47
- spriteBatchTexture: null,
48
- spriteBatchSmoothing: null,
44
+ quadBatchWriterBlendMode: null,
45
+ quadBatchWriterCount: 0,
46
+ quadBatchWriterInstanceBuffer: null,
47
+ quadBatchWriterInstanceData: new Float32Array(13 * 256),
48
+ quadBatchWriterTexture: null,
49
+ quadBatchWriterSampler: null,
50
+ quadBatchWriterStraightAlpha: false,
51
+ quadBatchWriterSmoothing: null,
49
52
  });
50
53
  state[EntityRuntimeKey] = runtime;
51
54
  return { state, gl, canvas, shaderLoc };
@@ -64,9 +67,9 @@ export function makeShaderLoc() {
64
67
  locTexCoord: 1,
65
68
  locMatrix: {},
66
69
  locAlpha: {},
67
- locColorMultiplier: {},
68
- locColorOffset: {},
69
- locHasColorTransform: {},
70
+ locColorScale: {},
71
+ locColorBias: {},
72
+ locHasColorScaleBias: {},
70
73
  locTexture: {},
71
74
  };
72
75
  }
@@ -1 +1 @@
1
- {"version":3,"file":"glTestHelper.js","sourceRoot":"","sources":["../src/glTestHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,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
1
+ import type { GlRenderState, GlTextureResolver, TextureBackingKind, TextureLike } from '@flighthq/types/contract';
2
+ export declare function registerGlBitmapTextureResolver(state: GlRenderState): void;
3
+ export declare function registerGlCompressedImageTextureResolver(state: GlRenderState): void;
4
+ export declare function registerGlImageTextureResolver(state: GlRenderState): void;
5
+ export declare function registerGlRenderTextureResolver(state: GlRenderState): void;
6
+ export declare function registerGlTextureResolver(state: GlRenderState, backingKind: TextureBackingKind, resolver: GlTextureResolver | null): void;
7
+ export declare function registerGlVideoTextureResolver(state: GlRenderState): void;
8
+ export declare function resolveGlTexture(state: GlRenderState, texture: Readonly<TextureLike>, premultiply?: boolean): WebGLTexture | null;
9
+ //# sourceMappingURL=glTextureResolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glTextureResolver.d.ts","sourceRoot":"","sources":["../src/glTextureResolver.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,aAAa,EACb,iBAAiB,EAGjB,kBAAkB,EAClB,WAAW,EACZ,MAAM,0BAA0B,CAAC;AAkBlC,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAE1E;AAED,wBAAgB,wCAAwC,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAEnF;AAED,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAEzE;AAGD,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAE1E;AAID,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,aAAa,EACpB,WAAW,EAAE,kBAAkB,EAC/B,QAAQ,EAAE,iBAAiB,GAAG,IAAI,GACjC,IAAI,CAKN;AAGD,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAEzE;AAOD,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,QAAQ,CAAC,WAAW,CAAC,EAC9B,WAAW,UAAQ,GAClB,YAAY,GAAG,IAAI,CAMrB"}
@@ -0,0 +1,68 @@
1
+ import { getTextureBackingKind } from '@flighthq/texture/contract';
2
+ import { BitmapTextureBackingKind, CompressedImageTextureBackingKind, ImageTextureBackingKind, RenderTextureBackingKind, VideoTextureBackingKind, } from '@flighthq/types/contract';
3
+ import { bindGlBitmapTexture, bindGlCompressedImageTexture, bindGlImageResourceTexture, bindGlVideoTexture, } from './glDraw';
4
+ import { getGlRenderStateRuntime } from './glRenderState';
5
+ import { bindGlRenderTexture } from './glRenderTexture';
6
+ export function registerGlBitmapTextureResolver(state) {
7
+ registerGlTextureResolver(state, BitmapTextureBackingKind, resolveGlBitmapTexture);
8
+ }
9
+ export function registerGlCompressedImageTextureResolver(state) {
10
+ registerGlTextureResolver(state, CompressedImageTextureBackingKind, resolveGlCompressedImageTexture);
11
+ }
12
+ export function registerGlImageTextureResolver(state) {
13
+ registerGlTextureResolver(state, ImageTextureBackingKind, resolveGlImageTexture);
14
+ }
15
+ // Installs the render-target realization.
16
+ export function registerGlRenderTextureResolver(state) {
17
+ registerGlTextureResolver(state, RenderTextureBackingKind, resolveGlRenderTexture);
18
+ }
19
+ // Registers or replaces one declared backing-kind resolver on this render state. Map.set is
20
+ // last-write-wins; passing null removes the key. No registration ordering or matcher scan exists.
21
+ export function registerGlTextureResolver(state, backingKind, resolver) {
22
+ const runtime = getGlRenderStateRuntime(state);
23
+ const registry = (runtime.glTextureResolverRegistry ??= new Map());
24
+ if (resolver === null)
25
+ registry.delete(backingKind);
26
+ else
27
+ registry.set(backingKind, resolver);
28
+ }
29
+ // Installs the dynamic host-video specialization.
30
+ export function registerGlVideoTextureResolver(state) {
31
+ registerGlTextureResolver(state, VideoTextureBackingKind, resolveGlVideoTexture);
32
+ }
33
+ // Resolves through one keyed lookup using the backing's declared kind. Resolution is deliberately not
34
+ // pure: each built-in resolver leaves its result bound to TEXTURE_2D on the active texture unit because
35
+ // GL upload and sampler application require that binding. Callers must not reorder this call across
36
+ // activeTexture/bind operations as though it only returned a handle. The CPU backing owns its kind; a
37
+ // GPU-origin target owns its own. An unbound or undeclared backing is the null sentinel.
38
+ export function resolveGlTexture(state, texture, premultiply = false) {
39
+ const registry = getGlRenderStateRuntime(state).glTextureResolverRegistry;
40
+ if (registry == null)
41
+ return null;
42
+ const backingKind = getTextureBackingKind(texture);
43
+ if (backingKind === null)
44
+ return null;
45
+ return registry.get(backingKind)?.(state, texture, premultiply) ?? null;
46
+ }
47
+ function resolveGlBitmapTexture(state, texture, premultiply) {
48
+ const bitmap = texture.storage.image;
49
+ return bitmap === null ? null : bindGlBitmapTexture(state, bitmap, texture.sampler, null, premultiply);
50
+ }
51
+ function resolveGlCompressedImageTexture(state, texture) {
52
+ const image = texture.storage.image;
53
+ return image === null ? null : bindGlCompressedImageTexture(state, image, texture.sampler);
54
+ }
55
+ function resolveGlImageTexture(state, texture, premultiply) {
56
+ const image = texture.storage.image;
57
+ return image === null ? null : bindGlImageResourceTexture(state, image, texture.sampler, null, premultiply);
58
+ }
59
+ function resolveGlRenderTexture(state, texture) {
60
+ return bindGlRenderTexture(state, texture);
61
+ }
62
+ function resolveGlVideoTexture(state, texture) {
63
+ const source = texture.storage.image?.source;
64
+ if (source == null || source.readyState < 2 || source.videoWidth <= 0 || source.videoHeight <= 0)
65
+ return null;
66
+ return bindGlVideoTexture(state, texture);
67
+ }
68
+ //# sourceMappingURL=glTextureResolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glTextureResolver.js","sourceRoot":"","sources":["../src/glTextureResolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAWnE,OAAO,EACL,wBAAwB,EACxB,iCAAiC,EACjC,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,mBAAmB,EACnB,4BAA4B,EAC5B,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE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E,WAAW,CAAC,CAAC;AAC9G,CAAC;AAED,SAAS,sBAAsB,CAAC,KAAoB,EAAE,OAA8B;IAClF,OAAO,mBAAmB,CAAC,KAAK,EAAE,OAAkC,CAAC,CAAC;AACxE,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAoB,EAAE,OAA8B;IACjF,MAAM,MAAM,GAAI,OAAO,CAAC,OAAO,CAAC,KAAwC,EAAE,MAG7D,CAAC;IACd,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC,UAAU,GAAG,CAAC,IAAI,MAAM,CAAC,UAAU,IAAI,CAAC,IAAI,MAAM,CAAC,WAAW,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAC9G,OAAO,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { ImageResource } from '@flighthq/types';
1
+ import type { ImageResource } from '@flighthq/types/contract';
2
2
  export declare function uploadGlTextureData(gl: WebGL2RenderingContext, target: number, width: number, height: number, data: Readonly<Uint8ClampedArray<ArrayBuffer>>): void;
3
3
  export declare function uploadGlTextureElement(gl: WebGL2RenderingContext, target: number, source: TexImageSource): void;
4
4
  export declare function uploadGlTextureImageResource(gl: WebGL2RenderingContext, target: number, image: Readonly<ImageResource>): void;
@@ -1 +1 @@
1
- {"version":3,"file":"glTextureUpload.d.ts","sourceRoot":"","sources":["../src/glTextureUpload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAWrD,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,sBAAsB,EAC1B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,QAAQ,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC,GAC7C,IAAI,CAYN;AAID,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,sBAAsB,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAE/G;AAMD,wBAAgB,4BAA4B,CAC1C,EAAE,EAAE,sBAAsB,EAC1B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,QAAQ,CAAC,aAAa,CAAC,GAC7B,IAAI,CAGN"}
1
+ {"version":3,"file":"glTextureUpload.d.ts","sourceRoot":"","sources":["../src/glTextureUpload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAW9D,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,sBAAsB,EAC1B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,QAAQ,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC,GAC7C,IAAI,CAYN;AAID,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,sBAAsB,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAE/G;AAGD,wBAAgB,4BAA4B,CAC1C,EAAE,EAAE,sBAAsB,EAC1B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,QAAQ,CAAC,aAAa,CAAC,GAC7B,IAAI,CAEN"}
@@ -3,7 +3,7 @@
3
3
  // no sampler or pixel-store state: premultiply, wrap, and filter are the caller's policy applied around
4
4
  // the call, so one primitive serves both the premultiplied 2D sprite path and the raw-radiance cube path.
5
5
  // The caller owns creating and binding the texture and choosing the target.
6
- // Uploads raw CPU pixels (rgba8, straight from a Surface's `data`) through the ArrayBufferView overload.
6
+ // Uploads raw CPU pixels (rgba8, straight from a Bitmap's `data`) through the ArrayBufferView overload.
7
7
  // The portable bedrock upload — no web types in the signature — so a native GL/Vulkan backend reimplements
8
8
  // it 1:1. `width`/`height` are the pixel dimensions the data fills.
9
9
  export function uploadGlTextureData(gl, target, width, height, data) {
@@ -14,14 +14,8 @@ export function uploadGlTextureData(gl, target, width, height, data) {
14
14
  export function uploadGlTextureElement(gl, target, source) {
15
15
  gl.texImage2D(target, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
16
16
  }
17
- // Dispatches an ImageResource to whichever representation it carries: the element fast-path when a decoded
18
- // `source` is present, else the portable `data` path (a generated Surface). The seam that makes data-backed
19
- // resources first-class — the same texture uploads whether it was loaded (element) or generated in memory
20
- // (data). Assumes the resource has pixels in at least one form.
17
+ // Uploads a host-backed ImageResource through the decoded-element fast path.
21
18
  export function uploadGlTextureImageResource(gl, target, image) {
22
- if (image.source !== null)
23
- uploadGlTextureElement(gl, target, image.source);
24
- else
25
- uploadGlTextureData(gl, target, image.width, image.height, image.data);
19
+ uploadGlTextureElement(gl, target, image.source);
26
20
  }
27
21
  //# sourceMappingURL=glTextureUpload.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"glTextureUpload.js","sourceRoot":"","sources":["../src/glTextureUpload.ts"],"names":[],"mappings":"AAEA,uGAAuG;AACvG,yGAAyG;AACzG,wGAAwG;AACxG,0GAA0G;AAC1G,4EAA4E;AAE5E,yGAAyG;AACzG,2GAA2G;AAC3G,oEAAoE;AACpE,MAAM,UAAU,mBAAmB,CACjC,EAA0B,EAC1B,MAAc,EACd,KAAa,EACb,MAAc,EACd,IAA8C;IAE9C,EAAE,CAAC,UAAU,CACX,MAAM,EACN,CAAC,EACD,EAAE,CAAC,IAAI,EACP,KAAK,EACL,MAAM,EACN,CAAC,EACD,EAAE,CAAC,IAAI,EACP,EAAE,CAAC,aAAa,EAChB,IAAsC,CACvC,CAAC;AACJ,CAAC;AAED,oGAAoG;AACpG,2GAA2G;AAC3G,MAAM,UAAU,sBAAsB,CAAC,EAA0B,EAAE,MAAc,EAAE,MAAsB;IACvG,EAAE,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;AACvE,CAAC;AAED,2GA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MAAwB,CAAC,CAAC;AACrE,CAAC"}
@@ -1,3 +1,3 @@
1
- import type { VideoTexture } from '@flighthq/types';
2
- export declare function uploadGlTextureVideoFrame(gl: WebGL2RenderingContext, videoTexture: Readonly<VideoTexture>, uploadedFrameId: number): number;
1
+ import type { ImageResource } from '@flighthq/types/contract';
2
+ export declare function uploadGlTextureVideoFrame(gl: WebGL2RenderingContext, image: Readonly<ImageResource>, uploadedVersion: number): number;
3
3
  //# sourceMappingURL=glTextureVideoUpload.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"glTextureVideoUpload.d.ts","sourceRoot":"","sources":["../src/glTextureVideoUpload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAcpD,wBAAgB,yBAAyB,CACvC,EAAE,EAAE,sBAAsB,EAC1B,YAAY,EAAE,QAAQ,CAAC,YAAY,CAAC,EACpC,eAAe,EAAE,MAAM,GACtB,MAAM,CAUR"}
1
+ {"version":3,"file":"glTextureVideoUpload.d.ts","sourceRoot":"","sources":["../src/glTextureVideoUpload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAc9D,wBAAgB,yBAAyB,CACvC,EAAE,EAAE,sBAAsB,EAC1B,KAAK,EAAE,QAAQ,CAAC,aAAa,CAAC,EAC9B,eAAe,EAAE,MAAM,GACtB,MAAM,CAUR"}
@@ -1,24 +1,24 @@
1
1
  import { uploadGlTextureElement } from './glTextureUpload';
2
- // The per-frame video-to-GPU upload path. A VideoTexture's backing HTMLVideoElement decodes new pixels
2
+ // The per-frame video-to-GPU upload path. An ImageResource's borrowed HTMLVideoElement decodes new pixels
3
3
  // continuously, so a driver re-uploads the currently-bound GL texture whenever the element's frame
4
4
  // advances — but not on frames where nothing changed (a paused or stalled stream), which would waste a
5
- // full-frame DMA. `uploadedFrameId` is the id the caller last uploaded; this compares it to the
6
- // VideoTexture's `frameId` and re-uploads through the element fast-path only on a change, returning the
5
+ // full-frame DMA. `uploadedVersion` is the backing revision the caller last uploaded; this compares it to the
6
+ // backing's `version` and re-uploads through the element fast-path only on a change, returning the
7
7
  // id now on the GPU so the caller stores it for the next frame.
8
8
  //
9
9
  // The caller owns creating, binding, and setting sampler/pixel-store state on the texture; this writes
10
- // level 0 at gl.TEXTURE_2D. Returns `uploadedFrameId` unchanged (no GL call) when the frame has not
10
+ // level 0 at gl.TEXTURE_2D. Returns `uploadedVersion` unchanged (no GL call) when the frame has not
11
11
  // advanced or the element has no decoded frame yet, so it is safe to call every frame unconditionally.
12
- export function uploadGlTextureVideoFrame(gl, videoTexture, uploadedFrameId) {
13
- if (videoTexture.frameId === uploadedFrameId)
14
- return uploadedFrameId;
15
- const element = videoTexture.source.element;
12
+ export function uploadGlTextureVideoFrame(gl, image, uploadedVersion) {
13
+ if (image.version === uploadedVersion)
14
+ return uploadedVersion;
15
+ const element = image.source;
16
16
  // A first-frame guard: HAVE_CURRENT_DATA (2) with non-zero dimensions. texImage2D on an element with
17
17
  // no decoded frame throws in some browsers, so skip until a frame exists and report no upload.
18
18
  if (element === null || element.readyState < 2 || element.videoWidth <= 0 || element.videoHeight <= 0) {
19
- return uploadedFrameId;
19
+ return uploadedVersion;
20
20
  }
21
21
  uploadGlTextureElement(gl, gl.TEXTURE_2D, element);
22
- return videoTexture.frameId;
22
+ return image.version;
23
23
  }
24
24
  //# sourceMappingURL=glTextureVideoUpload.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"glTextureVideoUpload.js","sourceRoot":"","sources":["../src/glTextureVideoUpload.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,uGAAuG;AACvG,mGAAmG;AACnG,uGAAuG;AACvG,gGAAgG;AAChG,wGAAwG;AACxG,gEAAgE;AAChE,EAAE;AACF,uGAAuG;AACvG,oGAAoG;AACpG,uGAAuG;AACvG,MAAM,UAAU,yBAAyB,CACvC,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,UAAU,EAAE,OAAoC,CAAC,CAAC;IAChF,OAAO,KAAK,CAAC,OAAO,CAAC;AACvB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,20 +1,2 @@
1
- export * from './glBackground';
2
- export * from './glCompressedTexture';
3
- export * from './glDraw';
4
- export * from './glElement';
5
- export * from './glFullscreenPass';
6
- export * from './glLinearToSrgbPass';
7
- export * from './glMaterialRegistry';
8
- export * from './glPresentRenderTarget';
9
- export * from './glProgram';
10
- export * from './glReadback';
11
- export * from './glRenderPass';
12
- export * from './glRenderState';
13
- export * from './glRenderTarget';
14
- export * from './glRenderTargetPool';
15
- export * from './glShader';
16
- export * from './glShaderBinding';
17
- export * from './glSkinPaletteTexture';
18
- export * from './glTextureUpload';
19
- export * from './glTextureVideoUpload';
1
+ export { beginGlRenderPass, bindGlImageResourceTexture, bindGlRenderTexture, bindGlTexture, createGlCanvasElement, createExternalGlTexture, createGlRenderState, createGlRenderTarget, destroyGlRenderTexture, disposeExternalGlTexture, enableGlRenderTextureGuards, enableGlBlendModeSupport, endGlRenderPass, explainGlRenderTexture, registerGlBitmapTextureResolver, registerGlCompressedTextureDecoder, registerGlCompressedImageTextureResolver, registerGlCompressedTextureUpload, registerGlImageTextureResolver, registerGlRenderTextureResolver, registerGlTextureResolver, registerGlVideoTextureResolver, renderGlBackground, renderIntoGlRenderTexture, resolveGlTexture, uploadGlCompressedTextureContainer, } from './contract';
20
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,aAAa,EACb,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,2BAA2B,EAC3B,wBAAwB,EACxB,eAAe,EACf,sBAAsB,EACtB,+BAA+B,EAC/B,kCAAkC,EAClC,wCAAwC,EACxC,iCAAiC,EACjC,8BAA8B,EAC9B,+BAA+B,EAC/B,yBAAyB,EACzB,8BAA8B,EAC9B,kBAAkB,EAClB,yBAAyB,EACzB,gBAAgB,EAChB,kCAAkC,GACnC,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -1,20 +1,2 @@
1
- export * from './glBackground';
2
- export * from './glCompressedTexture';
3
- export * from './glDraw';
4
- export * from './glElement';
5
- export * from './glFullscreenPass';
6
- export * from './glLinearToSrgbPass';
7
- export * from './glMaterialRegistry';
8
- export * from './glPresentRenderTarget';
9
- export * from './glProgram';
10
- export * from './glReadback';
11
- export * from './glRenderPass';
12
- export * from './glRenderState';
13
- export * from './glRenderTarget';
14
- export * from './glRenderTargetPool';
15
- export * from './glShader';
16
- export * from './glShaderBinding';
17
- export * from './glSkinPaletteTexture';
18
- export * from './glTextureUpload';
19
- export * from './glTextureVideoUpload';
1
+ export { beginGlRenderPass, bindGlImageResourceTexture, bindGlRenderTexture, bindGlTexture, createGlCanvasElement, createExternalGlTexture, createGlRenderState, createGlRenderTarget, destroyGlRenderTexture, disposeExternalGlTexture, enableGlRenderTextureGuards, enableGlBlendModeSupport, endGlRenderPass, explainGlRenderTexture, registerGlBitmapTextureResolver, registerGlCompressedTextureDecoder, registerGlCompressedImageTextureResolver, registerGlCompressedTextureUpload, registerGlImageTextureResolver, registerGlRenderTextureResolver, registerGlTextureResolver, registerGlVideoTextureResolver, renderGlBackground, renderIntoGlRenderTexture, resolveGlTexture, uploadGlCompressedTextureContainer, } from './contract';
20
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,aAAa,EACb,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,2BAA2B,EAC3B,wBAAwB,EACxB,eAAe,EACf,sBAAsB,EACtB,+BAA+B,EAC/B,kCAAkC,EAClC,wCAAwC,EACxC,iCAAiC,EACjC,8BAA8B,EAC9B,+BAA+B,EAC/B,yBAAyB,EACzB,8BAA8B,EAC9B,kBAAkB,EAClB,yBAAyB,EACzB,gBAAgB,EAChB,kCAAkC,GACnC,MAAM,YAAY,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flighthq/render-gl",
3
- "version": "0.2.1-next.841.373388f",
3
+ "version": "0.3.0-next.1032.e2b99fc",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/flighthq/flight.git",
@@ -13,6 +13,10 @@
13
13
  ".": {
14
14
  "types": "./dist/index.d.ts",
15
15
  "default": "./dist/index.js"
16
+ },
17
+ "./contract": {
18
+ "types": "./dist/contract.d.ts",
19
+ "default": "./dist/contract.js"
16
20
  }
17
21
  },
18
22
  "files": [
@@ -32,10 +36,12 @@
32
36
  "clean:dist": "tsx ../../scripts/clean-package-dist.ts"
33
37
  },
34
38
  "dependencies": {
35
- "@flighthq/scene2d": "0.2.1-next.841.373388f",
36
- "@flighthq/geometry": "0.2.1-next.841.373388f",
37
- "@flighthq/render": "0.2.1-next.841.373388f",
38
- "@flighthq/types": "0.2.1-next.841.373388f"
39
+ "@flighthq/log": "0.3.0-next.1032.e2b99fc",
40
+ "@flighthq/scene2d": "0.3.0-next.1032.e2b99fc",
41
+ "@flighthq/geometry": "0.3.0-next.1032.e2b99fc",
42
+ "@flighthq/render": "0.3.0-next.1032.e2b99fc",
43
+ "@flighthq/texture": "0.3.0-next.1032.e2b99fc",
44
+ "@flighthq/types": "0.3.0-next.1032.e2b99fc"
39
45
  },
40
46
  "devDependencies": {
41
47
  "typescript": "^5.3.0"
@@ -0,0 +1,22 @@
1
+ import { areGlRenderTextureGuardsEnabled, enableGlRenderTextureGuards } from './enableGlRenderTextureGuards';
2
+ import { createGlState } from './glTestHelper';
3
+
4
+ describe('areGlRenderTextureGuardsEnabled', () => {
5
+ it('reports whether diagnostics were installed for the context', () => {
6
+ const { state } = createGlState();
7
+ expect(areGlRenderTextureGuardsEnabled(state)).toBe(false);
8
+
9
+ enableGlRenderTextureGuards(state);
10
+
11
+ expect(areGlRenderTextureGuardsEnabled(state)).toBe(true);
12
+ });
13
+ });
14
+
15
+ describe('enableGlRenderTextureGuards', () => {
16
+ it('is idempotent', () => {
17
+ const { state } = createGlState();
18
+ enableGlRenderTextureGuards(state);
19
+ enableGlRenderTextureGuards(state);
20
+ expect(areGlRenderTextureGuardsEnabled(state)).toBe(true);
21
+ });
22
+ });
@@ -1,4 +1,4 @@
1
- import { BlendMode } from '@flighthq/types';
1
+ import { BlendMode } from '@flighthq/types/contract';
2
2
 
3
3
  import { renderGlBackground } from './glBackground';
4
4
  import { getGlRenderStateRuntime } from './glRenderState';
@@ -29,6 +29,15 @@ describe('renderGlBackground', () => {
29
29
  expect(gl.clear).toHaveBeenCalledWith((gl as unknown as { COLOR_BUFFER_BIT: number }).COLOR_BUFFER_BIT);
30
30
  });
31
31
 
32
+ it('preserves an active partial-target viewport origin', () => {
33
+ const { state, gl } = createGlState();
34
+ getGlRenderStateRuntime(state).renderTargetViewport = { height: 40, width: 30, x: 10, y: 20 };
35
+
36
+ renderGlBackground(state);
37
+
38
+ expect(gl.viewport).toHaveBeenLastCalledWith(10, 20, 30, 40);
39
+ });
40
+
32
41
  it('resets currentBlendMode to null', () => {
33
42
  const { state } = createGlState();
34
43
  const runtime = getGlRenderStateRuntime(state);
@@ -1,4 +1,5 @@
1
- import type { GlCompressedTextureSupport, ImageResource, TextureContainer } from '@flighthq/types';
1
+ import type { CompressedImage, GlCompressedTextureSupport, TextureContainer } from '@flighthq/types/contract';
2
+ import { CompressedImageTextureBackingKind } from '@flighthq/types/contract';
2
3
 
3
4
  import {
4
5
  detectGlCompressedTextureSupport,
@@ -46,17 +47,14 @@ function makeContainer(): TextureContainer {
46
47
  };
47
48
  }
48
49
 
49
- // A compressed-only ImageResource wrapping makeContainer, for exercising the installed upload seam.
50
- function uploadableCompressedImage(containerOverrides?: Partial<TextureContainer>): ImageResource {
50
+ function uploadableCompressedImage(containerOverrides?: Partial<TextureContainer>): CompressedImage {
51
51
  return {
52
- source: null,
53
- data: null,
54
52
  compressed: { container: { ...makeContainer(), ...containerOverrides }, payload: new Uint8Array(16) },
55
- width: 4,
56
53
  height: 4,
54
+ kind: CompressedImageTextureBackingKind,
57
55
  version: 1,
58
- alphaType: 'straight',
59
- } as unknown as ImageResource;
56
+ width: 4,
57
+ } as unknown as CompressedImage;
60
58
  }
61
59
 
62
60
  describe('detectGlCompressedTextureSupport', () => {
@@ -140,7 +138,7 @@ describe('registerGlCompressedTextureUpload', () => {
140
138
  expect(getGlRenderStateRuntime(state).compressedTextureUpload).toBeNull();
141
139
  });
142
140
 
143
- it('uploads a compressed-only ImageResource once installed, threading the registered decoder', () => {
141
+ it('uploads a CompressedImage once installed, threading the registered decoder', () => {
144
142
  const { state, gl } = createGlState();
145
143
  const rgba = new Uint8ClampedArray(4 * 4 * 4);
146
144
  const decode = vi.fn(() => rgba);
@@ -152,14 +150,6 @@ describe('registerGlCompressedTextureUpload', () => {
152
150
  expect(decode).toHaveBeenCalledWith('bc3', 4, 4, expect.any(Uint8Array));
153
151
  });
154
152
 
155
- it('reports false for a resource with no compressed payload', () => {
156
- const { state, gl } = createGlState();
157
- registerGlCompressedTextureUpload(state);
158
- const uploader = getGlRenderStateRuntime(state).compressedTextureUpload!;
159
- const plain = { source: null, data: null, compressed: null } as unknown as ImageResource;
160
- expect(uploader(gl, plain, null)).toBe(false);
161
- });
162
-
163
153
  it('rejects non-2D containers because the installed image bridge is bound to TEXTURE_2D', () => {
164
154
  const { state } = createGlState();
165
155
  registerGlCompressedTextureUpload(state);