Skip to main content

Class: RenderingSurface

Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/RenderingSurface.ts:36

A rendering surface backed by an HTML canvas.

The context can be specified as either 2D, WebGL or WebGL2 along with its attributes.

The canvas is automatically resized to match the size of the HTML element it is attached to.

Extends​

Constructors​

Constructor​

new RenderingSurface(params: {
canvas_element: string | HTMLCanvasElement;
} &
| {
context_type: "2d";
context_attributes?: CanvasRenderingContext2DSettings;
}
| {
context_type: "webgl" | "webgl2";
context_attributes?: WebGLContextAttributes & {
xrCompatible?: boolean;
};
}): RenderingSurface;

Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/RenderingSurface.ts:81

Creates a new rendering surface.

Parameters​

ParameterTypeDescription
params{ canvas_element: string | HTMLCanvasElement; } & | { context_type: "2d"; context_attributes?: CanvasRenderingContext2DSettings; } | { context_type: "webgl" | "webgl2"; context_attributes?: WebGLContextAttributes & { xrCompatible?: boolean; }; }-

Returns​

RenderingSurface

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/RenderingSurface.ts:55

Width of the surface.

Returns​

number

Overrides​

RenderingSurfaceBase.width


height​

Get Signature​

get height(): number;

Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/RenderingSurface.ts:62

Height of the surface.

Returns​

number

Overrides​

RenderingSurfaceBase.height


canvas​

Get Signature​

get canvas(): HTMLCanvasElement;

Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/RenderingSurface.ts:69

HTML canvas on which the final frame is displayed.

Returns​

HTMLCanvasElement


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/RenderingSurface.ts:129

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/RenderingSurface.ts:139

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/RenderingSurface.ts:146

Returns the bounding rectangle of the surface.

Returns​

Rect

Overrides​

RenderingSurfaceBase.getBoundingRect


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