mirror of
https://github.com/electron/electron.git
synced 2026-01-09 15:38:08 -05:00
feat: add `sharedTexture` module. Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: reito <reito@chromium.org>
29 lines
984 B
JavaScript
29 lines
984 B
JavaScript
const { sharedTexture } = require('electron');
|
|
const { ipcRenderer, contextBridge } = require('electron/renderer');
|
|
|
|
contextBridge.exposeInMainWorld('textures', {
|
|
onSharedTexture: (cb) => {
|
|
// Step 0: Register the receiver for transferred shared texture
|
|
sharedTexture.setSharedTextureReceiver(async (data) => {
|
|
// Step 5: Receive the imported shared texture
|
|
const { importedSharedTexture: imported } = data;
|
|
await cb(imported);
|
|
|
|
// Release the imported shared texture since we're done.
|
|
// No need to use the callback here, as the util function automatically
|
|
// managed the lifetime via sync token.
|
|
imported.release();
|
|
});
|
|
},
|
|
webGpuUnavailable: () => {
|
|
ipcRenderer.send('webgpu-unavailable');
|
|
},
|
|
verifyCapturedImage: (verify) => {
|
|
ipcRenderer.on('verify-captured-image', (e, images) => {
|
|
verify(images, (result) => {
|
|
ipcRenderer.send('verify-captured-image-done', result);
|
|
});
|
|
});
|
|
}
|
|
});
|