feat: Use JSI's ArrayBuffer
instead of TypedArray
(#2408)
* feat: Use JSI's `ArrayBuffer` instead of `TypedArray` * fix: Fix move memory * feat: Implement iOS * Format * Update JSIJNIConversion.cpp * fix: Fix Android `toArrayBuffer` and other * Catch FP call errors * Update return type * Use `CPU_READ_OFTEN` flag as well * CPU flag * Run destructors under `jni::ThreadScope` * Update FrameProcessorPluginHostObject.cpp * fix: Fix `toArrayBuffer()` crash * Update Frame.ts
This commit is contained in:
@@ -57,7 +57,9 @@ export interface Frame {
|
||||
|
||||
/**
|
||||
* Get the underlying data of the Frame as a uint8 array buffer.
|
||||
*
|
||||
* The format of the buffer depends on the Frame's {@linkcode pixelFormat}.
|
||||
* This function might fail if the {@linkcode pixelFormat} is `private`.
|
||||
*
|
||||
* Note that Frames are allocated on the GPU, so calling `toArrayBuffer()` will copy from the GPU to the CPU.
|
||||
*
|
||||
@@ -67,13 +69,14 @@ export interface Frame {
|
||||
* 'worklet'
|
||||
*
|
||||
* if (frame.pixelFormat === 'rgb') {
|
||||
* const data = frame.toArrayBuffer()
|
||||
* const buffer = frame.toArrayBuffer()
|
||||
* const data = new Uint8Array(buffer)
|
||||
* console.log(`Pixel at 0,0: RGB(${data[0]}, ${data[1]}, ${data[2]})`)
|
||||
* }
|
||||
* }, [])
|
||||
* ```
|
||||
*/
|
||||
toArrayBuffer(): Uint8Array
|
||||
toArrayBuffer(): ArrayBuffer
|
||||
/**
|
||||
* Returns a string representation of the frame.
|
||||
* @example
|
||||
|
Reference in New Issue
Block a user