react-native-webgpu 0.24.0 → 0.25.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.
- package/android/CMakeLists.txt +1 -0
- package/android/cpp/cpp-adapter.cpp +19 -96
- package/android/src/main/java/com/webgpu/BackingViewKind.java +5 -22
- package/android/src/main/java/com/webgpu/WebGPUAPI.java +0 -2
- package/android/src/main/java/com/webgpu/WebGPUModule.java +31 -0
- package/android/src/main/java/com/webgpu/WebGPUView.java +17 -34
- package/apple/WebGPUModule.mm +22 -0
- package/cpp/rnwgpu/GpuPurge.cpp +86 -0
- package/cpp/rnwgpu/GpuPurge.h +66 -0
- package/cpp/rnwgpu/SurfaceRegistry.h +0 -610
- package/cpp/rnwgpu/api/GPUDevice.cpp +59 -32
- package/cpp/rnwgpu/api/GPUDevice.h +49 -4
- package/cpp/rnwgpu/api/RNWebGPU.h +6 -0
- package/lib/commonjs/Canvas.js +8 -26
- package/lib/commonjs/Canvas.js.map +1 -1
- package/lib/commonjs/main/index.js +12 -0
- package/lib/commonjs/main/index.js.map +1 -1
- package/lib/commonjs/main/index.web.js +11 -0
- package/lib/commonjs/main/index.web.js.map +1 -1
- package/lib/commonjs/mock.js +4 -1
- package/lib/commonjs/mock.js.map +1 -1
- package/lib/commonjs/purgeGpuResources.js +29 -0
- package/lib/commonjs/purgeGpuResources.js.map +1 -0
- package/lib/module/Canvas.js +8 -26
- package/lib/module/Canvas.js.map +1 -1
- package/lib/module/main/index.js +1 -0
- package/lib/module/main/index.js.map +1 -1
- package/lib/module/main/index.web.js +1 -0
- package/lib/module/main/index.web.js.map +1 -1
- package/lib/module/mock.js +1 -0
- package/lib/module/mock.js.map +1 -1
- package/lib/module/purgeGpuResources.js +22 -0
- package/lib/module/purgeGpuResources.js.map +1 -0
- package/lib/typescript/lib/commonjs/Canvas.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/mock.d.ts +1 -0
- package/lib/typescript/lib/commonjs/mock.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/purgeGpuResources.d.ts +18 -0
- package/lib/typescript/lib/commonjs/purgeGpuResources.d.ts.map +1 -0
- package/lib/typescript/lib/module/Canvas.d.ts.map +1 -1
- package/lib/typescript/lib/module/main/index.d.ts +1 -0
- package/lib/typescript/lib/module/main/index.web.d.ts +1 -0
- package/lib/typescript/lib/module/mock.d.ts +1 -0
- package/lib/typescript/lib/module/mock.d.ts.map +1 -1
- package/lib/typescript/lib/module/purgeGpuResources.d.ts +2 -0
- package/lib/typescript/lib/module/purgeGpuResources.d.ts.map +1 -0
- package/lib/typescript/src/Canvas.d.ts +2 -12
- package/lib/typescript/src/Canvas.d.ts.map +1 -1
- package/lib/typescript/src/WebGPUViewNativeComponent.d.ts +1 -1
- package/lib/typescript/src/WebGPUViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/WebGPUViewNativeComponent.web.d.ts +1 -1
- package/lib/typescript/src/WebGPUViewNativeComponent.web.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/main/index.d.ts +1 -0
- package/lib/typescript/src/main/index.d.ts.map +1 -1
- package/lib/typescript/src/main/index.web.d.ts +1 -0
- package/lib/typescript/src/main/index.web.d.ts.map +1 -1
- package/lib/typescript/src/mock.d.ts +2 -1
- package/lib/typescript/src/mock.d.ts.map +1 -1
- package/lib/typescript/src/purgeGpuResources.d.ts +17 -0
- package/lib/typescript/src/purgeGpuResources.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/Canvas.tsx +12 -50
- package/src/WebGPUViewNativeComponent.ts +1 -1
- package/src/WebGPUViewNativeComponent.web.ts +1 -1
- package/src/index.tsx +1 -0
- package/src/main/index.tsx +1 -0
- package/src/main/index.web.tsx +1 -0
- package/src/mock.ts +2 -1
- package/src/purgeGpuResources.ts +21 -0
- package/android/src/main/java/com/webgpu/WebGPUHardwareBufferView.java +0 -278
|
@@ -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,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":[]}
|
|
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,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,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":[]}
|
|
@@ -5,6 +5,7 @@ export * from "../WebGPUViewNativeComponent";
|
|
|
5
5
|
export * from "../hooks";
|
|
6
6
|
export * from "../GPUDeviceProvider";
|
|
7
7
|
export * from "../formats";
|
|
8
|
+
export * from "../purgeGpuResources";
|
|
8
9
|
export * from "../video";
|
|
9
10
|
|
|
10
11
|
// We don't need to set all global properties on web, webgpu is already available globally
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["main/index.web.tsx"],"mappings":"AAAA,OAAO,iBAAiB;AAExB,cAAc,WAAW;AACzB,cAAc,cAAc;AAC5B,cAAc,8BAA8B;AAC5C,cAAc,UAAU;AACxB,cAAc,sBAAsB;AACpC,cAAc,YAAY;AAC1B,cAAc,UAAU;;AAExB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["main/index.web.tsx"],"mappings":"AAAA,OAAO,iBAAiB;AAExB,cAAc,WAAW;AACzB,cAAc,cAAc;AAC5B,cAAc,8BAA8B;AAC5C,cAAc,UAAU;AACxB,cAAc,sBAAsB;AACpC,cAAc,YAAY;AAC1B,cAAc,sBAAsB;AACpC,cAAc,UAAU;;AAExB","ignoreList":[]}
|
package/lib/module/mock.js
CHANGED
|
@@ -119,6 +119,7 @@ export const GPUDeviceProvider = ({
|
|
|
119
119
|
export const useMainDevice = () => {
|
|
120
120
|
throw new Error(`useMainDevice() ${NOT_AVAILABLE_UNDER_JEST}`);
|
|
121
121
|
};
|
|
122
|
+
export const purgeGpuResources = () => undefined;
|
|
122
123
|
export const importDevice = _pointer => {
|
|
123
124
|
throw new Error(`importDevice() ${NOT_AVAILABLE_UNDER_JEST}`);
|
|
124
125
|
};
|
package/lib/module/mock.js.map
CHANGED
|
@@ -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","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,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C,KAAK;IAChB;EACF;AACF;AAEA,MAAMI,wBAAwB,GAC5B,gIAAgI;
|
|
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","purgeGpuResources","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;EACdC,OAAO,EAAE,MAAM;EACfC,OAAO,EAAE,MAAM;EACfC,QAAQ,EAAE,MAAM;EAChBC,aAAa,EAAE;AACjB,CAAC;AAED,OAAO,MAAMC,eAAgC,G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AC,mBAAmBX,wBAAwB,EAAE,CAAC;AAChE,CAAC;AAED,OAAO,MAAMkC,iBAAiB,GAAGA,CAAA,KAAMnC,SAAS;AAEhD,OAAO,MAAMoC,YAAY,GAAIC,QAAgB,IAAgB;EAC3D,MAAM,IAAIzB,KAAK,CAAC,kBAAkBX,wBAAwB,EAAE,CAAC;AAC/D,CAAC;AAED,OAAO,MAAMqC,YAAY,GAAID,QAAgB,IAAiB;EAC5D,MAAM,IAAIzB,KAAK,CAAC,kBAAkBX,wBAAwB,EAAE,CAAC;AAC/D,CAAC;AAED,OAAO,MAAMsC,aAAa,GAAGA,CAAA,KAAMvC,SAAS;AAE5C,OAAO,MAAMwC,qBAAqB,GAAIC,QAAqC,IACzE9C,UAAU,CAAC6C,qBAAqB,CAACC,QAAQ,CAAC;AAE5C,OAAO,MAAMC,oBAAoB,GAAIC,MAAc,IACjDhD,UAAU,CAAC+C,oBAAoB,CAACC,MAAM,CAAC;AAEzC,OAAO,MAAMC,YAAY,GAAG;EAAEC,OAAO,EAAEA,CAAA,KAAM;AAAM,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the GPU memory nothing uses to the system. Most apps should never
|
|
3
|
+
* call it: `destroy()` lets Dawn reuse the memory, and react-native-webgpu
|
|
4
|
+
* purges on its own when the system is short of memory and, on Android, each
|
|
5
|
+
* time the app goes to the background.
|
|
6
|
+
*
|
|
7
|
+
* It is meant for a one-off peak (a video export) followed by a long stretch
|
|
8
|
+
* that needs far less GPU memory. Not for a render loop, not after each
|
|
9
|
+
* `destroy()`, not on unmount: memory Dawn would have reused has to be
|
|
10
|
+
* requested from the system again. It does not free what was not destroyed.
|
|
11
|
+
*
|
|
12
|
+
* It returns right away and works in the background. It covers every device
|
|
13
|
+
* created through react-native-webgpu; an imported device is purged by its
|
|
14
|
+
* owner. Not part of the WebGPU spec, and does nothing on the Web.
|
|
15
|
+
*/
|
|
16
|
+
export const purgeGpuResources = () => {
|
|
17
|
+
if (typeof RNWebGPU === "undefined") {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
RNWebGPU.purgeGpuResources();
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=purgeGpuResources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["purgeGpuResources","RNWebGPU"],"sourceRoot":"../../src","sources":["purgeGpuResources.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,iBAAiB,GAAGA,CAAA,KAAY;EAC3C,IAAI,OAAOC,QAAQ,KAAK,WAAW,EAAE;IACnC;EACF;EACAA,QAAQ,CAACD,iBAAiB,CAAC,CAAC;AAC9B,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../commonjs/Canvas.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../commonjs/Canvas.js"],"names":[],"mappings":";AAgKA;;;;;;QAiDC"}
|
|
@@ -70,6 +70,7 @@ export function GPUDeviceProvider({ children }: {
|
|
|
70
70
|
children: any;
|
|
71
71
|
}): any;
|
|
72
72
|
export function useMainDevice(): never;
|
|
73
|
+
export function purgeGpuResources(): undefined;
|
|
73
74
|
export function importDevice(_pointer: any): never;
|
|
74
75
|
export function adoptTexture(_pointer: any): never;
|
|
75
76
|
export function installWebGPU(): undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../commonjs/mock.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../commonjs/mock.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA4LW,4BAAW;;AA3EtB;;;;QAaC;AAGD;;;;;QAaC;AAED;;;EAGE;AAEF,oCAAsD;AAEtD;;;EAGE;AAEF,0DAAoD;AAEpD;;;EAGE;AAEF;;QAEsB;AAEtB,uCAEC;AAED,+CAAyC;AAEzC,mDAEC;AAED,mDAEC;AAED,2CAAqC;AAErC,6DAAoF;AAEpF,wDAA8E"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const __esModule: boolean;
|
|
2
|
+
/**
|
|
3
|
+
* Returns the GPU memory nothing uses to the system. Most apps should never
|
|
4
|
+
* call it: `destroy()` lets Dawn reuse the memory, and react-native-webgpu
|
|
5
|
+
* purges on its own when the system is short of memory and, on Android, each
|
|
6
|
+
* time the app goes to the background.
|
|
7
|
+
*
|
|
8
|
+
* It is meant for a one-off peak (a video export) followed by a long stretch
|
|
9
|
+
* that needs far less GPU memory. Not for a render loop, not after each
|
|
10
|
+
* `destroy()`, not on unmount: memory Dawn would have reused has to be
|
|
11
|
+
* requested from the system again. It does not free what was not destroyed.
|
|
12
|
+
*
|
|
13
|
+
* It returns right away and works in the background. It covers every device
|
|
14
|
+
* created through react-native-webgpu; an imported device is purged by its
|
|
15
|
+
* owner. Not part of the WebGPU spec, and does nothing on the Web.
|
|
16
|
+
*/
|
|
17
|
+
export function purgeGpuResources(): void;
|
|
18
|
+
//# sourceMappingURL=purgeGpuResources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"purgeGpuResources.d.ts","sourceRoot":"","sources":["../../../commonjs/purgeGpuResources.js"],"names":[],"mappings":";AAMA;;;;;;;;;;;;;;GAcG;AACH,0CAKC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../module/Canvas.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../module/Canvas.js"],"names":[],"mappings":"AAwJO;;;;;;;;GAiDN;kBAxMuE,OAAO"}
|
|
@@ -5,6 +5,7 @@ export * from "../WebGPUViewNativeComponent";
|
|
|
5
5
|
export * from "../hooks";
|
|
6
6
|
export * from "../GPUDeviceProvider";
|
|
7
7
|
export * from "../importDevice";
|
|
8
|
+
export * from "../purgeGpuResources";
|
|
8
9
|
export * from "../video";
|
|
9
10
|
export * from "../formats";
|
|
10
11
|
export { default as WebGPUModule } from "../NativeWebGPUModule";
|
|
@@ -71,6 +71,7 @@ export function GPUDeviceProvider({ children }: {
|
|
|
71
71
|
children: any;
|
|
72
72
|
}): any;
|
|
73
73
|
export function useMainDevice(): never;
|
|
74
|
+
export function purgeGpuResources(): undefined;
|
|
74
75
|
export function importDevice(_pointer: any): never;
|
|
75
76
|
export function adoptTexture(_pointer: any): never;
|
|
76
77
|
export function installWebGPU(): undefined;
|
|
@@ -1 +1 @@
|
|
|
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;;
|
|
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,+CAAyC;AACzC,mDAEN;AACM,mDAEN;AACM,2CAAqC;AACrC,6DAAoF;AACpF,wDAA8E;;IAE1E,4BAAW;;kBAnIJ,OAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"purgeGpuResources.d.ts","sourceRoot":"","sources":["../../../module/purgeGpuResources.js"],"names":[],"mappings":"AAeO,0CAKN"}
|
|
@@ -3,7 +3,7 @@ import type { ViewProps } from "react-native";
|
|
|
3
3
|
import type { CanvasRef } from "./types";
|
|
4
4
|
export type { CanvasRef, NativeCanvas, RNCanvasContext } from "./types";
|
|
5
5
|
/** The Android view a canvas draws into, see {@link AndroidCanvasProps}. */
|
|
6
|
-
export type AndroidBackingView = "TextureView" | "SurfaceView"
|
|
6
|
+
export type AndroidBackingView = "TextureView" | "SurfaceView";
|
|
7
7
|
/** The options of a canvas backed by a `TextureView`, the default. */
|
|
8
8
|
export interface AndroidTextureViewProps {
|
|
9
9
|
/**
|
|
@@ -49,16 +49,6 @@ export interface AndroidSurfaceViewProps {
|
|
|
49
49
|
*/
|
|
50
50
|
zOrderMediaOverlay?: boolean;
|
|
51
51
|
}
|
|
52
|
-
/** The options of a canvas backed by a `HardwareBufferView`. */
|
|
53
|
-
export interface AndroidHardwareBufferViewProps {
|
|
54
|
-
/**
|
|
55
|
-
* A plain view drawing each frame's `AHardwareBuffer` inline: composited
|
|
56
|
-
* like a `TextureView`, without its extra copy. Opt-in and experimental,
|
|
57
|
-
* on Android 10 and later; below that the canvas uses a `TextureView`,
|
|
58
|
-
* with a warning in development. Always composites with alpha.
|
|
59
|
-
*/
|
|
60
|
-
backingView: "HardwareBufferView";
|
|
61
|
-
}
|
|
62
52
|
/**
|
|
63
53
|
* Android-only rendering options: the native view behind the canvas and its
|
|
64
54
|
* options. The view is created when the canvas mounts and kept: a change of
|
|
@@ -66,7 +56,7 @@ export interface AndroidHardwareBufferViewProps {
|
|
|
66
56
|
* (with a `key`) to change it. `opaque` applies in place, and so do the
|
|
67
57
|
* z-order options on Android 11 and later. Ignored on iOS and web.
|
|
68
58
|
*/
|
|
69
|
-
export type AndroidCanvasProps = AndroidTextureViewProps | AndroidSurfaceViewProps
|
|
59
|
+
export type AndroidCanvasProps = AndroidTextureViewProps | AndroidSurfaceViewProps;
|
|
70
60
|
export interface CanvasProps extends ViewProps {
|
|
71
61
|
/**
|
|
72
62
|
* Android-only rendering options: the native view behind the canvas and its
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../src/Canvas.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAChF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAG9C,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,SAAS,CAAC;AAG1D,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAMxE,4EAA4E;AAC5E,MAAM,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../src/Canvas.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAChF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAG9C,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,SAAS,CAAC;AAG1D,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAMxE,4EAA4E;AAC5E,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG,aAAa,CAAC;AAE/D,sEAAsE;AACtE,MAAM,WAAW,uBAAuB;IACtC;;;;OAIG;IACH,WAAW,CAAC,EAAE,aAAa,CAAC;IAC5B;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,yDAAyD;AACzD,MAAM,WAAW,uBAAuB;IACtC;;;;;OAKG;IACH,WAAW,EAAE,aAAa,CAAC;IAC3B;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAC5B,uBAAuB,GAAG,uBAAuB,CAAC;AAEpD,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C;;;OAGG;IACH,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAClC;;;;OAIG;IACH,WAAW,CAAC,EAAE,oBAAoB,CAAC;IACnC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;CAC5B;AAoJD,eAAO,MAAM,MAAM,GAAI,qDAMpB,WAAW,sBAqDb,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CodegenTypes, ViewProps } from "react-native";
|
|
2
2
|
export interface NativeProps extends ViewProps {
|
|
3
3
|
contextId: CodegenTypes.Int32;
|
|
4
|
-
androidBackingView?: CodegenTypes.WithDefault<"TextureView" | "SurfaceView"
|
|
4
|
+
androidBackingView?: CodegenTypes.WithDefault<"TextureView" | "SurfaceView", "TextureView">;
|
|
5
5
|
androidOpaque?: CodegenTypes.WithDefault<boolean, false>;
|
|
6
6
|
androidZOrderOnTop?: CodegenTypes.WithDefault<boolean, false>;
|
|
7
7
|
androidZOrderMediaOverlay?: CodegenTypes.WithDefault<boolean, false>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebGPUViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/WebGPUViewNativeComponent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE5D,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,SAAS,EAAE,YAAY,CAAC,KAAK,CAAC;IAE9B,kBAAkB,CAAC,EAAE,YAAY,CAAC,WAAW,CAC3C,aAAa,GAAG,aAAa,
|
|
1
|
+
{"version":3,"file":"WebGPUViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/WebGPUViewNativeComponent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE5D,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,SAAS,EAAE,YAAY,CAAC,KAAK,CAAC;IAE9B,kBAAkB,CAAC,EAAE,YAAY,CAAC,WAAW,CAC3C,aAAa,GAAG,aAAa,EAC7B,aAAa,CACd,CAAC;IACF,aAAa,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACzD,kBAAkB,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC9D,yBAAyB,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAGrE,cAAc,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC1D,yBAAyB,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;CACtE;;AAGD,wBAAiE"}
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import type { CodegenTypes, ViewProps } from "react-native";
|
|
3
3
|
export interface NativeProps extends ViewProps {
|
|
4
4
|
contextId: CodegenTypes.Int32;
|
|
5
|
-
androidBackingView?: "TextureView" | "SurfaceView"
|
|
5
|
+
androidBackingView?: "TextureView" | "SurfaceView";
|
|
6
6
|
androidOpaque?: boolean;
|
|
7
7
|
androidZOrderOnTop?: boolean;
|
|
8
8
|
androidZOrderMediaOverlay?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebGPUViewNativeComponent.web.d.ts","sourceRoot":"","sources":["../../../src/WebGPUViewNativeComponent.web.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAI5D,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,SAAS,EAAE,YAAY,CAAC,KAAK,CAAC;IAE9B,kBAAkB,CAAC,EAAE,aAAa,GAAG,aAAa,
|
|
1
|
+
{"version":3,"file":"WebGPUViewNativeComponent.web.d.ts","sourceRoot":"","sources":["../../../src/WebGPUViewNativeComponent.web.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAI5D,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,SAAS,EAAE,YAAY,CAAC,KAAK,CAAC;IAE9B,kBAAkB,CAAC,EAAE,aAAa,GAAG,aAAa,CAAC;IACnD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,yBAAyB,CAAC,EAAE,OAAO,CAAC;IAGpC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC;AAGD,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,KAAK,EAAE,WAAW,GACjB,KAAK,CAAC,GAAG,CAAC,OAAO,CAyBnB"}
|
|
@@ -28,6 +28,7 @@ declare global {
|
|
|
28
28
|
createTestVideoFrame: (width: number, height: number, pixelFormat?: NativeBufferPixelFormat) => NativeBuffer;
|
|
29
29
|
createNativeBufferFromPointer: (pointer: bigint) => NativeBuffer;
|
|
30
30
|
importDevice: (pointer: bigint) => GPUDevice;
|
|
31
|
+
purgeGpuResources: () => void;
|
|
31
32
|
adoptTexture: (pointer: bigint) => GPUTexture;
|
|
32
33
|
createTestVideoPlayer: (source: string, pixelFormat?: NativeBufferPixelFormat) => VideoPlayer;
|
|
33
34
|
writeTestVideoFile: () => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAQA,OAAO,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EACV,8BAA8B,EAC9B,yBAAyB,EACzB,cAAc,EACd,wBAAwB,EACxB,mBAAmB,EACnB,yBAAyB,EACzB,wBAAwB,EACxB,kCAAkC,EAClC,sBAAsB,EACtB,gCAAgC,EAChC,oCAAoC,EACpC,YAAY,EACZ,eAAe,EACf,WAAW,EACX,YAAY,EACZ,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAEjB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC/E,YAAY,EACV,YAAY,EACZ,WAAW,EACX,cAAc,EACd,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,gCAAgC,EAChC,oCAAoC,EACpC,uBAAuB,EACvB,4BAA4B,EAC5B,oCAAoC,EACpC,wBAAwB,EACxB,kCAAkC,EAClC,sBAAsB,EACtB,WAAW,EACX,8BAA8B,EAC9B,yBAAyB,EACzB,6BAA6B,EAC7B,yBAAyB,GAC1B,MAAM,SAAS,CAAC;AAEjB,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,SAAS;QACjB,GAAG,EAAE,GAAG,CAAC;KACV;IAED,IAAI,SAAS,EAAE,SAAS,CAAC;IAGzB,IAAI,uBAAuB,EACvB;QACE,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,KAAK,MAAM,CAAC;QAC3D,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;KAClC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UAAU;QAIlB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;KAChC;IAED,UAAU,SAAS;QAKjB,qBAAqB,CACnB,UAAU,EAAE,kCAAkC,GAC7C,kBAAkB,CAAC;QACtB,yBAAyB,CACvB,UAAU,EAAE,gCAAgC,GAC3C,sBAAsB,CAAC;QAC1B,iBAAiB,CAAC,UAAU,EAAE,wBAAwB,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"}
|
|
@@ -6,6 +6,7 @@ export * from "../WebGPUViewNativeComponent";
|
|
|
6
6
|
export * from "../hooks";
|
|
7
7
|
export * from "../GPUDeviceProvider";
|
|
8
8
|
export * from "../importDevice";
|
|
9
|
+
export * from "../purgeGpuResources";
|
|
9
10
|
export * from "../video";
|
|
10
11
|
export * from "../formats";
|
|
11
12
|
export { default as WebGPUModule } from "../NativeWebGPUModule";
|
|
@@ -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,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
|
+
{"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,sBAAsB,CAAC;AACrC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../src/main/index.web.tsx"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,CAAC;AAEzB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,UAAU,CAAC;AACzB,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../src/main/index.web.tsx"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,CAAC;AAEzB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,UAAU,CAAC;AACzB,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,UAAU,CAAC"}
|
|
@@ -8,7 +8,7 @@ export declare const GPUTextureUsage: GPUTextureUsage;
|
|
|
8
8
|
export declare const GPUShaderStage: GPUShaderStage;
|
|
9
9
|
export declare const GPUColorWrite: GPUColorWrite;
|
|
10
10
|
export declare const GPUMapMode: GPUMapMode;
|
|
11
|
-
export type { AndroidBackingView, AndroidCanvasProps,
|
|
11
|
+
export type { AndroidBackingView, AndroidCanvasProps, AndroidSurfaceViewProps, AndroidTextureViewProps, CanvasProps, CanvasRef, NativeCanvas, RNCanvasContext, } from "./Canvas";
|
|
12
12
|
export declare const Canvas: ({ android: _android, ref, ...props }: CanvasProps) => React.FunctionComponentElement<Omit<import("react-native").ViewProps, "ref"> & {
|
|
13
13
|
ref?: React.Ref<import("react-native").ViewInstance> | undefined;
|
|
14
14
|
}>;
|
|
@@ -34,6 +34,7 @@ export declare const GPUDeviceProvider: ({ children }: {
|
|
|
34
34
|
children?: ReactNode;
|
|
35
35
|
}) => string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null;
|
|
36
36
|
export declare const useMainDevice: () => never;
|
|
37
|
+
export declare const purgeGpuResources: () => undefined;
|
|
37
38
|
export declare const importDevice: (_pointer: bigint) => GPUDevice;
|
|
38
39
|
export declare const adoptTexture: (_pointer: bigint) => GPUTexture;
|
|
39
40
|
export declare const installWebGPU: () => undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock.d.ts","sourceRoot":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AsC,WAAW;;EASvE,CAAC;AAEF,YAAY,EACV,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAG5B,eAAO,MAAM,gBAAgB,GAAI,mFAK9B,qBAAqB;;EAQvB,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,cAAc,MAAM;;;CAGtD,CAAC;AAEH,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;AAEnB,eAAO,MAAM,aAAa,QAAO,KAEhC,CAAC;AAEF,eAAO,MAAM,iBAAiB,iBAAkB,CAAC;AAEjD,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"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the GPU memory nothing uses to the system. Most apps should never
|
|
3
|
+
* call it: `destroy()` lets Dawn reuse the memory, and react-native-webgpu
|
|
4
|
+
* purges on its own when the system is short of memory and, on Android, each
|
|
5
|
+
* time the app goes to the background.
|
|
6
|
+
*
|
|
7
|
+
* It is meant for a one-off peak (a video export) followed by a long stretch
|
|
8
|
+
* that needs far less GPU memory. Not for a render loop, not after each
|
|
9
|
+
* `destroy()`, not on unmount: memory Dawn would have reused has to be
|
|
10
|
+
* requested from the system again. It does not free what was not destroyed.
|
|
11
|
+
*
|
|
12
|
+
* It returns right away and works in the background. It covers every device
|
|
13
|
+
* created through react-native-webgpu; an imported device is purged by its
|
|
14
|
+
* owner. Not part of the WebGPU spec, and does nothing on the Web.
|
|
15
|
+
*/
|
|
16
|
+
export declare const purgeGpuResources: () => void;
|
|
17
|
+
//# sourceMappingURL=purgeGpuResources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"purgeGpuResources.d.ts","sourceRoot":"","sources":["../../../src/purgeGpuResources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iBAAiB,QAAO,IAKpC,CAAC"}
|
package/package.json
CHANGED
package/src/Canvas.tsx
CHANGED
|
@@ -12,8 +12,7 @@ export type { CanvasRef, NativeCanvas, RNCanvasContext } from "./types";
|
|
|
12
12
|
const generateContextId = () => RNWebGPU.allocateContextId();
|
|
13
13
|
|
|
14
14
|
/** The Android view a canvas draws into, see {@link AndroidCanvasProps}. */
|
|
15
|
-
export type AndroidBackingView =
|
|
16
|
-
"TextureView" | "SurfaceView" | "HardwareBufferView";
|
|
15
|
+
export type AndroidBackingView = "TextureView" | "SurfaceView";
|
|
17
16
|
|
|
18
17
|
/** The options of a canvas backed by a `TextureView`, the default. */
|
|
19
18
|
export interface AndroidTextureViewProps {
|
|
@@ -62,17 +61,6 @@ export interface AndroidSurfaceViewProps {
|
|
|
62
61
|
zOrderMediaOverlay?: boolean;
|
|
63
62
|
}
|
|
64
63
|
|
|
65
|
-
/** The options of a canvas backed by a `HardwareBufferView`. */
|
|
66
|
-
export interface AndroidHardwareBufferViewProps {
|
|
67
|
-
/**
|
|
68
|
-
* A plain view drawing each frame's `AHardwareBuffer` inline: composited
|
|
69
|
-
* like a `TextureView`, without its extra copy. Opt-in and experimental,
|
|
70
|
-
* on Android 10 and later; below that the canvas uses a `TextureView`,
|
|
71
|
-
* with a warning in development. Always composites with alpha.
|
|
72
|
-
*/
|
|
73
|
-
backingView: "HardwareBufferView";
|
|
74
|
-
}
|
|
75
|
-
|
|
76
64
|
/**
|
|
77
65
|
* Android-only rendering options: the native view behind the canvas and its
|
|
78
66
|
* options. The view is created when the canvas mounts and kept: a change of
|
|
@@ -81,9 +69,7 @@ export interface AndroidHardwareBufferViewProps {
|
|
|
81
69
|
* z-order options on Android 11 and later. Ignored on iOS and web.
|
|
82
70
|
*/
|
|
83
71
|
export type AndroidCanvasProps =
|
|
84
|
-
|
|
|
85
|
-
| AndroidSurfaceViewProps
|
|
86
|
-
| AndroidHardwareBufferViewProps;
|
|
72
|
+
AndroidTextureViewProps | AndroidSurfaceViewProps;
|
|
87
73
|
|
|
88
74
|
export interface CanvasProps extends ViewProps {
|
|
89
75
|
/**
|
|
@@ -128,25 +114,16 @@ const resolveBackingView = (
|
|
|
128
114
|
android?: AndroidCanvasProps,
|
|
129
115
|
): AndroidBackingView => {
|
|
130
116
|
const { backingView } = options(android);
|
|
131
|
-
return backingView === "SurfaceView"
|
|
132
|
-
? backingView
|
|
133
|
-
: "TextureView";
|
|
117
|
+
return backingView === "SurfaceView" ? backingView : "TextureView";
|
|
134
118
|
};
|
|
135
119
|
|
|
136
|
-
// Whether the canvas composites as opaque
|
|
137
|
-
//
|
|
138
|
-
// unless asked otherwise, and a HardwareBufferView always composites with
|
|
139
|
-
// alpha.
|
|
120
|
+
// Whether the canvas composites as opaque: a SurfaceView is opaque unless
|
|
121
|
+
// asked otherwise, a TextureView is translucent unless asked otherwise.
|
|
140
122
|
const resolveOpaque = (android?: AndroidCanvasProps): boolean => {
|
|
141
123
|
const { opaque } = options(android);
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
case "TextureView":
|
|
146
|
-
return opaque === true;
|
|
147
|
-
case "HardwareBufferView":
|
|
148
|
-
return false;
|
|
149
|
-
}
|
|
124
|
+
return resolveBackingView(android) === "SurfaceView"
|
|
125
|
+
? opaque !== false
|
|
126
|
+
: opaque === true;
|
|
150
127
|
};
|
|
151
128
|
|
|
152
129
|
// The native props the `android` prop resolves to.
|
|
@@ -169,28 +146,13 @@ const warnIgnoredChange = (prop: string) =>
|
|
|
169
146
|
"to change it.",
|
|
170
147
|
);
|
|
171
148
|
|
|
172
|
-
// Warns, in development on Android, about
|
|
173
|
-
//
|
|
174
|
-
//
|
|
175
|
-
//
|
|
176
|
-
// The native side only says so in logcat, which is not where a JS developer
|
|
177
|
-
// looks.
|
|
149
|
+
// Warns, in development on Android, about a change of these props that the
|
|
150
|
+
// native view ignores: the backing view is created from them when the canvas
|
|
151
|
+
// mounts (see WebGPUView.java, whose setters these rules mirror). The native
|
|
152
|
+
// side only says so in logcat, which is not where a JS developer looks.
|
|
178
153
|
const useBackingViewWarning = (android?: AndroidCanvasProps) => {
|
|
179
154
|
const mount = useRef(android);
|
|
180
155
|
const prev = useRef(android);
|
|
181
|
-
useEffect(() => {
|
|
182
|
-
if (
|
|
183
|
-
__DEV__ &&
|
|
184
|
-
Platform.OS === "android" &&
|
|
185
|
-
resolveBackingView(mount.current) === "HardwareBufferView" &&
|
|
186
|
-
Number(Platform.Version) < 29
|
|
187
|
-
) {
|
|
188
|
-
console.warn(
|
|
189
|
-
"android.backingView: HardwareBufferView needs Android 10, the " +
|
|
190
|
-
"canvas uses a TextureView.",
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
}, []);
|
|
194
156
|
useEffect(() => {
|
|
195
157
|
if (__DEV__ && Platform.OS === "android") {
|
|
196
158
|
const { current: before } = prev;
|
|
@@ -5,7 +5,7 @@ export interface NativeProps extends ViewProps {
|
|
|
5
5
|
contextId: CodegenTypes.Int32;
|
|
6
6
|
// The `android` prop, resolved (see Canvas.tsx)
|
|
7
7
|
androidBackingView?: CodegenTypes.WithDefault<
|
|
8
|
-
"TextureView" | "SurfaceView"
|
|
8
|
+
"TextureView" | "SurfaceView",
|
|
9
9
|
"TextureView"
|
|
10
10
|
>;
|
|
11
11
|
androidOpaque?: CodegenTypes.WithDefault<boolean, false>;
|
|
@@ -7,7 +7,7 @@ import { contextIdToId } from "./utils";
|
|
|
7
7
|
export interface NativeProps extends ViewProps {
|
|
8
8
|
contextId: CodegenTypes.Int32;
|
|
9
9
|
// The `android` prop, resolved: Android-only, never reaches the DOM
|
|
10
|
-
androidBackingView?: "TextureView" | "SurfaceView"
|
|
10
|
+
androidBackingView?: "TextureView" | "SurfaceView";
|
|
11
11
|
androidOpaque?: boolean;
|
|
12
12
|
androidZOrderOnTop?: boolean;
|
|
13
13
|
androidZOrderMediaOverlay?: boolean;
|
package/src/index.tsx
CHANGED
|
@@ -113,6 +113,7 @@ declare global {
|
|
|
113
113
|
// device from Skia.getNativeDevice()) into a GPUDevice. Requires the
|
|
114
114
|
// exporter to link this process's single Dawn copy.
|
|
115
115
|
importDevice: (pointer: bigint) => GPUDevice;
|
|
116
|
+
purgeGpuResources: () => void;
|
|
116
117
|
// Wrap an externally created WGPUTexture pointer into a GPUTexture,
|
|
117
118
|
// taking ownership of one reference (pair with producers that return a
|
|
118
119
|
// +1 pointer, e.g. Skia.Image.MakeGPUTextureFromImage()).
|
package/src/main/index.tsx
CHANGED
package/src/main/index.web.tsx
CHANGED
|
@@ -6,6 +6,7 @@ export * from "../WebGPUViewNativeComponent";
|
|
|
6
6
|
export * from "../hooks";
|
|
7
7
|
export * from "../GPUDeviceProvider";
|
|
8
8
|
export * from "../formats";
|
|
9
|
+
export * from "../purgeGpuResources";
|
|
9
10
|
export * from "../video";
|
|
10
11
|
|
|
11
12
|
// We don't need to set all global properties on web, webgpu is already available globally
|
package/src/mock.ts
CHANGED
|
@@ -85,7 +85,6 @@ const NOT_AVAILABLE_UNDER_JEST =
|
|
|
85
85
|
export type {
|
|
86
86
|
AndroidBackingView,
|
|
87
87
|
AndroidCanvasProps,
|
|
88
|
-
AndroidHardwareBufferViewProps,
|
|
89
88
|
AndroidSurfaceViewProps,
|
|
90
89
|
AndroidTextureViewProps,
|
|
91
90
|
CanvasProps,
|
|
@@ -147,6 +146,8 @@ export const useMainDevice = (): never => {
|
|
|
147
146
|
throw new Error(`useMainDevice() ${NOT_AVAILABLE_UNDER_JEST}`);
|
|
148
147
|
};
|
|
149
148
|
|
|
149
|
+
export const purgeGpuResources = () => undefined;
|
|
150
|
+
|
|
150
151
|
export const importDevice = (_pointer: bigint): GPUDevice => {
|
|
151
152
|
throw new Error(`importDevice() ${NOT_AVAILABLE_UNDER_JEST}`);
|
|
152
153
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the GPU memory nothing uses to the system. Most apps should never
|
|
3
|
+
* call it: `destroy()` lets Dawn reuse the memory, and react-native-webgpu
|
|
4
|
+
* purges on its own when the system is short of memory and, on Android, each
|
|
5
|
+
* time the app goes to the background.
|
|
6
|
+
*
|
|
7
|
+
* It is meant for a one-off peak (a video export) followed by a long stretch
|
|
8
|
+
* that needs far less GPU memory. Not for a render loop, not after each
|
|
9
|
+
* `destroy()`, not on unmount: memory Dawn would have reused has to be
|
|
10
|
+
* requested from the system again. It does not free what was not destroyed.
|
|
11
|
+
*
|
|
12
|
+
* It returns right away and works in the background. It covers every device
|
|
13
|
+
* created through react-native-webgpu; an imported device is purged by its
|
|
14
|
+
* owner. Not part of the WebGPU spec, and does nothing on the Web.
|
|
15
|
+
*/
|
|
16
|
+
export const purgeGpuResources = (): void => {
|
|
17
|
+
if (typeof RNWebGPU === "undefined") {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
RNWebGPU.purgeGpuResources();
|
|
21
|
+
};
|