@flighthq/render-gl 0.5.0-next.1944.cd6b6e7 → 0.5.1-edge.638.d4dbd4e
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.
- package/README.md +2 -2
- package/dist/contract.d.ts +2 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +2 -0
- package/dist/contract.js.map +1 -1
- package/dist/enableGlRenderStateGuards.js +1 -1
- package/dist/enableGlRenderStateGuards.js.map +1 -1
- package/dist/enableGlRenderTextureGuards.d.ts.map +1 -1
- package/dist/enableGlRenderTextureGuards.js.map +1 -1
- package/dist/glBackground.js +2 -2
- package/dist/glBackground.js.map +1 -1
- package/dist/glCompressedTexture.d.ts +4 -4
- package/dist/glCompressedTexture.d.ts.map +1 -1
- package/dist/glCompressedTexture.js.map +1 -1
- package/dist/glContext.d.ts +3 -0
- package/dist/glContext.d.ts.map +1 -0
- package/dist/glContext.js +16 -0
- package/dist/glContext.js.map +1 -0
- package/dist/glDraw.d.ts +4 -1
- package/dist/glDraw.d.ts.map +1 -1
- package/dist/glDraw.js +75 -65
- package/dist/glDraw.js.map +1 -1
- package/dist/glElement.d.ts +8 -0
- package/dist/glElement.d.ts.map +1 -1
- package/dist/glElement.js +20 -6
- package/dist/glElement.js.map +1 -1
- package/dist/glExternalTexture.d.ts.map +1 -1
- package/dist/glExternalTexture.js +8 -6
- package/dist/glExternalTexture.js.map +1 -1
- package/dist/glFullscreenPass.d.ts +3 -3
- package/dist/glFullscreenPass.d.ts.map +1 -1
- package/dist/glFullscreenPass.js +58 -17
- package/dist/glFullscreenPass.js.map +1 -1
- package/dist/glLinearToSrgbPass.d.ts.map +1 -1
- package/dist/glLinearToSrgbPass.js.map +1 -1
- package/dist/glPipeline.d.ts +5 -0
- package/dist/glPipeline.d.ts.map +1 -0
- package/dist/glPipeline.js +33 -0
- package/dist/glPipeline.js.map +1 -0
- package/dist/glPresentRenderTarget.d.ts.map +1 -1
- package/dist/glPresentRenderTarget.js.map +1 -1
- package/dist/glProgram.d.ts +4 -3
- package/dist/glProgram.d.ts.map +1 -1
- package/dist/glProgram.js.map +1 -1
- package/dist/glRenderPass.d.ts.map +1 -1
- package/dist/glRenderPass.js +5 -6
- package/dist/glRenderPass.js.map +1 -1
- package/dist/glRenderState.d.ts +8 -13
- package/dist/glRenderState.d.ts.map +1 -1
- package/dist/glRenderState.js +93 -253
- package/dist/glRenderState.js.map +1 -1
- package/dist/glRenderStateBracket.d.ts.map +1 -1
- package/dist/glRenderStateBracket.js +14 -10
- package/dist/glRenderStateBracket.js.map +1 -1
- package/dist/glRenderTarget.d.ts.map +1 -1
- package/dist/glRenderTarget.js +10 -12
- package/dist/glRenderTarget.js.map +1 -1
- package/dist/glRenderTexture.d.ts.map +1 -1
- package/dist/glRenderTexture.js +6 -11
- package/dist/glRenderTexture.js.map +1 -1
- package/dist/glShader.d.ts +9 -15
- package/dist/glShader.d.ts.map +1 -1
- package/dist/glShader.js +8 -9
- package/dist/glShader.js.map +1 -1
- package/dist/glSkinPaletteTexture.d.ts +4 -4
- package/dist/glSkinPaletteTexture.d.ts.map +1 -1
- package/dist/glSkinPaletteTexture.js.map +1 -1
- package/dist/glTestHelper.d.ts +1 -1
- package/dist/glTestHelper.d.ts.map +1 -1
- package/dist/glTestHelper.js +28 -21
- package/dist/glTestHelper.js.map +1 -1
- package/dist/glTextureResolver.d.ts +4 -1
- package/dist/glTextureResolver.d.ts.map +1 -1
- package/dist/glTextureResolver.js +30 -13
- package/dist/glTextureResolver.js.map +1 -1
- package/dist/glTextureUpload.d.ts +4 -4
- package/dist/glTextureUpload.d.ts.map +1 -1
- package/dist/glTextureUpload.js.map +1 -1
- package/dist/glTextureVideoUpload.d.ts +2 -2
- package/dist/glTextureVideoUpload.d.ts.map +1 -1
- package/dist/glTextureVideoUpload.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
- package/src/enableGlRenderStateGuards.test.ts +5 -2
- package/src/enableGlTextureResolverGuards.test.ts +1 -1
- package/src/glBackground.test.ts +3 -4
- package/src/glContext.test.ts +83 -0
- package/src/glDraw.test.ts +150 -43
- package/src/glElement.test.ts +153 -24
- package/src/glExternalTexture.test.ts +13 -0
- package/src/glFullscreenPass.test.ts +143 -7
- package/src/glPipeline.test.ts +96 -0
- package/src/glReadback.test.ts +1 -1
- package/src/glRenderPass.test.ts +12 -14
- package/src/glRenderState.test.ts +400 -179
- package/src/glRenderStateBracket.test.ts +39 -14
- package/src/glRenderTarget.test.ts +3 -3
- package/src/glRenderTexture.test.ts +2 -2
- package/src/glShader.test.ts +15 -11
- package/src/glTextureResolver.test.ts +24 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glTextureResolver.js","sourceRoot":"","sources":["../src/glTextureResolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"glTextureResolver.js","sourceRoot":"","sources":["../src/glTextureResolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAClH,OAAO,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAchH,OAAO,EACL,uBAAuB,EACvB,gCAAgC,EAChC,sBAAsB,EACtB,cAAc,EACd,kBAAkB,EAClB,6BAA6B,GAC9B,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,mBAAmB,EACnB,4BAA4B,EAC5B,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,MAAM,UAAU,+BAA+B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ighthq/types/contract';
|
|
2
|
-
export declare function uploadGlTextureData(gl:
|
|
3
|
-
export declare function uploadGlTextureElement(gl:
|
|
4
|
-
export declare function uploadGlTextureImageResource(gl:
|
|
1
|
+
import type { GlContext, Image } from '@flighthq/types/contract';
|
|
2
|
+
export declare function uploadGlTextureData(gl: GlContext, target: number, width: number, height: number, data: Readonly<Uint8ClampedArray<ArrayBuffer>>, internalFormat?: number): void;
|
|
3
|
+
export declare function uploadGlTextureElement(gl: GlContext, target: number, source: TexImageSource, internalFormat?: number): void;
|
|
4
|
+
export declare function uploadGlTextureImageResource(gl: GlContext, target: number, image: Readonly<Image>, internalFormat?: number): void;
|
|
5
5
|
//# sourceMappingURL=glTextureUpload.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glTextureUpload.d.ts","sourceRoot":"","sources":["../src/glTextureUpload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"glTextureUpload.d.ts","sourceRoot":"","sources":["../src/glTextureUpload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAWjE,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,SAAS,EACb,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,QAAQ,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC,EAC9C,cAAc,GAAE,MAAgB,GAC/B,IAAI,CAYN;AAID,wBAAgB,sBAAsB,CACpC,EAAE,EAAE,SAAS,EACb,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,cAAc,EACtB,cAAc,GAAE,MAAgB,GAC/B,IAAI,CAEN;AAGD,wBAAgB,4BAA4B,CAC1C,EAAE,EAAE,SAAS,EACb,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,EACtB,cAAc,GAAE,MAAgB,GAC/B,IAAI,CAEN"}
|
|
@@ -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,wGAAwG;AACxG,2GAA2G;AAC3G,oEAAoE;AACpE,MAAM,UAAU,mBAAmB,CACjC,
|
|
1
|
+
{"version":3,"file":"glTextureUpload.js","sourceRoot":"","sources":["../src/glTextureUpload.ts"],"names":[],"mappings":"AAEA,uGAAuG;AACvG,yGAAyG;AACzG,wGAAwG;AACxG,0GAA0G;AAC1G,4EAA4E;AAE5E,wGAAwG;AACxG,2GAA2G;AAC3G,oEAAoE;AACpE,MAAM,UAAU,mBAAmB,CACjC,EAAa,EACb,MAAc,EACd,KAAa,EACb,MAAc,EACd,IAA8C,EAC9C,iBAAyB,EAAE,CAAC,IAAI;IAEhC,EAAE,CAAC,UAAU,CACX,MAAM,EACN,CAAC,EACD,cAAc,EACd,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,CACpC,EAAa,EACb,MAAc,EACd,MAAsB,EACtB,iBAAyB,EAAE,CAAC,IAAI;IAEhC,EAAE,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,cAAc,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;AAC9E,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,4BAA4B,CAC1C,EAAa,EACb,MAAc,EACd,KAAsB,EACtB,iBAAyB,EAAE,CAAC,IAAI;IAEhC,sBAAsB,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,MAAwB,EAAE,cAAc,CAAC,CAAC;AACrF,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Image } from '@flighthq/types/contract';
|
|
2
|
-
export declare function uploadGlTextureVideoFrame(gl:
|
|
1
|
+
import type { GlContext, Image } from '@flighthq/types/contract';
|
|
2
|
+
export declare function uploadGlTextureVideoFrame(gl: GlContext, image: Readonly<Image>, uploadedVersion: number, internalFormat?: 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,KAAK,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"glTextureVideoUpload.d.ts","sourceRoot":"","sources":["../src/glTextureVideoUpload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAcjE,wBAAgB,yBAAyB,CACvC,EAAE,EAAE,SAAS,EACb,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,EACtB,eAAe,EAAE,MAAM,EACvB,cAAc,GAAE,MAAgB,GAC/B,MAAM,CAUR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glTextureVideoUpload.js","sourceRoot":"","sources":["../src/glTextureVideoUpload.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,kGAAkG;AAClG,mGAAmG;AACnG,uGAAuG;AACvG,6GAA6G;AAC7G,kGAAkG;AAClG,gEAAgE;AAChE,EAAE;AACF,uGAAuG;AACvG,oGAAoG;AACpG,uGAAuG;AACvG,MAAM,UAAU,yBAAyB,CACvC,
|
|
1
|
+
{"version":3,"file":"glTextureVideoUpload.js","sourceRoot":"","sources":["../src/glTextureVideoUpload.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,kGAAkG;AAClG,mGAAmG;AACnG,uGAAuG;AACvG,6GAA6G;AAC7G,kGAAkG;AAClG,gEAAgE;AAChE,EAAE;AACF,uGAAuG;AACvG,oGAAoG;AACpG,uGAAuG;AACvG,MAAM,UAAU,yBAAyB,CACvC,EAAa,EACb,KAAsB,EACtB,eAAuB,EACvB,iBAAyB,EAAE,CAAC,IAAI;IAEhC,IAAI,KAAK,CAAC,OAAO,KAAK,eAAe;QAAE,OAAO,eAAe,CAAC;IAC9D,MAAM,OAAO,GAAG,KAAK,CAAC,MAAiC,CAAC;IACxD,qGAAqG;IACrG,+FAA+F;IAC/F,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,CAAC,UAAU,GAAG,CAAC,IAAI,OAAO,CAAC,UAAU,IAAI,CAAC,IAAI,OAAO,CAAC,WAAW,IAAI,CAAC,EAAE,CAAC;QACtG,OAAO,eAAe,CAAC;IACzB,CAAC;IACD,sBAAsB,CAAC,EAAE,EAAE,EAAE,CAAC,UAAU,EAAE,OAAoC,EAAE,cAAc,CAAC,CAAC;IAChG,OAAO,KAAK,CAAC,OAAO,CAAC;AACvB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { acquireGlRenderTexture, beginGlRenderPass, bindGlImageResourceTexture, bindGlRenderTexture, bindGlTexture, clearGlRenderTexture,
|
|
1
|
+
export { acquireGlRenderTexture, beginGlRenderPass, bindGlImageResourceTexture, bindGlRenderTexture, bindGlTexture, clearGlRenderTexture, createGlCanvasElement, createGlRenderSurface, createExternalGlTexture, createGlOffscreenRenderState, createGlContextFromCanvasElement, createEmptyGlRegistries, createGlContextState, createGlPipeline, createGlRenderState, createGlRenderTexturePool, createGlRenderTarget, destroyGlRenderTarget, destroyGlRenderTexture, destroyGlRenderTexturePool, destroyGlRenderState, disposeExternalGlTexture, enableGlRenderTextureGuards, enableGlRenderStateGuards, enableGlTextureResolverGuards, enableGlBlendModeSupport, endGlRenderPass, explainGlRenderSurfaceAbsence, explainGlRenderTarget, explainGlRenderTexture, explainGlTextureResolution, getGlPipelineRegistries, isGlRenderTargetFormatSupported, registerGlBitmapTextureResolver, registerGlCompressedTextureDecoder, registerGlCompressedImageTextureResolver, registerGlCompressedTextureUpload, registerGlImageTextureResolver, registerGlRenderTextureResolver, registerStandardGlTextureResolvers, registerGlTextureResolver, presentGlRenderTarget, renderGlBackground, renderIntoGlRenderTexture, releaseGlRenderTexture, resolveGlRenderTargetAxes, resolveGlTexture, setGlRenderTransform2D, standardGlBlendRealizations, standardGlTextureResolvers, uploadGlCompressedTextureContainer, withGlRenderTextures, } from './contract';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,4BAA4B,EAC5B,gCAAgC,EAChC,uBAAuB,EACvB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,EACzB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,0BAA0B,EAC1B,oBAAoB,EACpB,wBAAwB,EACxB,2BAA2B,EAC3B,yBAAyB,EACzB,6BAA6B,EAC7B,wBAAwB,EACxB,eAAe,EACf,6BAA6B,EAC7B,qBAAqB,EACrB,sBAAsB,EACtB,0BAA0B,EAC1B,uBAAuB,EACvB,+BAA+B,EAC/B,+BAA+B,EAC/B,kCAAkC,EAClC,wCAAwC,EACxC,iCAAiC,EACjC,8BAA8B,EAC9B,+BAA+B,EAC/B,kCAAkC,EAClC,yBAAyB,EACzB,qBAAqB,EACrB,kBAAkB,EAClB,yBAAyB,EACzB,sBAAsB,EACtB,yBAAyB,EACzB,gBAAgB,EAChB,sBAAsB,EACtB,2BAA2B,EAC3B,0BAA0B,EAC1B,kCAAkC,EAClC,oBAAoB,GACrB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { acquireGlRenderTexture, beginGlRenderPass, bindGlImageResourceTexture, bindGlRenderTexture, bindGlTexture, clearGlRenderTexture,
|
|
1
|
+
export { acquireGlRenderTexture, beginGlRenderPass, bindGlImageResourceTexture, bindGlRenderTexture, bindGlTexture, clearGlRenderTexture, createGlCanvasElement, createGlRenderSurface, createExternalGlTexture, createGlOffscreenRenderState, createGlContextFromCanvasElement, createEmptyGlRegistries, createGlContextState, createGlPipeline, createGlRenderState, createGlRenderTexturePool, createGlRenderTarget, destroyGlRenderTarget, destroyGlRenderTexture, destroyGlRenderTexturePool, destroyGlRenderState, disposeExternalGlTexture, enableGlRenderTextureGuards, enableGlRenderStateGuards, enableGlTextureResolverGuards, enableGlBlendModeSupport, endGlRenderPass, explainGlRenderSurfaceAbsence, explainGlRenderTarget, explainGlRenderTexture, explainGlTextureResolution, getGlPipelineRegistries, isGlRenderTargetFormatSupported, registerGlBitmapTextureResolver, registerGlCompressedTextureDecoder, registerGlCompressedImageTextureResolver, registerGlCompressedTextureUpload, registerGlImageTextureResolver, registerGlRenderTextureResolver, registerStandardGlTextureResolvers, registerGlTextureResolver, presentGlRenderTarget, renderGlBackground, renderIntoGlRenderTexture, releaseGlRenderTexture, resolveGlRenderTargetAxes, resolveGlTexture, setGlRenderTransform2D, standardGlBlendRealizations, standardGlTextureResolvers, uploadGlCompressedTextureContainer, withGlRenderTextures, } from './contract';
|
|
2
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,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,4BAA4B,EAC5B,gCAAgC,EAChC,uBAAuB,EACvB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,EACzB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,0BAA0B,EAC1B,oBAAoB,EACpB,wBAAwB,EACxB,2BAA2B,EAC3B,yBAAyB,EACzB,6BAA6B,EAC7B,wBAAwB,EACxB,eAAe,EACf,6BAA6B,EAC7B,qBAAqB,EACrB,sBAAsB,EACtB,0BAA0B,EAC1B,uBAAuB,EACvB,+BAA+B,EAC/B,+BAA+B,EAC/B,kCAAkC,EAClC,wCAAwC,EACxC,iCAAiC,EACjC,8BAA8B,EAC9B,+BAA+B,EAC/B,kCAAkC,EAClC,yBAAyB,EACzB,qBAAqB,EACrB,kBAAkB,EAClB,yBAAyB,EACzB,sBAAsB,EACtB,yBAAyB,EACzB,gBAAgB,EAChB,sBAAsB,EACtB,2BAA2B,EAC3B,0BAA0B,EAC1B,kCAAkC,EAClC,oBAAoB,GACrB,MAAM,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/render-gl",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1-edge.638.d4dbd4e",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,16 +38,16 @@
|
|
|
38
38
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@flighthq/color": "0.5.
|
|
42
|
-
"@flighthq/entity": "0.5.
|
|
43
|
-
"@flighthq/log": "0.5.
|
|
44
|
-
"@flighthq/scene2d": "0.5.
|
|
45
|
-
"@flighthq/geometry": "0.5.
|
|
46
|
-
"@flighthq/render": "0.5.
|
|
47
|
-
"@flighthq/registry": "0.5.
|
|
48
|
-
"@flighthq/signals": "0.5.
|
|
49
|
-
"@flighthq/texture": "0.5.
|
|
50
|
-
"@flighthq/types": "0.5.
|
|
41
|
+
"@flighthq/color": "0.5.1-edge.638.d4dbd4e",
|
|
42
|
+
"@flighthq/entity": "0.5.1-edge.638.d4dbd4e",
|
|
43
|
+
"@flighthq/log": "0.5.1-edge.638.d4dbd4e",
|
|
44
|
+
"@flighthq/scene2d": "0.5.1-edge.638.d4dbd4e",
|
|
45
|
+
"@flighthq/geometry": "0.5.1-edge.638.d4dbd4e",
|
|
46
|
+
"@flighthq/render": "0.5.1-edge.638.d4dbd4e",
|
|
47
|
+
"@flighthq/registry": "0.5.1-edge.638.d4dbd4e",
|
|
48
|
+
"@flighthq/signals": "0.5.1-edge.638.d4dbd4e",
|
|
49
|
+
"@flighthq/texture": "0.5.1-edge.638.d4dbd4e",
|
|
50
|
+
"@flighthq/types": "0.5.1-edge.638.d4dbd4e"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"typescript": "^5.3.0"
|
|
@@ -4,14 +4,17 @@ import type { LogEntry } from '@flighthq/types/contract';
|
|
|
4
4
|
import { RegistryEntryState } from '@flighthq/types/contract';
|
|
5
5
|
|
|
6
6
|
import { areGlRenderStateGuardsEnabled, enableGlRenderStateGuards } from './enableGlRenderStateGuards';
|
|
7
|
+
import { createGlContextFromCanvasElement } from './glContext';
|
|
7
8
|
import { useGlProgram } from './glDraw';
|
|
8
|
-
import {
|
|
9
|
+
import { createEmptyGlRegistries, createGlPipeline } from './glPipeline';
|
|
10
|
+
import { createGlContextState, createGlRenderState, getGlRenderStateRuntime } from './glRenderState';
|
|
9
11
|
import { makeGL } from './glTestHelper';
|
|
10
12
|
|
|
11
13
|
function createState() {
|
|
12
14
|
const canvas = document.createElement('canvas');
|
|
13
15
|
canvas.getContext = vi.fn().mockReturnValue(makeGL()) as typeof canvas.getContext;
|
|
14
|
-
|
|
16
|
+
const contextState = createGlContextState(createGlContextFromCanvasElement(canvas));
|
|
17
|
+
return createGlRenderState(contextState, createGlPipeline(createEmptyGlRegistries()));
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
describe('areGlRenderStateGuardsEnabled', () => {
|
|
@@ -42,7 +42,7 @@ describe('enableGlTextureResolverGuards', () => {
|
|
|
42
42
|
expect(entries[0]?.data).toMatchObject({
|
|
43
43
|
kind: 'acme.missing.gl',
|
|
44
44
|
message:
|
|
45
|
-
'resolveGlTexture: texture source kind has no registered resolver —
|
|
45
|
+
'resolveGlTexture: texture source kind has no registered resolver — rebuild the GlPipeline with the required resolver and create the render state from that pipeline',
|
|
46
46
|
});
|
|
47
47
|
} finally {
|
|
48
48
|
removeLogSink(sink.sink);
|
package/src/glBackground.test.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { srgbChannelToLinear } from '@flighthq/color/contract';
|
|
2
|
-
import { BlendMode } from '@flighthq/types/contract';
|
|
3
2
|
|
|
4
3
|
import { renderGlBackground } from './glBackground';
|
|
5
4
|
import { getGlRenderStateRuntime } from './glRenderState';
|
|
@@ -39,12 +38,12 @@ describe('renderGlBackground', () => {
|
|
|
39
38
|
expect(gl.viewport).toHaveBeenLastCalledWith(10, 20, 30, 40);
|
|
40
39
|
});
|
|
41
40
|
|
|
42
|
-
it('
|
|
41
|
+
it('invalidates currentBlendSignature', () => {
|
|
43
42
|
const { state } = createGlState();
|
|
44
43
|
const runtime = getGlRenderStateRuntime(state);
|
|
45
|
-
runtime.
|
|
44
|
+
runtime.context.currentBlendSignature = { dst: 0, equation: 0, src: 0 };
|
|
46
45
|
renderGlBackground(state);
|
|
47
|
-
expect(runtime.
|
|
46
|
+
expect(runtime.context.currentBlendSignature).toBeNull();
|
|
48
47
|
});
|
|
49
48
|
|
|
50
49
|
it('passes fractional RGBA values through unchanged', () => {
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { build } from 'esbuild';
|
|
2
|
+
|
|
3
|
+
import { createGlContextFromCanvasElement } from './glContext';
|
|
4
|
+
import { makeGL } from './glTestHelper';
|
|
5
|
+
|
|
6
|
+
function makeCanvas(context: WebGL2RenderingContext | null = makeGL()): HTMLCanvasElement {
|
|
7
|
+
const canvas = document.createElement('canvas');
|
|
8
|
+
canvas.getContext = vi.fn().mockReturnValue(context) as typeof canvas.getContext;
|
|
9
|
+
return canvas;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
describe('createGlContextFromCanvasElement', () => {
|
|
13
|
+
it('returns the canvas WebGL2 context', () => {
|
|
14
|
+
const gl = makeGL();
|
|
15
|
+
expect(createGlContextFromCanvasElement(makeCanvas(gl))).toBe(gl);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('requests the context defaults independently from render options', () => {
|
|
19
|
+
const canvas = makeCanvas();
|
|
20
|
+
createGlContextFromCanvasElement(canvas);
|
|
21
|
+
expect(canvas.getContext).toHaveBeenCalledWith('webgl2', {
|
|
22
|
+
alpha: true,
|
|
23
|
+
antialias: true,
|
|
24
|
+
powerPreference: 'default',
|
|
25
|
+
stencil: true,
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('applies context options and lets explicit attributes override their convenience fields', () => {
|
|
30
|
+
const canvas = makeCanvas();
|
|
31
|
+
createGlContextFromCanvasElement(canvas, {
|
|
32
|
+
antialias: false,
|
|
33
|
+
contextAttributes: { alpha: false, antialias: true, preserveDrawingBuffer: true },
|
|
34
|
+
powerPreference: 'high-performance',
|
|
35
|
+
});
|
|
36
|
+
expect(canvas.getContext).toHaveBeenCalledWith('webgl2', {
|
|
37
|
+
alpha: false,
|
|
38
|
+
antialias: true,
|
|
39
|
+
powerPreference: 'high-performance',
|
|
40
|
+
preserveDrawingBuffer: true,
|
|
41
|
+
stencil: true,
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('throws when the canvas has no WebGL2 context', () => {
|
|
46
|
+
expect(() => createGlContextFromCanvasElement(makeCanvas(null))).toThrow('Failed to get WebGL2 context.');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('tree-shakes canvas context acquisition out of a context-first state bundle', async () => {
|
|
50
|
+
const renderStateBundle = await bundleRenderGlExport('createGlRenderState');
|
|
51
|
+
expect(renderStateBundle).not.toContain('Failed to get WebGL2 context.');
|
|
52
|
+
expect(renderStateBundle).not.toMatch(/\.getContext\(["']webgl2["']/);
|
|
53
|
+
|
|
54
|
+
const contextBundle = await bundleRenderGlExport('createGlContextFromCanvasElement');
|
|
55
|
+
expect(contextBundle).toContain('Failed to get WebGL2 context.');
|
|
56
|
+
expect(contextBundle).toMatch(/\.getContext\(["']webgl2["']/);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
async function bundleRenderGlExport(name: 'createGlContextFromCanvasElement' | 'createGlRenderState'): Promise<string> {
|
|
61
|
+
const result = await build({
|
|
62
|
+
bundle: true,
|
|
63
|
+
format: 'esm',
|
|
64
|
+
logLevel: 'silent',
|
|
65
|
+
packages: 'external',
|
|
66
|
+
platform: 'browser',
|
|
67
|
+
stdin: {
|
|
68
|
+
contents: `export { ${name} } from './index.ts';`,
|
|
69
|
+
resolveDir: getFileUrlDirectory(import.meta.url),
|
|
70
|
+
sourcefile: `tree-shake-${name}.ts`,
|
|
71
|
+
},
|
|
72
|
+
treeShaking: true,
|
|
73
|
+
write: false,
|
|
74
|
+
});
|
|
75
|
+
return result.outputFiles[0]!.text;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function getFileUrlDirectory(url: string): string {
|
|
79
|
+
const directory = new URL('.', url);
|
|
80
|
+
const pathname = decodeURIComponent(directory.pathname);
|
|
81
|
+
if (directory.hostname !== '') return `//${directory.hostname}${pathname}`;
|
|
82
|
+
return /^\/[A-Za-z]:\//.test(pathname) ? pathname.slice(1) : pathname;
|
|
83
|
+
}
|
package/src/glDraw.test.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
bindGlCompressedImageTexture,
|
|
18
18
|
bindGlImageResourceTexture,
|
|
19
19
|
bindGlTexture,
|
|
20
|
+
bindGlTextureRealization,
|
|
20
21
|
bindGlVideoTexture,
|
|
21
22
|
createGlTexture,
|
|
22
23
|
drawGlQuad,
|
|
@@ -25,12 +26,26 @@ import {
|
|
|
25
26
|
registerDefaultGlBlendModes,
|
|
26
27
|
registerGlBlendMode,
|
|
27
28
|
setGlQuadMatrixFromOffset,
|
|
29
|
+
standardGlBlendRealizations,
|
|
28
30
|
updateGlTexture,
|
|
29
31
|
useGlProgram,
|
|
30
32
|
} from './glDraw';
|
|
31
|
-
import {
|
|
33
|
+
import { createEmptyGlRegistries, createGlPipeline } from './glPipeline';
|
|
34
|
+
import {
|
|
35
|
+
createGlContextState,
|
|
36
|
+
createGlOffscreenRenderState,
|
|
37
|
+
createGlRenderState,
|
|
38
|
+
getGlRenderStateRuntime,
|
|
39
|
+
invalidateGlRenderStateCache,
|
|
40
|
+
} from './glRenderState';
|
|
32
41
|
import { registerGlBitmapShader } from './glShaderRegistry';
|
|
33
|
-
import { createGlState } from './glTestHelper';
|
|
42
|
+
import { createGlState, makeGL } from './glTestHelper';
|
|
43
|
+
|
|
44
|
+
const testPipeline = createGlPipeline(createEmptyGlRegistries());
|
|
45
|
+
|
|
46
|
+
function createTestGlRenderState(gl: WebGL2RenderingContext) {
|
|
47
|
+
return createGlRenderState(createGlContextState(gl), testPipeline);
|
|
48
|
+
}
|
|
34
49
|
|
|
35
50
|
// A single 4×4 bc3 level for exercising the opt-in compressed upload seam.
|
|
36
51
|
function compressedBc3Image(): CompressedImage {
|
|
@@ -84,10 +99,49 @@ function makeSampler(overrides?: Partial<SamplerLike>): SamplerLike {
|
|
|
84
99
|
}
|
|
85
100
|
|
|
86
101
|
describe('applyGlBlendMode', () => {
|
|
102
|
+
it('applies a different realization for the same mode on a derived state', () => {
|
|
103
|
+
const gl = makeGL();
|
|
104
|
+
const screen = createTestGlRenderState(gl);
|
|
105
|
+
registerGlBlendMode(screen, 'acme.Split', { dst: 'ONE', equation: 'MIN', src: 'ONE' });
|
|
106
|
+
const offscreen = createGlOffscreenRenderState(
|
|
107
|
+
screen.contextState,
|
|
108
|
+
createGlPipeline(getGlRenderStateRuntime(screen).registries),
|
|
109
|
+
);
|
|
110
|
+
registerGlBlendMode(screen, 'acme.Split', { dst: 'ONE', src: 'ZERO' });
|
|
111
|
+
|
|
112
|
+
applyGlBlendMode(offscreen, 'acme.Split');
|
|
113
|
+
expect(gl.blendEquation).toHaveBeenLastCalledWith(gl.MIN);
|
|
114
|
+
expect(gl.blendFunc).toHaveBeenLastCalledWith(gl.ONE, gl.ONE);
|
|
115
|
+
vi.mocked(gl.blendEquation).mockClear();
|
|
116
|
+
vi.mocked(gl.blendFunc).mockClear();
|
|
117
|
+
applyGlBlendMode(screen, 'acme.Split');
|
|
118
|
+
|
|
119
|
+
expect(gl.blendEquation).toHaveBeenCalledWith(gl.FUNC_ADD);
|
|
120
|
+
expect(gl.blendFunc).toHaveBeenCalledWith(gl.ZERO, gl.ONE);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('applies normal blending after the binding cache is invalidated', () => {
|
|
124
|
+
const { state, gl } = createGlState();
|
|
125
|
+
registerDefaultGlBlendModes(state);
|
|
126
|
+
applyGlBlendMode(state, BlendMode.Add);
|
|
127
|
+
invalidateGlRenderStateCache(state);
|
|
128
|
+
vi.mocked(gl.blendEquation).mockClear();
|
|
129
|
+
vi.mocked(gl.blendFunc).mockClear();
|
|
130
|
+
|
|
131
|
+
applyGlBlendMode(state, null);
|
|
132
|
+
|
|
133
|
+
expect(gl.blendEquation).toHaveBeenCalledWith(gl.FUNC_ADD);
|
|
134
|
+
expect(gl.blendFunc).toHaveBeenCalledWith(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
|
|
135
|
+
});
|
|
136
|
+
|
|
87
137
|
it('does not call blendFunc when blend mode has not changed', () => {
|
|
88
138
|
const { state, gl } = createGlState();
|
|
89
139
|
registerDefaultGlBlendModes(state);
|
|
90
|
-
getGlRenderStateRuntime(state).
|
|
140
|
+
getGlRenderStateRuntime(state).context.currentBlendSignature = {
|
|
141
|
+
dst: gl.ONE_MINUS_SRC_ALPHA,
|
|
142
|
+
equation: gl.FUNC_ADD,
|
|
143
|
+
src: gl.ONE,
|
|
144
|
+
};
|
|
91
145
|
applyGlBlendMode(state, BlendMode.Normal);
|
|
92
146
|
expect(gl.blendFunc).not.toHaveBeenCalled();
|
|
93
147
|
});
|
|
@@ -166,11 +220,15 @@ describe('applyGlBlendMode', () => {
|
|
|
166
220
|
expect(gl.blendFunc).toHaveBeenCalledWith(g.ONE, g.ONE_MINUS_SRC_ALPHA);
|
|
167
221
|
});
|
|
168
222
|
|
|
169
|
-
it('updates
|
|
170
|
-
const { state } = createGlState();
|
|
223
|
+
it('updates the realized blend signature after the change', () => {
|
|
224
|
+
const { state, gl } = createGlState();
|
|
171
225
|
registerDefaultGlBlendModes(state);
|
|
172
226
|
applyGlBlendMode(state, BlendMode.Add);
|
|
173
|
-
expect(getGlRenderStateRuntime(state).
|
|
227
|
+
expect(getGlRenderStateRuntime(state).context.currentBlendSignature).toEqual({
|
|
228
|
+
dst: gl.ONE,
|
|
229
|
+
equation: gl.FUNC_ADD,
|
|
230
|
+
src: gl.ONE,
|
|
231
|
+
});
|
|
174
232
|
});
|
|
175
233
|
|
|
176
234
|
it('calls blendFunc again when mode switches', () => {
|
|
@@ -196,20 +254,6 @@ describe('applyGlSamplerState', () => {
|
|
|
196
254
|
});
|
|
197
255
|
});
|
|
198
256
|
|
|
199
|
-
// A 1x1 bitmap with an explicit encoding and texel, for the alpha-encoding round trip below.
|
|
200
|
-
function encodedBitmap(alphaType: 'straight' | 'premultiplied', rgba: readonly number[]): Bitmap {
|
|
201
|
-
return {
|
|
202
|
-
alphaType,
|
|
203
|
-
data: new Uint8ClampedArray(rgba),
|
|
204
|
-
format: 'rgba8unorm',
|
|
205
|
-
gamut: 'srgb',
|
|
206
|
-
height: 1,
|
|
207
|
-
kind: BitmapTextureSourceKind,
|
|
208
|
-
version: 1,
|
|
209
|
-
width: 1,
|
|
210
|
-
} as unknown as Bitmap;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
257
|
describe('bindGlBitmapTexture', () => {
|
|
214
258
|
it('uploads CPU-readable pixels via the raw-pixel path', () => {
|
|
215
259
|
const { state, gl } = createGlState();
|
|
@@ -258,6 +302,20 @@ describe('bindGlBitmapTexture', () => {
|
|
|
258
302
|
});
|
|
259
303
|
});
|
|
260
304
|
|
|
305
|
+
// A 1x1 bitmap with an explicit encoding and texel, for the alpha-encoding round trip below.
|
|
306
|
+
function encodedBitmap(alphaType: 'straight' | 'premultiplied', rgba: readonly number[]): Bitmap {
|
|
307
|
+
return {
|
|
308
|
+
alphaType,
|
|
309
|
+
data: new Uint8ClampedArray(rgba),
|
|
310
|
+
format: 'rgba8unorm',
|
|
311
|
+
gamut: 'srgb',
|
|
312
|
+
height: 1,
|
|
313
|
+
kind: BitmapTextureSourceKind,
|
|
314
|
+
version: 1,
|
|
315
|
+
width: 1,
|
|
316
|
+
} as unknown as Bitmap;
|
|
317
|
+
}
|
|
318
|
+
|
|
261
319
|
// The uploader resolves the source's DECLARED encoding to the one the caller asked for, in BOTH
|
|
262
320
|
// directions. The straight direction is what makes a premultiplied source safe as a 3D material map: 3D
|
|
263
321
|
// binds with premultiply=false and premultiplies in its fragment tail, so passing premultiplied rgb
|
|
@@ -302,7 +360,7 @@ describe('bindGlCompressedImageTexture', () => {
|
|
|
302
360
|
bindGlCompressedImageTexture(state, image);
|
|
303
361
|
expect(decode).toHaveBeenCalledWith('bc3', 4, 4, expect.any(Uint8Array));
|
|
304
362
|
expect(gl.texImage2D).toHaveBeenCalled();
|
|
305
|
-
expect(getGlRenderStateRuntime(state).
|
|
363
|
+
expect(getGlRenderStateRuntime(state).context.currentTextureRealization?.straightAlpha).toBe(true);
|
|
306
364
|
});
|
|
307
365
|
|
|
308
366
|
it('preserves straight-alpha sampling on a cache hit', () => {
|
|
@@ -314,9 +372,9 @@ describe('bindGlCompressedImageTexture', () => {
|
|
|
314
372
|
);
|
|
315
373
|
const image = compressedBc3Image();
|
|
316
374
|
bindGlCompressedImageTexture(state, image);
|
|
317
|
-
getGlRenderStateRuntime(state).
|
|
375
|
+
getGlRenderStateRuntime(state).context.currentTextureRealization = null;
|
|
318
376
|
bindGlCompressedImageTexture(state, image);
|
|
319
|
-
expect(getGlRenderStateRuntime(state).
|
|
377
|
+
expect(getGlRenderStateRuntime(state).context.currentTextureRealization?.straightAlpha).toBe(true);
|
|
320
378
|
});
|
|
321
379
|
|
|
322
380
|
it('skips the image when no compressed uploader is registered', () => {
|
|
@@ -405,10 +463,10 @@ describe('bindGlTexture', () => {
|
|
|
405
463
|
const img = document.createElement('img');
|
|
406
464
|
const texture = bindGlTexture(state, img);
|
|
407
465
|
const runtime = getGlRenderStateRuntime(state);
|
|
408
|
-
runtime.
|
|
466
|
+
runtime.context.currentTextureRealization = null;
|
|
409
467
|
bindGlTexture(state, img);
|
|
410
468
|
expect(gl.bindTexture).toHaveBeenCalledWith((gl as unknown as { TEXTURE_2D: number }).TEXTURE_2D, texture);
|
|
411
|
-
expect(
|
|
469
|
+
expect(getGlRenderStateRuntime(state).context.currentTextureRealization?.texture).toBe(texture);
|
|
412
470
|
});
|
|
413
471
|
|
|
414
472
|
it('rebinds a cached texture even when it is already current, for multi-unit correctness', () => {
|
|
@@ -558,6 +616,28 @@ describe('bindGlTexture', () => {
|
|
|
558
616
|
});
|
|
559
617
|
});
|
|
560
618
|
|
|
619
|
+
describe('bindGlTextureRealization', () => {
|
|
620
|
+
it('binds and publishes the texture handle with its alpha interpretation as one record', () => {
|
|
621
|
+
const { state, gl } = createGlState();
|
|
622
|
+
const texture = gl.createTexture()!;
|
|
623
|
+
|
|
624
|
+
expect(bindGlTextureRealization(state, { straightAlpha: true, texture })).toBe(texture);
|
|
625
|
+
|
|
626
|
+
expect(gl.bindTexture).toHaveBeenLastCalledWith(gl.TEXTURE_2D, texture);
|
|
627
|
+
expect(getGlRenderStateRuntime(state).context.currentTextureRealization).toEqual({ straightAlpha: true, texture });
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
it('unbinds and invalidates the texture realization together', () => {
|
|
631
|
+
const { state, gl } = createGlState();
|
|
632
|
+
bindGlTextureRealization(state, { straightAlpha: true, texture: gl.createTexture()! });
|
|
633
|
+
|
|
634
|
+
expect(bindGlTextureRealization(state, null)).toBeNull();
|
|
635
|
+
|
|
636
|
+
expect(gl.bindTexture).toHaveBeenLastCalledWith(gl.TEXTURE_2D, null);
|
|
637
|
+
expect(getGlRenderStateRuntime(state).context.currentTextureRealization).toBeNull();
|
|
638
|
+
});
|
|
639
|
+
});
|
|
640
|
+
|
|
561
641
|
describe('bindGlVideoTexture', () => {
|
|
562
642
|
function videoTexture(version: number, readyState = 4, videoWidth = 320, videoHeight = 240): Texture {
|
|
563
643
|
return {
|
|
@@ -696,7 +776,7 @@ describe('createGlTexture', () => {
|
|
|
696
776
|
it('stores the new texture as currentTexture on state', () => {
|
|
697
777
|
const { state } = createGlState();
|
|
698
778
|
const texture = createGlTexture(state);
|
|
699
|
-
expect(getGlRenderStateRuntime(state).
|
|
779
|
+
expect(getGlRenderStateRuntime(state).context.currentTextureRealization?.texture).toBe(texture);
|
|
700
780
|
});
|
|
701
781
|
});
|
|
702
782
|
|
|
@@ -841,7 +921,10 @@ describe('registerGlBlendMode', () => {
|
|
|
841
921
|
const replacement = { src: 'ZERO', dst: 'ONE' } as const;
|
|
842
922
|
registerGlBlendMode(screen, 'acme.Foo', initial);
|
|
843
923
|
const snapshot = getGlRenderStateRuntime(screen).registries.blendRealizations;
|
|
844
|
-
const offscreen = createGlOffscreenRenderState(
|
|
924
|
+
const offscreen = createGlOffscreenRenderState(
|
|
925
|
+
screen.contextState,
|
|
926
|
+
createGlPipeline(getGlRenderStateRuntime(screen).registries),
|
|
927
|
+
);
|
|
845
928
|
|
|
846
929
|
registerGlBlendMode(screen, 'acme.Foo', replacement);
|
|
847
930
|
|
|
@@ -860,7 +943,11 @@ describe('setGlQuadMatrixFromOffset', () => {
|
|
|
860
943
|
// Identity transform + offset (dx=10, dy=20): effective tx = 0 + 1*10 + 0*20 = 10
|
|
861
944
|
const runtime = getGlRenderStateRuntime(state);
|
|
862
945
|
setGlQuadMatrixFromOffset(state, 1, 0, 0, 1, 0, 0, 10, 20);
|
|
863
|
-
expect(gl.uniformMatrix3fv).toHaveBeenCalledWith(
|
|
946
|
+
expect(gl.uniformMatrix3fv).toHaveBeenCalledWith(
|
|
947
|
+
runtime.context.currentShader!.locations!.locMatrix,
|
|
948
|
+
false,
|
|
949
|
+
runtime.matrixArray,
|
|
950
|
+
);
|
|
864
951
|
// tx * 2/200 - 1 = 10 * 0.01 - 1 = -0.9
|
|
865
952
|
expect(runtime.matrixArray[6]).toBeCloseTo(-0.9);
|
|
866
953
|
// -ty * 2/100 + 1 = -20 * 0.02 + 1 = 0.6
|
|
@@ -876,12 +963,29 @@ describe('setGlQuadMatrixFromOffset', () => {
|
|
|
876
963
|
});
|
|
877
964
|
});
|
|
878
965
|
|
|
966
|
+
describe('standardGlBlendRealizations', () => {
|
|
967
|
+
it('carries the six default fixed-function blend modes', () => {
|
|
968
|
+
expect(standardGlBlendRealizations.entries.size).toBe(6);
|
|
969
|
+
expect(standardGlBlendRealizations.entries.has(BlendMode.Add)).toBe(true);
|
|
970
|
+
expect(standardGlBlendRealizations.entries.has(BlendMode.Darken)).toBe(true);
|
|
971
|
+
expect(standardGlBlendRealizations.entries.has(BlendMode.Lighten)).toBe(true);
|
|
972
|
+
expect(standardGlBlendRealizations.entries.has(BlendMode.Multiply)).toBe(true);
|
|
973
|
+
expect(standardGlBlendRealizations.entries.has(BlendMode.Normal)).toBe(true);
|
|
974
|
+
expect(standardGlBlendRealizations.entries.has(BlendMode.Screen)).toBe(true);
|
|
975
|
+
});
|
|
976
|
+
|
|
977
|
+
it('does not include advanced blend modes that need a shader pass', () => {
|
|
978
|
+
expect(standardGlBlendRealizations.entries.has(AdvancedBlendMode.Overlay)).toBe(false);
|
|
979
|
+
expect(standardGlBlendRealizations.entries.has(AdvancedBlendMode.HardLight)).toBe(false);
|
|
980
|
+
});
|
|
981
|
+
});
|
|
982
|
+
|
|
879
983
|
describe('updateGlTexture', () => {
|
|
880
984
|
it('binds the texture when it is not the current one', () => {
|
|
881
985
|
const { state, gl } = createGlState();
|
|
882
986
|
const texture = {} as WebGLTexture;
|
|
883
987
|
const canvas = document.createElement('canvas');
|
|
884
|
-
getGlRenderStateRuntime(state).
|
|
988
|
+
getGlRenderStateRuntime(state).context.currentTextureRealization = null;
|
|
885
989
|
updateGlTexture(state, texture, canvas);
|
|
886
990
|
expect(gl.bindTexture).toHaveBeenCalledWith((gl as unknown as { TEXTURE_2D: number }).TEXTURE_2D, texture);
|
|
887
991
|
});
|
|
@@ -890,17 +994,17 @@ describe('updateGlTexture', () => {
|
|
|
890
994
|
const { state } = createGlState();
|
|
891
995
|
const texture = {} as WebGLTexture;
|
|
892
996
|
const runtime = getGlRenderStateRuntime(state);
|
|
893
|
-
runtime.
|
|
997
|
+
runtime.context.currentTextureRealization = null;
|
|
894
998
|
updateGlTexture(state, {} as WebGLTexture, document.createElement('canvas'));
|
|
895
999
|
updateGlTexture(state, texture, document.createElement('canvas'));
|
|
896
1000
|
// The last call should have updated currentTexture
|
|
897
|
-
expect(
|
|
1001
|
+
expect(getGlRenderStateRuntime(state).context.currentTextureRealization?.texture).toBe(texture);
|
|
898
1002
|
});
|
|
899
1003
|
|
|
900
1004
|
it('rebinds even when the texture is already current (currentTexture is unit-blind)', () => {
|
|
901
1005
|
const { state, gl } = createGlState();
|
|
902
1006
|
const texture = {} as WebGLTexture;
|
|
903
|
-
getGlRenderStateRuntime(state).
|
|
1007
|
+
getGlRenderStateRuntime(state).context.currentTextureRealization = { straightAlpha: false, texture };
|
|
904
1008
|
updateGlTexture(state, texture, document.createElement('canvas'));
|
|
905
1009
|
// Never skip on currentTexture: the active unit may have changed since it was set, so uploading
|
|
906
1010
|
// without rebinding could target the wrong texture.
|
|
@@ -910,7 +1014,7 @@ describe('updateGlTexture', () => {
|
|
|
910
1014
|
it('always calls texImage2D to upload canvas data', () => {
|
|
911
1015
|
const { state, gl } = createGlState();
|
|
912
1016
|
const texture = {} as WebGLTexture;
|
|
913
|
-
getGlRenderStateRuntime(state).
|
|
1017
|
+
getGlRenderStateRuntime(state).context.currentTextureRealization = { straightAlpha: false, texture };
|
|
914
1018
|
updateGlTexture(state, texture, document.createElement('canvas'));
|
|
915
1019
|
expect(gl.texImage2D).toHaveBeenCalled();
|
|
916
1020
|
});
|
|
@@ -918,7 +1022,7 @@ describe('updateGlTexture', () => {
|
|
|
918
1022
|
it('sets premultiply alpha before uploading', () => {
|
|
919
1023
|
const { state, gl } = createGlState();
|
|
920
1024
|
const texture = {} as WebGLTexture;
|
|
921
|
-
getGlRenderStateRuntime(state).
|
|
1025
|
+
getGlRenderStateRuntime(state).context.currentTextureRealization = { straightAlpha: false, texture };
|
|
922
1026
|
updateGlTexture(state, texture, document.createElement('canvas'));
|
|
923
1027
|
expect(gl.pixelStorei).toHaveBeenCalledWith(
|
|
924
1028
|
(gl as unknown as { UNPACK_PREMULTIPLY_ALPHA_WEBGL: number }).UNPACK_PREMULTIPLY_ALPHA_WEBGL,
|
|
@@ -931,25 +1035,28 @@ describe('useGlProgram', () => {
|
|
|
931
1035
|
it('calls useProgram when no program is active', () => {
|
|
932
1036
|
const { state, gl } = createGlState();
|
|
933
1037
|
const runtime = getGlRenderStateRuntime(state);
|
|
934
|
-
runtime.
|
|
1038
|
+
runtime.context.currentShader = null;
|
|
935
1039
|
useGlProgram(state);
|
|
936
|
-
expect(gl.useProgram).toHaveBeenCalledWith(runtime.
|
|
1040
|
+
expect(gl.useProgram).toHaveBeenCalledWith(runtime.defaultBitmapShader!.program);
|
|
937
1041
|
});
|
|
938
1042
|
|
|
939
1043
|
it('does not call useProgram when program is already active', () => {
|
|
940
1044
|
const { state, gl } = createGlState();
|
|
941
1045
|
const runtime = getGlRenderStateRuntime(state);
|
|
942
|
-
runtime.
|
|
1046
|
+
runtime.context.currentShader = {
|
|
1047
|
+
locations: runtime.defaultBitmapShader!.locations,
|
|
1048
|
+
program: runtime.defaultBitmapShader!.program,
|
|
1049
|
+
};
|
|
943
1050
|
useGlProgram(state);
|
|
944
1051
|
expect(gl.useProgram).not.toHaveBeenCalled();
|
|
945
1052
|
});
|
|
946
1053
|
|
|
947
|
-
it('stores the program as
|
|
1054
|
+
it('stores the program as the current shader after activation', () => {
|
|
948
1055
|
const { state } = createGlState();
|
|
949
1056
|
const runtime = getGlRenderStateRuntime(state);
|
|
950
|
-
runtime.
|
|
1057
|
+
runtime.context.currentShader = null;
|
|
951
1058
|
useGlProgram(state);
|
|
952
|
-
expect(
|
|
1059
|
+
expect(getGlRenderStateRuntime(state).context.currentShader?.program).toBe(runtime.defaultBitmapShader!.program);
|
|
953
1060
|
});
|
|
954
1061
|
|
|
955
1062
|
it('uses the registered bitmap shader program and locations', () => {
|
|
@@ -957,7 +1064,7 @@ describe('useGlProgram', () => {
|
|
|
957
1064
|
const runtime = getGlRenderStateRuntime(state);
|
|
958
1065
|
const shader = {
|
|
959
1066
|
bind: vi.fn(),
|
|
960
|
-
locations: { ...runtime.
|
|
1067
|
+
locations: { ...runtime.defaultBitmapShader!.locations, program: {} as WebGLProgram },
|
|
961
1068
|
program: {} as WebGLProgram,
|
|
962
1069
|
};
|
|
963
1070
|
shader.locations.program = shader.program;
|
|
@@ -966,7 +1073,7 @@ describe('useGlProgram', () => {
|
|
|
966
1073
|
useGlProgram(state);
|
|
967
1074
|
|
|
968
1075
|
expect(gl.useProgram).toHaveBeenCalledWith(shader.program);
|
|
969
|
-
expect(runtime.
|
|
970
|
-
expect(runtime.
|
|
1076
|
+
expect(runtime.context.currentShader?.locations).toBe(shader.locations);
|
|
1077
|
+
expect(runtime.context.currentShader?.program).toBe(shader.program);
|
|
971
1078
|
});
|
|
972
1079
|
});
|