@luma.gl/core 9.2.5 → 9.3.0-alpha.10
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/dist/adapter/canvas-context.d.ts +6 -162
- package/dist/adapter/canvas-context.d.ts.map +1 -1
- package/dist/adapter/canvas-context.js +5 -419
- package/dist/adapter/canvas-context.js.map +1 -1
- package/dist/adapter/canvas-observer.d.ts +32 -0
- package/dist/adapter/canvas-observer.d.ts.map +1 -0
- package/dist/adapter/canvas-observer.js +90 -0
- package/dist/adapter/canvas-observer.js.map +1 -0
- package/dist/adapter/canvas-surface.d.ts +150 -0
- package/dist/adapter/canvas-surface.d.ts.map +1 -0
- package/dist/adapter/canvas-surface.js +392 -0
- package/dist/adapter/canvas-surface.js.map +1 -0
- package/dist/adapter/device.d.ts +81 -16
- package/dist/adapter/device.d.ts.map +1 -1
- package/dist/adapter/device.js +196 -10
- package/dist/adapter/device.js.map +1 -1
- package/dist/adapter/luma.js +1 -1
- package/dist/adapter/luma.js.map +1 -1
- package/dist/adapter/presentation-context.d.ts +11 -0
- package/dist/adapter/presentation-context.d.ts.map +1 -0
- package/dist/adapter/presentation-context.js +12 -0
- package/dist/adapter/presentation-context.js.map +1 -0
- package/dist/adapter/resources/buffer.d.ts +5 -5
- package/dist/adapter/resources/buffer.d.ts.map +1 -1
- package/dist/adapter/resources/buffer.js +18 -7
- package/dist/adapter/resources/buffer.js.map +1 -1
- package/dist/adapter/resources/command-buffer.d.ts +3 -1
- package/dist/adapter/resources/command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/command-buffer.js +3 -1
- package/dist/adapter/resources/command-buffer.js.map +1 -1
- package/dist/adapter/resources/command-encoder.d.ts +30 -7
- package/dist/adapter/resources/command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/command-encoder.js +68 -2
- package/dist/adapter/resources/command-encoder.js.map +1 -1
- package/dist/adapter/resources/compute-pipeline.d.ts +2 -2
- package/dist/adapter/resources/compute-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/fence.d.ts +16 -0
- package/dist/adapter/resources/fence.d.ts.map +1 -0
- package/dist/adapter/resources/fence.js +17 -0
- package/dist/adapter/resources/fence.js.map +1 -0
- package/dist/adapter/resources/framebuffer.d.ts +1 -1
- package/dist/adapter/resources/framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/framebuffer.js +15 -12
- package/dist/adapter/resources/framebuffer.js.map +1 -1
- package/dist/adapter/resources/query-set.d.ts +17 -1
- package/dist/adapter/resources/query-set.d.ts.map +1 -1
- package/dist/adapter/resources/query-set.js.map +1 -1
- package/dist/adapter/resources/render-pipeline.d.ts +28 -10
- package/dist/adapter/resources/render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/render-pipeline.js +21 -2
- package/dist/adapter/resources/render-pipeline.js.map +1 -1
- package/dist/adapter/resources/resource.d.ts +13 -0
- package/dist/adapter/resources/resource.d.ts.map +1 -1
- package/dist/adapter/resources/resource.js +243 -14
- package/dist/adapter/resources/resource.js.map +1 -1
- package/dist/adapter/resources/shader.js +27 -25
- package/dist/adapter/resources/shader.js.map +1 -1
- package/dist/adapter/resources/shared-render-pipeline.d.ts +22 -0
- package/dist/adapter/resources/shared-render-pipeline.d.ts.map +1 -0
- package/dist/adapter/resources/shared-render-pipeline.js +25 -0
- package/dist/adapter/resources/shared-render-pipeline.js.map +1 -0
- package/dist/adapter/resources/texture-view.d.ts +1 -1
- package/dist/adapter/resources/texture-view.d.ts.map +1 -1
- package/dist/adapter/resources/texture.d.ts +168 -28
- package/dist/adapter/resources/texture.d.ts.map +1 -1
- package/dist/adapter/resources/texture.js +284 -25
- package/dist/adapter/resources/texture.js.map +1 -1
- package/dist/adapter/types/attachments.d.ts +1 -1
- package/dist/adapter/types/attachments.d.ts.map +1 -1
- package/dist/adapter/types/buffer-layout.d.ts +1 -1
- package/dist/adapter/types/buffer-layout.d.ts.map +1 -1
- package/dist/adapter/types/parameters.d.ts +3 -1
- package/dist/adapter/types/parameters.d.ts.map +1 -1
- package/dist/adapter/types/parameters.js +1 -0
- package/dist/adapter/types/parameters.js.map +1 -1
- package/dist/adapter/types/shader-layout.d.ts +10 -6
- package/dist/adapter/types/shader-layout.d.ts.map +1 -1
- package/dist/adapter/types/uniforms.d.ts +6 -0
- package/dist/adapter/types/uniforms.d.ts.map +1 -1
- package/dist/adapter-utils/bind-groups.d.ts +9 -0
- package/dist/adapter-utils/bind-groups.d.ts.map +1 -0
- package/dist/adapter-utils/bind-groups.js +41 -0
- package/dist/adapter-utils/bind-groups.js.map +1 -0
- package/dist/adapter-utils/format-compiler-log.d.ts.map +1 -1
- package/dist/adapter-utils/format-compiler-log.js +23 -15
- package/dist/adapter-utils/format-compiler-log.js.map +1 -1
- package/dist/adapter-utils/get-attribute-from-layouts.d.ts +2 -2
- package/dist/adapter-utils/get-attribute-from-layouts.d.ts.map +1 -1
- package/dist/adapter-utils/get-attribute-from-layouts.js +6 -6
- package/dist/adapter-utils/get-attribute-from-layouts.js.map +1 -1
- package/dist/dist.dev.js +2692 -645
- package/dist/dist.min.js +10 -9
- package/dist/factories/bind-group-factory.d.ts +20 -0
- package/dist/factories/bind-group-factory.d.ts.map +1 -0
- package/dist/factories/bind-group-factory.js +79 -0
- package/dist/factories/bind-group-factory.js.map +1 -0
- package/dist/factories/core-module-state.d.ts +7 -0
- package/dist/factories/core-module-state.d.ts.map +1 -0
- package/dist/{shadertypes/data-types/shader-types.js → factories/core-module-state.js} +1 -1
- package/dist/factories/core-module-state.js.map +1 -0
- package/dist/factories/pipeline-factory.d.ts +54 -0
- package/dist/factories/pipeline-factory.d.ts.map +1 -0
- package/dist/factories/pipeline-factory.js +270 -0
- package/dist/factories/pipeline-factory.js.map +1 -0
- package/dist/factories/shader-factory.d.ts +20 -0
- package/dist/factories/shader-factory.d.ts.map +1 -0
- package/dist/factories/shader-factory.js +84 -0
- package/dist/factories/shader-factory.js.map +1 -0
- package/dist/index.cjs +2427 -554
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +30 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -7
- package/dist/index.js.map +1 -1
- package/dist/portable/shader-block-writer.d.ts +51 -0
- package/dist/portable/shader-block-writer.d.ts.map +1 -0
- package/dist/portable/shader-block-writer.js +185 -0
- package/dist/portable/shader-block-writer.js.map +1 -0
- package/dist/portable/uniform-block.d.ts +1 -1
- package/dist/portable/uniform-block.d.ts.map +1 -1
- package/dist/portable/uniform-store.d.ts +55 -24
- package/dist/portable/uniform-store.d.ts.map +1 -1
- package/dist/portable/uniform-store.js +73 -25
- package/dist/portable/uniform-store.js.map +1 -1
- package/dist/shadertypes/data-types/data-type-decoder.d.ts +20 -0
- package/dist/shadertypes/data-types/data-type-decoder.d.ts.map +1 -0
- package/dist/shadertypes/data-types/data-type-decoder.js +79 -0
- package/dist/shadertypes/data-types/data-type-decoder.js.map +1 -0
- package/dist/shadertypes/data-types/data-types.d.ts +31 -12
- package/dist/shadertypes/data-types/data-types.d.ts.map +1 -1
- package/dist/shadertypes/data-types/decode-data-types.d.ts.map +1 -1
- package/dist/shadertypes/data-types/decode-data-types.js +2 -1
- package/dist/shadertypes/data-types/decode-data-types.js.map +1 -1
- package/dist/{image-utils → shadertypes/image-types}/image-types.d.ts +0 -6
- package/dist/shadertypes/image-types/image-types.d.ts.map +1 -0
- package/dist/shadertypes/image-types/image-types.js.map +1 -0
- package/dist/shadertypes/shader-types/shader-block-layout.d.ts +72 -0
- package/dist/shadertypes/shader-types/shader-block-layout.d.ts.map +1 -0
- package/dist/shadertypes/shader-types/shader-block-layout.js +209 -0
- package/dist/shadertypes/shader-types/shader-block-layout.js.map +1 -0
- package/dist/shadertypes/shader-types/shader-type-decoder.d.ts +41 -0
- package/dist/shadertypes/shader-types/shader-type-decoder.d.ts.map +1 -0
- package/dist/shadertypes/{data-types/decode-shader-types.js → shader-types/shader-type-decoder.js} +43 -4
- package/dist/shadertypes/shader-types/shader-type-decoder.js.map +1 -0
- package/dist/shadertypes/shader-types/shader-types.d.ts +101 -0
- package/dist/shadertypes/shader-types/shader-types.d.ts.map +1 -0
- package/dist/shadertypes/shader-types/shader-types.js +30 -0
- package/dist/shadertypes/shader-types/shader-types.js.map +1 -0
- package/dist/shadertypes/texture-types/pixel-utils.d.ts.map +1 -0
- package/dist/shadertypes/{textures → texture-types}/pixel-utils.js +4 -4
- package/dist/shadertypes/texture-types/pixel-utils.js.map +1 -0
- package/dist/shadertypes/texture-types/texture-format-decoder.d.ts +36 -0
- package/dist/shadertypes/texture-types/texture-format-decoder.d.ts.map +1 -0
- package/dist/shadertypes/{textures → texture-types}/texture-format-decoder.js +109 -37
- package/dist/shadertypes/texture-types/texture-format-decoder.js.map +1 -0
- package/dist/shadertypes/texture-types/texture-format-generics.d.ts +34 -0
- package/dist/shadertypes/texture-types/texture-format-generics.d.ts.map +1 -0
- package/dist/shadertypes/texture-types/texture-format-generics.js.map +1 -0
- package/dist/shadertypes/texture-types/texture-format-table.d.ts.map +1 -0
- package/dist/shadertypes/{textures → texture-types}/texture-format-table.js +10 -9
- package/dist/shadertypes/texture-types/texture-format-table.js.map +1 -0
- package/dist/shadertypes/{textures → texture-types}/texture-formats.d.ts +51 -17
- package/dist/shadertypes/texture-types/texture-formats.d.ts.map +1 -0
- package/dist/shadertypes/{textures → texture-types}/texture-formats.js +1 -0
- package/dist/shadertypes/texture-types/texture-formats.js.map +1 -0
- package/dist/shadertypes/texture-types/texture-layout.d.ts +5 -0
- package/dist/shadertypes/texture-types/texture-layout.d.ts.map +1 -0
- package/dist/shadertypes/texture-types/texture-layout.js +41 -0
- package/dist/shadertypes/texture-types/texture-layout.js.map +1 -0
- package/dist/shadertypes/vertex-types/vertex-format-decoder.d.ts +24 -0
- package/dist/shadertypes/vertex-types/vertex-format-decoder.d.ts.map +1 -0
- package/dist/shadertypes/vertex-types/vertex-format-decoder.js +106 -0
- package/dist/shadertypes/vertex-types/vertex-format-decoder.js.map +1 -0
- package/dist/shadertypes/vertex-types/vertex-formats.d.ts +50 -0
- package/dist/shadertypes/vertex-types/vertex-formats.d.ts.map +1 -0
- package/dist/shadertypes/vertex-types/vertex-formats.js.map +1 -0
- package/dist/utils/array-equal.d.ts +1 -1
- package/dist/utils/array-equal.d.ts.map +1 -1
- package/dist/utils/array-equal.js +15 -9
- package/dist/utils/array-equal.js.map +1 -1
- package/dist/utils/assert.d.ts +5 -0
- package/dist/utils/assert.d.ts.map +1 -0
- package/dist/utils/assert.js +17 -0
- package/dist/utils/assert.js.map +1 -0
- package/dist/utils/stats-manager.d.ts.map +1 -1
- package/dist/utils/stats-manager.js +61 -1
- package/dist/utils/stats-manager.js.map +1 -1
- package/package.json +6 -6
- package/src/adapter/canvas-context.ts +7 -556
- package/src/adapter/canvas-observer.ts +130 -0
- package/src/adapter/canvas-surface.ts +521 -0
- package/src/adapter/device.ts +312 -24
- package/src/adapter/presentation-context.ts +16 -0
- package/src/adapter/resources/buffer.ts +19 -9
- package/src/adapter/resources/command-buffer.ts +4 -2
- package/src/adapter/resources/command-encoder.ts +101 -10
- package/src/adapter/resources/compute-pipeline.ts +2 -2
- package/src/adapter/resources/fence.ts +32 -0
- package/src/adapter/resources/framebuffer.ts +16 -13
- package/src/adapter/resources/query-set.ts +17 -1
- package/src/adapter/resources/render-pipeline.ts +52 -16
- package/src/adapter/resources/resource.ts +289 -14
- package/src/adapter/resources/shader.ts +28 -28
- package/src/adapter/resources/shared-render-pipeline.ts +40 -0
- package/src/adapter/resources/texture-view.ts +1 -1
- package/src/adapter/resources/texture.ts +427 -49
- package/src/adapter/types/attachments.ts +1 -1
- package/src/adapter/types/buffer-layout.ts +1 -1
- package/src/adapter/types/parameters.ts +4 -1
- package/src/adapter/types/shader-layout.ts +15 -9
- package/src/adapter/types/uniforms.ts +12 -0
- package/src/adapter-utils/bind-groups.ts +71 -0
- package/src/adapter-utils/format-compiler-log.ts +23 -15
- package/src/adapter-utils/get-attribute-from-layouts.ts +8 -11
- package/src/factories/bind-group-factory.ts +139 -0
- package/src/factories/core-module-state.ts +11 -0
- package/src/factories/pipeline-factory.ts +328 -0
- package/src/factories/shader-factory.ts +103 -0
- package/src/index.ts +70 -26
- package/src/portable/shader-block-writer.ts +254 -0
- package/src/portable/uniform-block.ts +1 -1
- package/src/portable/uniform-store.ts +98 -40
- package/src/shadertypes/data-types/data-type-decoder.ts +105 -0
- package/src/shadertypes/data-types/data-types.ts +100 -48
- package/src/shadertypes/data-types/decode-data-types.ts +2 -1
- package/src/{image-utils → shadertypes/image-types}/image-types.ts +0 -7
- package/src/shadertypes/shader-types/shader-block-layout.ts +340 -0
- package/src/shadertypes/{data-types/decode-shader-types.ts → shader-types/shader-type-decoder.ts} +88 -14
- package/src/shadertypes/shader-types/shader-types.ts +207 -0
- package/src/shadertypes/{textures → texture-types}/pixel-utils.ts +4 -4
- package/src/shadertypes/{textures → texture-types}/texture-format-decoder.ts +166 -45
- package/src/shadertypes/{textures → texture-types}/texture-format-generics.ts +42 -48
- package/src/shadertypes/{textures → texture-types}/texture-format-table.ts +10 -9
- package/src/shadertypes/{textures → texture-types}/texture-formats.ts +73 -17
- package/src/shadertypes/texture-types/texture-layout.ts +60 -0
- package/src/shadertypes/vertex-types/vertex-format-decoder.ts +131 -0
- package/src/shadertypes/vertex-types/vertex-formats.ts +183 -0
- package/src/utils/array-equal.ts +21 -9
- package/src/utils/assert.ts +18 -0
- package/src/utils/stats-manager.ts +76 -2
- package/dist/image-utils/image-types.d.ts.map +0 -1
- package/dist/image-utils/image-types.js.map +0 -1
- package/dist/portable/uniform-buffer-layout.d.ts +0 -28
- package/dist/portable/uniform-buffer-layout.d.ts.map +0 -1
- package/dist/portable/uniform-buffer-layout.js +0 -96
- package/dist/portable/uniform-buffer-layout.js.map +0 -1
- package/dist/shadertypes/data-types/decode-shader-types.d.ts +0 -17
- package/dist/shadertypes/data-types/decode-shader-types.d.ts.map +0 -1
- package/dist/shadertypes/data-types/decode-shader-types.js.map +0 -1
- package/dist/shadertypes/data-types/shader-types.d.ts +0 -45
- package/dist/shadertypes/data-types/shader-types.d.ts.map +0 -1
- package/dist/shadertypes/data-types/shader-types.js.map +0 -1
- package/dist/shadertypes/textures/pixel-utils.d.ts.map +0 -1
- package/dist/shadertypes/textures/pixel-utils.js.map +0 -1
- package/dist/shadertypes/textures/texture-format-decoder.d.ts +0 -18
- package/dist/shadertypes/textures/texture-format-decoder.d.ts.map +0 -1
- package/dist/shadertypes/textures/texture-format-decoder.js.map +0 -1
- package/dist/shadertypes/textures/texture-format-generics.d.ts +0 -33
- package/dist/shadertypes/textures/texture-format-generics.d.ts.map +0 -1
- package/dist/shadertypes/textures/texture-format-generics.js.map +0 -1
- package/dist/shadertypes/textures/texture-format-table.d.ts.map +0 -1
- package/dist/shadertypes/textures/texture-format-table.js.map +0 -1
- package/dist/shadertypes/textures/texture-formats.d.ts.map +0 -1
- package/dist/shadertypes/textures/texture-formats.js.map +0 -1
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.d.ts +0 -18
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.d.ts.map +0 -1
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.js +0 -100
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.js.map +0 -1
- package/dist/shadertypes/vertex-arrays/vertex-formats.d.ts +0 -27
- package/dist/shadertypes/vertex-arrays/vertex-formats.d.ts.map +0 -1
- package/dist/shadertypes/vertex-arrays/vertex-formats.js.map +0 -1
- package/src/portable/uniform-buffer-layout.ts +0 -118
- package/src/shadertypes/data-types/shader-types.ts +0 -87
- package/src/shadertypes/vertex-arrays/decode-vertex-format.ts +0 -124
- package/src/shadertypes/vertex-arrays/vertex-formats.ts +0 -91
- /package/dist/{image-utils → shadertypes/image-types}/image-types.js +0 -0
- /package/dist/shadertypes/{textures → texture-types}/pixel-utils.d.ts +0 -0
- /package/dist/shadertypes/{textures → texture-types}/texture-format-generics.js +0 -0
- /package/dist/shadertypes/{textures → texture-types}/texture-format-table.d.ts +0 -0
- /package/dist/shadertypes/{vertex-arrays → vertex-types}/vertex-formats.js +0 -0
|
@@ -1,167 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import type { TextureFormatDepthStencil } from "../shadertypes/textures/texture-formats.js";
|
|
4
|
-
/** Properties for a CanvasContext */
|
|
5
|
-
export type CanvasContextProps = {
|
|
6
|
-
/** Identifier, for debugging */
|
|
7
|
-
id?: string;
|
|
8
|
-
/** If a canvas not supplied, one will be created and added to the DOM. If a string, a canvas with that id will be looked up in the DOM */
|
|
9
|
-
canvas?: HTMLCanvasElement | OffscreenCanvas | string | null;
|
|
10
|
-
/** If new canvas is created, it will be created in the specified container, otherwise is appended as a child of document.body */
|
|
11
|
-
container?: HTMLElement | string | null;
|
|
12
|
-
/** Width in pixels of the canvas - used when creating a new canvas */
|
|
13
|
-
width?: number;
|
|
14
|
-
/** Height in pixels of the canvas - used when creating a new canvas */
|
|
15
|
-
height?: number;
|
|
16
|
-
/** Visibility (only used if new canvas is created). */
|
|
17
|
-
visible?: boolean;
|
|
18
|
-
/** Whether to size the drawing buffer to the pixel size during auto resize. If a number is provided it is used as a static pixel ratio */
|
|
19
|
-
useDevicePixels?: boolean | number;
|
|
20
|
-
/** Whether to track window resizes. */
|
|
21
|
-
autoResize?: boolean;
|
|
22
|
-
/** @see https://developer.mozilla.org/en-US/docs/Web/API/GPUCanvasContext/configure#alphamode */
|
|
23
|
-
alphaMode?: 'opaque' | 'premultiplied';
|
|
24
|
-
/** @see https://developer.mozilla.org/en-US/docs/Web/API/GPUCanvasContext/configure#colorspace */
|
|
25
|
-
colorSpace?: 'srgb';
|
|
26
|
-
/** Whether to track position changes. Calls this.device.onPositionChange */
|
|
27
|
-
trackPosition?: boolean;
|
|
28
|
-
};
|
|
29
|
-
export type MutableCanvasContextProps = {
|
|
30
|
-
/** Whether to size the drawing buffer to the pixel size during auto resize. If a number is provided it is used as a static pixel ratio */
|
|
31
|
-
useDevicePixels?: boolean | number;
|
|
32
|
-
};
|
|
1
|
+
export type { CanvasContextProps, MutableCanvasContextProps } from "./canvas-surface.js";
|
|
2
|
+
import { CanvasSurface } from "./canvas-surface.js";
|
|
33
3
|
/**
|
|
34
|
-
* Manages a canvas. Supports both HTML or offscreen canvas
|
|
35
|
-
*
|
|
36
|
-
* - Provides check for DOM loaded
|
|
37
|
-
* @todo commit() @see https://github.com/w3ctag/design-reviews/issues/288
|
|
38
|
-
* @todo transferControlToOffscreen: @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/transferControlToOffscreen
|
|
4
|
+
* Manages a renderable backend canvas. Supports both HTML or offscreen canvas
|
|
5
|
+
* and returns backend framebuffers sourced from the canvas itself.
|
|
39
6
|
*/
|
|
40
|
-
export declare abstract class CanvasContext {
|
|
41
|
-
static
|
|
42
|
-
static isOffscreenCanvas(canvas: unknown): canvas is OffscreenCanvas;
|
|
43
|
-
static defaultProps: Required<CanvasContextProps>;
|
|
44
|
-
abstract readonly device: Device;
|
|
7
|
+
export declare abstract class CanvasContext extends CanvasSurface {
|
|
8
|
+
static defaultProps: Required<import("./canvas-surface").CanvasContextProps>;
|
|
45
9
|
abstract readonly handle: unknown;
|
|
46
|
-
readonly id: string;
|
|
47
|
-
readonly props: Required<CanvasContextProps>;
|
|
48
|
-
readonly canvas: HTMLCanvasElement | OffscreenCanvas;
|
|
49
|
-
/** Handle to HTML canvas */
|
|
50
|
-
readonly htmlCanvas?: HTMLCanvasElement;
|
|
51
|
-
/** Handle to wrapped OffScreenCanvas */
|
|
52
|
-
readonly offscreenCanvas?: OffscreenCanvas;
|
|
53
|
-
readonly type: 'html-canvas' | 'offscreen-canvas' | 'node';
|
|
54
|
-
/** Promise that resolved once the resize observer has updated the pixel size */
|
|
55
|
-
initialized: Promise<void>;
|
|
56
|
-
isInitialized: boolean;
|
|
57
|
-
/** Visibility is automatically updated (via an IntersectionObserver) */
|
|
58
|
-
isVisible: boolean;
|
|
59
|
-
/** Width of canvas in CSS units (tracked by a ResizeObserver) */
|
|
60
|
-
cssWidth: number;
|
|
61
|
-
/** Height of canvas in CSS units (tracked by a ResizeObserver) */
|
|
62
|
-
cssHeight: number;
|
|
63
|
-
/** Device pixel ratio. Automatically updated via media queries */
|
|
64
|
-
devicePixelRatio: number;
|
|
65
|
-
/** Exact width of canvas in physical pixels (tracked by a ResizeObserver) */
|
|
66
|
-
devicePixelWidth: number;
|
|
67
|
-
/** Exact height of canvas in physical pixels (tracked by a ResizeObserver) */
|
|
68
|
-
devicePixelHeight: number;
|
|
69
|
-
/** Width of drawing buffer: automatically tracks this.pixelWidth if props.autoResize is true */
|
|
70
|
-
drawingBufferWidth: number;
|
|
71
|
-
/** Height of drawing buffer: automatically tracks this.pixelHeight if props.autoResize is true */
|
|
72
|
-
drawingBufferHeight: number;
|
|
73
|
-
protected _initializedResolvers: {
|
|
74
|
-
promise: Promise<void>;
|
|
75
|
-
resolve: (t: void) => void;
|
|
76
|
-
reject: (error: Error) => void;
|
|
77
|
-
};
|
|
78
|
-
protected readonly _resizeObserver: ResizeObserver | undefined;
|
|
79
|
-
protected readonly _intersectionObserver: IntersectionObserver | undefined;
|
|
80
|
-
protected _position: [number, number];
|
|
81
|
-
protected destroyed: boolean;
|
|
82
|
-
abstract get [Symbol.toStringTag](): string;
|
|
83
|
-
toString(): string;
|
|
84
|
-
constructor(props?: CanvasContextProps);
|
|
85
|
-
destroy(): void;
|
|
86
|
-
setProps(props: MutableCanvasContextProps): this;
|
|
87
|
-
/** Returns a framebuffer with properly resized current 'swap chain' textures */
|
|
88
|
-
abstract getCurrentFramebuffer(options?: {
|
|
89
|
-
depthStencilFormat?: TextureFormatDepthStencil | false;
|
|
90
|
-
}): Framebuffer;
|
|
91
|
-
/**
|
|
92
|
-
* Returns the size covered by the canvas in CSS pixels
|
|
93
|
-
* @note This can be different from the actual device pixel size of a canvas due to DPR scaling, and rounding to integer pixels
|
|
94
|
-
* @note This is independent of the canvas' internal drawing buffer size (.width, .height).
|
|
95
|
-
*/
|
|
96
|
-
getCSSSize(): [number, number];
|
|
97
|
-
getPosition(): [number, number];
|
|
98
|
-
/**
|
|
99
|
-
* Returns the size covered by the canvas in actual device pixels.
|
|
100
|
-
* @note This can be different from the 'CSS' size of a canvas due to DPR scaling, and rounding to integer pixels
|
|
101
|
-
* @note This is independent of the canvas' internal drawing buffer size (.width, .height).
|
|
102
|
-
*/
|
|
103
|
-
getDevicePixelSize(): [number, number];
|
|
104
|
-
/** Get the drawing buffer size (number of pixels GPU is rendering into, can be different from CSS size) */
|
|
105
|
-
getDrawingBufferSize(): [number, number];
|
|
106
|
-
/** Returns the biggest allowed framebuffer size. @todo Allow the application to limit this? */
|
|
107
|
-
getMaxDrawingBufferSize(): [number, number];
|
|
108
|
-
/** Update the canvas drawing buffer size. Called automatically if props.autoResize is true. */
|
|
109
|
-
setDrawingBufferSize(width: number, height: number): void;
|
|
110
|
-
/**
|
|
111
|
-
* Returns the current DPR (number of physical pixels per CSS pixel), if props.useDevicePixels is true
|
|
112
|
-
* @note This can be a fractional (non-integer) number, e.g. when the user zooms in the browser.
|
|
113
|
-
* @note This function handles the non-HTML canvas cases
|
|
114
|
-
*/
|
|
115
|
-
getDevicePixelRatio(): number;
|
|
116
|
-
/**
|
|
117
|
-
* Maps CSS pixel position to device pixel position
|
|
118
|
-
*/
|
|
119
|
-
cssToDevicePixels(cssPixel: [number, number], yInvert?: boolean): {
|
|
120
|
-
x: number;
|
|
121
|
-
y: number;
|
|
122
|
-
width: number;
|
|
123
|
-
height: number;
|
|
124
|
-
};
|
|
125
|
-
/** @deprecated - use .getDevicePixelSize() */
|
|
126
|
-
getPixelSize(): [number, number];
|
|
127
|
-
/** @deprecated - TODO which values should we use for aspect */
|
|
128
|
-
getAspect(): number;
|
|
129
|
-
/** @deprecated Returns multiplier need to convert CSS size to Device size */
|
|
130
|
-
cssToDeviceRatio(): number;
|
|
131
|
-
/** @deprecated Use canvasContext.setDrawingBufferSize() */
|
|
132
|
-
resize(size: {
|
|
133
|
-
width: number;
|
|
134
|
-
height: number;
|
|
135
|
-
}): void;
|
|
136
|
-
/**
|
|
137
|
-
* Performs platform specific updates (WebGPU vs WebGL)
|
|
138
|
-
* Can be called after changes to size or props,
|
|
139
|
-
* to give implementation an opportunity to update configurations.
|
|
140
|
-
*/
|
|
141
|
-
protected abstract _updateDevice(): void;
|
|
142
|
-
/**
|
|
143
|
-
* Allows subclass constructor to override the canvas id for auto created canvases.
|
|
144
|
-
* This can really help when debugging DOM in apps that create multiple devices
|
|
145
|
-
*/
|
|
146
|
-
protected _setAutoCreatedCanvasId(id: string): void;
|
|
147
|
-
/** reacts to an observed intersection */
|
|
148
|
-
protected _handleIntersection(entries: IntersectionObserverEntry[]): void;
|
|
149
|
-
/**
|
|
150
|
-
* Reacts to an observed resize by using the most accurate pixel size information the browser can provide
|
|
151
|
-
* @see https://web.dev/articles/device-pixel-content-box
|
|
152
|
-
* @see https://webgpufundamentals.org/webgpu/lessons/webgpu-resizing-the-canvas.html
|
|
153
|
-
*/
|
|
154
|
-
protected _handleResize(entries: ResizeObserverEntry[]): void;
|
|
155
|
-
protected _updateDrawingBufferSize(): void;
|
|
156
|
-
/** Monitor DPR changes */
|
|
157
|
-
_observeDevicePixelRatio(): void;
|
|
158
|
-
/** Start tracking positions with a timer */
|
|
159
|
-
_trackPosition(intervalMs?: number): void;
|
|
160
|
-
/**
|
|
161
|
-
* Calculated the absolute position of the canvas
|
|
162
|
-
* @note - getBoundingClientRect() is normally cheap but can be expensive
|
|
163
|
-
* if called before browser has finished a reflow. Should not be the case here.
|
|
164
|
-
*/
|
|
165
|
-
updatePosition(): void;
|
|
166
10
|
}
|
|
167
11
|
//# sourceMappingURL=canvas-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas-context.d.ts","sourceRoot":"","sources":["../../src/adapter/canvas-context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"canvas-context.d.ts","sourceRoot":"","sources":["../../src/adapter/canvas-context.ts"],"names":[],"mappings":"AAIA,YAAY,EAAC,kBAAkB,EAAE,yBAAyB,EAAC,4BAAyB;AACpF,OAAO,EAAC,aAAa,EAAC,4BAAyB;AAE/C;;;GAGG;AACH,8BAAsB,aAAc,SAAQ,aAAa;IACvD,OAAgB,YAAY,0DAA8B;IAE1D,kBAA2B,MAAM,EAAE,OAAO,CAAC;CAC5C"}
|
|
@@ -1,426 +1,12 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
import {
|
|
5
|
-
import { uid } from "../utils/uid.js";
|
|
6
|
-
import { withResolvers } from "../utils/promise-utils.js";
|
|
4
|
+
import { CanvasSurface } from "./canvas-surface.js";
|
|
7
5
|
/**
|
|
8
|
-
* Manages a canvas. Supports both HTML or offscreen canvas
|
|
9
|
-
*
|
|
10
|
-
* - Provides check for DOM loaded
|
|
11
|
-
* @todo commit() @see https://github.com/w3ctag/design-reviews/issues/288
|
|
12
|
-
* @todo transferControlToOffscreen: @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/transferControlToOffscreen
|
|
6
|
+
* Manages a renderable backend canvas. Supports both HTML or offscreen canvas
|
|
7
|
+
* and returns backend framebuffers sourced from the canvas itself.
|
|
13
8
|
*/
|
|
14
|
-
export class CanvasContext {
|
|
15
|
-
static
|
|
16
|
-
return typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement;
|
|
17
|
-
}
|
|
18
|
-
static isOffscreenCanvas(canvas) {
|
|
19
|
-
return typeof OffscreenCanvas !== 'undefined' && canvas instanceof OffscreenCanvas;
|
|
20
|
-
}
|
|
21
|
-
static defaultProps = {
|
|
22
|
-
id: undefined,
|
|
23
|
-
canvas: null,
|
|
24
|
-
width: 800,
|
|
25
|
-
height: 600,
|
|
26
|
-
useDevicePixels: true,
|
|
27
|
-
autoResize: true,
|
|
28
|
-
container: null,
|
|
29
|
-
visible: true,
|
|
30
|
-
alphaMode: 'opaque',
|
|
31
|
-
colorSpace: 'srgb',
|
|
32
|
-
trackPosition: false
|
|
33
|
-
};
|
|
34
|
-
id;
|
|
35
|
-
props;
|
|
36
|
-
canvas;
|
|
37
|
-
/** Handle to HTML canvas */
|
|
38
|
-
htmlCanvas;
|
|
39
|
-
/** Handle to wrapped OffScreenCanvas */
|
|
40
|
-
offscreenCanvas;
|
|
41
|
-
type;
|
|
42
|
-
/** Promise that resolved once the resize observer has updated the pixel size */
|
|
43
|
-
initialized;
|
|
44
|
-
isInitialized = false;
|
|
45
|
-
/** Visibility is automatically updated (via an IntersectionObserver) */
|
|
46
|
-
isVisible = true;
|
|
47
|
-
/** Width of canvas in CSS units (tracked by a ResizeObserver) */
|
|
48
|
-
cssWidth;
|
|
49
|
-
/** Height of canvas in CSS units (tracked by a ResizeObserver) */
|
|
50
|
-
cssHeight;
|
|
51
|
-
/** Device pixel ratio. Automatically updated via media queries */
|
|
52
|
-
devicePixelRatio;
|
|
53
|
-
/** Exact width of canvas in physical pixels (tracked by a ResizeObserver) */
|
|
54
|
-
devicePixelWidth;
|
|
55
|
-
/** Exact height of canvas in physical pixels (tracked by a ResizeObserver) */
|
|
56
|
-
devicePixelHeight;
|
|
57
|
-
/** Width of drawing buffer: automatically tracks this.pixelWidth if props.autoResize is true */
|
|
58
|
-
drawingBufferWidth;
|
|
59
|
-
/** Height of drawing buffer: automatically tracks this.pixelHeight if props.autoResize is true */
|
|
60
|
-
drawingBufferHeight;
|
|
61
|
-
_initializedResolvers = withResolvers();
|
|
62
|
-
_resizeObserver;
|
|
63
|
-
_intersectionObserver;
|
|
64
|
-
_position;
|
|
65
|
-
destroyed = false;
|
|
66
|
-
toString() {
|
|
67
|
-
return `${this[Symbol.toStringTag]}(${this.id})`;
|
|
68
|
-
}
|
|
69
|
-
constructor(props) {
|
|
70
|
-
this.props = { ...CanvasContext.defaultProps, ...props };
|
|
71
|
-
props = this.props;
|
|
72
|
-
this.initialized = this._initializedResolvers.promise;
|
|
73
|
-
// Create a canvas element if needed
|
|
74
|
-
if (!isBrowser()) {
|
|
75
|
-
// TODO - does this prevent app from using jsdom style polyfills?
|
|
76
|
-
this.canvas = { width: props.width || 1, height: props.height || 1 };
|
|
77
|
-
}
|
|
78
|
-
else if (!props.canvas) {
|
|
79
|
-
this.canvas = createCanvasElement(props);
|
|
80
|
-
}
|
|
81
|
-
else if (typeof props.canvas === 'string') {
|
|
82
|
-
this.canvas = getCanvasFromDOM(props.canvas);
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
this.canvas = props.canvas;
|
|
86
|
-
}
|
|
87
|
-
if (CanvasContext.isHTMLCanvas(this.canvas)) {
|
|
88
|
-
this.id = props.id || this.canvas.id;
|
|
89
|
-
this.type = 'html-canvas';
|
|
90
|
-
this.htmlCanvas = this.canvas;
|
|
91
|
-
}
|
|
92
|
-
else if (CanvasContext.isOffscreenCanvas(this.canvas)) {
|
|
93
|
-
this.id = props.id || 'offscreen-canvas';
|
|
94
|
-
this.type = 'offscreen-canvas';
|
|
95
|
-
this.offscreenCanvas = this.canvas;
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
// TODO - Node.js support is currently untested (was used for headless-gl in luma v8)
|
|
99
|
-
this.id = props.id || 'node-canvas-context';
|
|
100
|
-
this.type = 'node';
|
|
101
|
-
}
|
|
102
|
-
// Initialize size variables to some sane values (these will be updated by ResizeObserver)
|
|
103
|
-
this.cssWidth = this.htmlCanvas?.clientWidth || this.canvas.width;
|
|
104
|
-
this.cssHeight = this.htmlCanvas?.clientHeight || this.canvas.height;
|
|
105
|
-
this.devicePixelWidth = this.canvas.width;
|
|
106
|
-
this.devicePixelHeight = this.canvas.height;
|
|
107
|
-
this.drawingBufferWidth = this.canvas.width;
|
|
108
|
-
this.drawingBufferHeight = this.canvas.height;
|
|
109
|
-
this.devicePixelRatio = globalThis.devicePixelRatio || 1;
|
|
110
|
-
this._position = [0, 0];
|
|
111
|
-
if (CanvasContext.isHTMLCanvas(this.canvas)) {
|
|
112
|
-
// Track visibility changes
|
|
113
|
-
this._intersectionObserver = new IntersectionObserver(entries => this._handleIntersection(entries));
|
|
114
|
-
this._intersectionObserver.observe(this.canvas);
|
|
115
|
-
// Track size changes
|
|
116
|
-
this._resizeObserver = new ResizeObserver(entries => this._handleResize(entries));
|
|
117
|
-
try {
|
|
118
|
-
this._resizeObserver.observe(this.canvas, { box: 'device-pixel-content-box' });
|
|
119
|
-
}
|
|
120
|
-
catch {
|
|
121
|
-
// Safari fallback
|
|
122
|
-
this._resizeObserver.observe(this.canvas, { box: 'content-box' });
|
|
123
|
-
}
|
|
124
|
-
// Track device pixel ratio changes.
|
|
125
|
-
// Defer call to after construction completes to ensure `this.device` is available.
|
|
126
|
-
setTimeout(() => this._observeDevicePixelRatio(), 0);
|
|
127
|
-
// Track top/left position changes
|
|
128
|
-
if (this.props.trackPosition) {
|
|
129
|
-
this._trackPosition();
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
destroy() {
|
|
134
|
-
this.destroyed = true;
|
|
135
|
-
}
|
|
136
|
-
setProps(props) {
|
|
137
|
-
if ('useDevicePixels' in props) {
|
|
138
|
-
this.props.useDevicePixels = props.useDevicePixels || false;
|
|
139
|
-
this._updateDrawingBufferSize();
|
|
140
|
-
}
|
|
141
|
-
return this;
|
|
142
|
-
}
|
|
143
|
-
// SIZE METHODS
|
|
144
|
-
/**
|
|
145
|
-
* Returns the size covered by the canvas in CSS pixels
|
|
146
|
-
* @note This can be different from the actual device pixel size of a canvas due to DPR scaling, and rounding to integer pixels
|
|
147
|
-
* @note This is independent of the canvas' internal drawing buffer size (.width, .height).
|
|
148
|
-
*/
|
|
149
|
-
getCSSSize() {
|
|
150
|
-
return [this.cssWidth, this.cssHeight];
|
|
151
|
-
}
|
|
152
|
-
getPosition() {
|
|
153
|
-
return this._position;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Returns the size covered by the canvas in actual device pixels.
|
|
157
|
-
* @note This can be different from the 'CSS' size of a canvas due to DPR scaling, and rounding to integer pixels
|
|
158
|
-
* @note This is independent of the canvas' internal drawing buffer size (.width, .height).
|
|
159
|
-
*/
|
|
160
|
-
getDevicePixelSize() {
|
|
161
|
-
return [this.devicePixelWidth, this.devicePixelHeight];
|
|
162
|
-
}
|
|
163
|
-
/** Get the drawing buffer size (number of pixels GPU is rendering into, can be different from CSS size) */
|
|
164
|
-
getDrawingBufferSize() {
|
|
165
|
-
return [this.drawingBufferWidth, this.drawingBufferHeight];
|
|
166
|
-
}
|
|
167
|
-
/** Returns the biggest allowed framebuffer size. @todo Allow the application to limit this? */
|
|
168
|
-
getMaxDrawingBufferSize() {
|
|
169
|
-
const maxTextureDimension = this.device.limits.maxTextureDimension2D;
|
|
170
|
-
return [maxTextureDimension, maxTextureDimension];
|
|
171
|
-
}
|
|
172
|
-
/** Update the canvas drawing buffer size. Called automatically if props.autoResize is true. */
|
|
173
|
-
setDrawingBufferSize(width, height) {
|
|
174
|
-
this.canvas.width = width;
|
|
175
|
-
this.canvas.height = height;
|
|
176
|
-
this.drawingBufferWidth = width;
|
|
177
|
-
this.drawingBufferHeight = height;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Returns the current DPR (number of physical pixels per CSS pixel), if props.useDevicePixels is true
|
|
181
|
-
* @note This can be a fractional (non-integer) number, e.g. when the user zooms in the browser.
|
|
182
|
-
* @note This function handles the non-HTML canvas cases
|
|
183
|
-
*/
|
|
184
|
-
getDevicePixelRatio() {
|
|
185
|
-
const dpr = typeof window !== 'undefined' && window.devicePixelRatio;
|
|
186
|
-
return dpr || 1;
|
|
187
|
-
}
|
|
188
|
-
// DEPRECATED METHODS
|
|
189
|
-
/**
|
|
190
|
-
* Maps CSS pixel position to device pixel position
|
|
191
|
-
*/
|
|
192
|
-
cssToDevicePixels(cssPixel, yInvert = true) {
|
|
193
|
-
const ratio = this.cssToDeviceRatio();
|
|
194
|
-
const [width, height] = this.getDrawingBufferSize();
|
|
195
|
-
return scalePixels(cssPixel, ratio, width, height, yInvert);
|
|
196
|
-
}
|
|
197
|
-
/** @deprecated - use .getDevicePixelSize() */
|
|
198
|
-
getPixelSize() {
|
|
199
|
-
return this.getDevicePixelSize();
|
|
200
|
-
}
|
|
201
|
-
/** @deprecated - TODO which values should we use for aspect */
|
|
202
|
-
getAspect() {
|
|
203
|
-
const [width, height] = this.getDevicePixelSize();
|
|
204
|
-
return width / height;
|
|
205
|
-
}
|
|
206
|
-
/** @deprecated Returns multiplier need to convert CSS size to Device size */
|
|
207
|
-
cssToDeviceRatio() {
|
|
208
|
-
try {
|
|
209
|
-
const [drawingBufferWidth] = this.getDrawingBufferSize();
|
|
210
|
-
const [cssWidth] = this.getCSSSize();
|
|
211
|
-
return cssWidth ? drawingBufferWidth / cssWidth : 1;
|
|
212
|
-
}
|
|
213
|
-
catch {
|
|
214
|
-
return 1;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
/** @deprecated Use canvasContext.setDrawingBufferSize() */
|
|
218
|
-
resize(size) {
|
|
219
|
-
this.setDrawingBufferSize(size.width, size.height);
|
|
220
|
-
}
|
|
221
|
-
// IMPLEMENTATION
|
|
222
|
-
/**
|
|
223
|
-
* Allows subclass constructor to override the canvas id for auto created canvases.
|
|
224
|
-
* This can really help when debugging DOM in apps that create multiple devices
|
|
225
|
-
*/
|
|
226
|
-
_setAutoCreatedCanvasId(id) {
|
|
227
|
-
if (this.htmlCanvas?.id === 'lumagl-auto-created-canvas') {
|
|
228
|
-
this.htmlCanvas.id = id;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
/** reacts to an observed intersection */
|
|
232
|
-
_handleIntersection(entries) {
|
|
233
|
-
const entry = entries.find(entry_ => entry_.target === this.canvas);
|
|
234
|
-
if (!entry) {
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
// TODO - store intersection rectangle?
|
|
238
|
-
const isVisible = entry.isIntersecting;
|
|
239
|
-
if (this.isVisible !== isVisible) {
|
|
240
|
-
this.isVisible = isVisible;
|
|
241
|
-
this.device.props.onVisibilityChange(this);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Reacts to an observed resize by using the most accurate pixel size information the browser can provide
|
|
246
|
-
* @see https://web.dev/articles/device-pixel-content-box
|
|
247
|
-
* @see https://webgpufundamentals.org/webgpu/lessons/webgpu-resizing-the-canvas.html
|
|
248
|
-
*/
|
|
249
|
-
_handleResize(entries) {
|
|
250
|
-
const entry = entries.find(entry_ => entry_.target === this.canvas);
|
|
251
|
-
if (!entry) {
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
// Update CSS size using content box size
|
|
255
|
-
this.cssWidth = entry.contentBoxSize[0].inlineSize;
|
|
256
|
-
this.cssHeight = entry.contentBoxSize[0].blockSize;
|
|
257
|
-
// Update our drawing buffer size variables, saving the old values for logging
|
|
258
|
-
const oldPixelSize = this.getDevicePixelSize();
|
|
259
|
-
// Use the most accurate drawing buffer size information the current browser can provide
|
|
260
|
-
// Note: content box sizes are guaranteed to be integers
|
|
261
|
-
// Note: Safari falls back to contentBoxSize
|
|
262
|
-
const devicePixelWidth = entry.devicePixelContentBoxSize?.[0].inlineSize ||
|
|
263
|
-
entry.contentBoxSize[0].inlineSize * devicePixelRatio;
|
|
264
|
-
const devicePixelHeight = entry.devicePixelContentBoxSize?.[0].blockSize ||
|
|
265
|
-
entry.contentBoxSize[0].blockSize * devicePixelRatio;
|
|
266
|
-
// Make sure we don't overflow the maximum supported texture size
|
|
267
|
-
const [maxDevicePixelWidth, maxDevicePixelHeight] = this.getMaxDrawingBufferSize();
|
|
268
|
-
this.devicePixelWidth = Math.max(1, Math.min(devicePixelWidth, maxDevicePixelWidth));
|
|
269
|
-
this.devicePixelHeight = Math.max(1, Math.min(devicePixelHeight, maxDevicePixelHeight));
|
|
270
|
-
this._updateDrawingBufferSize();
|
|
271
|
-
// Inform the device
|
|
272
|
-
this.device.props.onResize(this, { oldPixelSize });
|
|
273
|
-
}
|
|
274
|
-
_updateDrawingBufferSize() {
|
|
275
|
-
// Update the canvas drawing buffer size
|
|
276
|
-
if (this.props.autoResize) {
|
|
277
|
-
if (typeof this.props.useDevicePixels === 'number') {
|
|
278
|
-
const dpr = this.props.useDevicePixels;
|
|
279
|
-
this.setDrawingBufferSize(this.cssWidth * dpr, this.cssHeight * dpr);
|
|
280
|
-
}
|
|
281
|
-
else if (this.props.useDevicePixels) {
|
|
282
|
-
this.setDrawingBufferSize(this.devicePixelWidth, this.devicePixelHeight);
|
|
283
|
-
}
|
|
284
|
-
else {
|
|
285
|
-
this.setDrawingBufferSize(this.cssWidth, this.cssHeight);
|
|
286
|
-
}
|
|
287
|
-
// Inform the subclass
|
|
288
|
-
this._updateDevice();
|
|
289
|
-
}
|
|
290
|
-
// Resolve the initialized promise
|
|
291
|
-
this._initializedResolvers.resolve();
|
|
292
|
-
this.isInitialized = true;
|
|
293
|
-
this.updatePosition();
|
|
294
|
-
}
|
|
295
|
-
/** Monitor DPR changes */
|
|
296
|
-
_observeDevicePixelRatio() {
|
|
297
|
-
const oldRatio = this.devicePixelRatio;
|
|
298
|
-
this.devicePixelRatio = window.devicePixelRatio;
|
|
299
|
-
this.updatePosition();
|
|
300
|
-
// Inform the device
|
|
301
|
-
this.device.props.onDevicePixelRatioChange(this, { oldRatio });
|
|
302
|
-
// Set up a one time query against the current resolution.
|
|
303
|
-
matchMedia(`(resolution: ${this.devicePixelRatio}dppx)`).addEventListener('change', () => this._observeDevicePixelRatio(), { once: true });
|
|
304
|
-
}
|
|
305
|
-
/** Start tracking positions with a timer */
|
|
306
|
-
_trackPosition(intervalMs = 100) {
|
|
307
|
-
const intervalId = setInterval(() => {
|
|
308
|
-
if (this.destroyed) {
|
|
309
|
-
clearInterval(intervalId);
|
|
310
|
-
}
|
|
311
|
-
else {
|
|
312
|
-
this.updatePosition();
|
|
313
|
-
}
|
|
314
|
-
}, intervalMs);
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Calculated the absolute position of the canvas
|
|
318
|
-
* @note - getBoundingClientRect() is normally cheap but can be expensive
|
|
319
|
-
* if called before browser has finished a reflow. Should not be the case here.
|
|
320
|
-
*/
|
|
321
|
-
updatePosition() {
|
|
322
|
-
const newRect = this.htmlCanvas?.getBoundingClientRect();
|
|
323
|
-
if (newRect) {
|
|
324
|
-
// We only track position since we rely on the more precise ResizeObserver for size
|
|
325
|
-
const position = [newRect.left, newRect.top];
|
|
326
|
-
this._position ??= position;
|
|
327
|
-
const positionChanged = position[0] !== this._position[0] || position[1] !== this._position[1];
|
|
328
|
-
if (positionChanged) {
|
|
329
|
-
const oldPosition = this._position;
|
|
330
|
-
this._position = position;
|
|
331
|
-
this.device.props.onPositionChange?.(this, { oldPosition });
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
// HELPER FUNCTIONS
|
|
337
|
-
/** Get a container element from a string or DOM element */
|
|
338
|
-
function getContainer(container) {
|
|
339
|
-
if (typeof container === 'string') {
|
|
340
|
-
const element = document.getElementById(container);
|
|
341
|
-
if (!element) {
|
|
342
|
-
throw new Error(`${container} is not an HTML element`);
|
|
343
|
-
}
|
|
344
|
-
return element;
|
|
345
|
-
}
|
|
346
|
-
if (container) {
|
|
347
|
-
return container;
|
|
348
|
-
}
|
|
349
|
-
return document.body;
|
|
350
|
-
}
|
|
351
|
-
/** Get a Canvas element from DOM id */
|
|
352
|
-
function getCanvasFromDOM(canvasId) {
|
|
353
|
-
const canvas = document.getElementById(canvasId);
|
|
354
|
-
if (!CanvasContext.isHTMLCanvas(canvas)) {
|
|
355
|
-
throw new Error('Object is not a canvas element');
|
|
356
|
-
}
|
|
357
|
-
return canvas;
|
|
358
|
-
}
|
|
359
|
-
/** Create a new canvas */
|
|
360
|
-
function createCanvasElement(props) {
|
|
361
|
-
const { width, height } = props;
|
|
362
|
-
const newCanvas = document.createElement('canvas');
|
|
363
|
-
newCanvas.id = uid('lumagl-auto-created-canvas');
|
|
364
|
-
newCanvas.width = width || 1;
|
|
365
|
-
newCanvas.height = height || 1;
|
|
366
|
-
newCanvas.style.width = Number.isFinite(width) ? `${width}px` : '100%';
|
|
367
|
-
newCanvas.style.height = Number.isFinite(height) ? `${height}px` : '100%';
|
|
368
|
-
if (!props?.visible) {
|
|
369
|
-
newCanvas.style.visibility = 'hidden';
|
|
370
|
-
}
|
|
371
|
-
// Insert the canvas in the DOM
|
|
372
|
-
const container = getContainer(props?.container || null);
|
|
373
|
-
container.insertBefore(newCanvas, container.firstChild);
|
|
374
|
-
return newCanvas;
|
|
375
|
-
}
|
|
376
|
-
/**
|
|
377
|
-
* Scales pixels linearly, handles edge cases
|
|
378
|
-
* @param pixel
|
|
379
|
-
* @param ratio
|
|
380
|
-
* @param width
|
|
381
|
-
* @param height
|
|
382
|
-
* @param yInvert
|
|
383
|
-
* @returns
|
|
384
|
-
*/
|
|
385
|
-
function scalePixels(pixel, ratio, width, height, yInvert) {
|
|
386
|
-
const point = pixel;
|
|
387
|
-
const x = scaleX(point[0], ratio, width);
|
|
388
|
-
let y = scaleY(point[1], ratio, height, yInvert);
|
|
389
|
-
// Find boundaries of next pixel to provide valid range of device pixel locations
|
|
390
|
-
let t = scaleX(point[0] + 1, ratio, width);
|
|
391
|
-
// If next pixel's position is clamped to boundary, use it as is, otherwise subtract 1 for current pixel boundary
|
|
392
|
-
const xHigh = t === width - 1 ? t : t - 1;
|
|
393
|
-
t = scaleY(point[1] + 1, ratio, height, yInvert);
|
|
394
|
-
let yHigh;
|
|
395
|
-
if (yInvert) {
|
|
396
|
-
// If next pixel's position is clamped to boundary, use it as is, otherwise clamp it to valid range
|
|
397
|
-
t = t === 0 ? t : t + 1;
|
|
398
|
-
// swap y and yHigh
|
|
399
|
-
yHigh = y;
|
|
400
|
-
y = t;
|
|
401
|
-
}
|
|
402
|
-
else {
|
|
403
|
-
// If next pixel's position is clamped to boundary, use it as is, otherwise clamp it to valid range
|
|
404
|
-
yHigh = t === height - 1 ? t : t - 1;
|
|
405
|
-
// y remains same
|
|
406
|
-
}
|
|
407
|
-
return {
|
|
408
|
-
x,
|
|
409
|
-
y,
|
|
410
|
-
// when ratio < 1, current css pixel and next css pixel may point to same device pixel, set width/height to 1 in those cases.
|
|
411
|
-
width: Math.max(xHigh - x + 1, 1),
|
|
412
|
-
height: Math.max(yHigh - y + 1, 1)
|
|
413
|
-
};
|
|
414
|
-
}
|
|
415
|
-
function scaleX(x, ratio, width) {
|
|
416
|
-
// since we are rounding to nearest, when ratio > 1, edge pixels may point to out of bounds value, clamp to the limit
|
|
417
|
-
const r = Math.min(Math.round(x * ratio), width - 1);
|
|
418
|
-
return r;
|
|
419
|
-
}
|
|
420
|
-
function scaleY(y, ratio, height, yInvert) {
|
|
421
|
-
// since we are rounding to nearest, when ratio > 1, edge pixels may point to out of bounds value, clamp to the limit
|
|
422
|
-
return yInvert
|
|
423
|
-
? Math.max(0, height - 1 - Math.round(y * ratio))
|
|
424
|
-
: Math.min(Math.round(y * ratio), height - 1);
|
|
9
|
+
export class CanvasContext extends CanvasSurface {
|
|
10
|
+
static defaultProps = CanvasSurface.defaultProps;
|
|
425
11
|
}
|
|
426
12
|
//# sourceMappingURL=canvas-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas-context.js","sourceRoot":"","sources":["../../src/adapter/canvas-context.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AAIxC,OAAO,EAAC,GAAG,EAAC,wBAAqB;AACjC,OAAO,EAAC,aAAa,EAAC,kCAA+B;AAiCrD;;;;;;GAMG;AACH,MAAM,OAAgB,aAAa;IACjC,MAAM,CAAC,YAAY,CAAC,MAAe;QACjC,OAAO,OAAO,iBAAiB,KAAK,WAAW,IAAI,MAAM,YAAY,iBAAiB,CAAC;IACzF,CAAC;IAED,MAAM,CAAC,iBAAiB,CAAC,MAAe;QACtC,OAAO,OAAO,e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