@flighthq/application-gl 0.5.1-next.1069.554a2ac → 0.5.1-next.1201.9b49dee
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
CHANGED
|
@@ -13,5 +13,5 @@ Import the supported application-facing API from `@flighthq/application-gl`. The
|
|
|
13
13
|
This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
|
|
14
14
|
|
|
15
15
|
- [Flight project](https://github.com/flighthq/flight)
|
|
16
|
-
- [Source for @flighthq/application-gl@0.5.1-next.
|
|
17
|
-
- [License](https://github.com/flighthq/flight/blob/
|
|
16
|
+
- [Source for @flighthq/application-gl@0.5.1-next.1201.9b49dee](https://github.com/flighthq/flight/tree/9b49dee3f22f6b2838c3d237edcc77bca65734f2/packages/application-gl)
|
|
17
|
+
- [License](https://github.com/flighthq/flight/blob/9b49dee3f22f6b2838c3d237edcc77bca65734f2/LICENSE.md)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glApplicationRenderView.d.ts","sourceRoot":"","sources":["../src/glApplicationRenderView.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"glApplicationRenderView.d.ts","sourceRoot":"","sources":["../src/glApplicationRenderView.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,iBAAiB,EACjB,uBAAuB,EACvB,8BAA8B,EAG/B,MAAM,0BAA0B,CAAC;AAMlC,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,QAAQ,CAAC,8BAA8B,CAAC,GAChD,uBAAuB,CA4BzB;AAID,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,uBAAuB,GAAG,IAAI,CAIlF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createApplicationRenderView, detachApplicationRenderView } from '@flighthq/application/contract';
|
|
2
|
+
import { createWebGlContext } from '@flighthq/host-web/contract';
|
|
2
3
|
import { createViewport } from '@flighthq/node/contract';
|
|
3
|
-
import {
|
|
4
|
+
import { createGlRenderState, createGlTextureRenderTarget, destroyGlRenderState, destroyGlTextureRenderTarget, invalidateGlRenderStateCache, resizeGlTextureRenderTarget, } from '@flighthq/render-gl/contract';
|
|
4
5
|
// Allocates the GL realization of an ApplicationRenderView. Creation does not attach the resize signal;
|
|
5
6
|
// call attachApplicationRenderView explicitly when the window should drive subsequent synchronization.
|
|
6
7
|
// The returned view owns the state and target allocated here; destroy it with
|
|
@@ -9,13 +10,12 @@ export function createGlApplicationRenderView(window, canvas, options) {
|
|
|
9
10
|
const width = Math.max(0, Math.round(window.width * window.devicePixelRatio));
|
|
10
11
|
const height = Math.max(0, Math.round(window.height * window.devicePixelRatio));
|
|
11
12
|
synchronizeGlCanvasBackingStore(canvas, width, height);
|
|
12
|
-
const context =
|
|
13
|
-
const
|
|
14
|
-
const renderState = createGlRenderState(contextState, options.pipeline, {
|
|
13
|
+
const context = createWebGlContext(canvas, options.context);
|
|
14
|
+
const renderState = createGlRenderState(context, options.pipeline, {
|
|
15
15
|
...options.render,
|
|
16
16
|
pixelRatio: window.devicePixelRatio,
|
|
17
17
|
});
|
|
18
|
-
const renderTarget =
|
|
18
|
+
const renderTarget = createGlTextureRenderTarget(renderState, {
|
|
19
19
|
...options.target,
|
|
20
20
|
height,
|
|
21
21
|
width,
|
|
@@ -31,7 +31,7 @@ export function createGlApplicationRenderView(window, canvas, options) {
|
|
|
31
31
|
// createGlApplicationRenderView. The canvas and ApplicationWindow remain caller-owned.
|
|
32
32
|
export function destroyGlApplicationRenderView(view) {
|
|
33
33
|
detachApplicationRenderView(view);
|
|
34
|
-
|
|
34
|
+
destroyGlTextureRenderTarget(view.renderTarget);
|
|
35
35
|
destroyGlRenderState(view.renderState);
|
|
36
36
|
}
|
|
37
37
|
function resizeGlApplicationRenderView(canvas, renderState, renderTarget, width, height) {
|
|
@@ -41,7 +41,7 @@ function resizeGlApplicationRenderView(canvas, renderState, renderTarget, width,
|
|
|
41
41
|
const storageWidth = Math.max(1, Math.ceil(width));
|
|
42
42
|
const storageHeight = Math.max(1, Math.ceil(height));
|
|
43
43
|
if (renderTarget.width !== storageWidth || renderTarget.height !== storageHeight) {
|
|
44
|
-
|
|
44
|
+
resizeGlTextureRenderTarget(renderState, renderTarget, width, height);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
function synchronizeGlCanvasBackingStore(canvas, width, height) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glApplicationRenderView.js","sourceRoot":"","sources":["../src/glApplicationRenderView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAC1G,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"glApplicationRenderView.js","sourceRoot":"","sources":["../src/glApplicationRenderView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAC1G,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EACL,mBAAmB,EACnB,2BAA2B,EAC3B,oBAAoB,EACpB,4BAA4B,EAC5B,4BAA4B,EAC5B,2BAA2B,GAC5B,MAAM,8BAA8B,CAAC;AAStC,wGAAwG;AACxG,uGAAuG;AACvG,8EAA8E;AAC9E,kCAAkC;AAClC,MAAM,UAAU,6BAA6B,CAC3C,MAAyB,EACzB,MAAyB,EACzB,OAAiD;IAEjD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAC9E,MAAM,M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+BAA+B,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC;QAC3D,4BAA4B,CAAC,WAAW,CAAC,CAAC;IAC5C,CAAC;IACD,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACnD,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACrD,IAAI,YAAY,CAAC,KAAK,KAAK,YAAY,IAAI,YAAY,CAAC,MAAM,KAAK,aAAa,EAAE,CAAC;QACjF,2BAA2B,CAAC,WAAW,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IACxE,CAAC;AACH,CAAC;AAED,SAAS,+BAA+B,CAAC,MAAyB,EAAE,KAAa,EAAE,MAAc;IAC/F,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK,EAAE,CAAC;QAC3B,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QAC7B,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;QACvB,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/application-gl",
|
|
3
|
-
"version": "0.5.1-next.
|
|
3
|
+
"version": "0.5.1-next.1201.9b49dee",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,10 +38,11 @@
|
|
|
38
38
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@flighthq/application": "0.5.1-next.
|
|
42
|
-
"@flighthq/node": "0.5.1-next.
|
|
43
|
-
"@flighthq/render-gl": "0.5.1-next.
|
|
44
|
-
"@flighthq/types": "0.5.1-next.
|
|
41
|
+
"@flighthq/application": "0.5.1-next.1201.9b49dee",
|
|
42
|
+
"@flighthq/node": "0.5.1-next.1201.9b49dee",
|
|
43
|
+
"@flighthq/render-gl": "0.5.1-next.1201.9b49dee",
|
|
44
|
+
"@flighthq/types": "0.5.1-next.1201.9b49dee",
|
|
45
|
+
"@flighthq/host-web": "0.5.1-next.1201.9b49dee"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"@flighthq/signals": "*",
|
|
@@ -3,31 +3,30 @@ import {
|
|
|
3
3
|
createApplicationWindow,
|
|
4
4
|
synchronizeApplicationRenderView,
|
|
5
5
|
} from '@flighthq/application/contract';
|
|
6
|
+
import * as hostWebContract from '@flighthq/host-web/contract';
|
|
6
7
|
import * as nodeContract from '@flighthq/node/contract';
|
|
7
8
|
import * as renderGlContract from '@flighthq/render-gl/contract';
|
|
8
9
|
import { emitSignal } from '@flighthq/signals/contract';
|
|
9
|
-
import type { GlPipeline, GlRenderState,
|
|
10
|
+
import type { GlPipeline, GlRenderState, GlTextureRenderTarget } from '@flighthq/types/contract';
|
|
10
11
|
|
|
11
12
|
import { createGlApplicationRenderView, destroyGlApplicationRenderView } from './glApplicationRenderView';
|
|
12
13
|
|
|
13
14
|
beforeEach(() => {
|
|
14
15
|
vi.spyOn(nodeContract, 'createViewport').mockImplementation((options) => ({ ...options, x: 0, y: 0 }) as never);
|
|
15
16
|
|
|
16
|
-
vi.spyOn(
|
|
17
|
+
vi.spyOn(hostWebContract, 'createWebGlContext').mockImplementation(
|
|
17
18
|
() => ({ drawingBufferHeight: 0, drawingBufferWidth: 0 }) as never,
|
|
18
19
|
);
|
|
19
|
-
vi.spyOn(renderGlContract, 'createGlContextState').mockImplementation(((gl: never) => ({ gl })) as never);
|
|
20
20
|
vi.spyOn(renderGlContract, 'createGlRenderState').mockImplementation(((
|
|
21
|
-
|
|
21
|
+
gl: never,
|
|
22
22
|
_pipeline: never,
|
|
23
23
|
options: { pixelRatio: number },
|
|
24
24
|
) => ({
|
|
25
|
-
|
|
26
|
-
gl: (contextState as { gl: unknown }).gl,
|
|
25
|
+
gl,
|
|
27
26
|
pixelRatio: options.pixelRatio,
|
|
28
27
|
renderTransform2D: { a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0 },
|
|
29
28
|
})) as never);
|
|
30
|
-
vi.spyOn(renderGlContract, '
|
|
29
|
+
vi.spyOn(renderGlContract, 'createGlTextureRenderTarget').mockImplementation(((
|
|
31
30
|
_state: GlRenderState,
|
|
32
31
|
descriptor: { height: number; width: number },
|
|
33
32
|
) => ({
|
|
@@ -35,11 +34,11 @@ beforeEach(() => {
|
|
|
35
34
|
width: Math.max(1, descriptor.width),
|
|
36
35
|
})) as never);
|
|
37
36
|
vi.spyOn(renderGlContract, 'destroyGlRenderState').mockImplementation((() => {}) as never);
|
|
38
|
-
vi.spyOn(renderGlContract, '
|
|
37
|
+
vi.spyOn(renderGlContract, 'destroyGlTextureRenderTarget').mockImplementation((() => {}) as never);
|
|
39
38
|
vi.spyOn(renderGlContract, 'invalidateGlRenderStateCache').mockImplementation((() => {}) as never);
|
|
40
|
-
vi.spyOn(renderGlContract, '
|
|
39
|
+
vi.spyOn(renderGlContract, 'resizeGlTextureRenderTarget').mockImplementation(((
|
|
41
40
|
_state: GlRenderState,
|
|
42
|
-
target:
|
|
41
|
+
target: GlTextureRenderTarget,
|
|
43
42
|
width: number,
|
|
44
43
|
height: number,
|
|
45
44
|
) => {
|
|
@@ -71,19 +70,16 @@ describe('createGlApplicationRenderView', () => {
|
|
|
71
70
|
|
|
72
71
|
expect(canvas.width).toBe(640);
|
|
73
72
|
expect(canvas.height).toBe(360);
|
|
74
|
-
expect(
|
|
75
|
-
expect(renderGlContract.createGlContextState).toHaveBeenCalledWith(
|
|
76
|
-
vi.mocked(renderGlContract.createGlContextFromCanvasElement).mock.results[0].value,
|
|
77
|
-
);
|
|
73
|
+
expect(hostWebContract.createWebGlContext).toHaveBeenCalledWith(canvas, { antialias: false });
|
|
78
74
|
expect(renderGlContract.createGlRenderState).toHaveBeenCalledWith(
|
|
79
|
-
vi.mocked(
|
|
75
|
+
vi.mocked(hostWebContract.createWebGlContext).mock.results[0].value,
|
|
80
76
|
pipeline,
|
|
81
77
|
{
|
|
82
78
|
pixelRatio: 2,
|
|
83
79
|
roundPixels: true,
|
|
84
80
|
},
|
|
85
81
|
);
|
|
86
|
-
expect(renderGlContract.
|
|
82
|
+
expect(renderGlContract.createGlTextureRenderTarget).toHaveBeenCalledWith(view.renderState, {
|
|
87
83
|
colorSpace: 'linear',
|
|
88
84
|
depth: 'depth-stencil',
|
|
89
85
|
height: 360,
|
|
@@ -99,17 +95,22 @@ describe('createGlApplicationRenderView', () => {
|
|
|
99
95
|
const canvas = document.createElement('canvas');
|
|
100
96
|
const view = createGlApplicationRenderView(window, canvas, { pipeline });
|
|
101
97
|
vi.mocked(renderGlContract.invalidateGlRenderStateCache).mockClear();
|
|
102
|
-
vi.mocked(renderGlContract.
|
|
98
|
+
vi.mocked(renderGlContract.resizeGlTextureRenderTarget).mockClear();
|
|
103
99
|
|
|
104
100
|
synchronizeApplicationRenderView(view);
|
|
105
101
|
expect(renderGlContract.invalidateGlRenderStateCache).not.toHaveBeenCalled();
|
|
106
|
-
expect(renderGlContract.
|
|
102
|
+
expect(renderGlContract.resizeGlTextureRenderTarget).not.toHaveBeenCalled();
|
|
107
103
|
|
|
108
104
|
window.width = 30;
|
|
109
105
|
synchronizeApplicationRenderView(view);
|
|
110
106
|
expect(canvas.width).toBe(30);
|
|
111
107
|
expect(renderGlContract.invalidateGlRenderStateCache).toHaveBeenCalledWith(view.renderState);
|
|
112
|
-
expect(renderGlContract.
|
|
108
|
+
expect(renderGlContract.resizeGlTextureRenderTarget).toHaveBeenCalledWith(
|
|
109
|
+
view.renderState,
|
|
110
|
+
view.renderTarget,
|
|
111
|
+
30,
|
|
112
|
+
10,
|
|
113
|
+
);
|
|
113
114
|
});
|
|
114
115
|
});
|
|
115
116
|
|
|
@@ -120,14 +121,14 @@ describe('destroyGlApplicationRenderView', () => {
|
|
|
120
121
|
window.height = 10;
|
|
121
122
|
const view = createGlApplicationRenderView(window, document.createElement('canvas'), { pipeline });
|
|
122
123
|
attachApplicationRenderView(view);
|
|
123
|
-
vi.mocked(renderGlContract.
|
|
124
|
+
vi.mocked(renderGlContract.resizeGlTextureRenderTarget).mockClear();
|
|
124
125
|
|
|
125
126
|
destroyGlApplicationRenderView(view);
|
|
126
127
|
window.width = 30;
|
|
127
128
|
emitSignal(window.onResize);
|
|
128
129
|
|
|
129
|
-
expect(renderGlContract.
|
|
130
|
-
expect(renderGlContract.
|
|
130
|
+
expect(renderGlContract.resizeGlTextureRenderTarget).not.toHaveBeenCalled();
|
|
131
|
+
expect(renderGlContract.destroyGlTextureRenderTarget).toHaveBeenCalledWith(view.renderTarget);
|
|
131
132
|
expect(renderGlContract.destroyGlRenderState).toHaveBeenCalledWith(view.renderState);
|
|
132
133
|
});
|
|
133
134
|
});
|