3.2 KiB
sharedTexture
Import shared textures into Electron and converts platform specific handles into
VideoFrame. Supports all Web rendering systems, and can be transferred across Electron processes. Read here for more information.
Methods
The sharedTexture module has the following methods:
Note: Experimental APIs are marked as such and could be removed in the future.
sharedTexture.importSharedTexture(options) Experimental
optionsObject - Options for importing shared textures.textureInfoSharedTextureImportTextureInfo - The information of the shared texture to import.allReferencesReleasedFunction (optional) - Called when all references in all processes are released. You should keep the imported texture valid until this callback is called.
Imports the shared texture from the given options.
Note
This method is only available in the main process.
Returns SharedTextureImported - The imported shared texture.
sharedTexture.sendSharedTexture(options, ...args) Experimental
optionsObject - Options for sending shared texture.frameWebFrameMain - The target frame to transfer the shared texture to. ForWebContents, you can passwebContents.mainFrame. If you provide awebFrameMainthat is not a main frame, you'll need to enablewebPreferences.nodeIntegrationInSubFramesfor this, since this feature requires IPC between main and the frame.importedSharedTextureSharedTextureImported - The imported shared texture.
...argsany[] - Additional arguments to pass to the renderer process.
Send the imported shared texture to a renderer process. You must register a receiver at renderer process before calling this method. This method has a 1000ms timeout. Ensure the receiver is set and the renderer process is alive before calling this method.
Note
This method is only available in the main process.
Returns Promise<void> - Resolves when the transfer is complete.
sharedTexture.setSharedTextureReceiver(callback) Experimental
callbackFunction<Promise<void>> - The function to receive the imported shared texture.receivedSharedTextureDataObject - The data received from the main process.importedSharedTextureSharedTextureImported - The imported shared texture.
...argsany[] - Additional arguments passed from the main process.
Set a callback to receive imported shared textures from the main process.
Note
This method is only available in the renderer process.
Properties
The sharedTexture module has the following properties:
sharedTexture.subtle Experimental
A SharedTextureSubtle property, provides subtle APIs for interacting with shared texture for advanced users.