Skip to main content

Class: OffscreenSurface<ContextType, ContextOptions>

Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/OffscreenSurface.ts:13

Extends​

Type Parameters​

Type Parameter
ContextType extends CanvasContextType
ContextOptions

Constructors​

Constructor​

new OffscreenSurface<ContextType, ContextOptions>(params: {
width: number;
height: number;
context_constructor: (canvas: OffscreenCanvas | HTMLCanvasElement, context_type: ContextType, options?: ContextOptions) => ContextProvider;
context_type: ContextType;
context_attributes?: ContextOptions;
}): OffscreenSurface<ContextType, ContextOptions>;

Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/OffscreenSurface.ts:59

Creates a new offscreen surface.

Parameters​

ParameterTypeDescription
params{ width: number; height: number; context_constructor: (canvas: OffscreenCanvas | HTMLCanvasElement, context_type: ContextType, options?: ContextOptions) => ContextProvider; context_type: ContextType; context_attributes?: ContextOptions; }-
params.widthnumberThe width of the offscreen canvas.
params.heightnumberThe height of the offscreen canvas.
params.context_constructor(canvas: OffscreenCanvas | HTMLCanvasElement, context_type: ContextType, options?: ContextOptions) => ContextProviderThe constructor of the context.
params.context_typeContextTypeThe type of context to create.
params.context_attributes?ContextOptionsThe attributes of the context.

Returns​

OffscreenSurface<ContextType, ContextOptions>

Overrides​

RenderingSurfaceBase.constructor

Properties​

PropertyModifierTypeDefault valueDescriptionInherited from
viewportsreadonlyViewport[][]List of viewports bound to the current surface.RenderingSurfaceBase.viewports
relative_rectpublicRelativeRectundefinedNormalized dimensions and offset of the surface relative to the remote rendering surface.RenderingSurfaceBase.relative_rect
_scaleprotectednumber1.0Scale of the surface.RenderingSurfaceBase._scale

Accessors​

width​

Get Signature​

get width(): number;

Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/OffscreenSurface.ts:27

Width of the surface.

Returns​

number

Overrides​

RenderingSurfaceBase.width


height​

Get Signature​

get height(): number;

Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/OffscreenSurface.ts:34

Height of the surface.

Returns​

number

Overrides​

RenderingSurfaceBase.height


cameras​

Get Signature​

get cameras(): readonly Entity[];

Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/OffscreenSurface.ts:41

The cameras associated with the surface's viewports.

Returns​

readonly Entity[]


scale​

Get Signature​

get scale(): number;

Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/RenderingSurfaceBase.ts:49

Scale of the surface.

Returns​

number

Set Signature​

set scale(scale: number): void;

Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/RenderingSurfaceBase.ts:56

Set scale of the surface.

Parameters​
ParameterType
scalenumber
Returns​

void

Inherited from​

RenderingSurfaceBase.scale


dimensions​

Get Signature​

get dimensions(): Vec2;

Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/RenderingSurfaceBase.ts:71

Dimensions of the surface.

Returns​

Vec2

Inherited from​

RenderingSurfaceBase.dimensions

Methods​

release()​

release(): void;

Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/OffscreenSurface.ts:87

Releases the resources associated with the surface.

Returns​

void

Overrides​

RenderingSurfaceBase.release


getContext()​

getContext<ContextType>(): ContextType;

Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/OffscreenSurface.ts:95

Returns the context of the surface.

Type Parameters​

Type Parameter
ContextType extends ContextProvider

Returns​

ContextType


getBoundingRect()​

getBoundingRect(): Rect;

Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/OffscreenSurface.ts:102

Returns​

Rect

Overrides​

RenderingSurfaceBase.getBoundingRect


resize()​

resize(width: number, height: number): void;

Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/OffscreenSurface.ts:109

Resizes the surface.

Parameters​

ParameterType
widthnumber
heightnumber

Returns​

void


isValid()​

isValid(): boolean;

Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/RenderingSurfaceBase.ts:104

Returns whether the current surface is valid.

Returns​

boolean

Inherited from​

RenderingSurfaceBase.isValid


drawFrame()​

drawFrame(params: {
decoded_frame: DecodedFrame;
}): void;

Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/RenderingSurfaceBase.ts:115

Draws the portions of the frame associated with the viewports to the backing element. Keeps a reference to the last frame drawn.

Parameters​

ParameterTypeDescription
params{ decoded_frame: DecodedFrame; }-
params.decoded_frameDecodedFrameThe frame to draw.

Returns​

void

Inherited from​

RenderingSurfaceBase.drawFrame


redrawLastFrame()​

redrawLastFrame(): void;

Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/RenderingSurfaceBase.ts:123

Redraws the last frame. No-op if its VideoFrame was since closed by the decoder.

Returns​

void

Inherited from​

RenderingSurfaceBase.redrawLastFrame


reset()​

reset(): void;

Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/RenderingSurfaceBase.ts:133

Resets the surface states.

Returns​

void

Inherited from​

RenderingSurfaceBase.reset


addEventListener()​

addEventListener<_EventName>(
event_name: _EventName,
listener: (event: RenderingSurfaceEvents[_EventName]) => void,
options?: boolean | AddEventListenerOptions): void;

Defined in: livelink.clients/livelink.base/sources/TypedEventTarget.ts:10

Type Parameters​

Type Parameter
_EventName extends "on-rendering-surface-resized"

Parameters​

ParameterType
event_name_EventName
listener(event: RenderingSurfaceEvents[_EventName]) => void
options?boolean | AddEventListenerOptions

Returns​

void

Inherited from​

RenderingSurfaceBase.addEventListener


removeEventListener()​

removeEventListener<_EventName>(
event_name: _EventName,
listener: (event: RenderingSurfaceEvents[_EventName]) => void,
options?: boolean | EventListenerOptions): void;

Defined in: livelink.clients/livelink.base/sources/TypedEventTarget.ts:21

Type Parameters​

Type Parameter
_EventName extends "on-rendering-surface-resized"

Parameters​

ParameterType
event_name_EventName
listener(event: RenderingSurfaceEvents[_EventName]) => void
options?boolean | EventListenerOptions

Returns​

void

Inherited from​

RenderingSurfaceBase.removeEventListener