react-native-webgpu 0.22.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/Package.swift +18 -129
  2. package/README.md +15 -2
  3. package/android/CMakeLists.txt +2 -1
  4. package/android/cpp/AndroidAnimationFrameSource.h +136 -0
  5. package/android/cpp/AndroidPlatformContext.h +65 -9
  6. package/android/cpp/cpp-adapter.cpp +148 -2
  7. package/android/src/main/java/com/webgpu/WebGPUModule.java +24 -7
  8. package/android/src/main/java/com/webgpu/WebGPUNativeBufferView.java +370 -0
  9. package/android/src/main/java/com/webgpu/WebGPUNativeBufferViewManager.java +56 -0
  10. package/android/src/main/java/com/webgpu/WebGPUTextureView.java +21 -0
  11. package/android/src/main/java/com/webgpu/WebGPUVideoPlayer.java +2 -2
  12. package/android/src/main/java/com/webgpu/WebGPUView.java +19 -3
  13. package/android/src/main/java/com/webgpu/WebGPUViewPackage.java +2 -2
  14. package/android/src/newarch/com/webgpu/WebGPUNativeBufferViewManagerSpec.java +24 -0
  15. package/apple/AppleAnimationFrameSource.mm +208 -0
  16. package/apple/ApplePlatformContext.h +8 -1
  17. package/apple/ApplePlatformContext.mm +75 -2
  18. package/apple/NativeBufferFenceWait.mm +88 -0
  19. package/apple/WebGPUNativeBufferView.h +15 -0
  20. package/apple/WebGPUNativeBufferView.mm +200 -0
  21. package/binaries.json +53 -105
  22. package/cpp/dawn/common/ExternalTextureParams.h +3 -3
  23. package/cpp/dawn/include/dawn/dawn_proc.h +53 -0
  24. package/cpp/dawn/include/dawn/dawn_proc_table.h +329 -0
  25. package/cpp/dawn/include/dawn/dawn_thread_dispatch_proc.h +47 -0
  26. package/cpp/dawn/include/dawn/dawn_version.h +51 -0
  27. package/cpp/dawn/include/dawn/native/D3D11Backend.h +65 -0
  28. package/cpp/dawn/include/dawn/native/D3D12Backend.h +104 -0
  29. package/cpp/dawn/include/dawn/native/D3DBackend.h +56 -0
  30. package/cpp/dawn/include/dawn/native/DawnNative.h +375 -0
  31. package/cpp/dawn/include/dawn/native/MetalBackend.h +67 -0
  32. package/cpp/dawn/include/dawn/native/NullBackend.h +39 -0
  33. package/cpp/dawn/include/dawn/native/OpenGLBackend.h +89 -0
  34. package/cpp/dawn/include/dawn/native/VulkanBackend.h +199 -0
  35. package/cpp/dawn/include/dawn/native/WebGPUBackend.h +49 -0
  36. package/cpp/dawn/include/dawn/native/dawn_native_export.h +49 -0
  37. package/cpp/dawn/include/dawn/platform/DawnPlatform.h +210 -0
  38. package/cpp/dawn/include/dawn/platform/dawn_platform_export.h +49 -0
  39. package/cpp/dawn/include/dawn/replay/Replay.h +99 -0
  40. package/cpp/dawn/include/dawn/replay/dawn_replay_export.h +49 -0
  41. package/cpp/dawn/include/dawn/webgpu.h +5119 -0
  42. package/cpp/dawn/include/dawn/webgpu_cpp.h +10506 -0
  43. package/cpp/dawn/include/dawn/webgpu_cpp_print.h +2897 -0
  44. package/cpp/dawn/include/webgpu/webgpu.h +33 -0
  45. package/cpp/dawn/include/webgpu/webgpu_cpp.h +33 -0
  46. package/cpp/dawn/include/webgpu/webgpu_cpp_chained_struct.h +57 -0
  47. package/cpp/dawn/include/webgpu/webgpu_cpp_print.h +33 -0
  48. package/cpp/dawn/include/webgpu/webgpu_enum_class_bitmasks.h +163 -0
  49. package/cpp/dawn/include/webgpu/webgpu_glfw.h +88 -0
  50. package/cpp/rnwgpu/AnimationFrames.cpp +576 -0
  51. package/cpp/rnwgpu/AnimationFrames.h +233 -0
  52. package/cpp/rnwgpu/NativeBufferViewRegistry.cpp +396 -0
  53. package/cpp/rnwgpu/NativeBufferViewRegistry.h +163 -0
  54. package/cpp/rnwgpu/PlatformContext.h +21 -1
  55. package/cpp/rnwgpu/RNWebGPUManager.cpp +17 -4
  56. package/cpp/rnwgpu/SurfaceRegistry.h +2 -2
  57. package/cpp/rnwgpu/api/GPUAdapter.cpp +2 -2
  58. package/cpp/rnwgpu/api/GPUDevice.cpp +16 -131
  59. package/cpp/rnwgpu/api/GPUDevice.h +0 -18
  60. package/cpp/rnwgpu/api/GPUExternalTexture.cpp +35 -3
  61. package/cpp/rnwgpu/api/GPUExternalTexture.h +4 -4
  62. package/cpp/rnwgpu/api/GPUQueue.cpp +1 -1
  63. package/cpp/rnwgpu/api/GPUQueue.h +1 -1
  64. package/cpp/rnwgpu/api/GPUSharedFence.h +1 -0
  65. package/cpp/rnwgpu/api/GPUSharedTextureMemory.cpp +11 -5
  66. package/cpp/rnwgpu/api/GPUSharedTextureMemory.h +21 -2
  67. package/cpp/rnwgpu/api/GPUTexture.h +18 -0
  68. package/cpp/rnwgpu/api/NativeFrameFeatures.h +1 -1
  69. package/cpp/rnwgpu/api/NativeFrameImport.cpp +20 -17
  70. package/cpp/rnwgpu/api/NativeFrameImport.h +31 -20
  71. package/cpp/rnwgpu/api/RNWebGPU.h +206 -7
  72. package/cpp/rnwgpu/api/VideoFrame.h +5 -4
  73. package/cpp/rnwgpu/api/VideoFrameBlit.h +2 -2
  74. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +21 -14
  75. package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +1 -1
  76. package/cpp/rnwgpu/api/descriptors/GPUSharedTextureMemoryDescriptor.h +17 -9
  77. package/cpp/rnwgpu/async/RuntimeContext.cpp +21 -4
  78. package/cpp/rnwgpu/async/RuntimeContext.h +8 -0
  79. package/lib/commonjs/NativeBufferView.js +131 -0
  80. package/lib/commonjs/NativeBufferView.js.map +1 -0
  81. package/lib/commonjs/NativeBufferViewNativeComponent.js +10 -0
  82. package/lib/commonjs/NativeBufferViewNativeComponent.js.map +1 -0
  83. package/lib/commonjs/animationFrame.js +91 -0
  84. package/lib/commonjs/animationFrame.js.map +1 -0
  85. package/lib/commonjs/index.js +16 -1
  86. package/lib/commonjs/index.js.map +1 -1
  87. package/lib/commonjs/main/index.js +12 -0
  88. package/lib/commonjs/main/index.js.map +1 -1
  89. package/lib/commonjs/mock.js +30 -1
  90. package/lib/commonjs/mock.js.map +1 -1
  91. package/lib/commonjs/video.js +21 -7
  92. package/lib/commonjs/video.js.map +1 -1
  93. package/lib/module/NativeBufferView.js +122 -0
  94. package/lib/module/NativeBufferView.js.map +1 -0
  95. package/lib/module/NativeBufferViewNativeComponent.js +4 -0
  96. package/lib/module/NativeBufferViewNativeComponent.js.map +1 -0
  97. package/lib/module/animationFrame.js +83 -0
  98. package/lib/module/animationFrame.js.map +1 -0
  99. package/lib/module/index.js +1 -0
  100. package/lib/module/index.js.map +1 -1
  101. package/lib/module/main/index.js +1 -0
  102. package/lib/module/main/index.js.map +1 -1
  103. package/lib/module/mock.js +21 -0
  104. package/lib/module/mock.js.map +1 -1
  105. package/lib/module/video.js +17 -4
  106. package/lib/module/video.js.map +1 -1
  107. package/lib/typescript/lib/commonjs/NativeBufferView.d.ts +48 -0
  108. package/lib/typescript/lib/commonjs/NativeBufferView.d.ts.map +1 -0
  109. package/lib/typescript/lib/commonjs/NativeBufferViewNativeComponent.d.ts +5 -0
  110. package/lib/typescript/lib/commonjs/NativeBufferViewNativeComponent.d.ts.map +1 -0
  111. package/lib/typescript/lib/commonjs/animationFrame.d.ts +54 -0
  112. package/lib/typescript/lib/commonjs/animationFrame.d.ts.map +1 -0
  113. package/lib/typescript/lib/commonjs/index.d.ts +2 -0
  114. package/lib/typescript/lib/commonjs/mock.d.ts +12 -0
  115. package/lib/typescript/lib/commonjs/mock.d.ts.map +1 -1
  116. package/lib/typescript/lib/commonjs/video.d.ts +9 -4
  117. package/lib/typescript/lib/commonjs/video.d.ts.map +1 -1
  118. package/lib/typescript/lib/module/NativeBufferView.d.ts +14 -0
  119. package/lib/typescript/lib/module/NativeBufferView.d.ts.map +1 -0
  120. package/lib/typescript/lib/module/NativeBufferViewNativeComponent.d.ts +3 -0
  121. package/lib/typescript/lib/module/NativeBufferViewNativeComponent.d.ts.map +1 -0
  122. package/lib/typescript/lib/module/animationFrame.d.ts +3 -0
  123. package/lib/typescript/lib/module/animationFrame.d.ts.map +1 -0
  124. package/lib/typescript/lib/module/index.d.ts +1 -0
  125. package/lib/typescript/lib/module/main/index.d.ts +1 -0
  126. package/lib/typescript/lib/module/mock.d.ts +14 -0
  127. package/lib/typescript/lib/module/mock.d.ts.map +1 -1
  128. package/lib/typescript/lib/module/video.d.ts +4 -3
  129. package/lib/typescript/lib/module/video.d.ts.map +1 -1
  130. package/lib/typescript/react-native.config.d.ts +1 -0
  131. package/lib/typescript/src/NativeBufferView.d.ts +99 -0
  132. package/lib/typescript/src/NativeBufferView.d.ts.map +1 -0
  133. package/lib/typescript/src/NativeBufferViewNativeComponent.d.ts +13 -0
  134. package/lib/typescript/src/NativeBufferViewNativeComponent.d.ts.map +1 -0
  135. package/lib/typescript/src/animationFrame.d.ts +59 -0
  136. package/lib/typescript/src/animationFrame.d.ts.map +1 -0
  137. package/lib/typescript/src/index.d.ts +18 -8
  138. package/lib/typescript/src/index.d.ts.map +1 -1
  139. package/lib/typescript/src/main/index.d.ts +1 -0
  140. package/lib/typescript/src/main/index.d.ts.map +1 -1
  141. package/lib/typescript/src/mock.d.ts +11 -0
  142. package/lib/typescript/src/mock.d.ts.map +1 -1
  143. package/lib/typescript/src/types.d.ts +33 -32
  144. package/lib/typescript/src/types.d.ts.map +1 -1
  145. package/lib/typescript/src/video.d.ts +18 -6
  146. package/lib/typescript/src/video.d.ts.map +1 -1
  147. package/package.json +16 -6
  148. package/react-native-webgpu.podspec +47 -79
  149. package/react-native.config.js +9 -6
  150. package/scripts/apple-binaries-utils.sh +280 -0
  151. package/scripts/prepare-apple-binaries.sh +309 -0
  152. package/scripts/spm-plugin.js +130 -0
  153. package/src/NativeBufferView.tsx +199 -0
  154. package/src/NativeBufferViewNativeComponent.ts +20 -0
  155. package/src/animationFrame.ts +82 -0
  156. package/src/index.tsx +48 -42
  157. package/src/main/index.tsx +1 -0
  158. package/src/mock.ts +35 -0
  159. package/src/types.ts +62 -88
  160. package/src/video.ts +32 -12
  161. package/cpp/rnwgpu/api/GPUNativeBufferExternalTexture.h +0 -60
  162. package/cpp/rnwgpu/api/GPUNativeBufferTexture.h +0 -52
  163. package/cpp/rnwgpu/api/GPUNativeBufferWrapper.cpp +0 -144
  164. package/cpp/rnwgpu/api/GPUNativeBufferWrapper.h +0 -143
  165. package/cpp/rnwgpu/api/descriptors/GPUNativeBufferTextureDescriptor.h +0 -55
@@ -45,6 +45,18 @@ export function Canvas({ android: _android, ref, ...props }: {
45
45
  }): React.FunctionComponentElement<Omit<import("react-native").ViewProps, "ref"> & {
46
46
  ref?: React.Ref<import("react-native").ViewInstance> | undefined;
47
47
  }>;
48
+ export function NativeBufferView({ resizeMode: _resizeMode, onPixelSizeChange: _onPixelSizeChange, ref, ...props }: {
49
+ [x: string]: any;
50
+ resizeMode: any;
51
+ onPixelSizeChange: any;
52
+ ref: any;
53
+ }): React.FunctionComponentElement<Omit<import("react-native").ViewProps, "ref"> & {
54
+ ref?: React.Ref<import("react-native").ViewInstance> | undefined;
55
+ }>;
56
+ export function useNativeBufferSize(_debounceMs: any): {
57
+ size: null;
58
+ onPixelSizeChange: () => undefined;
59
+ };
48
60
  export function useCanvasRef(): React.RefObject<null>;
49
61
  export function useSurface(): {
50
62
  ref: React.RefObject<null>;
@@ -62,6 +74,8 @@ export function useMainDevice(): never;
62
74
  export function importDevice(_pointer: any): never;
63
75
  export function adoptTexture(_pointer: any): never;
64
76
  export function installWebGPU(): undefined;
77
+ export function requestAnimationFrame(callback: any): number;
78
+ export function cancelAnimationFrame(handle: any): void;
65
79
  export namespace WebGPUModule {
66
80
  function install(): boolean;
67
81
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../module/mock.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwEO;;;;;;GAaN;AACM,sDAA6C;AAC7C;;;EAGL;AACK,0DAAoD;AACpD;;;EAGL;AACK;;QAEe;AACf,uCAEN;AACM,mDAEN;AACM,mDAEN;AACM,2CAAqC;;IAEjC,4BAAW;;kBA7GJ,OAAO"}
1
+ {"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../module/mock.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwEO;;;;;;GAaN;AAEM;;;;;;;GAaN;AACM;;;EAGL;AACK,sDAA6C;AAC7C;;;EAGL;AACK,0DAAoD;AACpD;;;EAGL;AACK;;QAEe;AACf,uCAEN;AACM,mDAEN;AACM,mDAEN;AACM,2CAAqC;AACrC,6DAAoF;AACpF,wDAA8E;;IAE1E,4BAAW;;kBAlIJ,OAAO"}
@@ -1,4 +1,5 @@
1
- export function createVideoPlayer(source: any, options: any): import("../../src").VideoPlayer;
2
- export function createVideoFrameFromNativeBuffer(pointer: any): import("../../src").NativeVideoFrame;
3
- export function createTestVideoFrame(width: any, height: any): import("../../src").NativeVideoFrame;
1
+ export function createTestVideoPlayer(source: any, options: any): import("../../src").VideoPlayer;
2
+ export function createNativeBufferFromPointer(pointer: any): import("../../src").NativeBuffer;
3
+ export function createTestVideoFrame(width: any, height: any): import("../../src").NativeBuffer;
4
+ export function createNativeBuffer(width: any, height: any, options: any): import("../../src").NativeBuffer;
4
5
  //# sourceMappingURL=video.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"video.d.ts","sourceRoot":"","sources":["../../../module/video.js"],"names":[],"mappings":"AAgCO,8FAA0H;AAQ1H,qGAAwI;AAOxI,oGAAkH"}
1
+ {"version":3,"file":"video.d.ts","sourceRoot":"","sources":["../../../module/video.js"],"names":[],"mappings":"AAoCO,kGAAsI;AAQtI,8FAA+H;AAO/H,gGAAkH;AASlH,4GAA8H"}
@@ -1,4 +1,5 @@
1
1
  export namespace spm {
2
2
  let name: string;
3
+ let autolinkingPlugin: string;
3
4
  }
4
5
  //# sourceMappingURL=react-native.config.d.ts.map
@@ -0,0 +1,99 @@
1
+ import React from "react";
2
+ import type { ViewProps } from "react-native";
3
+ import type { GPUSharedFenceState, NativeBuffer } from "./types";
4
+ /**
5
+ * How a {@link NativeBufferView} fits a buffer whose size differs from its
6
+ * own (in physical pixels), for instance while the producer catches up with
7
+ * a resize. A buffer of exactly the view's size is shown 1:1 in every mode.
8
+ *
9
+ * - `stretch` (the default): scaled to the bounds, ignoring the aspect ratio.
10
+ * - `contain`: scaled to fit inside the bounds, keeping the aspect ratio.
11
+ * - `cover`: scaled to fill the bounds, keeping the aspect ratio; the excess
12
+ * is cropped.
13
+ * - `topLeft`: not scaled; anchored at the top left corner and cropped.
14
+ */
15
+ export type NativeBufferResizeMode = "stretch" | "contain" | "cover" | "topLeft";
16
+ /** A size in physical pixels. */
17
+ export interface NativeBufferPixelSize {
18
+ width: number;
19
+ height: number;
20
+ }
21
+ export interface NativeBufferViewRef {
22
+ /**
23
+ * The id to pass to `RNWebGPU.presentNativeBuffer(viewId, frame, done)`,
24
+ * for instance from a worklet.
25
+ */
26
+ readonly viewId: number;
27
+ /**
28
+ * Displays `frame` once the GPU work that wrote it is done: `done` is what
29
+ * `GPUSharedTextureMemory.endAccess()` returned for that work (its
30
+ * `fences`), and the view waits for every fence. Without it, the buffer is
31
+ * shown right away. On Android, the view also waits for the frame's own
32
+ * acquire fence, if any. Returns immediately; the view shows the buffer on
33
+ * the next vsync after that.
34
+ *
35
+ * The buffer must not be written again while it is displayed: render the
36
+ * next content into another buffer and present that one. The view keeps
37
+ * its own reference on the buffer, so a buffer from `createNativeBuffer()`
38
+ * can be released right after this call.
39
+ *
40
+ * Frames from a pool (a `VideoPlayer`, a camera, a decoder) are different:
41
+ * the pool reuses the buffer for a later frame once the frame is released,
42
+ * even while the view still shows it, and the view then shows a later or
43
+ * half-written frame. Copy such a frame into a buffer from
44
+ * `createNativeBuffer()` (for instance by drawing it with WebGPU) and
45
+ * present the copy.
46
+ */
47
+ present(frame: NativeBuffer, done?: {
48
+ fences: GPUSharedFenceState[];
49
+ } | null): void;
50
+ }
51
+ export interface NativeBufferViewProps extends ViewProps {
52
+ /** See {@link NativeBufferResizeMode}. Defaults to `"stretch"`. */
53
+ resizeMode?: NativeBufferResizeMode;
54
+ /**
55
+ * The view's size in physical pixels: the size to render at for a sharp,
56
+ * 1:1 display. Called on mount and on every size change, with the
57
+ * rounding the platform's layout applied. See {@link useNativeBufferSize}
58
+ * to re-render only once a resize settles.
59
+ */
60
+ onPixelSizeChange?: (size: NativeBufferPixelSize) => void;
61
+ ref?: React.Ref<NativeBufferViewRef>;
62
+ }
63
+ /**
64
+ * Displays a native buffer (an `AHardwareBuffer` on Android, an `IOSurface`
65
+ * on Apple platforms) with no swap chain, no canvas context and no GPU device
66
+ * on the display side. Meant for content that is static or updated
67
+ * occasionally; animated content belongs in a `Canvas`.
68
+ *
69
+ * The view never allocates buffers. It reports its size in physical pixels
70
+ * ({@link NativeBufferViewProps.onPixelSizeChange}), and any producer
71
+ * (WebGPU, Skia, a camera, a decoder) renders into a buffer and presents it
72
+ * through the ref (frames from a camera or a decoder are copied first, see
73
+ * {@link NativeBufferViewRef.present}). With WebGPU:
74
+ *
75
+ * ```ts
76
+ * const frame = createNativeBuffer(size.width, size.height);
77
+ * const memory = device.importSharedTextureMemory({ source: frame });
78
+ * const texture = memory.createTexture();
79
+ * memory.beginAccess(texture, false);
80
+ * // ... render into texture and submit ...
81
+ * ref.current.present(frame, memory.endAccess(texture));
82
+ * texture.destroy();
83
+ * memory.destroy();
84
+ * frame.release();
85
+ * ```
86
+ */
87
+ export declare const NativeBufferView: ({ resizeMode, onPixelSizeChange, ref, ...props }: NativeBufferViewProps) => React.JSX.Element;
88
+ /**
89
+ * Tracks the pixel size of a {@link NativeBufferView}, settling resizes:
90
+ * the first size is reported right away, later ones once the view has kept
91
+ * the same size for `debounceMs` (during an animated resize the view
92
+ * stretches what it shows meanwhile). Pass `onPixelSizeChange` to the view
93
+ * and render a buffer of `size` whenever it changes.
94
+ */
95
+ export declare const useNativeBufferSize: (debounceMs?: number) => {
96
+ size: NativeBufferPixelSize | null;
97
+ onPixelSizeChange: (next: NativeBufferPixelSize) => void;
98
+ };
99
+ //# sourceMappingURL=NativeBufferView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeBufferView.d.ts","sourceRoot":"","sources":["../../../src/NativeBufferView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAwB,SAAS,EAAE,MAAM,cAAc,CAAC;AAGpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEjE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,sBAAsB,GAChC,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AAE9C,iCAAiC;AACjC,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,OAAO,CACL,KAAK,EAAE,YAAY,EACnB,IAAI,CAAC,EAAE;QAAE,MAAM,EAAE,mBAAmB,EAAE,CAAA;KAAE,GAAG,IAAI,GAC9C,IAAI,CAAC;CACT;AAED,MAAM,WAAW,qBAAsB,SAAQ,SAAS;IACtD,mEAAmE;IACnE,UAAU,CAAC,EAAE,sBAAsB,CAAC;IACpC;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAC1D,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;CACtC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,gBAAgB,GAAI,kDAK9B,qBAAqB,sBAwCvB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAAI,mBAAgB;;8BAMzC,qBAAqB;CAoC/B,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { CodegenTypes, ViewProps } from "react-native";
2
+ type PixelSizeChangeEvent = Readonly<{
3
+ width: CodegenTypes.Int32;
4
+ height: CodegenTypes.Int32;
5
+ }>;
6
+ export interface NativeProps extends ViewProps {
7
+ viewId: CodegenTypes.Int32;
8
+ resizeMode?: CodegenTypes.WithDefault<"stretch" | "contain" | "cover" | "topLeft", "stretch">;
9
+ onPixelSizeChange?: CodegenTypes.DirectEventHandler<PixelSizeChangeEvent>;
10
+ }
11
+ declare const _default: import("react-native").HostComponent<NativeProps>;
12
+ export default _default;
13
+ //# sourceMappingURL=NativeBufferViewNativeComponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeBufferViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/NativeBufferViewNativeComponent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE5D,KAAK,oBAAoB,GAAG,QAAQ,CAAC;IACnC,KAAK,EAAE,YAAY,CAAC,KAAK,CAAC;IAC1B,MAAM,EAAE,YAAY,CAAC,KAAK,CAAC;CAC5B,CAAC,CAAC;AAEH,MAAM,WAAW,WAAY,SAAQ,SAAS;IAE5C,MAAM,EAAE,YAAY,CAAC,KAAK,CAAC;IAC3B,UAAU,CAAC,EAAE,YAAY,CAAC,WAAW,CACnC,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,EAC3C,SAAS,CACV,CAAC;IACF,iBAAiB,CAAC,EAAE,YAAY,CAAC,kBAAkB,CAAC,oBAAoB,CAAC,CAAC;CAC3E;;AAGD,wBAA6E"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * `requestAnimationFrame`, paced by the display, on any runtime.
3
+ *
4
+ * Drop-in for the global one in a render loop:
5
+ *
6
+ * ```ts
7
+ * import { requestAnimationFrame } from "react-native-webgpu";
8
+ *
9
+ * const render = (timestamp: number) => {
10
+ * draw(timestamp);
11
+ * context.present();
12
+ * requestAnimationFrame(render);
13
+ * };
14
+ * requestAnimationFrame(render);
15
+ * ```
16
+ *
17
+ * React Native's global `requestAnimationFrame` is a timer: on Android it
18
+ * makes the next frame of the display only when it is requested before that
19
+ * frame starts, which leaves a loop that requests its next frame at the end
20
+ * of its work about 6 ms of a 120 Hz frame (past that, it drops to 60 fps),
21
+ * and on iOS it runs at 60 Hz. On a worklet runtime of your own
22
+ * (`createWorkletRuntime`), the global one polls every 16 ms (about 48 fps).
23
+ * This one follows the display wherever it is called:
24
+ *
25
+ * - On the React Native runtime, each frame of the display runs the callbacks
26
+ * requested before it, with the frame's time.
27
+ * - On a worklet runtime of your own, the runtime waits on its thread for the
28
+ * next frame of the display (the rest of the current frame at most), then
29
+ * runs them. Nothing else runs on the runtime during that wait.
30
+ * - On the Reanimated UI runtime, it is worklets' `requestAnimationFrame`,
31
+ * which is paced by the display already.
32
+ *
33
+ * Like a browser's, a callback requested while the frame's callbacks run gets
34
+ * the next frame, and every callback of a frame gets the same timestamp: the
35
+ * time the frame started, on the clock of `performance.now()`. The callbacks
36
+ * run once per frame of the display. A loop that overruns its frame runs
37
+ * again in the frame it overran into rather than waiting for the frame after.
38
+ * On the React Native runtime that run goes behind whatever waits there
39
+ * (React's updates, the app's other tasks), and the run after it waits for a
40
+ * frame of the display: the runtime is never the loop's alone.
41
+ *
42
+ * On the React Native runtime and on a worklet runtime of your own, no frame
43
+ * comes while the app is not in the foreground (the host activity is paused
44
+ * on Android, the app is not active on iOS): a loop stops with the app, and
45
+ * starts again when it is back.
46
+ *
47
+ * On iPhone, an app only gets more than 60 Hz with
48
+ * `CADisableMinimumFrameDurationOnPhone` set to true in its Info.plist. On
49
+ * macOS and on web, this is the runtime's own `requestAnimationFrame`.
50
+ */
51
+ export declare const requestAnimationFrame: (callback: (timestamp: number) => void) => number;
52
+ /**
53
+ * Cancels a callback requested with this package's `requestAnimationFrame`,
54
+ * on the runtime it was requested on. Not interchangeable with the global
55
+ * `cancelAnimationFrame`: each cancels the handles of its own
56
+ * `requestAnimationFrame`.
57
+ */
58
+ export declare const cancelAnimationFrame: (handle: number) => void;
59
+ //# sourceMappingURL=animationFrame.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animationFrame.d.ts","sourceRoot":"","sources":["../../../src/animationFrame.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,eAAO,MAAM,qBAAqB,GAChC,UAAU,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,KACpC,MAMF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAQ,MAAM,KAAG,IAOrD,CAAC"}
@@ -1,14 +1,19 @@
1
1
  import "./main/installNative";
2
- import type { GPUNativeBufferExternalTexture, GPUNativeBufferExternalTextureDescriptor, GPUNativeBufferTexture, GPUNativeBufferTextureDescriptor, GPUDrawElementImageDestination, GPUDrawElementImageSource, GPUSharedFence, GPUSharedFenceDescriptor, GPUDawnTogglesDescriptor, GPUNativeExternalTextureDescriptor, GPUSharedTextureMemory, GPUSharedTextureMemoryDescriptor, GPUCopyExternalNativeFrameSourceInfo, NativeCanvas, RNCanvasContext, VideoPlayer, NativeVideoFrame, NativeVideoPixelFormat } from "./types";
2
+ import type { GPUDrawElementImageDestination, GPUDrawElementImageSource, GPUSharedFence, GPUSharedFenceDescriptor, GPUSharedFenceState, CreateNativeBufferOptions, GPUDawnTogglesDescriptor, GPUNativeExternalTextureDescriptor, GPUSharedTextureMemory, GPUSharedTextureMemoryDescriptor, GPUCopyExternalNativeFrameSourceInfo, NativeCanvas, RNCanvasContext, VideoPlayer, NativeBuffer, NativeBufferPixelFormat } from "./types";
3
3
  export * from "./main";
4
4
  export * from "./constants";
5
5
  export { installWebGPU } from "./install";
6
- export type { NativeVideoFrame, VideoPlayer, GPUSharedFence, GPUSharedFenceDescriptor, GPUSharedFenceExportInfo, GPUSharedFenceState, GPUSharedFenceType, GPUSharedTextureMemory, GPUSharedTextureMemoryDescriptor, GPUSharedTextureMemoryEndAccessState, NativeVideoPixelFormat, CreateVideoPlayerOptions, GPUCopyExternalNativeFrameSourceInfo, GPUDawnTogglesDescriptor, GPUNativeExternalTextureDescriptor, NativeVideoFrameColorSpace, GPUExtent2D, GPUNativeBufferExternalTextureDescriptor, GPUNativeBufferTextureDescriptor, GPUNativeBufferWrapper, GPUNativeBufferTexture, GPUNativeBufferExternalTexture, GPUDrawElementImageDestination, GPUDrawElementImageSource, GPUDrawElementImageSourceView, } from "./types";
6
+ export { requestAnimationFrame, cancelAnimationFrame } from "./animationFrame";
7
+ export type { NativeBuffer, VideoPlayer, GPUSharedFence, GPUSharedFenceDescriptor, GPUSharedFenceExportInfo, GPUSharedFenceState, GPUSharedFenceType, GPUSharedTextureMemory, GPUSharedTextureMemoryDescriptor, GPUSharedTextureMemoryEndAccessState, NativeBufferPixelFormat, CreateTestVideoPlayerOptions, GPUCopyExternalNativeFrameSourceInfo, GPUDawnTogglesDescriptor, GPUNativeExternalTextureDescriptor, NativeBufferColorSpace, GPUExtent2D, GPUDrawElementImageDestination, GPUDrawElementImageSource, GPUDrawElementImageSourceView, CreateNativeBufferOptions, } from "./types";
7
8
  declare global {
8
9
  interface Navigator {
9
10
  gpu: GPU;
10
11
  }
11
12
  var navigator: Navigator;
13
+ var __webgpuAnimationFrames: {
14
+ request: (callback: (timestamp: number) => void) => number;
15
+ cancel: (handle: number) => void;
16
+ } | undefined;
12
17
  var RNWebGPU: {
13
18
  gpu: GPU;
14
19
  fabric: boolean;
@@ -19,13 +24,20 @@ declare global {
19
24
  destroyContext: (contextId: number) => void;
20
25
  DecodeToUTF8: (buffer: NodeJS.ArrayBufferView | ArrayBuffer) => string;
21
26
  createImageBitmap: typeof createImageBitmap;
22
- loadVideoFrame: (path: string) => NativeVideoFrame;
23
- createTestVideoFrame: (width: number, height: number, pixelFormat?: NativeVideoPixelFormat) => NativeVideoFrame;
24
- createVideoFrameFromNativeBuffer: (pointer: bigint) => NativeVideoFrame;
27
+ loadVideoFrame: (path: string) => NativeBuffer;
28
+ createTestVideoFrame: (width: number, height: number, pixelFormat?: NativeBufferPixelFormat) => NativeBuffer;
29
+ createNativeBufferFromPointer: (pointer: bigint) => NativeBuffer;
25
30
  importDevice: (pointer: bigint) => GPUDevice;
26
31
  adoptTexture: (pointer: bigint) => GPUTexture;
27
- createVideoPlayer: (source: string, pixelFormat?: NativeVideoPixelFormat) => VideoPlayer;
32
+ createTestVideoPlayer: (source: string, pixelFormat?: NativeBufferPixelFormat) => VideoPlayer;
28
33
  writeTestVideoFile: () => string;
34
+ createNativeBuffer: (width: number, height: number, options?: CreateNativeBufferOptions) => NativeBuffer;
35
+ allocateNativeBufferViewId: () => number;
36
+ retainNativeBufferView: (viewId: number) => void;
37
+ releaseNativeBufferView: (viewId: number) => void;
38
+ presentNativeBuffer: (viewId: number, frame: NativeBuffer, done?: {
39
+ fences: GPUSharedFenceState[];
40
+ } | null) => void;
29
41
  };
30
42
  interface GPUTexture {
31
43
  readonly nativePointer: bigint;
@@ -34,8 +46,6 @@ declare global {
34
46
  importExternalTexture(descriptor: GPUNativeExternalTextureDescriptor): GPUExternalTexture;
35
47
  importSharedTextureMemory(descriptor: GPUSharedTextureMemoryDescriptor): GPUSharedTextureMemory;
36
48
  importSharedFence(descriptor: GPUSharedFenceDescriptor): GPUSharedFence;
37
- createNativeBufferTexture(source: NativeVideoFrame, descriptor?: GPUNativeBufferTextureDescriptor): GPUNativeBufferTexture;
38
- createNativeBufferExternalTexture(source: NativeVideoFrame, descriptor?: GPUNativeBufferExternalTextureDescriptor): GPUNativeBufferExternalTexture;
39
49
  }
40
50
  interface GPUQueue {
41
51
  drawElementImageToTexture(source: GPUDrawElementImageSource, destination: GPUDrawElementImageDestination): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"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wB,GAAG,cAAc,CAAC;KACzE;IAmBD,UAAU,QAAQ;QAChB,yBAAyB,CACvB,MAAM,EAAE,yBAAyB,EACjC,WAAW,EAAE,8BAA8B,GAC1C,OAAO,CAAC,IAAI,CAAC,CAAC;QAQjB,0BAA0B,CACxB,MAAM,EAAE,oCAAoC,EAC5C,WAAW,EAAE,4BAA4B,EACzC,QAAQ,EAAE,iBAAiB,GAC1B,SAAS,CAAC;KACd;IAID,UAAU,mBAAmB;QAC3B,WAAW,CAAC,EAAE,wBAAwB,CAAC;QAOvC,6BAA6B,CAAC,EAAE,OAAO,CAAC;KACzC;IAMD,UAAU,4BAA4B;QACpC,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,CAAC;QAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB;IASD,UAAU,kBAAkB;QAC1B,OAAO,IAAI,IAAI,CAAC;KACjB;IAGD,SAAS,iBAAiB,CACxB,KAAK,EAAE,WAAW,GAAG,eAAe,EACpC,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,WAAW,CAAC,CAAC;CACzB"}
@@ -1,5 +1,6 @@
1
1
  import "./installNative";
2
2
  export * from "../Canvas";
3
+ export * from "../NativeBufferView";
3
4
  export * from "../Offscreen";
4
5
  export * from "../WebGPUViewNativeComponent";
5
6
  export * from "../hooks";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/main/index.tsx"],"names":[],"mappings":"AAKA,OAAO,iBAAiB,CAAC;AAoDzB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,UAAU,CAAC;AACzB,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/main/index.tsx"],"names":[],"mappings":"AAKA,OAAO,iBAAiB,CAAC;AAoDzB,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,UAAU,CAAC;AACzB,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  import type { ReactNode } from "react";
3
3
  import type { CanvasProps } from "./Canvas";
4
+ import type { NativeBufferViewProps } from "./NativeBufferView";
4
5
  export * from "./formats";
5
6
  export declare const GPUBufferUsage: GPUBufferUsage;
6
7
  export declare const GPUTextureUsage: GPUTextureUsage;
@@ -11,6 +12,14 @@ export type { AndroidBackingView, AndroidCanvasProps, AndroidHardwareBufferViewP
11
12
  export declare const Canvas: ({ android: _android, ref, ...props }: CanvasProps) => React.FunctionComponentElement<Omit<import("react-native").ViewProps, "ref"> & {
12
13
  ref?: React.Ref<import("react-native").ViewInstance> | undefined;
13
14
  }>;
15
+ export type { NativeBufferPixelSize, NativeBufferResizeMode, NativeBufferViewProps, NativeBufferViewRef, } from "./NativeBufferView";
16
+ export declare const NativeBufferView: ({ resizeMode: _resizeMode, onPixelSizeChange: _onPixelSizeChange, ref, ...props }: NativeBufferViewProps) => React.FunctionComponentElement<Omit<import("react-native").ViewProps, "ref"> & {
17
+ ref?: React.Ref<import("react-native").ViewInstance> | undefined;
18
+ }>;
19
+ export declare const useNativeBufferSize: (_debounceMs?: number) => {
20
+ size: null;
21
+ onPixelSizeChange: () => undefined;
22
+ };
14
23
  export declare const useCanvasRef: () => React.RefObject<null>;
15
24
  export declare const useSurface: () => {
16
25
  ref: React.RefObject<null>;
@@ -28,6 +37,8 @@ export declare const useMainDevice: () => never;
28
37
  export declare const importDevice: (_pointer: bigint) => GPUDevice;
29
38
  export declare const adoptTexture: (_pointer: bigint) => GPUTexture;
30
39
  export declare const installWebGPU: () => undefined;
40
+ export declare const requestAnimationFrame: (callback: (timestamp: number) => void) => number;
41
+ export declare const cancelAnimationFrame: (handle: number) => void;
31
42
  export declare const WebGPUModule: {
32
43
  install: () => boolean;
33
44
  };
@@ -1 +1 @@
1
- {"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../src/mock.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,WAAW,EAAiC,MAAM,UAAU,CAAC;AAa3E,cAAc,WAAW,CAAC;AAM1B,eAAO,MAAM,cAAc,EAAE,cAW5B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,eAO7B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,cAI5B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,aAM3B,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,UAGxB,CAAC;AAoBF,YAAY,EACV,kBAAkB,EAClB,kBAAkB,EAClB,8BAA8B,EAC9B,uBAAuB,EACvB,uBAAuB,EACvB,WAAW,EACX,SAAS,EACT,YAAY,EACZ,eAAe,GAChB,MAAM,UAAU,CAAC;AAGlB,eAAO,MAAM,MAAM,GAAI,sCAAsC,WAAW;;EASvE,CAAC;AAEF,eAAO,MAAM,YAAY,6BAA2B,CAAC;AACrD,eAAO,MAAM,UAAU;;;CAAqD,CAAC;AAC7E,eAAO,MAAM,4BAA4B,iBAAkB,CAAC;AAE5D,eAAO,MAAM,SAAS;;;CAA0C,CAAC;AAEjE,eAAO,MAAM,iBAAiB,GAAI,cAAc;IAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,6UACtD,CAAC;AAE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AC;AACrD,eAAO,MAAM,UAAU;;;CAAqD,CAAC;AAC7E,eAAO,MAAM,4BAA4B,iBAAkB,CAAC;AAE5D,eAAO,MAAM,SAAS;;;CAA0C,CAAC;AAEjE,eAAO,MAAM,iBAAiB,GAAI,cAAc;IAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,6UACtD,CAAC;AAEnB,eAAO,MAAM,aAAa,QAAO,KAEhC,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,UAAU,MAAM,KAAG,SAE/C,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,UAAU,MAAM,KAAG,UAE/C,CAAC;AAEF,eAAO,MAAM,aAAa,iBAAkB,CAAC;AAE7C,eAAO,MAAM,qBAAqB,GAAI,UAAU,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,WAC/B,CAAC;AAE7C,eAAO,MAAM,oBAAoB,GAAI,QAAQ,MAAM,SACV,CAAC;AAE1C,eAAO,MAAM,YAAY;;CAA2B,CAAC"}
@@ -28,16 +28,16 @@ export interface CanvasRef {
28
28
  getContext(contextName: "webgpu"): RNCanvasContext | null;
29
29
  getNativeSurface: () => NativeCanvas;
30
30
  }
31
- export type NativeVideoPixelFormat = "bgra8" | "nv12";
32
- export interface NativeVideoFrame {
31
+ export type NativeBufferPixelFormat = "bgra8" | "nv12";
32
+ export interface NativeBuffer {
33
33
  readonly handle: bigint;
34
34
  readonly width: number;
35
35
  readonly height: number;
36
- readonly pixelFormat: NativeVideoPixelFormat;
36
+ readonly pixelFormat: NativeBufferPixelFormat;
37
37
  readonly acquireFenceFd: bigint | null;
38
38
  release(): void;
39
39
  }
40
- export interface NativeVideoFrameColorSpace {
40
+ export interface NativeBufferColorSpace {
41
41
  matrix?: "identity" | "rec601" | "rec709" | "rec2020";
42
42
  range?: "identity" | "narrow" | "full";
43
43
  primaries?: "srgb" | "rec709" | "rec601" | "rec2020" | "display-p3";
@@ -48,32 +48,13 @@ export type GPUExtent2D = {
48
48
  height: number;
49
49
  } | [number, number];
50
50
  export interface GPUNativeExternalTextureDescriptor extends Omit<GPUExternalTextureDescriptor, "source"> {
51
- source: NativeVideoFrame;
52
- sourceColorSpace?: NativeVideoFrameColorSpace;
51
+ source: NativeBuffer | GPUTexture;
52
+ sourceColorSpace?: NativeBufferColorSpace;
53
53
  cropOrigin?: GPUOrigin2D;
54
54
  cropSize?: GPUExtent2D;
55
55
  }
56
- export type GPUNativeBufferExternalTextureDescriptor = Omit<GPUNativeExternalTextureDescriptor, "source">;
57
- export interface GPUNativeBufferTextureDescriptor {
58
- usage?: GPUTextureUsageFlags;
59
- label?: string;
60
- }
61
- export interface GPUNativeBufferWrapper {
62
- label: string;
63
- beginAccess(fences?: GPUSharedFenceState[]): void;
64
- endAccess(): GPUSharedFenceState | null;
65
- destroy(): void;
66
- }
67
- export interface GPUNativeBufferTexture extends GPUNativeBufferWrapper {
68
- readonly __brand: "GPUNativeBufferTexture";
69
- readonly texture: GPUTexture;
70
- }
71
- export interface GPUNativeBufferExternalTexture extends GPUNativeBufferWrapper {
72
- readonly __brand: "GPUNativeBufferExternalTexture";
73
- readonly externalTexture: GPUExternalTexture;
74
- }
75
56
  export interface VideoPlayer {
76
- copyLatestFrame(): NativeVideoFrame | null;
57
+ copyLatestFrame(): NativeBuffer | null;
77
58
  play(): void;
78
59
  pause(): void;
79
60
  release(): void;
@@ -88,14 +69,14 @@ export interface VideoPlayer {
88
69
  readonly frameRate: number;
89
70
  }
90
71
  export interface GPUCopyExternalNativeFrameSourceInfo {
91
- source: NativeVideoFrame;
72
+ source: NativeBuffer;
92
73
  origin?: GPUOrigin2D;
93
74
  flipY?: boolean;
94
75
  rotation?: 0 | 90 | 180 | 270;
95
76
  mirrored?: boolean;
96
77
  }
97
- export interface CreateVideoPlayerOptions {
98
- pixelFormat?: NativeVideoPixelFormat;
78
+ export interface CreateTestVideoPlayerOptions {
79
+ pixelFormat?: NativeBufferPixelFormat;
99
80
  }
100
81
  export type GPUDrawElementImageSourceView = number | {
101
82
  current: unknown;
@@ -111,10 +92,15 @@ export interface GPUDrawElementImageSource {
111
92
  export interface GPUDrawElementImageDestination extends GPUCopyExternalImageDestInfo {
112
93
  size?: GPUExtent3DStrict;
113
94
  }
114
- export interface GPUSharedTextureMemoryDescriptor {
115
- handle: bigint;
95
+ export type GPUSharedTextureMemoryDescriptor = {
116
96
  label?: string;
117
- }
97
+ } & ({
98
+ source: NativeBuffer;
99
+ handle?: undefined;
100
+ } | {
101
+ handle: bigint;
102
+ source?: undefined;
103
+ });
118
104
  export type GPUSharedFenceType = "mtl-shared-event" | "sync-fd" | "vk-semaphore-opaque-fd";
119
105
  export interface GPUSharedFenceDescriptor {
120
106
  type: GPUSharedFenceType;
@@ -151,5 +137,20 @@ export interface GPUSharedTextureMemory {
151
137
  endAccess(texture: GPUTexture): GPUSharedTextureMemoryEndAccessState;
152
138
  destroy(): void;
153
139
  }
140
+ /**
141
+ * The options of `createNativeBuffer()`. The buffer holds premultiplied
142
+ * pixels.
143
+ */
144
+ export interface CreateNativeBufferOptions {
145
+ /**
146
+ * Defaults to the preferred canvas format of the platform:
147
+ * `"rgba8unorm"` on Android, `"bgra8unorm"` on Apple platforms.
148
+ * `"rgba16float"` works on both; it gives more precision, not extended
149
+ * range: a `NativeBufferView` shows values in [0, 1] and clamps the rest.
150
+ */
151
+ format?: "rgba8unorm" | "bgra8unorm" | "rgba16float";
152
+ /** The primaries of the values. Defaults to `"srgb"`. */
153
+ colorSpace?: PredefinedColorSpace;
154
+ }
154
155
  export {};
155
156
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,KAAK,cAAc,GAAG,MAAM,CAAC;AAE7B,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,cAAc,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YA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CAAC;IACrD,yDAAyD;IACzD,UAAU,CAAC,EAAE,oBAAoB,CAAC;CACnC"}
@@ -1,7 +1,11 @@
1
- import type { CreateVideoPlayerOptions, NativeVideoFrame, VideoPlayer } from "./types";
1
+ import type { CreateNativeBufferOptions, CreateTestVideoPlayerOptions, NativeBuffer, VideoPlayer } from "./types";
2
2
  /**
3
3
  * Decodes a video into native frames the GPU samples without any copy.
4
4
  *
5
+ * For tests and examples only: video decoding is out of the scope of this
6
+ * library. For video in an app, use a video library and wrap its frames with
7
+ * `createNativeBufferFromPointer()`.
8
+ *
5
9
  * `source` is a URL (`http`, `https`, `file`) or a file path. Playback is
6
10
  * controlled like an HTMLMediaElement (`play()`, `pause()`, `currentTime`,
7
11
  * `loop`, `volume`); frames are pulled with `copyLatestFrame()` on every
@@ -9,7 +13,7 @@ import type { CreateVideoPlayerOptions, NativeVideoFrame, VideoPlayer } from "./
9
13
  * `importSharedTextureMemory()`:
10
14
  *
11
15
  * ```ts
12
- * const player = createVideoPlayer(url);
16
+ * const player = createTestVideoPlayer(url);
13
17
  * player.play();
14
18
  * const render = () => {
15
19
  * const frame = player.copyLatestFrame();
@@ -24,18 +28,26 @@ import type { CreateVideoPlayerOptions, NativeVideoFrame, VideoPlayer } from "./
24
28
  * `{ pixelFormat: "nv12" }`. On Android they are always in the decoder's
25
29
  * native YUV layout, for `importExternalTexture()`.
26
30
  */
27
- export declare const createVideoPlayer: (source: string, options?: CreateVideoPlayerOptions) => VideoPlayer;
31
+ export declare const createTestVideoPlayer: (source: string, options?: CreateTestVideoPlayerOptions) => VideoPlayer;
28
32
  /**
29
33
  * Wraps a native buffer produced by another library (a `CVPixelBufferRef` on
30
34
  * Apple platforms, an `AHardwareBuffer*` on Android, for instance
31
- * VisionCamera's `frame.getNativeBuffer().pointer`) into a `NativeVideoFrame`
35
+ * VisionCamera's `frame.getNativeBuffer().pointer`) into a `NativeBuffer`
32
36
  * that keeps it alive until released.
33
37
  */
34
- export declare const createVideoFrameFromNativeBuffer: (pointer: bigint) => NativeVideoFrame;
38
+ export declare const createNativeBufferFromPointer: (pointer: bigint) => NativeBuffer;
35
39
  /**
36
40
  * Allocates a native frame of the given size filled with a test pattern (a
37
41
  * red/green gradient with diagonal stripes in the blue channel), for examples
38
42
  * and tests that need a frame without a camera or a video.
39
43
  */
40
- export declare const createTestVideoFrame: (width: number, height: number) => NativeVideoFrame;
44
+ export declare const createTestVideoFrame: (width: number, height: number) => NativeBuffer;
45
+ /**
46
+ * Allocates an empty native buffer (an `AHardwareBuffer` on Android, an
47
+ * `IOSurface` on Apple platforms) that the GPU renders into and a
48
+ * `NativeBufferView` displays: import it with
49
+ * `device.importSharedTextureMemory({ source: frame })`, render into
50
+ * `memory.createTexture()` inside an access, then present it.
51
+ */
52
+ export declare const createNativeBuffer: (width: number, height: number, options?: CreateNativeBufferOptions) => NativeBuffer;
41
53
  //# sourceMappingURL=video.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"video.d.ts","sourceRoot":"","sources":["../../../src/video.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,gBAAgB,EAChB,WAAW,EACZ,MAAM,SAAS,CAAC;AAWjB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,MAAM,EACd,UAAU,wBAAwB,KACjC,WAC0E,CAAC;AAE9E;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,GAC3C,SAAS,MAAM,KACd,gBAGA,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAC/B,OAAO,MAAM,EACb,QAAQ,MAAM,KACb,gBACiE,CAAC"}
1
+ {"version":3,"file":"video.d.ts","sourceRoot":"","sources":["../../../src/video.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,4BAA4B,EAC5B,YAAY,EACZ,WAAW,EACZ,MAAM,SAAS,CAAC;AAWjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,qBAAqB,GAChC,QAAQ,MAAM,EACd,UAAU,4BAA4B,KACrC,WAIA,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,GAAI,SAAS,MAAM,KAAG,YAG7D,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAC/B,OAAO,MAAM,EACb,QAAQ,MAAM,KACb,YACiE,CAAC;AAErE;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,MAAM,EACb,QAAQ,MAAM,EACd,UAAU,yBAAyB,KAClC,YACsE,CAAC"}