react-native-skia 3.0.4 → 3.0.5

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 (204) hide show
  1. package/android/CMakeLists.txt +0 -2
  2. package/android/cpp/jni/JniPlatformContext.cpp +0 -24
  3. package/android/cpp/jni/include/JniPlatformContext.h +0 -2
  4. package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +0 -140
  5. package/android/src/main/java/com/reactnative/skia/PlatformContext.java +0 -5
  6. package/apple/RNSkApplePlatformContext.h +0 -10
  7. package/apple/RNSkApplePlatformContext.mm +0 -182
  8. package/cpp/api/JsiGPUTexture.h +48 -0
  9. package/cpp/api/JsiSkApi.h +1 -16
  10. package/cpp/api/JsiSkImage.h +0 -12
  11. package/cpp/api/JsiSkImageFactory.h +36 -57
  12. package/cpp/api/JsiSkSurface.h +3 -10
  13. package/cpp/api/JsiSkSurfaceFactory.h +13 -18
  14. package/cpp/rnskia/RNDawnContext.h +5 -113
  15. package/cpp/rnskia/RNDawnUtils.h +33 -0
  16. package/cpp/rnskia/RNSkPlatformContext.h +0 -54
  17. package/lib/commonjs/external/reanimated/index.d.ts +0 -1
  18. package/lib/commonjs/external/reanimated/index.js +0 -11
  19. package/lib/commonjs/external/reanimated/index.js.map +1 -1
  20. package/lib/commonjs/mock/index.js +1 -2
  21. package/lib/commonjs/mock/index.js.map +1 -1
  22. package/lib/commonjs/skia/types/GPUTexture.d.ts +11 -0
  23. package/lib/commonjs/skia/types/GPUTexture.js +2 -0
  24. package/lib/commonjs/skia/types/GPUTexture.js.map +1 -0
  25. package/lib/commonjs/skia/types/Image/Image.d.ts +0 -10
  26. package/lib/commonjs/skia/types/Image/Image.js.map +1 -1
  27. package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +25 -48
  28. package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
  29. package/lib/commonjs/skia/types/Skia.d.ts +0 -4
  30. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  31. package/lib/commonjs/skia/types/Surface/Surface.d.ts +3 -14
  32. package/lib/commonjs/skia/types/Surface/Surface.js.map +1 -1
  33. package/lib/commonjs/skia/types/Surface/SurfaceFactory.d.ts +10 -9
  34. package/lib/commonjs/skia/types/Surface/SurfaceFactory.js.map +1 -1
  35. package/lib/commonjs/skia/types/index.d.ts +1 -2
  36. package/lib/commonjs/skia/types/index.js +11 -22
  37. package/lib/commonjs/skia/types/index.js.map +1 -1
  38. package/lib/commonjs/skia/web/JsiSkImage.d.ts +0 -1
  39. package/lib/commonjs/skia/web/JsiSkImage.js +0 -4
  40. package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
  41. package/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +4 -5
  42. package/lib/commonjs/skia/web/JsiSkImageFactory.js +6 -10
  43. package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
  44. package/lib/commonjs/skia/web/JsiSkSurface.d.ts +0 -1
  45. package/lib/commonjs/skia/web/JsiSkSurface.js +0 -4
  46. package/lib/commonjs/skia/web/JsiSkSurface.js.map +1 -1
  47. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.d.ts +2 -2
  48. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js +1 -1
  49. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js.map +1 -1
  50. package/lib/commonjs/skia/web/JsiSkia.js +0 -4
  51. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  52. package/lib/module/external/reanimated/index.d.ts +0 -1
  53. package/lib/module/external/reanimated/index.js +0 -1
  54. package/lib/module/external/reanimated/index.js.map +1 -1
  55. package/lib/module/mock/index.js +1 -2
  56. package/lib/module/mock/index.js.map +1 -1
  57. package/lib/module/skia/types/GPUTexture.d.ts +11 -0
  58. package/lib/module/skia/types/GPUTexture.js +2 -0
  59. package/lib/module/skia/types/GPUTexture.js.map +1 -0
  60. package/lib/module/skia/types/Image/Image.d.ts +0 -10
  61. package/lib/module/skia/types/Image/Image.js.map +1 -1
  62. package/lib/module/skia/types/Image/ImageFactory.d.ts +25 -48
  63. package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
  64. package/lib/module/skia/types/Skia.d.ts +0 -4
  65. package/lib/module/skia/types/Skia.js.map +1 -1
  66. package/lib/module/skia/types/Surface/Surface.d.ts +3 -14
  67. package/lib/module/skia/types/Surface/Surface.js.map +1 -1
  68. package/lib/module/skia/types/Surface/SurfaceFactory.d.ts +10 -9
  69. package/lib/module/skia/types/Surface/SurfaceFactory.js.map +1 -1
  70. package/lib/module/skia/types/index.d.ts +1 -2
  71. package/lib/module/skia/types/index.js +1 -2
  72. package/lib/module/skia/types/index.js.map +1 -1
  73. package/lib/module/skia/web/JsiSkImage.d.ts +0 -1
  74. package/lib/module/skia/web/JsiSkImage.js +0 -4
  75. package/lib/module/skia/web/JsiSkImage.js.map +1 -1
  76. package/lib/module/skia/web/JsiSkImageFactory.d.ts +4 -5
  77. package/lib/module/skia/web/JsiSkImageFactory.js +6 -10
  78. package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
  79. package/lib/module/skia/web/JsiSkSurface.d.ts +0 -1
  80. package/lib/module/skia/web/JsiSkSurface.js +0 -4
  81. package/lib/module/skia/web/JsiSkSurface.js.map +1 -1
  82. package/lib/module/skia/web/JsiSkSurfaceFactory.d.ts +2 -2
  83. package/lib/module/skia/web/JsiSkSurfaceFactory.js +1 -1
  84. package/lib/module/skia/web/JsiSkSurfaceFactory.js.map +1 -1
  85. package/lib/module/skia/web/JsiSkia.js +0 -4
  86. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  87. package/lib/typescript/src/external/reanimated/index.d.ts +0 -1
  88. package/lib/typescript/src/skia/types/GPUTexture.d.ts +11 -0
  89. package/lib/typescript/src/skia/types/Image/Image.d.ts +0 -10
  90. package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +25 -48
  91. package/lib/typescript/src/skia/types/Skia.d.ts +0 -4
  92. package/lib/typescript/src/skia/types/Surface/Surface.d.ts +3 -14
  93. package/lib/typescript/src/skia/types/Surface/SurfaceFactory.d.ts +10 -9
  94. package/lib/typescript/src/skia/types/index.d.ts +1 -2
  95. package/lib/typescript/src/skia/web/JsiSkImage.d.ts +0 -1
  96. package/lib/typescript/src/skia/web/JsiSkImageFactory.d.ts +4 -5
  97. package/lib/typescript/src/skia/web/JsiSkSurface.d.ts +0 -1
  98. package/lib/typescript/src/skia/web/JsiSkSurfaceFactory.d.ts +2 -2
  99. package/package.json +1 -1
  100. package/src/external/reanimated/index.ts +0 -1
  101. package/src/mock/index.ts +0 -1
  102. package/src/skia/types/GPUTexture.ts +9 -0
  103. package/src/skia/types/Image/Image.ts +0 -11
  104. package/src/skia/types/Image/ImageFactory.ts +25 -55
  105. package/src/skia/types/Skia.ts +0 -4
  106. package/src/skia/types/Surface/Surface.ts +3 -15
  107. package/src/skia/types/Surface/SurfaceFactory.ts +11 -9
  108. package/src/skia/types/index.ts +1 -2
  109. package/src/skia/web/JsiSkImage.ts +0 -5
  110. package/src/skia/web/JsiSkImageFactory.ts +16 -16
  111. package/src/skia/web/JsiSkSurface.ts +0 -5
  112. package/src/skia/web/JsiSkSurfaceFactory.ts +2 -2
  113. package/src/skia/web/JsiSkia.ts +0 -4
  114. package/android/cpp/rnskia-android/AHardwareBufferUtils.cpp +0 -31
  115. package/android/cpp/rnskia-android/AHardwareBufferUtils.h +0 -13
  116. package/android/cpp/rnskia-android/RNSkAndroidVideo.cpp +0 -200
  117. package/android/cpp/rnskia-android/RNSkAndroidVideo.h +0 -44
  118. package/android/src/main/java/com/reactnative/skia/RNSkVideo.java +0 -320
  119. package/apple/RNSkAppleVideo.h +0 -78
  120. package/apple/RNSkAppleVideo.mm +0 -292
  121. package/cpp/api/JsiNativeBuffer.h +0 -56
  122. package/cpp/api/JsiTextureInfo.h +0 -53
  123. package/cpp/api/JsiVideo.h +0 -101
  124. package/cpp/rnskia/RNSkVideo.h +0 -31
  125. package/lib/commonjs/external/reanimated/useVideo.d.ts +0 -21
  126. package/lib/commonjs/external/reanimated/useVideo.js +0 -150
  127. package/lib/commonjs/external/reanimated/useVideo.js.map +0 -1
  128. package/lib/commonjs/external/reanimated/useVideoLoading.d.ts +0 -4
  129. package/lib/commonjs/external/reanimated/useVideoLoading.js +0 -40
  130. package/lib/commonjs/external/reanimated/useVideoLoading.js.map +0 -1
  131. package/lib/commonjs/external/reanimated/useVideoLoading.web.d.ts +0 -4
  132. package/lib/commonjs/external/reanimated/useVideoLoading.web.js +0 -20
  133. package/lib/commonjs/external/reanimated/useVideoLoading.web.js.map +0 -1
  134. package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.d.ts +0 -29
  135. package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.js +0 -15
  136. package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.js.map +0 -1
  137. package/lib/commonjs/skia/types/NativeBuffer/index.d.ts +0 -1
  138. package/lib/commonjs/skia/types/NativeBuffer/index.js +0 -17
  139. package/lib/commonjs/skia/types/NativeBuffer/index.js.map +0 -1
  140. package/lib/commonjs/skia/types/Video/Video.d.ts +0 -20
  141. package/lib/commonjs/skia/types/Video/Video.js +0 -6
  142. package/lib/commonjs/skia/types/Video/Video.js.map +0 -1
  143. package/lib/commonjs/skia/types/Video/index.d.ts +0 -1
  144. package/lib/commonjs/skia/types/Video/index.js +0 -17
  145. package/lib/commonjs/skia/types/Video/index.js.map +0 -1
  146. package/lib/commonjs/skia/web/CanvasKitWebGLBufferImpl.d.ts +0 -9
  147. package/lib/commonjs/skia/web/CanvasKitWebGLBufferImpl.js +0 -30
  148. package/lib/commonjs/skia/web/CanvasKitWebGLBufferImpl.js.map +0 -1
  149. package/lib/commonjs/skia/web/JsiSkNativeBufferFactory.d.ts +0 -9
  150. package/lib/commonjs/skia/web/JsiSkNativeBufferFactory.js +0 -48
  151. package/lib/commonjs/skia/web/JsiSkNativeBufferFactory.js.map +0 -1
  152. package/lib/commonjs/skia/web/JsiVideo.d.ts +0 -28
  153. package/lib/commonjs/skia/web/JsiVideo.js +0 -96
  154. package/lib/commonjs/skia/web/JsiVideo.js.map +0 -1
  155. package/lib/module/external/reanimated/useVideo.d.ts +0 -21
  156. package/lib/module/external/reanimated/useVideo.js +0 -142
  157. package/lib/module/external/reanimated/useVideo.js.map +0 -1
  158. package/lib/module/external/reanimated/useVideoLoading.d.ts +0 -4
  159. package/lib/module/external/reanimated/useVideoLoading.js +0 -33
  160. package/lib/module/external/reanimated/useVideoLoading.js.map +0 -1
  161. package/lib/module/external/reanimated/useVideoLoading.web.d.ts +0 -4
  162. package/lib/module/external/reanimated/useVideoLoading.web.js +0 -13
  163. package/lib/module/external/reanimated/useVideoLoading.web.js.map +0 -1
  164. package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.d.ts +0 -29
  165. package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.js +0 -5
  166. package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.js.map +0 -1
  167. package/lib/module/skia/types/NativeBuffer/index.d.ts +0 -1
  168. package/lib/module/skia/types/NativeBuffer/index.js +0 -2
  169. package/lib/module/skia/types/NativeBuffer/index.js.map +0 -1
  170. package/lib/module/skia/types/Video/Video.d.ts +0 -20
  171. package/lib/module/skia/types/Video/Video.js +0 -2
  172. package/lib/module/skia/types/Video/Video.js.map +0 -1
  173. package/lib/module/skia/types/Video/index.d.ts +0 -1
  174. package/lib/module/skia/types/Video/index.js +0 -2
  175. package/lib/module/skia/types/Video/index.js.map +0 -1
  176. package/lib/module/skia/web/CanvasKitWebGLBufferImpl.d.ts +0 -9
  177. package/lib/module/skia/web/CanvasKitWebGLBufferImpl.js +0 -23
  178. package/lib/module/skia/web/CanvasKitWebGLBufferImpl.js.map +0 -1
  179. package/lib/module/skia/web/JsiSkNativeBufferFactory.d.ts +0 -9
  180. package/lib/module/skia/web/JsiSkNativeBufferFactory.js +0 -41
  181. package/lib/module/skia/web/JsiSkNativeBufferFactory.js.map +0 -1
  182. package/lib/module/skia/web/JsiVideo.d.ts +0 -28
  183. package/lib/module/skia/web/JsiVideo.js +0 -88
  184. package/lib/module/skia/web/JsiVideo.js.map +0 -1
  185. package/lib/typescript/src/external/reanimated/useVideo.d.ts +0 -21
  186. package/lib/typescript/src/external/reanimated/useVideoLoading.d.ts +0 -4
  187. package/lib/typescript/src/external/reanimated/useVideoLoading.web.d.ts +0 -4
  188. package/lib/typescript/src/skia/types/NativeBuffer/NativeBufferFactory.d.ts +0 -29
  189. package/lib/typescript/src/skia/types/NativeBuffer/index.d.ts +0 -1
  190. package/lib/typescript/src/skia/types/Video/Video.d.ts +0 -20
  191. package/lib/typescript/src/skia/types/Video/index.d.ts +0 -1
  192. package/lib/typescript/src/skia/web/CanvasKitWebGLBufferImpl.d.ts +0 -9
  193. package/lib/typescript/src/skia/web/JsiSkNativeBufferFactory.d.ts +0 -9
  194. package/lib/typescript/src/skia/web/JsiVideo.d.ts +0 -28
  195. package/src/external/reanimated/useVideo.ts +0 -161
  196. package/src/external/reanimated/useVideoLoading.ts +0 -39
  197. package/src/external/reanimated/useVideoLoading.web.ts +0 -17
  198. package/src/skia/types/NativeBuffer/NativeBufferFactory.ts +0 -52
  199. package/src/skia/types/NativeBuffer/index.ts +0 -1
  200. package/src/skia/types/Video/Video.ts +0 -19
  201. package/src/skia/types/Video/index.ts +0 -1
  202. package/src/skia/web/CanvasKitWebGLBufferImpl.ts +0 -25
  203. package/src/skia/web/JsiSkNativeBufferFactory.ts +0 -51
  204. package/src/skia/web/JsiVideo.ts +0 -113
@@ -6,6 +6,7 @@
6
6
 
7
7
  #include <jsi/jsi.h>
8
8
 
9
+ #include "JsiGPUTexture.h"
9
10
  #include "JsiSkConverters.h"
10
11
  #include "JsiSkData.h"
11
12
  #include "JsiSkImage.h"
@@ -36,12 +37,17 @@ public:
36
37
  return std::make_shared<JsiSkImage>(getContext(), std::move(image));
37
38
  }
38
39
 
39
- std::shared_ptr<JsiSkImage> MakeImageFromNativeBuffer(void *rawPointer) {
40
- auto image = getContext()->makeImageFromNativeBuffer(rawPointer);
41
- if (image == nullptr) {
42
- throw std::runtime_error("Failed to convert NativeBuffer to SkImage!");
43
- }
44
- return std::make_shared<JsiSkImage>(getContext(), std::move(image));
40
+ // Native buffers (camera and video frames) are not imported by Skia: they
41
+ // are rendered into a texture of the shared device by react-native-webgpu,
42
+ // and the texture is wrapped with MakeImageFromGPUTexture. The method
43
+ // only exists on Web, where it draws a CanvasImageSource; on native it
44
+ // points callers at the texture path.
45
+ JSI_HOST_FUNCTION(MakeImageFromNativeBuffer) {
46
+ throw std::runtime_error(
47
+ "MakeImageFromNativeBuffer is only available on Web. On native "
48
+ "platforms, copy the frame into a texture with react-native-webgpu's "
49
+ "queue.copyExternalImageToTexture() and wrap the texture with "
50
+ "Skia.Image.MakeImageFromGPUTexture()");
45
51
  }
46
52
 
47
53
  std::variant<std::nullptr_t, std::shared_ptr<JsiSkImage>>
@@ -81,65 +87,38 @@ public:
81
87
  });
82
88
  }
83
89
 
84
- JSI_HOST_FUNCTION(MakeImageFromNativeTextureUnstable) {
85
- auto texInfo = JsiTextureInfo::fromValue(runtime, arguments[0]);
86
- auto image = getContext()->makeImageFromNativeTexture(
87
- texInfo, arguments[1].asNumber(), arguments[2].asNumber(),
88
- count > 3 && arguments[3].asBool());
89
- if (image == nullptr) {
90
- throw std::runtime_error("Failed to convert native texture to SkImage!");
91
- }
92
- if (count > 4) {
93
- auto jsiImage = tryGetJsiObject<JsiSkImage>(runtime, arguments[4]);
94
- if (jsiImage) {
95
- jsiImage->setObject(image);
96
- return jsi::Value(runtime, arguments[4]);
97
- }
98
- }
99
- return makeJsiObject(
100
- runtime, std::make_shared<JsiSkImage>(getContext(), std::move(image)));
101
- }
90
+ // Texture interop with react-native-webgpu. Both packages link one Dawn and
91
+ // share one device, so a GPUTexture created on the shared device
92
+ // (importDevice(Skia.getNativeDevice())) can be wrapped as is. The texture
93
+ // crosses the package boundary through its nativePointer (see
94
+ // JsiGPUTexture.h); the device handoff works the same way.
102
95
 
103
- // Pointer-based texture interop with react-native-webgpu. The GPUTexture
104
- // JS objects live in react-native-webgpu, so textures cross the package
105
- // boundary as raw WGPUTexture pointers (BigInt), exactly like the device
106
- // handoff (Skia.getNativeDevice / importDevice). Only sound on the shared
107
- // device: both packages link one Dawn and share one wgpu::Instance.
108
-
109
- JSI_HOST_FUNCTION(MakeImageFromNativeTexture) {
110
- if (count < 1 || !arguments[0].isBigInt()) {
111
- throw std::runtime_error("MakeImageFromNativeTexture requires a "
112
- "WGPUTexture pointer (BigInt), e.g. "
113
- "texture.nativePointer");
114
- }
115
- auto raw = reinterpret_cast<WGPUTexture>(
116
- arguments[0].asBigInt(runtime).asUint64(runtime));
117
- if (raw == nullptr) {
96
+ JSI_HOST_FUNCTION(MakeImageFromGPUTexture) {
97
+ if (count < 1) {
118
98
  throw std::runtime_error(
119
- "MakeImageFromNativeTexture: pointer must be non-null");
99
+ "MakeImageFromGPUTexture requires a GPUTexture argument");
120
100
  }
121
- // Borrow: AddRef so our wgpu::Texture holds its own reference; the
122
- // wrapped SkImage retains the texture for its lifetime (see
101
+ // The wrapped SkImage retains the texture for its lifetime (see
123
102
  // DawnContext::MakeImageFromTexture) and the caller keeps ownership of
124
103
  // the JS GPUTexture.
125
- wgpuTextureAddRef(raw);
126
- wgpu::Texture texture = wgpu::Texture::Acquire(raw);
104
+ wgpu::Texture texture =
105
+ gpuTextureFromValue(runtime, arguments[0], "MakeImageFromGPUTexture");
127
106
  auto &dawnContext = DawnContext::getInstance();
128
107
  auto image = dawnContext.MakeImageFromTexture(
129
108
  texture, static_cast<int>(texture.GetWidth()),
130
109
  static_cast<int>(texture.GetHeight()), texture.GetFormat());
131
110
  if (image == nullptr) {
132
111
  throw std::runtime_error(
133
- "MakeImageFromNativeTexture: failed to wrap the texture");
112
+ "MakeImageFromGPUTexture: failed to wrap the texture");
134
113
  }
135
114
  return makeJsiObject(
136
115
  runtime, std::make_shared<JsiSkImage>(getContext(), std::move(image)));
137
116
  }
138
117
 
139
- JSI_HOST_FUNCTION(MakeNativeTextureFromImage) {
118
+ JSI_HOST_FUNCTION(MakeGPUTextureFromImage) {
140
119
  if (count < 1) {
141
120
  throw std::runtime_error(
142
- "MakeNativeTextureFromImage requires an SkImage argument");
121
+ "MakeGPUTextureFromImage requires an SkImage argument");
143
122
  }
144
123
  auto image = JsiSkImage::fromValue(runtime, arguments[0]);
145
124
  if (!image) {
@@ -149,11 +128,13 @@ public:
149
128
  wgpu::Texture texture = dawnContext.MakeTextureFromImage(image);
150
129
  if (!texture) {
151
130
  throw std::runtime_error(
152
- "MakeNativeTextureFromImage: failed to create the texture");
131
+ "MakeGPUTextureFromImage: failed to create the texture");
153
132
  }
154
133
  // Transfer ownership: the returned pointer carries one reference and must
155
134
  // be adopted exactly once (react-native-webgpu's adoptTexture()), which
156
- // releases it when the JS GPUTexture is destroyed.
135
+ // releases it when the JS GPUTexture is destroyed. Only react-native-webgpu
136
+ // can build the typed GPUTexture object, which is why this returns a
137
+ // pointer while MakeImageFromGPUTexture takes the object.
157
138
  return jsi::BigInt::fromUint64(
158
139
  runtime, reinterpret_cast<uint64_t>(texture.MoveToCHandle()));
159
140
  }
@@ -165,17 +146,15 @@ public:
165
146
  &JsiSkImageFactory::MakeImageFromEncoded);
166
147
  installHostMethod(runtime, prototype, "MakeImageFromViewTag",
167
148
  &JsiSkImageFactory::MakeImageFromViewTag);
168
- installMethod(runtime, prototype, "MakeImageFromNativeBuffer",
169
- &JsiSkImageFactory::MakeImageFromNativeBuffer);
170
- installHostMethod(runtime, prototype, "MakeImageFromNativeTextureUnstable",
171
- &JsiSkImageFactory::MakeImageFromNativeTextureUnstable);
149
+ installHostMethod(runtime, prototype, "MakeImageFromNativeBuffer",
150
+ &JsiSkImageFactory::MakeImageFromNativeBuffer);
172
151
  installMethod(runtime, prototype, "MakeImage",
173
152
  &JsiSkImageFactory::MakeImage);
174
153
  installMethod(runtime, prototype, "MakeNull", &JsiSkImageFactory::MakeNull);
175
- installHostMethod(runtime, prototype, "MakeImageFromNativeTexture",
176
- &JsiSkImageFactory::MakeImageFromNativeTexture);
177
- installHostMethod(runtime, prototype, "MakeNativeTextureFromImage",
178
- &JsiSkImageFactory::MakeNativeTextureFromImage);
154
+ installHostMethod(runtime, prototype, "MakeImageFromGPUTexture",
155
+ &JsiSkImageFactory::MakeImageFromGPUTexture);
156
+ installHostMethod(runtime, prototype, "MakeGPUTextureFromImage",
157
+ &JsiSkImageFactory::MakeGPUTextureFromImage);
179
158
  }
180
159
 
181
160
  explicit JsiSkImageFactory(std::shared_ptr<RNSkPlatformContext> context)
@@ -10,7 +10,6 @@
10
10
  #include "JsiSkConverters.h"
11
11
  #include "JsiSkDispatcher.h"
12
12
  #include "JsiSkNativeObjects.h"
13
- #include "JsiTextureInfo.h"
14
13
 
15
14
  #include "JsiSkCanvas.h"
16
15
  #include "JsiSkImage.h"
@@ -81,8 +80,9 @@ public:
81
80
  void flush(JsiOptional<bool> syncParam) {
82
81
  auto surface = getObject();
83
82
  // When `sync` is true, block until the GPU has finished executing the
84
- // submitted work. Required before a native consumer on a different command
85
- // queue reads this surface's texture via getNativeTextureUnstable(). #3916
83
+ // submitted work. Required before a consumer on a different command queue
84
+ // (a secondary Dawn device, for instance) reads the texture this surface
85
+ // draws into (see Surface.MakeFromGPUTexture). #3916
86
86
  bool sync = syncParam.has_value() && *syncParam;
87
87
  // A raster surface (e.g. Skia.Surface.Make) has no Graphite recorder;
88
88
  // only Graphite-backed surfaces need to snap and submit a recording.
@@ -119,11 +119,6 @@ public:
119
119
  runtime, std::make_shared<JsiSkImage>(getContext(), std::move(image)));
120
120
  }
121
121
 
122
- JSI_HOST_FUNCTION(getNativeTextureUnstable) {
123
- auto texInfo = getContext()->getTexture(getObject());
124
- return JsiTextureInfo::toValue(runtime, texInfo);
125
- }
126
-
127
122
  size_t getMemoryPressure() override {
128
123
  if (isDisposed()) {
129
124
  return 0;
@@ -185,8 +180,6 @@ public:
185
180
  installHostMethod(runtime, prototype, "makeImageSnapshot",
186
181
  &JsiSkSurface::makeImageSnapshot);
187
182
  installMethod(runtime, prototype, "flush", &JsiSkSurface::flush);
188
- installHostMethod(runtime, prototype, "getNativeTextureUnstable",
189
- &JsiSkSurface::getNativeTextureUnstable);
190
183
  }
191
184
  };
192
185
 
@@ -6,6 +6,7 @@
6
6
 
7
7
  #include <jsi/jsi.h>
8
8
 
9
+ #include "JsiGPUTexture.h"
9
10
  #include "JsiSkNativeObjects.h"
10
11
 
11
12
  #include "JsiSkSurface.h"
@@ -62,29 +63,23 @@ public:
62
63
  }
63
64
 
64
65
  // Pointer-based texture interop with react-native-webgpu, the surface
65
- // counterpart of JsiSkImageFactory::MakeImageFromNativeTexture: Skia draws
66
+ // counterpart of JsiSkImageFactory::MakeImageFromGPUTexture: Skia draws
66
67
  // directly into a texture created on the shared device, so WebGPU can
67
68
  // sample what Skia drew without any copy.
68
- JSI_HOST_FUNCTION(MakeFromNativeTexture) {
69
- if (count < 1 || !arguments[0].isBigInt()) {
70
- throw std::runtime_error("MakeFromNativeTexture requires a WGPUTexture "
71
- "pointer (BigInt), e.g. texture.nativePointer");
72
- }
73
- auto raw = reinterpret_cast<WGPUTexture>(
74
- arguments[0].asBigInt(runtime).asUint64(runtime));
75
- if (raw == nullptr) {
69
+ JSI_HOST_FUNCTION(MakeFromGPUTexture) {
70
+ if (count < 1) {
76
71
  throw std::runtime_error(
77
- "MakeFromNativeTexture: pointer must be non-null");
72
+ "MakeFromGPUTexture requires a GPUTexture argument");
78
73
  }
79
- // AddRef so our wgpu::Texture holds its own reference: the surface keeps
80
- // the texture alive for its lifetime, and the JS GPUTexture keeps its own
81
- // reference, which the caller may release once the surface exists.
82
- wgpuTextureAddRef(raw);
83
- wgpu::Texture texture = wgpu::Texture::Acquire(raw);
74
+ // The surface keeps the texture alive for its lifetime, and the JS
75
+ // GPUTexture keeps its own reference, which the caller may release once
76
+ // the surface exists.
77
+ wgpu::Texture texture =
78
+ gpuTextureFromValue(runtime, arguments[0], "MakeFromGPUTexture");
84
79
  auto surface = DawnContext::getInstance().MakeSurfaceFromTexture(texture);
85
80
  if (surface == nullptr) {
86
81
  throw std::runtime_error(
87
- "MakeFromNativeTexture: failed to wrap the texture");
82
+ "MakeFromGPUTexture: failed to wrap the texture");
88
83
  }
89
84
  return makeJsiObject(runtime, std::make_shared<JsiSkSurface>(
90
85
  getContext(), std::move(surface)));
@@ -96,8 +91,8 @@ public:
96
91
  installMethod(runtime, prototype, "Make", &JsiSkSurfaceFactory::Make);
97
92
  installHostMethod(runtime, prototype, "MakeOffscreen",
98
93
  &JsiSkSurfaceFactory::MakeOffscreen);
99
- installHostMethod(runtime, prototype, "MakeFromNativeTexture",
100
- &JsiSkSurfaceFactory::MakeFromNativeTexture);
94
+ installHostMethod(runtime, prototype, "MakeFromGPUTexture",
95
+ &JsiSkSurfaceFactory::MakeFromGPUTexture);
101
96
  }
102
97
 
103
98
  explicit JsiSkSurfaceFactory(std::shared_ptr<RNSkPlatformContext> context)
@@ -25,13 +25,6 @@
25
25
 
26
26
  #include "src/gpu/graphite/ContextOptionsPriv.h"
27
27
 
28
- #ifdef __APPLE__
29
- #include <CoreVideo/CVPixelBuffer.h>
30
- #else
31
- #include <android/hardware_buffer.h>
32
- #include <android/hardware_buffer_jni.h>
33
- #endif
34
-
35
28
  namespace RNSkia {
36
29
 
37
30
  struct AsyncContext {
@@ -39,11 +32,6 @@ struct AsyncContext {
39
32
  std::unique_ptr<const SkSurface::AsyncReadResult> fResult;
40
33
  };
41
34
 
42
- struct SharedTextureContext {
43
- wgpu::SharedTextureMemory sharedTextureMemory;
44
- wgpu::Texture texture;
45
- };
46
-
47
35
  static void
48
36
  async_callback(void *c,
49
37
  std::unique_ptr<const SkImage::AsyncReadResult> result) {
@@ -54,9 +42,6 @@ async_callback(void *c,
54
42
 
55
43
  class DawnContext {
56
44
  public:
57
- // TODO: remove
58
- friend class RNSkApplePlatformContext;
59
-
60
45
  DawnContext(const DawnContext &) = delete;
61
46
  DawnContext &operator=(const DawnContext &) = delete;
62
47
 
@@ -143,84 +128,6 @@ public:
143
128
  fGraphiteContext->submit(syncToCpu);
144
129
  }
145
130
 
146
- sk_sp<SkImage> MakeImageFromBuffer(void *buffer) {
147
- #if defined(__ANDROID__) && __ANDROID_API__ < 26
148
- // AHardwareBuffer is only available from API 26
149
- (void)buffer;
150
- return nullptr;
151
- #else
152
- #ifdef __APPLE__
153
- wgpu::SharedTextureMemoryIOSurfaceDescriptor platformDesc;
154
- auto ioSurface = CVPixelBufferGetIOSurface((CVPixelBufferRef)buffer);
155
- platformDesc.ioSurface = ioSurface;
156
- int width = static_cast<int>(IOSurfaceGetWidth(ioSurface));
157
- int height = static_cast<int>(IOSurfaceGetHeight(ioSurface));
158
- #else
159
- wgpu::SharedTextureMemoryAHardwareBufferDescriptor platformDesc;
160
- auto ahb = reinterpret_cast<AHardwareBuffer *>(buffer);
161
- platformDesc.handle = ahb;
162
- AHardwareBuffer_Desc adesc;
163
- AHardwareBuffer_describe(ahb, &adesc);
164
- int width = adesc.width;
165
- int height = adesc.height;
166
- #endif
167
-
168
- wgpu::SharedTextureMemoryDescriptor desc = {};
169
- desc.nextInChain = &platformDesc;
170
- wgpu::SharedTextureMemory memory =
171
- backendContext.fDevice.ImportSharedTextureMemory(&desc);
172
-
173
- wgpu::TextureDescriptor textureDesc;
174
- textureDesc.format = DawnUtils::PreferredTextureFormat;
175
- textureDesc.dimension = wgpu::TextureDimension::e2D;
176
- textureDesc.usage =
177
- wgpu::TextureUsage::TextureBinding | wgpu::TextureUsage::CopySrc;
178
- textureDesc.size = {static_cast<uint32_t>(width),
179
- static_cast<uint32_t>(height), 1};
180
-
181
- wgpu::Texture texture = memory.CreateTexture(&textureDesc);
182
-
183
- wgpu::SharedTextureMemoryBeginAccessDescriptor beginAccessDesc;
184
- beginAccessDesc.initialized = true;
185
- beginAccessDesc.fenceCount = 0;
186
- #if defined(__ANDROID__)
187
- // Dawn's Vulkan backend requires the acquired VkImageLayout to be chained.
188
- // UNDEFINED (= 0) on both ends is the canonical "no prior GPU producer"
189
- // pattern (matches GPUSharedTextureMemory::beginAccess).
190
- wgpu::SharedTextureMemoryVkImageLayoutBeginState vkBegin = {};
191
- vkBegin.oldLayout = 0;
192
- vkBegin.newLayout = 0;
193
- beginAccessDesc.nextInChain = &vkBegin;
194
- #endif
195
- bool success =
196
- memory.BeginAccess(texture, &beginAccessDesc) == wgpu::Status::Success;
197
-
198
- if (success) {
199
- skgpu::graphite::BackendTexture betFromView =
200
- skgpu::graphite::BackendTextures::MakeDawn(texture.Get());
201
- auto result = SkImages::WrapTexture(
202
- getRecorder(), betFromView, DawnUtils::PreferedColorType,
203
- kPremul_SkAlphaType, nullptr,
204
- [](void *context) {
205
- auto ctx = static_cast<SharedTextureContext *>(context);
206
- wgpu::SharedTextureMemoryEndAccessState endState = {};
207
- #if defined(__ANDROID__)
208
- wgpu::SharedTextureMemoryVkImageLayoutEndState vkEnd = {};
209
- endState.nextInChain = &vkEnd;
210
- #endif
211
- ctx->sharedTextureMemory.EndAccess(ctx->texture, &endState);
212
- delete ctx;
213
- },
214
- new SharedTextureContext{memory, texture});
215
- return result;
216
- }
217
- if (!success) {
218
- return nullptr;
219
- }
220
- return nullptr;
221
- #endif
222
- }
223
-
224
131
  // Create offscreen surface
225
132
  sk_sp<SkSurface> MakeOffscreen(int width, int height,
226
133
  bool useP3ColorSpace = false) {
@@ -276,26 +183,11 @@ public:
276
183
  return nullptr;
277
184
  }
278
185
 
279
- // Map WebGPU format to Skia color type
280
- SkColorType colorType;
281
- switch (format) {
282
- case wgpu::TextureFormat::RGBA8Unorm:
283
- colorType = kRGBA_8888_SkColorType;
284
- break;
285
- case wgpu::TextureFormat::BGRA8Unorm:
286
- colorType = kBGRA_8888_SkColorType;
287
- break;
288
- case wgpu::TextureFormat::RGBA16Float:
289
- colorType = kRGBA_F16_SkColorType;
290
- break;
291
- case wgpu::TextureFormat::R8Unorm:
292
- colorType = kGray_8_SkColorType;
293
- break;
294
- default:
295
- // Use preferred color type for unsupported formats
296
- colorType = DawnUtils::PreferedColorType;
297
- break;
298
- }
186
+ // Map the WebGPU format to a Skia color type; fall back to the preferred
187
+ // color type for formats Skia does not sample.
188
+ SkColorType colorType =
189
+ DawnUtils::colorTypeForTextureFormat(format).value_or(
190
+ DawnUtils::PreferedColorType);
299
191
 
300
192
  skgpu::graphite::BackendTexture backendTexture =
301
193
  skgpu::graphite::BackendTextures::MakeDawn(texture.Get());
@@ -4,6 +4,8 @@
4
4
  #include <TargetConditionals.h>
5
5
  #endif
6
6
 
7
+ #include <optional>
8
+
7
9
  #include "webgpu/webgpu_cpp.h"
8
10
 
9
11
  #include "dawn/native/DawnNative.h"
@@ -79,6 +81,28 @@ inline wgpu::TextureFormat textureFormatForColorType(SkColorType colorType) {
79
81
  }
80
82
  }
81
83
 
84
+ // The color type Skia samples a texture of the given format with, or none
85
+ // when Skia cannot sample the format: multi-planar YUV (the biplanar
86
+ // 4:2:0 formats of an NV12 IOSurface, OpaqueYCbCrAndroid), depth/stencil and
87
+ // compressed formats.
88
+ inline std::optional<SkColorType>
89
+ colorTypeForTextureFormat(wgpu::TextureFormat format) {
90
+ switch (format) {
91
+ case wgpu::TextureFormat::RGBA8Unorm:
92
+ return kRGBA_8888_SkColorType;
93
+ case wgpu::TextureFormat::BGRA8Unorm:
94
+ return kBGRA_8888_SkColorType;
95
+ case wgpu::TextureFormat::RGBA16Float:
96
+ return kRGBA_F16_SkColorType;
97
+ case wgpu::TextureFormat::RGB10A2Unorm:
98
+ return kRGBA_1010102_SkColorType;
99
+ case wgpu::TextureFormat::R8Unorm:
100
+ return kGray_8_SkColorType;
101
+ default:
102
+ return std::nullopt;
103
+ }
104
+ }
105
+
82
106
  // Find the best matching GPU adapter for the current platform.
83
107
  // Sorts by adapter type (DiscreteGPU > IntegratedGPU > CPU) and selects the
84
108
  // first adapter matching the platform backend (Metal on Apple, Vulkan on
@@ -294,6 +318,15 @@ createDawnBackendContext(dawn::native::Instance *instance) {
294
318
  // Vulkan equivalent of the above: EndAccess exports a sync-fd fence.
295
319
  wgpu::FeatureName::SharedFenceSyncFD,
296
320
  wgpu::FeatureName::SharedFenceVkSemaphoreOpaqueFD,
321
+ // Video and camera frames are YUV AHardwareBuffers. Dawn imports them
322
+ // as OpaqueYCbCrAndroid textures, a format it only accepts on a device
323
+ // with one of its two YCbCr features, and react-native-webgpu samples
324
+ // them as external textures (importExternalTexture,
325
+ // copyExternalImageToTexture), which needs this one in particular.
326
+ // Without it, importing a frame on the shared device fails with
327
+ // "Unsupported texture format TextureFormat::OpaqueYCbCrAndroid".
328
+ // Experimental in Dawn, hence the allow_unsafe_apis instance toggle.
329
+ wgpu::FeatureName::OpaqueYCbCrAndroidForExternalTexture,
297
330
  #endif
298
331
  };
299
332
 
@@ -10,7 +10,6 @@
10
10
  #include <utility>
11
11
  #include <vector>
12
12
 
13
- #include "RNSkVideo.h"
14
13
  #include "RNWindowContext.h"
15
14
 
16
15
  #pragma clang diagnostic push
@@ -30,14 +29,6 @@ namespace RNSkia {
30
29
 
31
30
  namespace react = facebook::react;
32
31
 
33
- struct TextureInfo {
34
- const void *mtlTexture = nullptr;
35
- unsigned int glTarget = 0;
36
- unsigned int glID = 0;
37
- unsigned int glFormat = 0;
38
- bool glProtected = false;
39
- };
40
-
41
32
  class RNSkPlatformContext {
42
33
  public:
43
34
  /**
@@ -96,51 +87,6 @@ public:
96
87
  virtual sk_sp<SkSurface>
97
88
  makeOffscreenSurface(int width, int height, bool useP3ColorSpace = false) = 0;
98
89
 
99
- /**
100
- * Creates an image from a native buffer.
101
- * - On iOS, this is a `CVPixelBufferRef`
102
- * - On Android, this is a `AHardwareBuffer*`
103
- * @param buffer The native buffer.
104
- * @return sk_sp<SkImage>
105
- */
106
- virtual sk_sp<SkImage> makeImageFromNativeBuffer(void *buffer) = 0;
107
-
108
- // The handle-based texture interop of the Ganesh era (Metal and OpenGL
109
- // texture handles). Graphite textures cross the package boundary as
110
- // WGPUTexture pointers instead (see JsiSkImageFactory).
111
- sk_sp<SkImage> makeImageFromNativeTexture(const TextureInfo &textureInfo,
112
- int width, int height,
113
- bool mipMapped) {
114
- throw std::runtime_error(
115
- "makeImageFromNativeTexture is not available on Graphite, use "
116
- "Skia.Image.MakeImageFromNativeTexture(pointer)");
117
- }
118
-
119
- const TextureInfo getTexture(sk_sp<SkSurface> image) {
120
- throw std::runtime_error(
121
- "getTexture(surface) is not available on Graphite, use "
122
- "Skia.Surface.MakeFromNativeTexture(pointer)");
123
- }
124
-
125
- const TextureInfo getTexture(sk_sp<SkImage> image) {
126
- throw std::runtime_error(
127
- "getTexture(image) is not available on Graphite, use "
128
- "Skia.Image.MakeNativeTextureFromImage(image)");
129
- }
130
-
131
- virtual void releaseNativeBuffer(uint64_t pointer) = 0;
132
-
133
- virtual uint64_t makeNativeBuffer(sk_sp<SkImage> image) = 0;
134
-
135
- // Allocate a platform native buffer (IOSurface on Apple, AHardwareBuffer on
136
- // Android) of the given size filled with a procedural test pattern (RGB
137
- // gradient + diagonal stripes), entirely on the CPU. Intended for examples
138
- // and tests that need a buffer to feed into importExternalTexture without a
139
- // camera/video source. Release it with releaseNativeBuffer().
140
- virtual uint64_t makeTestNativeBuffer(int width, int height) = 0;
141
-
142
- virtual std::shared_ptr<RNSkVideo> createVideo(const std::string &url) = 0;
143
-
144
90
  /**
145
91
  * Return the Platform specific font manager
146
92
  */
@@ -3,4 +3,3 @@ export * from "./renderHelpers";
3
3
  export * from "./interpolators";
4
4
  export * from "./textures";
5
5
  export * from "./buffers";
6
- export * from "./useVideo";
@@ -58,15 +58,4 @@ Object.keys(_buffers).forEach(function (key) {
58
58
  }
59
59
  });
60
60
  });
61
- var _useVideo = require("./useVideo");
62
- Object.keys(_useVideo).forEach(function (key) {
63
- if (key === "default" || key === "__esModule") return;
64
- if (key in exports && exports[key] === _useVideo[key]) return;
65
- Object.defineProperty(exports, key, {
66
- enumerable: true,
67
- get: function () {
68
- return _useVideo[key];
69
- }
70
- });
71
- });
72
61
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_useAnimatedImageValue","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_renderHelpers","_interpolators","_textures","_buffers","_useVideo"],"sources":["index.ts"],"sourcesContent":["export * from \"./useAnimatedImageValue\";\nexport * from \"./renderHelpers\";\nexport * from \"./interpolators\";\nexport * from \"./textures\";\nexport * from \"./buffers\";\nexport * from \"./useVideo\";\n"],"mappings":";;;;;AAAA,IAAAA,sBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,sBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,sBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,sBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,cAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,cAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,cAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,cAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,cAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,cAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,cAAA,CAAAN,GAAA;EAAAH,MAAA,CAAA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"names":["_useAnimatedImageValue","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_renderHelpers","_interpolators","_textures","_buffers"],"sources":["index.ts"],"sourcesContent":["export * from \"./useAnimatedImageValue\";\nexport * from \"./renderHelpers\";\nexport * from \"./interpolators\";\nexport * from \"./textures\";\nexport * from \"./buffers\";\n"],"mappings":";;;;;AAAA,IAAAA,sBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,sBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,sBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,sBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,cAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,cAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,cAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,cAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,cAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,cAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,cAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,cAAA,CAAAN,GAAA;IAAA;EAAA;AAAA;AACA,IAAAO,SAAA,GAAAX,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAS,SAAA,EAAAR,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,SAAA,CAAAP,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAG,SAAA,CAAAP,GAAA;IAAA;EAAA;AAAA;AACA,IAAAQ,QAAA,GAAAZ,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAU,QAAA,EAAAT,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAQ,QAAA,CAAAR,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAI,QAAA,CAAAR,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -72,8 +72,7 @@ const Mock = CanvasKit => {
72
72
  useFonts: Noop,
73
73
  useTypeface: () => null,
74
74
  useImage: () => null,
75
- useSVG: () => null,
76
- useVideo: () => null
75
+ useSVG: () => null
77
76
  };
78
77
  };
79
78
  exports.Mock = Mock;
@@ -1 +1 @@
1
- {"version":3,"names":["_web","require","_JsiSkImage","Noop","undefined","NoopValue","current","NoopSharedValue","value","Mock","CanvasKit","global","SkiaApi","JsiSkApi","Skia","Canvas","View","getPreferredHighBitDepthCanvasFormat","SkiaPictureView","SkiaGraphiteView","JsiSkImage","drawAsPicture","drawAsImage","drawAsImageFromPicture","useCanvasRef","useCanvasSize","ref","size","width","height","useValue","useComputedValue","useTiming","useLoop","useSpring","useClockValue","useValueEffect","isOnMainThread","useClock","usePathInterpolation","useImageAsTexture","useTextureValue","useTextureValueFromPicture","useRSXformBuffer","usePointBuffer","useColorBuffer","useRectBuffer","useBuffer","useRawData","useData","useFont","Font","useFonts","useTypeface","useImage","useSVG","useVideo","exports"],"sources":["index.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport { JsiSkApi } from \"../skia/web\";\nimport { JsiSkImage } from \"../skia/web/JsiSkImage\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Noop: () => any = () => undefined;\nconst NoopValue = () => ({ current: 0 });\nconst NoopSharedValue = () => ({ value: 0 });\n\nexport const Mock = (CanvasKit: CanvasKit) => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n global.SkiaApi = JsiSkApi(CanvasKit);\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const Skia = global.SkiaApi;\n return {\n Skia,\n ...require(\"../renderer/components\"),\n ...require(\"../skia\"),\n ...require(\"../animation\"),\n ...require(\"../dom/types\"),\n ...require(\"../dom/nodes\"),\n Canvas: require(\"react-native\").View,\n getPreferredHighBitDepthCanvasFormat: () => \"rgba16float\",\n SkiaPictureView: require(\"react-native\").View,\n SkiaGraphiteView: require(\"react-native\").View,\n JsiSkImage: JsiSkImage,\n drawAsPicture: Noop,\n drawAsImage: Noop,\n drawAsImageFromPicture: Noop,\n useCanvasRef: NoopValue,\n useCanvasSize: () => ({\n ref: {\n current: 0,\n },\n size: {\n width: 0,\n height: 0,\n },\n }),\n // Skia Animations\n useValue: NoopValue,\n useComputedValue: NoopValue,\n useTiming: NoopValue,\n useLoop: NoopValue,\n useSpring: NoopValue,\n useClockValue: NoopValue,\n useValueEffect: Noop,\n // Reanimated hooks\n isOnMainThread: () => true,\n useClock: NoopSharedValue,\n usePathInterpolation: NoopSharedValue,\n useImageAsTexture: NoopSharedValue,\n useTextureValue: NoopSharedValue,\n useTextureValueFromPicture: NoopSharedValue,\n useRSXformBuffer: NoopSharedValue,\n usePointBuffer: NoopSharedValue,\n useColorBuffer: NoopSharedValue,\n useRectBuffer: NoopSharedValue,\n useBuffer: NoopSharedValue,\n useRawData: Noop,\n useData: Noop,\n useFont: () => Skia.Font(undefined, 0),\n useFonts: Noop,\n useTypeface: () => null,\n useImage: () => null,\n useSVG: () => null,\n useVideo: () => null,\n };\n};\n"],"mappings":";;;;;;AAEA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAEA;AACA,MAAME,IAAe,GAAGA,CAAA,KAAMC,SAAS;AACvC,MAAMC,SAAS,GAAGA,CAAA,MAAO;EAAEC,OAAO,EAAE;AAAE,CAAC,CAAC;AACxC,MAAMC,eAAe,GAAGA,CAAA,MAAO;EAAEC,KAAK,EAAE;AAAE,CAAC,CAAC;AAErC,MAAMC,IAAI,GAAIC,SAAoB,IAAK;EAC5C;EACA;EACAC,MAAM,CAACC,OAAO,GAAG,IAAAC,aAAQ,EAACH,SAAS,CAAC;EACpC;EACA;EACA,MAAMI,IAAI,GAAGH,MAAM,CAACC,OAAO;EAC3B,OAAO;IACLE,IAAI;IACJ,GAAGb,OAAO,CAAC,wBAAwB,CAAC;IACpC,GAAGA,OAAO,CAAC,SAAS,CAAC;IACrB,GAAGA,OAAO,CAAC,cAAc,CAAC;IAC1B,GAAGA,OAAO,CAAC,cAAc,CAAC;IAC1B,GAAGA,OAAO,CAAC,cAAc,CAAC;IAC1Bc,MAAM,EAAEd,OAAO,CAAC,cAAc,CAAC,CAACe,IAAI;IACpCC,oCAAoC,EAAEA,CAAA,KAAM,aAAa;IACzDC,eAAe,EAAEjB,OAAO,CAAC,cAAc,CAAC,CAACe,IAAI;IAC7CG,gBAAgB,EAAElB,OAAO,CAAC,cAAc,CAAC,CAACe,IAAI;IAC9CI,UAAU,EAAEA,sBAAU;IACtBC,aAAa,EAAElB,IAAI;IACnBmB,WAAW,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noop","undefined","NoopValue","current","NoopSharedValue","value","Mock","CanvasKit","global","SkiaApi","JsiSkApi","Skia","Canvas","View","getPreferredHighBitDepthCanvasFormat","SkiaPictureView","SkiaGraphiteView","JsiSkImage","drawAsPicture","drawAsImage","drawAsImageFromPicture","useCanvasRef","useCanvasSize","ref","size","width","height","useValue","useComputedValue","useTiming","useLoop","useSpring","useClockValue","useValueEffect","isOnMainThread","useClock","usePathInterpolation","useImageAsTexture","useTextureValue","useTextureValueFromPicture","useRSXformBuffer","usePointBuffer","useColorBuffer","useRectBuffer","useBuffer","useRawData","useData","useFont","Font","useFonts","useTypeface","useImage","useSVG","exports"],"sources":["index.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport { JsiSkApi } from \"../skia/web\";\nimport { JsiSkImage } from \"../skia/web/JsiSkImage\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Noop: () => any = () => undefined;\nconst NoopValue = () => ({ current: 0 });\nconst NoopSharedValue = () => ({ value: 0 });\n\nexport const Mock = (CanvasKit: CanvasKit) => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n global.SkiaApi = JsiSkApi(CanvasKit);\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const Skia = global.SkiaApi;\n return {\n Skia,\n ...require(\"../renderer/components\"),\n ...require(\"../skia\"),\n ...require(\"../animation\"),\n ...require(\"../dom/types\"),\n ...require(\"../dom/nodes\"),\n Canvas: require(\"react-native\").View,\n getPreferredHighBitDepthCanvasFormat: () => \"rgba16float\",\n SkiaPictureView: require(\"react-native\").View,\n SkiaGraphiteView: require(\"react-native\").View,\n JsiSkImage: JsiSkImage,\n drawAsPicture: Noop,\n drawAsImage: Noop,\n drawAsImageFromPicture: Noop,\n useCanvasRef: NoopValue,\n useCanvasSize: () => ({\n ref: {\n current: 0,\n },\n size: {\n width: 0,\n height: 0,\n },\n }),\n // Skia Animations\n useValue: NoopValue,\n useComputedValue: NoopValue,\n useTiming: NoopValue,\n useLoop: NoopValue,\n useSpring: NoopValue,\n useClockValue: NoopValue,\n useValueEffect: Noop,\n // Reanimated hooks\n isOnMainThread: () => true,\n useClock: NoopSharedValue,\n usePathInterpolation: NoopSharedValue,\n useImageAsTexture: NoopSharedValue,\n useTextureValue: NoopSharedValue,\n useTextureValueFromPicture: NoopSharedValue,\n useRSXformBuffer: NoopSharedValue,\n usePointBuffer: NoopSharedValue,\n useColorBuffer: NoopSharedValue,\n useRectBuffer: NoopSharedValue,\n useBuffer: NoopSharedValue,\n useRawData: Noop,\n useData: Noop,\n useFont: () => Skia.Font(undefined, 0),\n useFonts: Noop,\n useTypeface: () => null,\n useImage: () => null,\n useSVG: () => null,\n };\n};\n"],"mappings":";;;;;;AAEA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAEA;AACA,MAAME,IAAe,GAAGA,CAAA,KAAMC,SAAS;AACvC,MAAMC,SAAS,GAAGA,CAAA,MAAO;EAAEC,OAAO,EAAE;AAAE,CAAC,CAAC;AACxC,MAAMC,eAAe,GAAGA,CAAA,MAAO;EAAEC,KAAK,EAAE;AAAE,CAAC,CAAC;AAErC,MAAMC,IAAI,GAAIC,SAAoB,IAAK;EAC5C;EACA;EACAC,MAAM,CAACC,OAAO,GAAG,IAAAC,aAAQ,EAACH,SAAS,CAAC;EACpC;EACA;EACA,MAAMI,IAAI,GAAGH,MAAM,CAACC,OAAO;EAC3B,OAAO;IACLE,IAAI;IACJ,GAAGb,OAAO,CAAC,wBAAwB,CAAC;IACpC,GAAGA,OAAO,CAAC,SAAS,CAAC;IACrB,GAAGA,OAAO,CAAC,cAAc,CAAC;IAC1B,GAAGA,OAAO,CAAC,cAAc,CAAC;IAC1B,GAAGA,OAAO,CAAC,cAAc,CAAC;IAC1Bc,MAAM,EAAEd,OAAO,CAAC,cAAc,CAAC,CAACe,IAAI;IACpCC,oCAAoC,EAAEA,CAAA,KAAM,aAAa;IACz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I;IACpBC,MAAM,EAAEA,CAAA,KAAM;EAChB,CAAC;AACH,CAAC;AAACC,OAAA,CAAA/C,IAAA,GAAAA,IAAA","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * A WebGPU texture, as accepted by `Skia.Image.MakeImageFromGPUTexture` and
3
+ * `Skia.Surface.MakeFromGPUTexture`: a `GPUTexture` created with React Native
4
+ * WebGPU on the shared device, whose `nativePointer` (a non-spec extension)
5
+ * holds the `WGPUTexture` handle. The handle itself, as a `BigInt`, is
6
+ * accepted too for libraries that export textures without React Native
7
+ * WebGPU.
8
+ */
9
+ export type GPUTextureHandle = {
10
+ readonly nativePointer: bigint;
11
+ } | bigint;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=GPUTexture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["GPUTexture.ts"],"sourcesContent":["/**\n * A WebGPU texture, as accepted by `Skia.Image.MakeImageFromGPUTexture` and\n * `Skia.Surface.MakeFromGPUTexture`: a `GPUTexture` created with React Native\n * WebGPU on the shared device, whose `nativePointer` (a non-spec extension)\n * holds the `WGPUTexture` handle. The handle itself, as a `BigInt`, is\n * accepted too for libraries that export textures without React Native\n * WebGPU.\n */\nexport type GPUTextureHandle = { readonly nativePointer: bigint } | bigint;\n"],"mappings":"","ignoreList":[]}
@@ -56,16 +56,6 @@ export interface SkImage extends SkJSIInstance<"Image"> {
56
56
  * Returns the ImageInfo describing the image.
57
57
  */
58
58
  getImageInfo(): ImageInfo;
59
- /**
60
- * Returns the backend texture of the image.
61
- * The returned object can be used to create a Skia Image object.
62
- * The returned object is backend specific and should be used with caution.
63
- * It is the caller's responsibility to ensure that the texture is not used after the image is deleted.
64
- * The returned object may be null if the image does not have a backend texture.
65
- *
66
- * @return backend texture of the image or null
67
- */
68
- getNativeTextureUnstable(): unknown;
69
59
  /**
70
60
  * Returns this image as a shader with the specified tiling. It will use cubic sampling.
71
61
  * @param tx - tile mode in the x direction.