MCPcopy Create free account
hub / github.com/FastLED/FastLED / handleWorkerFrameUpdate

Function handleWorkerFrameUpdate

src/platforms/wasm/compiler/index.ts:1269–1294  ·  view source on GitHub ↗

* Handles frame update from worker - draws to mirror canvas * @param {Object} payload - Frame data with ImageBitmap

(payload)

Source from the content-addressed store, hash-verified

1267 * @param {Object} payload - Frame data with ImageBitmap
1268 */
1269function handleWorkerFrameUpdate(payload) {
1270 const { bitmap, width, height } = payload;
1271
1272 try {
1273 // Create mirror canvas if needed or resize if dimensions changed
1274 if (!mirrorCanvas || mirrorCanvas.width !== width || mirrorCanvas.height !== height) {
1275 console.log('Creating/resizing mirror canvas:', width, 'x', height);
1276
1277 if (mirrorCanvas) {
1278 document.body.removeChild(mirrorCanvas);
1279 }
1280
1281 mirrorCanvas = createMirrorCanvas(width, height);
1282 mirrorCanvasContext = mirrorCanvas.getContext('2d', { willReadFrequently: false });
1283 }
1284
1285 // Draw bitmap to mirror canvas (hardware-accelerated)
1286 if (mirrorCanvasContext) {
1287 mirrorCanvasContext.drawImage(bitmap, 0, 0);
1288 }
1289
1290 // Bitmap is transferred, no need to close it
1291 } catch (error) {
1292 console.error('Error drawing frame to mirror canvas:', error);
1293 }
1294}
1295
1296/**
1297 * Initializes main-thread video recording with worker frame transfer

Callers 1

setupWorkerFrameListenerFunction · 0.85

Calls 4

createMirrorCanvasFunction · 0.85
getContextMethod · 0.80
logMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected