Screen helpers · class
ExportTarget
Explained in Recording and clips.
class ExportTargetimport { ExportTarget } from '@driftengine/core';Constructor
new
constructor(options: ExportTargetOptions)| Parameter | Type | Description |
|---|---|---|
options | ExportTargetOptions |
Accessors
| Name | Type | Description |
|---|---|---|
widthget | number | |
heightget | number | |
aspectget | number | |
readyget | boolean | Whether the source canvas has actually taken the locked size yet. |
duplicateFrameget | boolean | Whether the frame compose() just drew is byte-identical to the one before it, because
the renderer's own count of presented frames did not move between the two calls.MoreFalse when |
pacingget | FramePacingReport |
Methods
lock
lock(): voidTake over the render surface and bake the mark, without a stream.
More
For an offline render, which composites and encodes frames itself and has nothing to
stream to. acquire is this plus a stream; keeping them separate means the offline
path never creates a MediaStream it would only have to stop.
acquire
acquire(): MediaStreamcaptureDue
captureDue(nowMs: number): booleanWhether the next frame drawn will be kept.
| Parameter | Type | Description |
|---|---|---|
nowMs | number |
More
Asked before rendering, so the render loop can skip a frame the recorder
would only throw away — see FramePacer.due for why that is a correctness
matter and not merely a saving.
Call this once per animation frame, drawing or not. The instant is kept and reused when the frame is handed over, so the schedule is queried and advanced on one clock. It used to take a second reading at the end of the render pass, which put the pacer's grid a whole render ahead of the frames arriving and cost most of the rate: target 60 fps on a 60 Hz display captured 59.5 when a frame cost 4 ms, 40 at 6 ms and 30 at 12 ms, and an export-size frame always costs more than 6 ms.
frameRendered
frameRendered(): booleanOne rendered frame. Composites and offers it to the recorder if it is due.
More
Must be called at the end of the render pass, in the same task: a WebGL drawing buffer is only guaranteed readable until the browser composites the page, so copying it from a timer produces black frames on some drivers.
Takes no instant on purpose — it uses the one captureDue was given for this
frame. There is no second clock to get wrong.
Returns true when the frame was captured, so a caller can count.
compose
compose(): HTMLCanvasElementDraw the current scene plus the mark into the composite.
More
Also the still-image path: a downloadable frame is the cheapest shareable artefact there is, and it must carry the same mark as the clip.
Draws unconditionally, even when duplicateFrame is about to say the source has not
changed. Deciding what to do with a repeated frame — drop it, hold the last one longer,
encode it anyway — is a policy choice about the file being produced, and this class
produces composites rather than files; see presentedFrames on ExportTargetOptions for
where that decision gets the information it needs to make it.
resetPacing
resetPacing(): voidStart the measurement over, keeping the schedule. See FramePacer.
release
release(): voidGive the surface back. Safe to call more than once.