@flighthq/application-gl 0.5.0-next.1944.cd6b6e7 → 0.5.1-next.597.ab004dd

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.0-next.1944.cd6b6e7](https://github.com/flighthq/flight/tree/cd6b6e71eb472b3a4249830a7743333f019fa7b7/packages/application-gl)
17
- - [License](https://github.com/flighthq/flight/blob/cd6b6e71eb472b3a4249830a7743333f019fa7b7/LICENSE.md)
16
+ - [Source for @flighthq/application-gl@0.5.1-next.597.ab004dd](https://github.com/flighthq/flight/tree/ab004ddc85b350cbd99a944e1e8108a016ae8af0/packages/application-gl)
17
+ - [License](https://github.com/flighthq/flight/blob/ab004ddc85b350cbd99a944e1e8108a016ae8af0/LICENSE.md)
@@ -1,4 +1,4 @@
1
1
  import type { ApplicationWindow, GlApplicationRenderView, GlApplicationRenderViewOptions } from '@flighthq/types/contract';
2
- export declare function createGlApplicationRenderView(window: ApplicationWindow, canvas: HTMLCanvasElement, options?: Readonly<GlApplicationRenderViewOptions>): GlApplicationRenderView;
2
+ export declare function createGlApplicationRenderView(window: ApplicationWindow, canvas: HTMLCanvasElement, options: Readonly<GlApplicationRenderViewOptions>): GlApplicationRenderView;
3
3
  export declare function destroyGlApplicationRenderView(view: GlApplicationRenderView): void;
4
4
  //# sourceMappingURL=glApplicationRenderView.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"glApplicationRenderView.d.ts","sourceRoot":"","sources":["../src/glApplicationRenderView.ts"],"names":[],"mappings":"AAUA,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,GAAE,QAAQ,CAAC,8BAA8B,CAAM,GACrD,uBAAuB,CAoBzB;AAID,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,uBAAuB,GAAG,IAAI,CAIlF"}
1
+ {"version":3,"file":"glApplicationRenderView.d.ts","sourceRoot":"","sources":["../src/glApplicationRenderView.ts"],"names":[],"mappings":"AAYA,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,CA6BzB;AAID,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,uBAAuB,GAAG,IAAI,CAIlF"}
@@ -1,15 +1,17 @@
1
1
  import { createApplicationRenderView, detachApplicationRenderView } from '@flighthq/application/contract';
2
2
  import { createViewport } from '@flighthq/node/contract';
3
- import { createGlRenderState, createGlRenderTarget, destroyGlRenderState, destroyGlRenderTarget, invalidateGlRenderStateCache, resizeGlRenderTarget, } from '@flighthq/render-gl/contract';
3
+ import { createGlContextFromCanvasElement, createGlContextState, createGlRenderState, createGlRenderTarget, destroyGlRenderState, destroyGlRenderTarget, invalidateGlRenderStateCache, resizeGlRenderTarget, } from '@flighthq/render-gl/contract';
4
4
  // Allocates the GL realization of an ApplicationRenderView. Creation does not attach the resize signal;
5
5
  // call attachApplicationRenderView explicitly when the window should drive subsequent synchronization.
6
6
  // The returned view owns the state and target allocated here; destroy it with
7
7
  // destroyGlApplicationRenderView.
8
- export function createGlApplicationRenderView(window, canvas, options = {}) {
8
+ export function createGlApplicationRenderView(window, canvas, options) {
9
9
  const width = Math.max(0, Math.round(window.width * window.devicePixelRatio));
10
10
  const height = Math.max(0, Math.round(window.height * window.devicePixelRatio));
11
11
  synchronizeGlCanvasBackingStore(canvas, width, height);
12
- const renderState = createGlRenderState(canvas, {
12
+ const context = createGlContextFromCanvasElement(canvas, options.context);
13
+ const contextState = createGlContextState(context);
14
+ const renderState = createGlRenderState(contextState, options.pipeline, {
13
15
  ...options.render,
14
16
  pixelRatio: window.devicePixelRatio,
15
17
  });
@@ -23,7 +25,7 @@ export function createGlApplicationRenderView(window, canvas, options = {}) {
23
25
  height,
24
26
  width,
25
27
  });
26
- return createApplicationRenderView(window, renderState, renderTarget, viewport, resizeGlApplicationRenderView);
28
+ return createApplicationRenderView(window, renderState, renderTarget, viewport, (state, target, nextWidth, nextHeight) => resizeGlApplicationRenderView(canvas, state, target, nextWidth, nextHeight));
27
29
  }
28
30
  // Detaches window observation and deterministically frees the target and state owned by
29
31
  // createGlApplicationRenderView. The canvas and ApplicationWindow remain caller-owned.
@@ -32,8 +34,8 @@ export function destroyGlApplicationRenderView(view) {
32
34
  destroyGlRenderTarget(view.renderState, view.renderTarget);
33
35
  destroyGlRenderState(view.renderState);
34
36
  }
35
- function resizeGlApplicationRenderView(renderState, renderTarget, width, height) {
36
- if (synchronizeGlCanvasBackingStore(renderState.canvas, width, height)) {
37
+ function resizeGlApplicationRenderView(canvas, renderState, renderTarget, width, height) {
38
+ if (synchronizeGlCanvasBackingStore(canvas, width, height)) {
37
39
  invalidateGlRenderStateCache(renderState);
38
40
  }
39
41
  const storageWidth = Math.max(1, Math.ceil(width));
@@ -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,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,4BAA4B,EAC5B,oB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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.0-next.1944.cd6b6e7",
3
+ "version": "0.5.1-next.597.ab004dd",
4
4
  "author": "Joshua Granick and other contributors",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -38,10 +38,10 @@
38
38
  "clean:dist": "tsx ../../scripts/clean-package-dist.ts"
39
39
  },
40
40
  "dependencies": {
41
- "@flighthq/application": "0.5.0-next.1944.cd6b6e7",
42
- "@flighthq/node": "0.5.0-next.1944.cd6b6e7",
43
- "@flighthq/render-gl": "0.5.0-next.1944.cd6b6e7",
44
- "@flighthq/types": "0.5.0-next.1944.cd6b6e7"
41
+ "@flighthq/application": "0.5.1-next.597.ab004dd",
42
+ "@flighthq/node": "0.5.1-next.597.ab004dd",
43
+ "@flighthq/render-gl": "0.5.1-next.597.ab004dd",
44
+ "@flighthq/types": "0.5.1-next.597.ab004dd"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@flighthq/signals": "*",
@@ -4,11 +4,13 @@ import {
4
4
  synchronizeApplicationRenderView,
5
5
  } from '@flighthq/application/contract';
6
6
  import { emitSignal } from '@flighthq/signals/contract';
7
- import type { GlRenderState, GlRenderTarget } from '@flighthq/types/contract';
7
+ import type { GlPipeline, GlRenderState, GlRenderTarget } from '@flighthq/types/contract';
8
8
 
9
9
  import { createGlApplicationRenderView, destroyGlApplicationRenderView } from './glApplicationRenderView';
10
10
 
11
11
  const mocks = vi.hoisted(() => ({
12
+ createGlContextFromCanvasElement: vi.fn(),
13
+ createGlContextState: vi.fn(),
12
14
  createGlRenderState: vi.fn(),
13
15
  createGlRenderTarget: vi.fn(),
14
16
  createViewport: vi.fn(),
@@ -23,6 +25,8 @@ vi.mock('@flighthq/node/contract', () => ({
23
25
  }));
24
26
 
25
27
  vi.mock('@flighthq/render-gl/contract', () => ({
28
+ createGlContextFromCanvasElement: mocks.createGlContextFromCanvasElement,
29
+ createGlContextState: mocks.createGlContextState,
26
30
  createGlRenderState: mocks.createGlRenderState,
27
31
  createGlRenderTarget: mocks.createGlRenderTarget,
28
32
  destroyGlRenderState: mocks.destroyGlRenderState,
@@ -32,8 +36,11 @@ vi.mock('@flighthq/render-gl/contract', () => ({
32
36
  }));
33
37
 
34
38
  beforeEach(() => {
35
- mocks.createGlRenderState.mockImplementation((canvas: HTMLCanvasElement, options: { pixelRatio: number }) => ({
36
- canvas,
39
+ mocks.createGlContextFromCanvasElement.mockImplementation(() => ({ drawingBufferHeight: 0, drawingBufferWidth: 0 }));
40
+ mocks.createGlContextState.mockImplementation((gl) => ({ gl }));
41
+ mocks.createGlRenderState.mockImplementation((contextState, _pipeline, options: { pixelRatio: number }) => ({
42
+ contextState,
43
+ gl: contextState.gl,
37
44
  pixelRatio: options.pixelRatio,
38
45
  renderTransform2D: { a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0 },
39
46
  }));
@@ -52,6 +59,8 @@ beforeEach(() => {
52
59
  );
53
60
  });
54
61
 
62
+ const pipeline = {} as GlPipeline;
63
+
55
64
  describe('createGlApplicationRenderView', () => {
56
65
  it('allocates and links the GL state, target, and device-pixel viewport', () => {
57
66
  const window = createApplicationWindow();
@@ -61,13 +70,22 @@ describe('createGlApplicationRenderView', () => {
61
70
  const canvas = document.createElement('canvas');
62
71
 
63
72
  const view = createGlApplicationRenderView(window, canvas, {
64
- render: { antialias: false },
73
+ context: { antialias: false },
74
+ pipeline,
75
+ render: { roundPixels: true },
65
76
  target: { colorSpace: 'linear', depth: 'depth-stencil' },
66
77
  });
67
78
 
68
79
  expect(canvas.width).toBe(640);
69
80
  expect(canvas.height).toBe(360);
70
- expect(mocks.createGlRenderState).toHaveBeenCalledWith(canvas, { antialias: false, pixelRatio: 2 });
81
+ expect(mocks.createGlContextFromCanvasElement).toHaveBeenCalledWith(canvas, { antialias: false });
82
+ expect(mocks.createGlContextState).toHaveBeenCalledWith(
83
+ mocks.createGlContextFromCanvasElement.mock.results[0].value,
84
+ );
85
+ expect(mocks.createGlRenderState).toHaveBeenCalledWith(mocks.createGlContextState.mock.results[0].value, pipeline, {
86
+ pixelRatio: 2,
87
+ roundPixels: true,
88
+ });
71
89
  expect(mocks.createGlRenderTarget).toHaveBeenCalledWith(view.renderState, {
72
90
  colorSpace: 'linear',
73
91
  depth: 'depth-stencil',
@@ -82,7 +100,7 @@ describe('createGlApplicationRenderView', () => {
82
100
  window.width = 20;
83
101
  window.height = 10;
84
102
  const canvas = document.createElement('canvas');
85
- const view = createGlApplicationRenderView(window, canvas);
103
+ const view = createGlApplicationRenderView(window, canvas, { pipeline });
86
104
  mocks.invalidateGlRenderStateCache.mockClear();
87
105
  mocks.resizeGlRenderTarget.mockClear();
88
106
 
@@ -103,7 +121,7 @@ describe('destroyGlApplicationRenderView', () => {
103
121
  const window = createApplicationWindow();
104
122
  window.width = 20;
105
123
  window.height = 10;
106
- const view = createGlApplicationRenderView(window, document.createElement('canvas'));
124
+ const view = createGlApplicationRenderView(window, document.createElement('canvas'), { pipeline });
107
125
  attachApplicationRenderView(view);
108
126
  mocks.resizeGlRenderTarget.mockClear();
109
127