Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/main-api/Renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,15 @@ export interface RendererMainSettings {
* @defaultValue `true`
*/
strictBounds?: boolean;

/**
* Canvas object to use for rendering
*
* @remarks
* This is used to render the scene graph. If not provided, a new canvas
* element will be created and appended to the target element.
*/
canvas?: HTMLCanvasElement;
}

/**
Expand Down Expand Up @@ -358,6 +367,7 @@ export class RendererMain extends EventEmitter {
quadBufferSize: settings.quadBufferSize ?? 4 * 1024 * 1024,
fontEngines: settings.fontEngines,
strictBounds: settings.strictBounds ?? true,
canvas: settings.canvas || document.createElement('canvas'),
};
this.settings = resolvedSettings;

Expand All @@ -367,12 +377,12 @@ export class RendererMain extends EventEmitter {
deviceLogicalPixelRatio,
devicePhysicalPixelRatio,
inspector,
canvas,
} = resolvedSettings;

const deviceLogicalWidth = appWidth * deviceLogicalPixelRatio;
const deviceLogicalHeight = appHeight * deviceLogicalPixelRatio;

const canvas = document.createElement('canvas');
this.canvas = canvas;
canvas.width = deviceLogicalWidth * devicePhysicalPixelRatio;
canvas.height = deviceLogicalHeight * devicePhysicalPixelRatio;
Expand Down
Loading