Skip to main content

Abstract Class: PresentationContext

Defined in: modules/core/src/adapter/presentation-context.ts:14

Tracks a destination canvas for presentation. Backend implementations either borrow the default GPU-backed canvas (WebGL) or render directly into the destination canvas (WebGPU).

Extends​

  • CanvasSurface

Constructors​

Constructor​

new PresentationContext(props?): PresentationContext

Defined in: modules/core/src/adapter/canvas-surface.ts:152

Parameters​

props?​

CanvasContextProps

Returns​

PresentationContext

Inherited from​

CanvasSurface.constructor

Properties​

canvas​

readonly canvas: HTMLCanvasElement | OffscreenCanvas

Defined in: modules/core/src/adapter/canvas-surface.ts:103

Inherited from​

CanvasContext.canvas


cssHeight​

cssHeight: number

Defined in: modules/core/src/adapter/canvas-surface.ts:120

Height of canvas in CSS units (tracked by a ResizeObserver)

Inherited from​

CanvasSurface.cssHeight


cssWidth​

cssWidth: number

Defined in: modules/core/src/adapter/canvas-surface.ts:118

Width of canvas in CSS units (tracked by a ResizeObserver)

Inherited from​

CanvasSurface.cssWidth


device​

abstract readonly device: Device

Defined in: modules/core/src/adapter/canvas-surface.ts:98

Inherited from​

CanvasSurface.device


devicePixelHeight​

devicePixelHeight: number

Defined in: modules/core/src/adapter/canvas-surface.ts:127

Exact height of canvas in physical pixels (tracked by a ResizeObserver)

Inherited from​

CanvasSurface.devicePixelHeight


devicePixelRatio​

devicePixelRatio: number

Defined in: modules/core/src/adapter/canvas-surface.ts:123

Device pixel ratio. Automatically updated via media queries

Inherited from​

CanvasSurface.devicePixelRatio


devicePixelWidth​

devicePixelWidth: number

Defined in: modules/core/src/adapter/canvas-surface.ts:125

Exact width of canvas in physical pixels (tracked by a ResizeObserver)

Inherited from​

CanvasSurface.devicePixelWidth


drawingBufferHeight​

drawingBufferHeight: number

Defined in: modules/core/src/adapter/canvas-surface.ts:132

Height of drawing buffer: automatically tracks this.pixelHeight if props.autoResize is true

Inherited from​

CanvasSurface.drawingBufferHeight


drawingBufferWidth​

drawingBufferWidth: number

Defined in: modules/core/src/adapter/canvas-surface.ts:130

Width of drawing buffer: automatically tracks this.pixelWidth if props.autoResize is true

Inherited from​

CanvasSurface.drawingBufferWidth


handle​

abstract readonly handle: unknown

Defined in: modules/core/src/adapter/canvas-surface.ts:99

Inherited from​

CanvasSurface.handle


htmlCanvas?​

readonly optional htmlCanvas?: HTMLCanvasElement

Defined in: modules/core/src/adapter/canvas-surface.ts:105

Handle to HTML canvas

Inherited from​

CanvasSurface.htmlCanvas


id​

readonly id: string

Defined in: modules/core/src/adapter/canvas-surface.ts:100

Inherited from​

CanvasSurface.id


initialized​

initialized: Promise<void>

Defined in: modules/core/src/adapter/canvas-surface.ts:111

Promise that resolved once the resize observer has updated the pixel size

Inherited from​

CanvasSurface.initialized


isInitialized​

isInitialized: boolean = false

Defined in: modules/core/src/adapter/canvas-surface.ts:112

Inherited from​

CanvasSurface.isInitialized


isVisible​

isVisible: boolean = true

Defined in: modules/core/src/adapter/canvas-surface.ts:115

Visibility is automatically updated (via an IntersectionObserver)

Inherited from​

CanvasSurface.isVisible


offscreenCanvas?​

readonly optional offscreenCanvas?: OffscreenCanvas

Defined in: modules/core/src/adapter/canvas-surface.ts:107

Handle to wrapped OffScreenCanvas

Inherited from​

CanvasSurface.offscreenCanvas


props​

readonly props: Required<CanvasContextProps>

Defined in: modules/core/src/adapter/canvas-surface.ts:102

Inherited from​

CanvasSurface.props


type​

readonly type: "html-canvas" | "offscreen-canvas" | "node"

Defined in: modules/core/src/adapter/canvas-surface.ts:108

Inherited from​

CanvasContext.type


defaultProps​

static defaultProps: Required<CanvasContextProps>

Defined in: modules/core/src/adapter/canvas-surface.ts:81

Inherited from​

CanvasSurface.defaultProps

Accessors​

[toStringTag]​

Get Signature​

get abstract [toStringTag](): string

Defined in: modules/core/src/adapter/canvas-surface.ts:146

Returns​

string

Inherited from​

CanvasSurface.[toStringTag]

Methods​

_observeDevicePixelRatio()​

_observeDevicePixelRatio(): void

Defined in: modules/core/src/adapter/canvas-surface.ts:460

Returns​

void

Inherited from​

CanvasSurface._observeDevicePixelRatio


_resizeDrawingBufferIfNeeded()​

_resizeDrawingBufferIfNeeded(): void

Defined in: modules/core/src/adapter/canvas-surface.ts:438

Returns​

void

Inherited from​

CanvasSurface._resizeDrawingBufferIfNeeded


_startObservers()​

_startObservers(): void

Defined in: modules/core/src/adapter/canvas-surface.ts:325

Starts DOM observation after the derived context and its device are fully initialized.

CanvasSurface construction runs before subclasses can assign this.device, and the default WebGL canvas context is created before WebGLDevice has initialized limits, features, and the rest of its runtime state. Deferring observer startup avoids early ResizeObserver and DPR callbacks running against a partially initialized device.

Returns​

void

Inherited from​

CanvasSurface._startObservers


_stopObservers()​

_stopObservers(): void

Defined in: modules/core/src/adapter/canvas-surface.ts:340

Stops all DOM observation and timers associated with a canvas surface.

This pairs with _startObservers() so teardown uses the same lifecycle whether a context is explicitly destroyed, abandoned during device reuse, or temporarily has not started observing yet. Centralizing shutdown here keeps resize/DPR/position watchers from surviving past the lifetime of the owning device.

Returns​

void

Inherited from​

CanvasSurface._stopObservers


cssToDevicePixels()​

cssToDevicePixels(cssPixel, yInvert?): object

Defined in: modules/core/src/adapter/canvas-surface.ts:264

Parameters​

cssPixel​

[number, number]

yInvert?​

boolean = true

Returns​

object

height​

height: number

width​

width: number

x​

x: number

y​

y: number

Inherited from​

CanvasSurface.cssToDevicePixels


cssToDeviceRatio()​

cssToDeviceRatio(): number

Defined in: modules/core/src/adapter/canvas-surface.ts:290

Returns​

number

Deprecated​

Returns multiplier need to convert CSS size to Device size

Inherited from​

CanvasSurface.cssToDeviceRatio


destroy()​

destroy(): void

Defined in: modules/core/src/adapter/canvas-surface.ts:202

Returns​

void

Inherited from​

CanvasSurface.destroy


getAspect()​

getAspect(): number

Defined in: modules/core/src/adapter/canvas-surface.ts:284

Returns​

number

Deprecated​

Use the current drawing buffer size for projection setup.

Inherited from​

CanvasSurface.getAspect


getCSSSize()​

getCSSSize(): [number, number]

Defined in: modules/core/src/adapter/canvas-surface.ts:227

Returns​

[number, number]

Inherited from​

CanvasSurface.getCSSSize


getCurrentFramebuffer()​

getCurrentFramebuffer(options?): Framebuffer

Defined in: modules/core/src/adapter/canvas-surface.ts:220

Returns a framebuffer with properly resized current 'swap chain' textures

Parameters​

options?​
depthStencilFormat?​

false | TextureFormatDepthStencil

Returns​

Framebuffer

Inherited from​

CanvasSurface.getCurrentFramebuffer


getDevicePixelRatio()​

getDevicePixelRatio(): number

Defined in: modules/core/src/adapter/canvas-surface.ts:259

Returns​

number

Inherited from​

CanvasSurface.getDevicePixelRatio


getDevicePixelSize()​

getDevicePixelSize(): [number, number]

Defined in: modules/core/src/adapter/canvas-surface.ts:235

Returns​

[number, number]

Inherited from​

CanvasSurface.getDevicePixelSize


getDrawingBufferSize()​

getDrawingBufferSize(): [number, number]

Defined in: modules/core/src/adapter/canvas-surface.ts:239

Returns​

[number, number]

Inherited from​

CanvasSurface.getDrawingBufferSize


getMaxDrawingBufferSize()​

getMaxDrawingBufferSize(): [number, number]

Defined in: modules/core/src/adapter/canvas-surface.ts:243

Returns​

[number, number]

Inherited from​

CanvasSurface.getMaxDrawingBufferSize


getPixelSize()​

getPixelSize(): [number, number]

Defined in: modules/core/src/adapter/canvas-surface.ts:279

Returns​

[number, number]

Deprecated​

  • use .getDevicePixelSize()

Inherited from​

CanvasSurface.getPixelSize


getPosition()​

getPosition(): [number, number]

Defined in: modules/core/src/adapter/canvas-surface.ts:231

Returns​

[number, number]

Inherited from​

CanvasSurface.getPosition


present()​

abstract present(): void

Defined in: modules/core/src/adapter/presentation-context.ts:15

Returns​

void


resize()​

resize(size): void

Defined in: modules/core/src/adapter/canvas-surface.ts:301

Parameters​

size​
height​

number

width​

number

Returns​

void

Deprecated​

Use canvasContext.setDrawingBufferSize()

Inherited from​

CanvasSurface.resize


setDrawingBufferSize()​

setDrawingBufferSize(width, height): void

Defined in: modules/core/src/adapter/canvas-surface.ts:248

Parameters​

width​

number

height​

number

Returns​

void

Inherited from​

CanvasSurface.setDrawingBufferSize


setProps()​

setProps(props): this

Defined in: modules/core/src/adapter/canvas-surface.ts:211

Parameters​

props​

MutableCanvasContextProps

Returns​

this

Inherited from​

CanvasSurface.setProps


toString()​

toString(): string

Defined in: modules/core/src/adapter/canvas-surface.ts:148

Returns​

string

Inherited from​

CanvasSurface.toString


updatePosition()​

updatePosition(): void

Defined in: modules/core/src/adapter/canvas-surface.ts:483

Returns​

void

Inherited from​

CanvasSurface.updatePosition


isHTMLCanvas()​

static isHTMLCanvas(canvas): canvas is HTMLCanvasElement

Defined in: modules/core/src/adapter/canvas-surface.ts:73

Parameters​

canvas​

unknown

Returns​

canvas is HTMLCanvasElement

Inherited from​

CanvasSurface.isHTMLCanvas


isOffscreenCanvas()​

static isOffscreenCanvas(canvas): canvas is OffscreenCanvas

Defined in: modules/core/src/adapter/canvas-surface.ts:77

Parameters​

canvas​

unknown

Returns​

canvas is OffscreenCanvas

Inherited from​

CanvasSurface.isOffscreenCanvas