react-native-webgpu 0.21.4 → 0.23.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 (170) hide show
  1. package/README.md +15 -2
  2. package/android/CMakeLists.txt +10 -8
  3. package/android/build.gradle +111 -20
  4. package/android/cpp/AndroidAnimationFrameSource.h +136 -0
  5. package/android/cpp/AndroidPlatformContext.h +55 -0
  6. package/android/cpp/cpp-adapter.cpp +148 -2
  7. package/android/src/main/java/com/webgpu/WebGPUModule.java +21 -4
  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 +1 -1
  12. package/android/src/main/java/com/webgpu/WebGPUView.java +19 -3
  13. package/android/src/main/java/com/webgpu/WebGPUViewManager.java +10 -0
  14. package/android/src/main/java/com/webgpu/WebGPUViewPackage.java +2 -2
  15. package/android/src/newarch/com/webgpu/WebGPUNativeBufferViewManagerSpec.java +24 -0
  16. package/apple/AppleAnimationFrameSource.mm +208 -0
  17. package/apple/ApplePlatformContext.h +6 -0
  18. package/apple/ApplePlatformContext.mm +73 -0
  19. package/apple/MetalLayerColorSpace.h +17 -0
  20. package/apple/MetalLayerColorSpace.mm +36 -57
  21. package/apple/MetalView.h +4 -0
  22. package/apple/MetalView.mm +14 -0
  23. package/apple/NativeBufferFenceWait.mm +88 -0
  24. package/apple/RNWGUIKit.h +4 -1
  25. package/apple/WebGPUModule.mm +26 -1
  26. package/apple/WebGPUNativeBufferView.h +15 -0
  27. package/apple/WebGPUNativeBufferView.mm +200 -0
  28. package/apple/WebGPUView.h +2 -1
  29. package/apple/WebGPUView.mm +6 -0
  30. package/binaries.json +156 -0
  31. package/cpp/jsi/NativeObject.h +12 -5
  32. package/cpp/rnwgpu/AnimationFrames.cpp +576 -0
  33. package/cpp/rnwgpu/AnimationFrames.h +233 -0
  34. package/cpp/rnwgpu/CanvasColorSpace.h +16 -0
  35. package/cpp/rnwgpu/NativeBufferViewRegistry.cpp +396 -0
  36. package/cpp/rnwgpu/NativeBufferViewRegistry.h +163 -0
  37. package/cpp/rnwgpu/PlatformContext.h +20 -0
  38. package/cpp/rnwgpu/RNWebGPUManager.cpp +17 -4
  39. package/cpp/rnwgpu/SurfaceRegistry.h +26 -30
  40. package/cpp/rnwgpu/api/GPUAdapter.cpp +1 -1
  41. package/cpp/rnwgpu/api/GPUCanvasContext.cpp +41 -3
  42. package/cpp/rnwgpu/api/GPUCanvasContext.h +7 -3
  43. package/cpp/rnwgpu/api/GPUDevice.cpp +16 -131
  44. package/cpp/rnwgpu/api/GPUDevice.h +0 -18
  45. package/cpp/rnwgpu/api/GPUExternalTexture.cpp +35 -3
  46. package/cpp/rnwgpu/api/GPUExternalTexture.h +4 -4
  47. package/cpp/rnwgpu/api/GPUQueue.cpp +1 -1
  48. package/cpp/rnwgpu/api/GPUQueue.h +1 -1
  49. package/cpp/rnwgpu/api/GPUSharedFence.h +1 -0
  50. package/cpp/rnwgpu/api/GPUSharedTextureMemory.cpp +11 -5
  51. package/cpp/rnwgpu/api/GPUSharedTextureMemory.h +21 -2
  52. package/cpp/rnwgpu/api/GPUTexture.h +18 -0
  53. package/cpp/rnwgpu/api/NativeFrameFeatures.h +1 -1
  54. package/cpp/rnwgpu/api/NativeFrameImport.cpp +20 -17
  55. package/cpp/rnwgpu/api/NativeFrameImport.h +31 -20
  56. package/cpp/rnwgpu/api/RNWebGPU.h +201 -3
  57. package/cpp/rnwgpu/api/VideoFrame.h +5 -4
  58. package/cpp/rnwgpu/api/VideoFrameBlit.h +2 -2
  59. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +21 -14
  60. package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +1 -1
  61. package/cpp/rnwgpu/api/descriptors/GPUSharedTextureMemoryDescriptor.h +17 -9
  62. package/cpp/rnwgpu/async/RuntimeContext.cpp +21 -4
  63. package/cpp/rnwgpu/async/RuntimeContext.h +8 -0
  64. package/lib/commonjs/Canvas.js +33 -1
  65. package/lib/commonjs/Canvas.js.map +1 -1
  66. package/lib/commonjs/NativeBufferView.js +131 -0
  67. package/lib/commonjs/NativeBufferView.js.map +1 -0
  68. package/lib/commonjs/NativeBufferViewNativeComponent.js +10 -0
  69. package/lib/commonjs/NativeBufferViewNativeComponent.js.map +1 -0
  70. package/lib/commonjs/WebGPUViewNativeComponent.js.map +1 -1
  71. package/lib/commonjs/WebGPUViewNativeComponent.web.js +2 -0
  72. package/lib/commonjs/WebGPUViewNativeComponent.web.js.map +1 -1
  73. package/lib/commonjs/animationFrame.js +91 -0
  74. package/lib/commonjs/animationFrame.js.map +1 -0
  75. package/lib/commonjs/index.js +16 -1
  76. package/lib/commonjs/index.js.map +1 -1
  77. package/lib/commonjs/main/index.js +12 -0
  78. package/lib/commonjs/main/index.js.map +1 -1
  79. package/lib/commonjs/mock.js +30 -1
  80. package/lib/commonjs/mock.js.map +1 -1
  81. package/lib/commonjs/video.js +14 -4
  82. package/lib/commonjs/video.js.map +1 -1
  83. package/lib/module/Canvas.js +33 -1
  84. package/lib/module/Canvas.js.map +1 -1
  85. package/lib/module/NativeBufferView.js +122 -0
  86. package/lib/module/NativeBufferView.js.map +1 -0
  87. package/lib/module/NativeBufferViewNativeComponent.js +4 -0
  88. package/lib/module/NativeBufferViewNativeComponent.js.map +1 -0
  89. package/lib/module/WebGPUViewNativeComponent.js.map +1 -1
  90. package/lib/module/WebGPUViewNativeComponent.web.js +2 -0
  91. package/lib/module/WebGPUViewNativeComponent.web.js.map +1 -1
  92. package/lib/module/animationFrame.js +83 -0
  93. package/lib/module/animationFrame.js.map +1 -0
  94. package/lib/module/index.js +1 -0
  95. package/lib/module/index.js.map +1 -1
  96. package/lib/module/main/index.js +1 -0
  97. package/lib/module/main/index.js.map +1 -1
  98. package/lib/module/mock.js +21 -0
  99. package/lib/module/mock.js.map +1 -1
  100. package/lib/module/video.js +11 -2
  101. package/lib/module/video.js.map +1 -1
  102. package/lib/typescript/lib/commonjs/Canvas.d.ts +3 -1
  103. package/lib/typescript/lib/commonjs/Canvas.d.ts.map +1 -1
  104. package/lib/typescript/lib/commonjs/NativeBufferView.d.ts +48 -0
  105. package/lib/typescript/lib/commonjs/NativeBufferView.d.ts.map +1 -0
  106. package/lib/typescript/lib/commonjs/NativeBufferViewNativeComponent.d.ts +5 -0
  107. package/lib/typescript/lib/commonjs/NativeBufferViewNativeComponent.d.ts.map +1 -0
  108. package/lib/typescript/lib/commonjs/WebGPUViewNativeComponent.web.d.ts.map +1 -1
  109. package/lib/typescript/lib/commonjs/animationFrame.d.ts +54 -0
  110. package/lib/typescript/lib/commonjs/animationFrame.d.ts.map +1 -0
  111. package/lib/typescript/lib/commonjs/index.d.ts +2 -0
  112. package/lib/typescript/lib/commonjs/mock.d.ts +12 -0
  113. package/lib/typescript/lib/commonjs/mock.d.ts.map +1 -1
  114. package/lib/typescript/lib/commonjs/video.d.ts +3 -2
  115. package/lib/typescript/lib/commonjs/video.d.ts.map +1 -1
  116. package/lib/typescript/lib/module/Canvas.d.ts +3 -1
  117. package/lib/typescript/lib/module/Canvas.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/WebGPUViewNativeComponent.web.d.ts.map +1 -1
  123. package/lib/typescript/lib/module/animationFrame.d.ts +3 -0
  124. package/lib/typescript/lib/module/animationFrame.d.ts.map +1 -0
  125. package/lib/typescript/lib/module/index.d.ts +1 -0
  126. package/lib/typescript/lib/module/main/index.d.ts +1 -0
  127. package/lib/typescript/lib/module/mock.d.ts +14 -0
  128. package/lib/typescript/lib/module/mock.d.ts.map +1 -1
  129. package/lib/typescript/lib/module/video.d.ts +3 -2
  130. package/lib/typescript/lib/module/video.d.ts.map +1 -1
  131. package/lib/typescript/src/Canvas.d.ts +17 -1
  132. package/lib/typescript/src/Canvas.d.ts.map +1 -1
  133. package/lib/typescript/src/NativeBufferView.d.ts +99 -0
  134. package/lib/typescript/src/NativeBufferView.d.ts.map +1 -0
  135. package/lib/typescript/src/NativeBufferViewNativeComponent.d.ts +13 -0
  136. package/lib/typescript/src/NativeBufferViewNativeComponent.d.ts.map +1 -0
  137. package/lib/typescript/src/WebGPUViewNativeComponent.d.ts +2 -0
  138. package/lib/typescript/src/WebGPUViewNativeComponent.d.ts.map +1 -1
  139. package/lib/typescript/src/WebGPUViewNativeComponent.web.d.ts +2 -0
  140. package/lib/typescript/src/WebGPUViewNativeComponent.web.d.ts.map +1 -1
  141. package/lib/typescript/src/animationFrame.d.ts +59 -0
  142. package/lib/typescript/src/animationFrame.d.ts.map +1 -0
  143. package/lib/typescript/src/index.d.ts +18 -8
  144. package/lib/typescript/src/index.d.ts.map +1 -1
  145. package/lib/typescript/src/main/index.d.ts +1 -0
  146. package/lib/typescript/src/main/index.d.ts.map +1 -1
  147. package/lib/typescript/src/mock.d.ts +11 -0
  148. package/lib/typescript/src/mock.d.ts.map +1 -1
  149. package/lib/typescript/src/types.d.ts +32 -31
  150. package/lib/typescript/src/types.d.ts.map +1 -1
  151. package/lib/typescript/src/video.d.ts +12 -4
  152. package/lib/typescript/src/video.d.ts.map +1 -1
  153. package/package.json +8 -2
  154. package/react-native-webgpu.podspec +1 -1
  155. package/src/Canvas.tsx +67 -1
  156. package/src/NativeBufferView.tsx +199 -0
  157. package/src/NativeBufferViewNativeComponent.ts +20 -0
  158. package/src/WebGPUViewNativeComponent.ts +4 -0
  159. package/src/WebGPUViewNativeComponent.web.ts +6 -0
  160. package/src/animationFrame.ts +82 -0
  161. package/src/index.tsx +45 -39
  162. package/src/main/index.tsx +1 -0
  163. package/src/mock.ts +35 -0
  164. package/src/types.ts +61 -87
  165. package/src/video.ts +20 -7
  166. package/cpp/rnwgpu/api/GPUNativeBufferExternalTexture.h +0 -60
  167. package/cpp/rnwgpu/api/GPUNativeBufferTexture.h +0 -52
  168. package/cpp/rnwgpu/api/GPUNativeBufferWrapper.cpp +0 -144
  169. package/cpp/rnwgpu/api/GPUNativeBufferWrapper.h +0 -143
  170. package/cpp/rnwgpu/api/descriptors/GPUNativeBufferTextureDescriptor.h +0 -55
@@ -0,0 +1,122 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import React, { useCallback, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from "react";
3
+ import NativeBufferViewNative from "./NativeBufferViewNativeComponent";
4
+
5
+ /**
6
+ * How a {@link NativeBufferView} fits a buffer whose size differs from its
7
+ * own (in physical pixels), for instance while the producer catches up with
8
+ * a resize. A buffer of exactly the view's size is shown 1:1 in every mode.
9
+ *
10
+ * - `stretch` (the default): scaled to the bounds, ignoring the aspect ratio.
11
+ * - `contain`: scaled to fit inside the bounds, keeping the aspect ratio.
12
+ * - `cover`: scaled to fill the bounds, keeping the aspect ratio; the excess
13
+ * is cropped.
14
+ * - `topLeft`: not scaled; anchored at the top left corner and cropped.
15
+ */
16
+
17
+ /** A size in physical pixels. */
18
+
19
+ /**
20
+ * Displays a native buffer (an `AHardwareBuffer` on Android, an `IOSurface`
21
+ * on Apple platforms) with no swap chain, no canvas context and no GPU device
22
+ * on the display side. Meant for content that is static or updated
23
+ * occasionally; animated content belongs in a `Canvas`.
24
+ *
25
+ * The view never allocates buffers. It reports its size in physical pixels
26
+ * ({@link NativeBufferViewProps.onPixelSizeChange}), and any producer
27
+ * (WebGPU, Skia, a camera, a decoder) renders into a buffer and presents it
28
+ * through the ref (frames from a camera or a decoder are copied first, see
29
+ * {@link NativeBufferViewRef.present}). With WebGPU:
30
+ *
31
+ * ```ts
32
+ * const frame = createNativeBuffer(size.width, size.height);
33
+ * const memory = device.importSharedTextureMemory({ source: frame });
34
+ * const texture = memory.createTexture();
35
+ * memory.beginAccess(texture, false);
36
+ * // ... render into texture and submit ...
37
+ * ref.current.present(frame, memory.endAccess(texture));
38
+ * texture.destroy();
39
+ * memory.destroy();
40
+ * frame.release();
41
+ * ```
42
+ */
43
+ export const NativeBufferView = ({
44
+ resizeMode,
45
+ onPixelSizeChange,
46
+ ref,
47
+ ...props
48
+ }) => {
49
+ // Native hands out the id: unique for the life of the process, as the
50
+ // native registry outlives a reload.
51
+ const [viewId] = useState(() => RNWebGPU.allocateNativeBufferViewId());
52
+ useImperativeHandle(ref, () => ({
53
+ viewId,
54
+ present: (frame, done) => RNWebGPU.presentNativeBuffer(viewId, frame, done ?? null)
55
+ }), [viewId]);
56
+
57
+ // The JS side's hold on the native entry; presents to an id nobody holds
58
+ // are dropped. A layout effect, so the entry exists before the ref reaches
59
+ // a parent's effects. Not taken in the useState initializer above: React
60
+ // StrictMode calls it twice and discards one id.
61
+ useLayoutEffect(() => {
62
+ RNWebGPU.retainNativeBufferView(viewId);
63
+ return () => RNWebGPU.releaseNativeBufferView(viewId);
64
+ }, [viewId]);
65
+ const onNativePixelSizeChange = useCallback(event => {
66
+ const {
67
+ width,
68
+ height
69
+ } = event.nativeEvent;
70
+ onPixelSizeChange?.({
71
+ width,
72
+ height
73
+ });
74
+ }, [onPixelSizeChange]);
75
+ return /*#__PURE__*/React.createElement(NativeBufferViewNative, _extends({}, props, {
76
+ viewId: viewId,
77
+ resizeMode: resizeMode,
78
+ onPixelSizeChange: onNativePixelSizeChange
79
+ }));
80
+ };
81
+
82
+ /**
83
+ * Tracks the pixel size of a {@link NativeBufferView}, settling resizes:
84
+ * the first size is reported right away, later ones once the view has kept
85
+ * the same size for `debounceMs` (during an animated resize the view
86
+ * stretches what it shows meanwhile). Pass `onPixelSizeChange` to the view
87
+ * and render a buffer of `size` whenever it changes.
88
+ */
89
+ export const useNativeBufferSize = (debounceMs = 150) => {
90
+ const [size, setSize] = useState(null);
91
+ const current = useRef(null);
92
+ const timer = useRef(null);
93
+ const onPixelSizeChange = useCallback(next => {
94
+ if (timer.current !== null) {
95
+ clearTimeout(timer.current);
96
+ timer.current = null;
97
+ }
98
+ const settle = () => {
99
+ timer.current = null;
100
+ const previous = current.current;
101
+ if (previous === null || previous.width !== next.width || previous.height !== next.height) {
102
+ current.current = next;
103
+ setSize(next);
104
+ }
105
+ };
106
+ if (current.current === null || debounceMs <= 0) {
107
+ settle();
108
+ } else {
109
+ timer.current = setTimeout(settle, debounceMs);
110
+ }
111
+ }, [debounceMs]);
112
+ useEffect(() => () => {
113
+ if (timer.current !== null) {
114
+ clearTimeout(timer.current);
115
+ }
116
+ }, []);
117
+ return {
118
+ size,
119
+ onPixelSizeChange
120
+ };
121
+ };
122
+ //# sourceMappingURL=NativeBufferView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useCallback","useEffect","useImperativeHandle","useLayoutEffect","useRef","useState","NativeBufferViewNative","NativeBufferView","resizeMode","onPixelSizeChange","ref","props","viewId","RNWebGPU","allocateNativeBufferViewId","present","frame","done","presentNativeBuffer","retainNativeBufferView","releaseNativeBufferView","onNativePixelSizeChange","event","width","height","nativeEvent","createElement","_extends","useNativeBufferSize","debounceMs","size","setSize","current","timer","next","clearTimeout","settle","previous","setTimeout"],"sourceRoot":"../../src","sources":["NativeBufferView.tsx"],"mappings":";AAAA,OAAOA,KAAK,IACVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,eAAe,EACfC,MAAM,EACNC,QAAQ,QACH,OAAO;AAGd,OAAOC,sBAAsB,MAAM,mCAAmC;;AAGtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;;AAmDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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"react-native";
2
+ // eslint-disable-next-line import/no-default-export
3
+ export default codegenNativeComponent("WebGPUNativeBufferView");
4
+ //# sourceMappingURL=NativeBufferViewNativeComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["codegenNativeComponent"],"sourceRoot":"../../src","sources":["NativeBufferViewNativeComponent.ts"],"mappings":"AAAA,SAASA,sBAAsB,QAAQ,cAAc;AAkBrD;AACA,eAAeA,sBAAsB,CAAc,wBAAwB,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["codegenNativeComponent"],"sourceRoot":"../../src","sources":["WebGPUViewNativeComponent.ts"],"mappings":"AAAA,SAASA,sBAAsB,QAAQ,cAAc;AAerD;AACA,eAAeA,sBAAsB,CAAc,YAAY,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["codegenNativeComponent"],"sourceRoot":"../../src","sources":["WebGPUViewNativeComponent.ts"],"mappings":"AAAA,SAASA,sBAAsB,QAAQ,cAAc;AAmBrD;AACA,eAAeA,sBAAsB,CAAc,YAAY,CAAC","ignoreList":[]}
@@ -10,6 +10,8 @@ export default function WebGPUViewNativeComponent(props) {
10
10
  androidOpaque: _androidOpaque,
11
11
  androidZOrderOnTop: _androidZOrderOnTop,
12
12
  androidZOrderMediaOverlay: _androidZOrderMediaOverlay,
13
+ appleDisplayP3: _appleDisplayP3,
14
+ appleExtendedDynamicRange: _appleExtendedDynamicRange,
13
15
  ...rest
14
16
  } = props;
15
17
 
@@ -1 +1 @@
1
- {"version":3,"names":["React","StyleSheet","contextIdToId","WebGPUViewNativeComponent","props","contextId","style","androidBackingView","_androidBackingView","androidOpaque","_androidOpaque","androidZOrderOnTop","_androidZOrderOnTop","androidZOrderMediaOverlay","_androidZOrderMediaOverlay","rest","createElement","id","styles","view","flex1","create","flex","alignItems","backgroundColor","border","boxSizing","display","flexBasis","flexDirection","flexShrink","listStyle","margin","minHeight","minWidth","padding","position","zIndex"],"sourceRoot":"../../src","sources":["WebGPUViewNativeComponent.web.ts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WebGPUViewNativeComponent","props","contextId","style","androidBackingView","_androidBackingView","androidOpaque","_androidOpaque","androidZOrderOnTop","_androidZOrderOnTop","androidZOrderMediaOverlay","_androidZOrderMediaOverlay","appleDisplayP3","_appleDisplayP3","appleExtendedDynamicRange","_appleExtendedDynamicRange","rest","createElement","id","styles","view","flex1","create","flex","alignItems","backgroundColor","border","boxSizing","display","flexBasis","flexDirection","flexShrink","listStyle","margin","minHeight","minWidth","padding","position","zIndex"],"sourceRoot":"../../src","sources":["WebGPUViewNativeComponent.web.ts"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,QAAQ,cAAc;AAGzC,SAASC,aAAa,QAAQ,SAAS;AAevC;AACA,eAAe,SAASC,yBAAyBA,CAC/CC,KAAkB,EACC;EACnB,MAAM;IACJC,SAAS;IACTC,KAAK;IACLC,kBAAkB,EAAEC,mBAAmB;IACvCC,aAAa,EAAEC,cAAc;IAC7BC,kBAAkB,EAAEC,mBAAmB;IACvCC,yBAAyB,EAAEC,0BAA0B;IACrDC,cAAc,EAAEC,eAAe;IAC/BC,yBAAyB,EAAEC,0BAA0B;IACrD,GAAGC;EACL,CAAC,GAAGf,KAAK;;EAET;EACA;EACA;EACA,oBAAOJ,KAAK,CAACoB,aAAa,CAAC,QAAQ,EAAE;IACnC,GAAGD,IAAI;IACPE,EAAE,EAAEnB,aAAa,CAACG,SAAS,CAAC;IAC5BC,KAAK,EAAE;MACL,GAAGgB,MAAM,CAACC,IAAI;MACd,GAAGD,MAAM,CAACE,KAAK;MACf,IAAI,OAAOlB,KAAK,KAAK,QAAQ,GAAGA,KAAK,GAAG,CAAC,CAAC;IAC5C;EACF,CAAC,CAAC;AACJ;AAEA,MAAMgB,MAAM,GAAGrB,UAAU,CAACwB,MAAM,CAAC;EAC/BD,KAAK,EAAE;IACLE,IAAI,EAAE;EACR,CAAC;EACDH,IAAI,EAAE;IACJI,UAAU,EAAE,SAAS;IACrBC,eAAe,EAAE,aAAa;IAC9B;IACA;IACAC,MAAM,EAAE,eAAe;IACvBC,SAAS,EAAE,YAAY;IACvBC,OAAO,EAAE,MAAM;IACfC,SAAS,EAAE,MAAM;IACjBC,aAAa,EAAE,QAAQ;IACvBC,UAAU,EAAE,CAAC;IACbC,SAAS,EAAE,MAAM;IACjBC,MAAM,EAAE,CAAC;IACTC,SAAS,EAAE,CAAC;IACZC,QAAQ,EAAE,CAAC;IACXC,OAAO,EAAE,CAAC;IACVC,QAAQ,EAAE,UAAU;IACpBC,MAAM,EAAE;EACV;AACF,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,83 @@
1
+ // The native animation frames (AnimationFramesHostObject in
2
+ // cpp/rnwgpu/AnimationFrames.h), installed on the main runtime. Read at module
3
+ // scope, like the helpers of `./install`, and captured into the worklets
4
+ // below: worklets hands a HostObject to every runtime by reference, and its
5
+ // methods act on the runtime that calls them. Undefined on web and node, where
6
+ // the browser's requestAnimationFrame is the one to use.
7
+ const frames = globalThis.__webgpuAnimationFrames;
8
+
9
+ /**
10
+ * `requestAnimationFrame`, paced by the display, on any runtime.
11
+ *
12
+ * Drop-in for the global one in a render loop:
13
+ *
14
+ * ```ts
15
+ * import { requestAnimationFrame } from "react-native-webgpu";
16
+ *
17
+ * const render = (timestamp: number) => {
18
+ * draw(timestamp);
19
+ * context.present();
20
+ * requestAnimationFrame(render);
21
+ * };
22
+ * requestAnimationFrame(render);
23
+ * ```
24
+ *
25
+ * React Native's global `requestAnimationFrame` is a timer: on Android it
26
+ * makes the next frame of the display only when it is requested before that
27
+ * frame starts, which leaves a loop that requests its next frame at the end
28
+ * of its work about 6 ms of a 120 Hz frame (past that, it drops to 60 fps),
29
+ * and on iOS it runs at 60 Hz. On a worklet runtime of your own
30
+ * (`createWorkletRuntime`), the global one polls every 16 ms (about 48 fps).
31
+ * This one follows the display wherever it is called:
32
+ *
33
+ * - On the React Native runtime, each frame of the display runs the callbacks
34
+ * requested before it, with the frame's time.
35
+ * - On a worklet runtime of your own, the runtime waits on its thread for the
36
+ * next frame of the display (the rest of the current frame at most), then
37
+ * runs them. Nothing else runs on the runtime during that wait.
38
+ * - On the Reanimated UI runtime, it is worklets' `requestAnimationFrame`,
39
+ * which is paced by the display already.
40
+ *
41
+ * Like a browser's, a callback requested while the frame's callbacks run gets
42
+ * the next frame, and every callback of a frame gets the same timestamp: the
43
+ * time the frame started, on the clock of `performance.now()`. The callbacks
44
+ * run once per frame of the display. A loop that overruns its frame runs
45
+ * again in the frame it overran into rather than waiting for the frame after.
46
+ * On the React Native runtime that run goes behind whatever waits there
47
+ * (React's updates, the app's other tasks), and the run after it waits for a
48
+ * frame of the display: the runtime is never the loop's alone.
49
+ *
50
+ * On the React Native runtime and on a worklet runtime of your own, no frame
51
+ * comes while the app is not in the foreground (the host activity is paused
52
+ * on Android, the app is not active on iOS): a loop stops with the app, and
53
+ * starts again when it is back.
54
+ *
55
+ * On iPhone, an app only gets more than 60 Hz with
56
+ * `CADisableMinimumFrameDurationOnPhone` set to true in its Info.plist. On
57
+ * macOS and on web, this is the runtime's own `requestAnimationFrame`.
58
+ */
59
+ export const requestAnimationFrame = callback => {
60
+ "worklet";
61
+
62
+ if (frames === undefined) {
63
+ return globalThis.requestAnimationFrame(callback);
64
+ }
65
+ return frames.request(callback);
66
+ };
67
+
68
+ /**
69
+ * Cancels a callback requested with this package's `requestAnimationFrame`,
70
+ * on the runtime it was requested on. Not interchangeable with the global
71
+ * `cancelAnimationFrame`: each cancels the handles of its own
72
+ * `requestAnimationFrame`.
73
+ */
74
+ export const cancelAnimationFrame = handle => {
75
+ "worklet";
76
+
77
+ if (frames === undefined) {
78
+ globalThis.cancelAnimationFrame(handle);
79
+ return;
80
+ }
81
+ frames.cancel(handle);
82
+ };
83
+ //# sourceMappingURL=animationFrame.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["frames","globalThis","__webgpuAnimationFrames","requestAnimationFrame","callback","undefined","request","cancelAnimationFrame","handle","cancel"],"sourceRoot":"../../src","sources":["animationFrame.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,MAAM,GAAGC,UAAU,CAACC,uBAAuB;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,GAChCC,QAAqC,IAC1B;EACX,SAAS;;EACT,IAAIJ,MAAM,KAAKK,SAAS,EAAE;IACxB,OAAOJ,UAAU,CAACE,qBAAqB,CAACC,QAAQ,CAAC;EACnD;EACA,OAAOJ,MAAM,CAACM,OAAO,CAACF,QAAQ,CAAC;AACjC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMG,oBAAoB,GAAIC,MAAc,IAAW;EAC5D,SAAS;;EACT,IAAIR,MAAM,KAAKK,SAAS,EAAE;IACxBJ,UAAU,CAACM,oBAAoB,CAACC,MAAM,CAAC;IACvC;EACF;EACAR,MAAM,CAACS,MAAM,CAACD,MAAM,CAAC;AACvB,CAAC","ignoreList":[]}
@@ -10,4 +10,5 @@ import "./main/installNative";
10
10
  export * from "./main";
11
11
  export * from "./constants";
12
12
  export { installWebGPU } from "./install";
13
+ export { requestAnimationFrame, cancelAnimationFrame } from "./animationFrame";
13
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["installWebGPU"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,sBAAsB;AAuB7B,cAAc,QAAQ;AACtB,cAAc,aAAa;AAC3B,SAASA,aAAa,QAAQ,WAAW","ignoreList":[]}
1
+ {"version":3,"names":["installWebGPU","requestAnimationFrame","cancelAnimationFrame"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,sBAAsB;AAqB7B,cAAc,QAAQ;AACtB,cAAc,aAAa;AAC3B,SAASA,aAAa,QAAQ,WAAW;AACzC,SAASC,qBAAqB,EAAEC,oBAAoB,QAAQ,kBAAkB","ignoreList":[]}
@@ -38,6 +38,7 @@ const installDrawElementImageToTexture = () => {
38
38
  };
39
39
  };
40
40
  export * from "../Canvas";
41
+ export * from "../NativeBufferView";
41
42
  export * from "../Offscreen";
42
43
  export * from "../WebGPUViewNativeComponent";
43
44
  export * from "../hooks";
@@ -1 +1 @@
1
- {"version":3,"names":["findNodeHandle","registerWebGPUForReanimated","resolveElementSource","source","instance","current","tag","undefined","Error","installDrawElementImageToTexture","GPUQueue","native","prototype","drawElementImageToTexture","destination","call","default","WebGPUModule","RNWebGPU","navigator","gpu","userAgent","global","createImageBitmap","bind"],"sourceRoot":"../../../src","sources":["main/index.tsx"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,OAAO,iBAAiB;AAExB,SAASA,cAAc,QAAQ,cAAc;AAE7C,SAASC,2BAA2B,QAAQ,aAAa;AAGzD;AACA;AACA;AACA;AACA,MAAMC,oBAAoB,GAAIC,MAAqC,IAAK;EACtE,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAE;IAC9B,OAAOA,MAAM;EACf;EACA,MAAMC,QAAQ,GACZD,MAAM,KAAK,IAAI,IAAI,OAAOA,MAAM,KAAK,QAAQ,IAAI,SAAS,IAAIA,MAAM,GAChEA,MAAM,CAACE,OAAO,GACdF,MAAM;EACZ;EACA,MAAMG,GAAG,GAAGF,QAAQ,IAAI,IAAI,GAAG,IAAI,GAAGJ,cAAc,CAACI,QAAe,CAAC;EACrE,IAAIE,GAAG,KAAK,IAAI,IAAIA,GAAG,KAAKC,SAAS,EAAE;IACrC,MAAM,IAAIC,KAAK,CACb,qEAAqE,GACnE,+DAA+D,GAC/D,s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I,CAACN,QAAQ,CAAC;EACvET,gCAAgC,CAAC,CAAC;AACpC","ignoreList":[]}
1
+ {"version":3,"names":["findNodeHandle","registerWebGPUForReanimated","resolveElementSource","source","instance","current","tag","undefined","Error","installDrawElementImageToTexture","GPUQueue","native","prototype","drawElementImageToTexture","destination","call","default","WebGPUModule","RNWebGPU","navigator","gpu","userAgent","global","createImageBitmap","bind"],"sourceRoot":"../../../src","sources":["main/index.tsx"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,OAAO,iBAAiB;AAExB,SAASA,cAAc,QAAQ,cAAc;AAE7C,SAASC,2BAA2B,QAAQ,aAAa;AAGzD;AACA;AACA;AACA;AACA,MAAMC,oBAAoB,GAAIC,MAAqC,IAAK;EACtE,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAE;IAC9B,OAAOA,MAAM;EACf;EACA,MAAMC,QAAQ,GACZD,MAAM,KAAK,IAAI,IAAI,OAAOA,MAAM,KAAK,QAAQ,IAAI,SAAS,IAAIA,MAAM,GAChEA,MAAM,CAACE,OAAO,GACdF,MAAM;EACZ;EACA,MAAMG,GAAG,GAAGF,QAAQ,IAAI,IAAI,GAAG,IAAI,GAAGJ,cAAc,CAACI,QAAe,CAAC;EACrE,IAAIE,GAAG,KAAK,IAAI,IAAIA,GAAG,KAAKC,SAAS,EAAE;IACrC,MAAM,IAAIC,KAAK,CACb,qEAAqE,GACnE,+DAA+D,GAC/D,sBACJ,CAAC;EACH;EACA,OAAOF,GAAG;AACZ,CAAC;AAED,MAAMG,gCAAgC,GAAGA,CAAA,KAAM;EAC7C,IAAI,OAAOC,QAAQ,KAAK,WAAW,EAAE;IACnC;EACF;EACA,MAAMC,MAAM,GAAGD,QAAQ,CAACE,SAAS,CAACC,yBAAyB;EAC3D,IAAI,OAAOF,MAAM,KAAK,UAAU,EAAE;IAChC;EACF;EACAD,QAAQ,CAACE,SAAS,CAACC,yBAAyB,GAAG,UAE7CV,MAAM,EACNW,WAAW,EACX;IACA,OAAOH,MAAM,CAACI,IAAI,CAChB,IAAI,EACJ;MAAE,GAAGZ,MAAM;MAAEA,MAAM,EAAED,oBAAoB,CAACC,MAAM,CAACA,MAAM;IAAE,CAAC,EAC1DW,WACF,CAAC;EACH,CAAC;AACH,CAAC;AAED,cAAc,WAAW;AACzB,cAAc,qBAAqB;AACnC,cAAc,cAAc;AAC5B,cAAc,8BAA8B;AAC5C,cAAc,UAAU;AACxB,cAAc,sBAAsB;AACpC,cAAc,iBAAiB;AAC/B,cAAc,UAAU;AACxB,cAAc,YAAY;AAE1B,SAASE,OAAO,IAAIC,YAAY,QAAQ,uBAAuB;AAE/DhB,2BAA2B,CAAC,CAAC;AAE7B,IAAI,OAAOiB,QAAQ,KAAK,WAAW,EAAE;EACnC,IAAI,CAACC,SAAS,EAAE;IACd;IACAA,SAAS,GAAG;MACVC,GAAG,EAAEF,QAAQ,CAACE,GAAG;MACjBC,SAAS,EAAE;IACb,CAAC;EACH,CAAC,MAAM;IACLF,SAAS,CAACC,GAAG,GAAGF,QAAQ,CAACE,GAAG;IAC5B,IAAI,OAAOD,SAAS,CAACE,SAAS,KAAK,QAAQ,EAAE;MAC3C,IAAI;QACF;QACA;QACAF,SAAS,CAACE,SAAS,GAAG,cAAc;MACtC,CAAC,CAAC,MAAM;QACN;MAAA;IAEJ;EACF;EACAC,MAAM,CAACC,iBAAiB,GACtBD,MAAM,CAACC,iBAAiB,IAAIL,QAAQ,CAACK,iBAAiB,CAACC,IAAI,CAACN,QAAQ,CAAC;EACvET,gCAAgC,CAAC,CAAC;AACpC","ignoreList":[]}
@@ -84,6 +84,25 @@ export const Canvas = ({
84
84
  }));
85
85
  return /*#__PURE__*/React.createElement(View, props);
86
86
  };
87
+ // Renders as a plain View; present() fails like the other GPU entry points.
88
+ export const NativeBufferView = ({
89
+ resizeMode: _resizeMode,
90
+ onPixelSizeChange: _onPixelSizeChange,
91
+ ref,
92
+ ...props
93
+ }) => {
94
+ React.useImperativeHandle(ref, () => ({
95
+ viewId: -1,
96
+ present: () => {
97
+ throw new Error(`NativeBufferView.present() ${NOT_AVAILABLE_UNDER_JEST}`);
98
+ }
99
+ }));
100
+ return /*#__PURE__*/React.createElement(View, props);
101
+ };
102
+ export const useNativeBufferSize = _debounceMs => ({
103
+ size: null,
104
+ onPixelSizeChange: () => undefined
105
+ });
87
106
  export const useCanvasRef = () => React.useRef(null);
88
107
  export const useSurface = () => ({
89
108
  ref: React.useRef(null),
@@ -107,6 +126,8 @@ export const adoptTexture = _pointer => {
107
126
  throw new Error(`adoptTexture() ${NOT_AVAILABLE_UNDER_JEST}`);
108
127
  };
109
128
  export const installWebGPU = () => undefined;
129
+ export const requestAnimationFrame = callback => globalThis.requestAnimationFrame(callback);
130
+ export const cancelAnimationFrame = handle => globalThis.cancelAnimationFrame(handle);
110
131
  export const WebGPUModule = {
111
132
  install: () => false
112
133
  };
@@ -1 +1 @@
1
- {"version":3,"names":["React","View","GPUBufferUsage","MAP_READ","MAP_WRITE","COPY_SRC","COPY_DST","INDEX","VERTEX","UNIFORM","STORAGE","INDIRECT","QUERY_RESOLVE","GPUTextureUsage","TEXTURE_BINDING","STORAGE_BINDING","RENDER_ATTACHMENT","TRANSIENT_ATTACHMENT","GPUShaderStage","FRAGMENT","COMPUTE","GPUColorWrite","RED","GREEN","BLUE","ALPHA","ALL","GPUMapMode","READ","WRITE","g","globalThis","key","value","Object","entries","undefined","NOT_AVAILABLE_UNDER_JEST","Canvas","android","_android","ref","props","useImperativeHandle","getContextId","getContext","_contextName","getNativeSurface","Error","createElement","useCanvasRef","useRef","useSurface","surface","warnIfNotHardwareAccelerated","useDevice","adapter","device","GPUDeviceProvider","children","useMainDevice","importDevice","_pointer","adoptTexture","installWebGPU","WebGPUModule","install"],"sourceRoot":"../../src","sources":["mock.ts"],"mappings":"AAAA;AACA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,IAAI,QAAQ,cAAc;AAInC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,cA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D,MAAM,IAAId,KAAK,CAAC,kBAAkBX,wBAAwB,EAAE,CAAC;AAC/D,CAAC;AAED,OAAO,MAAM2B,aAAa,GAAGA,CAAA,KAAM5B,SAAS;AAE5C,OAAO,MAAM6B,YAAY,GAAG;EAAEC,OAAO,EAAEA,CAAA,KAAM;AAAM,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","View","GPUBufferUsage","MAP_READ","MAP_WRITE","COPY_SRC","COPY_DST","INDEX","VERTEX","UNIFORM","STORAGE","INDIRECT","QUERY_RESOLVE","GPUTextureUsage","TEXTURE_BINDING","STORAGE_BINDING","RENDER_ATTACHMENT","TRANSIENT_ATTACHMENT","GPUShaderStage","FRAGMENT","COMPUTE","GPUColorWrite","RED","GREEN","BLUE","ALPHA","ALL","GPUMapMode","READ","WRITE","g","globalThis","key","value","Object","entries","undefined","NOT_AVAILABLE_UNDER_JEST","Canvas","android","_android","ref","props","useImperativeHandle","getContextId","getContext","_contextName","getNativeSurface","Error","createElement","NativeBufferView","resizeMode","_resizeMode","onPixelSizeChange","_onPixelSizeChange","viewId","present","useNativeBufferSize","_debounceMs","size","useCanvasRef","useRef","useSurface","surface","warnIfNotHardwareAccelerated","useDevice","adapter","device","GPUDeviceProvider","children","useMainDevice","importDevice","_pointer","adoptTexture","installWebGPU","requestAnimationFrame","callback","cancelAnimationFrame","handle","WebGPUModule","install"],"sourceRoot":"../../src","sources":["mock.ts"],"mappings":"AAAA;AACA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,IAAI,QAAQ,cAAc;AAKnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,cAAc,WAAW;;AAEzB;AACA;AACA;AACA;AACA,OAAO,MAAMC,cAA8B,GAAG;EAC5CC,QAAQ,EAAE,MAAM;EAChBC,SAAS,EAAE,MAAM;EACjBC,QAAQ,EAAE,MAAM;EAChBC,QAAQ,EAAE,MAAM;EAChBC,KAAK,EAAE,MAAM;EACbC,MAAM,EAAE,MAAM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GAAGA,CAAC;EAAEC;AAAmC,CAAC,KACtEA,QAAQ,IAAI,IAAI;AAElB,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAa;EACxC,MAAM,IAAItB,KAAK,CAAC,mBAAmBX,wBAAwB,EAAE,CAAC;AAChE,CAAC;AAED,OAAO,MAAMkC,YAAY,GAAIC,QAAgB,IAAgB;EAC3D,MAAM,IAAIxB,KAAK,CAAC,kBAAkBX,wBAAwB,EAAE,CAAC;AAC/D,CAAC;AAED,OAAO,MAAMoC,YAAY,GAAID,QAAgB,IAAiB;EAC5D,MAAM,IAAIxB,KAAK,CAAC,kBAAkBX,wBAAwB,EAAE,CAAC;AAC/D,CAAC;AAED,OAAO,MAAMqC,aAAa,GAAGA,CAAA,KAAMtC,SAAS;AAE5C,OAAO,MAAMuC,qBAAqB,GAAIC,QAAqC,IACzE7C,UAAU,CAAC4C,qBAAqB,CAACC,QAAQ,CAAC;AAE5C,OAAO,MAAMC,oBAAoB,GAAIC,MAAc,IACjD/C,UAAU,CAAC8C,oBAAoB,CAACC,MAAM,CAAC;AAEzC,OAAO,MAAMC,YAAY,GAAG;EAAEC,OAAO,EAAEA,CAAA,KAAM;AAAM,CAAC","ignoreList":[]}
@@ -35,10 +35,10 @@ export const createVideoPlayer = (source, options) => native("createVideoPlayer"
35
35
  /**
36
36
  * Wraps a native buffer produced by another library (a `CVPixelBufferRef` on
37
37
  * Apple platforms, an `AHardwareBuffer*` on Android, for instance
38
- * VisionCamera's `frame.getNativeBuffer().pointer`) into a `NativeVideoFrame`
38
+ * VisionCamera's `frame.getNativeBuffer().pointer`) into a `NativeBuffer`
39
39
  * that keeps it alive until released.
40
40
  */
41
- export const createVideoFrameFromNativeBuffer = pointer => native("createVideoFrameFromNativeBuffer").createVideoFrameFromNativeBuffer(pointer);
41
+ export const createNativeBufferFromPointer = pointer => native("createNativeBufferFromPointer").createNativeBufferFromPointer(pointer);
42
42
 
43
43
  /**
44
44
  * Allocates a native frame of the given size filled with a test pattern (a
@@ -46,4 +46,13 @@ export const createVideoFrameFromNativeBuffer = pointer => native("createVideoFr
46
46
  * and tests that need a frame without a camera or a video.
47
47
  */
48
48
  export const createTestVideoFrame = (width, height) => native("createTestVideoFrame").createTestVideoFrame(width, height);
49
+
50
+ /**
51
+ * Allocates an empty native buffer (an `AHardwareBuffer` on Android, an
52
+ * `IOSurface` on Apple platforms) that the GPU renders into and a
53
+ * `NativeBufferView` displays: import it with
54
+ * `device.importSharedTextureMemory({ source: frame })`, render into
55
+ * `memory.createTexture()` inside an access, then present it.
56
+ */
57
+ export const createNativeBuffer = (width, height, options) => native("createNativeBuffer").createNativeBuffer(width, height, options);
49
58
  //# sourceMappingURL=video.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["native","name","RNWebGPU","Error","createVideoPlayer","source","options","pixelFormat","createVideoFrameFromNativeBuffer","pointer","createTestVideoFrame","width","height"],"sourceRoot":"../../src","sources":["video.ts"],"mappings":"AAMA,MAAMA,MAAM,GAAIC,IAAY,IAAK;EAC/B,IAAI,OAAOC,QAAQ,KAAK,WAAW,EAAE;IACnC,MAAM,IAAIC,KAAK,CACb,kDAAkDF,IAAI,iBACxD,CAAC;EACH;EACA,OAAOC,QAAQ;AACjB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAME,iBAAiB,GAAGA,CAC/BC,MAAc,EACdC,OAAkC,KAElCN,MAAM,CAAC,mBAAmB,CAAC,CAACI,iBAAiB,CAACC,MAAM,EAAEC,OAAO,EAAEC,WAAW,CAAC;;AAE7E;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gCAAgC,GAC3CC,OAAe,IAEfT,MAAM,CAAC,kCAAkC,CAAC,CAACQ,gCAAgC,CACzEC,OACF,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,GAAGA,CAClCC,KAAa,EACbC,MAAc,KAEdZ,MAAM,CAAC,sBAAsB,CAAC,CAACU,oBAAoB,CAACC,KAAK,EAAEC,MAAM,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["native","name","RNWebGPU","Error","createVideoPlayer","source","options","pixelFormat","createNativeBufferFromPointer","pointer","createTestVideoFrame","width","height","createNativeBuffer"],"sourceRoot":"../../src","sources":["video.ts"],"mappings":"AAOA,MAAMA,MAAM,GAAIC,IAAY,IAAK;EAC/B,IAAI,OAAOC,QAAQ,KAAK,WAAW,EAAE;IACnC,MAAM,IAAIC,KAAK,CACb,kDAAkDF,IAAI,iBACxD,CAAC;EACH;EACA,OAAOC,QAAQ;AACjB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAME,iBAAiB,GAAGA,CAC/BC,MAAc,EACdC,OAAkC,KAElCN,MAAM,CAAC,mBAAmB,CAAC,CAACI,iBAAiB,CAACC,MAAM,EAAEC,OAAO,EAAEC,WAAW,CAAC;;AAE7E;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,6BAA6B,GAAIC,OAAe,IAC3DT,MAAM,CAAC,+BAA+B,CAAC,CAACQ,6BAA6B,CACnEC,OACF,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,GAAGA,CAClCC,KAAa,EACbC,MAAc,KAEdZ,MAAM,CAAC,sBAAsB,CAAC,CAACU,oBAAoB,CAACC,KAAK,EAAEC,MAAM,CAAC;;AAEpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,GAAGA,CAChCF,KAAa,EACbC,MAAc,EACdN,OAAmC,KAEnCN,MAAM,CAAC,oBAAoB,CAAC,CAACa,kBAAkB,CAACF,KAAK,EAAEC,MAAM,EAAEN,OAAO,CAAC","ignoreList":[]}
@@ -1,7 +1,9 @@
1
1
  export const __esModule: boolean;
2
- export function Canvas({ android, ref, ...props }: {
2
+ export function Canvas({ android, colorSpace, toneMapping, ref, ...props }: {
3
3
  [x: string]: any;
4
4
  android: any;
5
+ colorSpace: any;
6
+ toneMapping: any;
5
7
  ref: any;
6
8
  }): any;
7
9
  //# sourceMappingURL=Canvas.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../commonjs/Canvas.js"],"names":[],"mappings":";AAqJA;;;;QA8CC"}
1
+ {"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../commonjs/Canvas.js"],"names":[],"mappings":";AAkLA;;;;;;QAiDC"}
@@ -0,0 +1,48 @@
1
+ export const __esModule: boolean;
2
+ /**
3
+ * How a {@link NativeBufferView} fits a buffer whose size differs from its
4
+ * own (in physical pixels), for instance while the producer catches up with
5
+ * a resize. A buffer of exactly the view's size is shown 1:1 in every mode.
6
+ *
7
+ * - `stretch` (the default): scaled to the bounds, ignoring the aspect ratio.
8
+ * - `contain`: scaled to fit inside the bounds, keeping the aspect ratio.
9
+ * - `cover`: scaled to fill the bounds, keeping the aspect ratio; the excess
10
+ * is cropped.
11
+ * - `topLeft`: not scaled; anchored at the top left corner and cropped.
12
+ */
13
+ /** A size in physical pixels. */
14
+ /**
15
+ * Displays a native buffer (an `AHardwareBuffer` on Android, an `IOSurface`
16
+ * on Apple platforms) with no swap chain, no canvas context and no GPU device
17
+ * on the display side. Meant for content that is static or updated
18
+ * occasionally; animated content belongs in a `Canvas`.
19
+ *
20
+ * The view never allocates buffers. It reports its size in physical pixels
21
+ * ({@link NativeBufferViewProps.onPixelSizeChange}), and any producer
22
+ * (WebGPU, Skia, a camera, a decoder) renders into a buffer and presents it
23
+ * through the ref (frames from a camera or a decoder are copied first, see
24
+ * {@link NativeBufferViewRef.present}). With WebGPU:
25
+ *
26
+ * ```ts
27
+ * const frame = createNativeBuffer(size.width, size.height);
28
+ * const memory = device.importSharedTextureMemory({ source: frame });
29
+ * const texture = memory.createTexture();
30
+ * memory.beginAccess(texture, false);
31
+ * // ... render into texture and submit ...
32
+ * ref.current.present(frame, memory.endAccess(texture));
33
+ * texture.destroy();
34
+ * memory.destroy();
35
+ * frame.release();
36
+ * ```
37
+ */
38
+ export function NativeBufferView({ resizeMode, onPixelSizeChange, ref, ...props }: {
39
+ [x: string]: any;
40
+ resizeMode: any;
41
+ onPixelSizeChange: any;
42
+ ref: any;
43
+ }): any;
44
+ export function useNativeBufferSize(debounceMs?: number): {
45
+ size: any;
46
+ onPixelSizeChange: any;
47
+ };
48
+ //# sourceMappingURL=NativeBufferView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeBufferView.d.ts","sourceRoot":"","sources":["../../../commonjs/NativeBufferView.js"],"names":[],"mappings":";AAWA;;;;;;;;;;GAUG;AAEH,iCAAiC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH;;;;;QAqCC;AAUD;;;EAgCC"}
@@ -0,0 +1,5 @@
1
+ export const __esModule: boolean;
2
+ declare const _default: _reactNative.HostComponent<{}>;
3
+ export default _default;
4
+ import _reactNative = require("react-native");
5
+ //# sourceMappingURL=NativeBufferViewNativeComponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeBufferViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../commonjs/NativeBufferViewNativeComponent.js"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"WebGPUViewNativeComponent.web.d.ts","sourceRoot":"","sources":["../../../commonjs/WebGPUViewNativeComponent.web.js"],"names":[],"mappings":";;AAWA,4DAuBC"}
1
+ {"version":3,"file":"WebGPUViewNativeComponent.web.d.ts","sourceRoot":"","sources":["../../../commonjs/WebGPUViewNativeComponent.web.js"],"names":[],"mappings":";;AAWA,4DAyBC"}
@@ -0,0 +1,54 @@
1
+ export const __esModule: boolean;
2
+ /**
3
+ * `requestAnimationFrame`, paced by the display, on any runtime.
4
+ *
5
+ * Drop-in for the global one in a render loop:
6
+ *
7
+ * ```ts
8
+ * import { requestAnimationFrame } from "react-native-webgpu";
9
+ *
10
+ * const render = (timestamp: number) => {
11
+ * draw(timestamp);
12
+ * context.present();
13
+ * requestAnimationFrame(render);
14
+ * };
15
+ * requestAnimationFrame(render);
16
+ * ```
17
+ *
18
+ * React Native's global `requestAnimationFrame` is a timer: on Android it
19
+ * makes the next frame of the display only when it is requested before that
20
+ * frame starts, which leaves a loop that requests its next frame at the end
21
+ * of its work about 6 ms of a 120 Hz frame (past that, it drops to 60 fps),
22
+ * and on iOS it runs at 60 Hz. On a worklet runtime of your own
23
+ * (`createWorkletRuntime`), the global one polls every 16 ms (about 48 fps).
24
+ * This one follows the display wherever it is called:
25
+ *
26
+ * - On the React Native runtime, each frame of the display runs the callbacks
27
+ * requested before it, with the frame's time.
28
+ * - On a worklet runtime of your own, the runtime waits on its thread for the
29
+ * next frame of the display (the rest of the current frame at most), then
30
+ * runs them. Nothing else runs on the runtime during that wait.
31
+ * - On the Reanimated UI runtime, it is worklets' `requestAnimationFrame`,
32
+ * which is paced by the display already.
33
+ *
34
+ * Like a browser's, a callback requested while the frame's callbacks run gets
35
+ * the next frame, and every callback of a frame gets the same timestamp: the
36
+ * time the frame started, on the clock of `performance.now()`. The callbacks
37
+ * run once per frame of the display. A loop that overruns its frame runs
38
+ * again in the frame it overran into rather than waiting for the frame after.
39
+ * On the React Native runtime that run goes behind whatever waits there
40
+ * (React's updates, the app's other tasks), and the run after it waits for a
41
+ * frame of the display: the runtime is never the loop's alone.
42
+ *
43
+ * On the React Native runtime and on a worklet runtime of your own, no frame
44
+ * comes while the app is not in the foreground (the host activity is paused
45
+ * on Android, the app is not active on iOS): a loop stops with the app, and
46
+ * starts again when it is back.
47
+ *
48
+ * On iPhone, an app only gets more than 60 Hz with
49
+ * `CADisableMinimumFrameDurationOnPhone` set to true in its Info.plist. On
50
+ * macOS and on web, this is the runtime's own `requestAnimationFrame`.
51
+ */
52
+ export function requestAnimationFrame(callback: any): number;
53
+ export function cancelAnimationFrame(handle: any): void;
54
+ //# sourceMappingURL=animationFrame.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animationFrame.d.ts","sourceRoot":"","sources":["../../../commonjs/animationFrame.js"],"names":[],"mappings":";AAcA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,6DAOC;AASD,wDAQC"}
@@ -1,3 +1,5 @@
1
1
  export const __esModule: boolean;
2
+ export const cancelAnimationFrame: (handle: any) => void;
2
3
  export const installWebGPU: () => void;
4
+ export const requestAnimationFrame: (callback: any) => number;
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -46,6 +46,16 @@ export function Canvas({ android: _android, ref, ...props }: {
46
46
  android: any;
47
47
  ref: any;
48
48
  }): any;
49
+ export function NativeBufferView({ resizeMode: _resizeMode, onPixelSizeChange: _onPixelSizeChange, ref, ...props }: {
50
+ [x: string]: any;
51
+ resizeMode: any;
52
+ onPixelSizeChange: any;
53
+ ref: any;
54
+ }): any;
55
+ export function useNativeBufferSize(_debounceMs: any): {
56
+ size: null;
57
+ onPixelSizeChange: () => undefined;
58
+ };
49
59
  export function useCanvasRef(): any;
50
60
  export function useSurface(): {
51
61
  ref: any;
@@ -63,4 +73,6 @@ export function useMainDevice(): never;
63
73
  export function importDevice(_pointer: any): never;
64
74
  export function adoptTexture(_pointer: any): never;
65
75
  export function installWebGPU(): undefined;
76
+ export function requestAnimationFrame(callback: any): number;
77
+ export function cancelAnimationFrame(handle: any): void;
66
78
  //# sourceMappingURL=mock.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../commonjs/mock.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA4JW,4BAAW;;AAhDtB;;;;QAaC;AAED,oCAAsD;AAEtD;;;EAGE;AAEF,0DAAoD;AAEpD;;;EAGE;AAEF;;QAEsB;AAEtB,uCAEC;AAED,mDAEC;AAED,mDAEC;AAED,2CAAqC"}
1
+ {"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../commonjs/mock.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAyLW,4BAAW;;AAzEtB;;;;QAaC;AAGD;;;;;QAaC;AAED;;;EAGE;AAEF,oCAAsD;AAEtD;;;EAGE;AAEF,0DAAoD;AAEpD;;;EAGE;AAEF;;QAEsB;AAEtB,uCAEC;AAED,mDAEC;AAED,mDAEC;AAED,2CAAqC;AAErC,6DAAoF;AAEpF,wDAA8E"}
@@ -25,6 +25,7 @@ export const __esModule: boolean;
25
25
  * native YUV layout, for `importExternalTexture()`.
26
26
  */
27
27
  export function createVideoPlayer(source: any, options: any): import("../../src").VideoPlayer;
28
- export function createVideoFrameFromNativeBuffer(pointer: any): import("../../src").NativeVideoFrame;
29
- export function createTestVideoFrame(width: any, height: any): import("../../src").NativeVideoFrame;
28
+ export function createNativeBufferFromPointer(pointer: any): import("../../src").NativeBuffer;
29
+ export function createTestVideoFrame(width: any, height: any): import("../../src").NativeBuffer;
30
+ export function createNativeBuffer(width: any, height: any, options: any): import("../../src").NativeBuffer;
30
31
  //# sourceMappingURL=video.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"video.d.ts","sourceRoot":"","sources":["../../../commonjs/video.js"],"names":[],"mappings":";AAaA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,8FAA0H;AAS1H,qGAAwI;AAQxI,oGAAkH"}
1
+ {"version":3,"file":"video.d.ts","sourceRoot":"","sources":["../../../commonjs/video.js"],"names":[],"mappings":";AAaA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,8FAA0H;AAS1H,8FAA+H;AAQ/H,gGAAkH;AAUlH,4GAA8H"}
@@ -1,6 +1,8 @@
1
- export function Canvas({ android, ref, ...props }: {
1
+ export function Canvas({ android, colorSpace, toneMapping, ref, ...props }: {
2
2
  [x: string]: any;
3
3
  android: any;
4
+ colorSpace: any;
5
+ toneMapping: any;
4
6
  ref: any;
5
7
  }): React.FunctionComponentElement<Omit<import("react-native").ViewProps, "ref"> & {
6
8
  ref?: React.Ref<import("react-native").ViewInstance> | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../module/Canvas.js"],"names":[],"mappings":"AA6IO;;;;;;GA8CN;kBA1LuE,OAAO"}
1
+ {"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../module/Canvas.js"],"names":[],"mappings":"AA0KO;;;;;;;;GAiDN;kBA1NuE,OAAO"}
@@ -0,0 +1,14 @@
1
+ export function NativeBufferView({ resizeMode, onPixelSizeChange, ref, ...props }: {
2
+ [x: string]: any;
3
+ resizeMode: any;
4
+ onPixelSizeChange: any;
5
+ ref: any;
6
+ }): React.FunctionComponentElement<Omit<{}, "ref"> & {
7
+ ref?: React.Ref<import("react-native").HostInstance> | undefined;
8
+ }>;
9
+ export function useNativeBufferSize(debounceMs?: number): {
10
+ size: null;
11
+ onPixelSizeChange: (next: any) => void;
12
+ };
13
+ import React from "react";
14
+ //# sourceMappingURL=NativeBufferView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeBufferView.d.ts","sourceRoot":"","sources":["../../../module/NativeBufferView.js"],"names":[],"mappings":"AA0CO;;;;;;;GAqCN;AASM;;;EAgCN;kBAvHqG,OAAO"}
@@ -0,0 +1,3 @@
1
+ declare const _default: import("react-native").HostComponent<{}>;
2
+ export default _default;
3
+ //# sourceMappingURL=NativeBufferViewNativeComponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeBufferViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../module/NativeBufferViewNativeComponent.js"],"names":[],"mappings":""}