@shopify/react-native-skia 2.4.17 → 2.4.19

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 (87) hide show
  1. package/android/cpp/rnskia-android/RNSkAndroidVideo.cpp +34 -0
  2. package/android/cpp/rnskia-android/RNSkAndroidVideo.h +3 -0
  3. package/android/src/main/java/com/shopify/reactnative/skia/RNSkVideo.java +72 -18
  4. package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseView.java +7 -7
  5. package/apple/RNSkAppleVideo.h +30 -3
  6. package/apple/RNSkAppleVideo.mm +172 -17
  7. package/cpp/api/JsiSkApi.h +15 -13
  8. package/cpp/api/JsiSkHostObjects.h +57 -3
  9. package/cpp/api/JsiSkImage.h +19 -5
  10. package/cpp/api/JsiSkPicture.h +19 -5
  11. package/cpp/api/JsiSkSurface.h +19 -5
  12. package/cpp/api/JsiVideo.h +15 -2
  13. package/cpp/api/recorder/Convertor.h +4 -2
  14. package/cpp/jsi2/EnumMapper.h +49 -34
  15. package/cpp/jsi2/JSIConverter.h +149 -99
  16. package/cpp/jsi2/NativeObject.h +23 -25
  17. package/cpp/jsi2/Promise.cpp +10 -6
  18. package/cpp/jsi2/Promise.h +9 -7
  19. package/cpp/rnskia/RNDawnContext.h +3 -8
  20. package/cpp/rnskia/RNSkManager.cpp +13 -7
  21. package/cpp/rnskia/RNSkVideo.h +3 -0
  22. package/cpp/rnwgpu/api/GPUAdapter.cpp +31 -32
  23. package/cpp/rnwgpu/api/GPUAdapter.h +1 -1
  24. package/cpp/rnwgpu/api/GPUBuffer.cpp +8 -8
  25. package/cpp/rnwgpu/api/GPUCommandEncoder.h +4 -4
  26. package/cpp/rnwgpu/api/GPUDevice.h +12 -12
  27. package/cpp/rnwgpu/api/GPUQueue.cpp +45 -44
  28. package/cpp/rnwgpu/api/GPUQueue.h +1 -1
  29. package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +1 -1
  30. package/cpp/rnwgpu/api/GPURenderPassEncoder.h +1 -1
  31. package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +1 -1
  32. package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +1 -1
  33. package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +7 -6
  34. package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +1 -1
  35. package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +1 -1
  36. package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +1 -1
  37. package/cpp/rnwgpu/async/AsyncRunner.cpp +2 -1
  38. package/cpp/rnwgpu/async/AsyncRunner.h +2 -1
  39. package/lib/commonjs/external/reanimated/useVideo.js +30 -31
  40. package/lib/commonjs/external/reanimated/useVideo.js.map +1 -1
  41. package/lib/commonjs/renderer/Offscreen.js +1 -0
  42. package/lib/commonjs/renderer/Offscreen.js.map +1 -1
  43. package/lib/commonjs/skia/types/Video/Video.d.ts +3 -0
  44. package/lib/commonjs/skia/types/Video/Video.js.map +1 -1
  45. package/lib/commonjs/skia/web/JsiVideo.d.ts +3 -0
  46. package/lib/commonjs/skia/web/JsiVideo.js +9 -0
  47. package/lib/commonjs/skia/web/JsiVideo.js.map +1 -1
  48. package/lib/commonjs/sksg/Container.web.js +1 -0
  49. package/lib/commonjs/sksg/Container.web.js.map +1 -1
  50. package/lib/commonjs/sksg/HostConfig.js +4 -1
  51. package/lib/commonjs/sksg/HostConfig.js.map +1 -1
  52. package/lib/commonjs/sksg/Reconciler.js +6 -6
  53. package/lib/commonjs/sksg/Reconciler.js.map +1 -1
  54. package/lib/commonjs/sksg/StaticContainer.js +1 -0
  55. package/lib/commonjs/sksg/StaticContainer.js.map +1 -1
  56. package/lib/module/external/reanimated/useVideo.js +30 -31
  57. package/lib/module/external/reanimated/useVideo.js.map +1 -1
  58. package/lib/module/renderer/Offscreen.js +1 -0
  59. package/lib/module/renderer/Offscreen.js.map +1 -1
  60. package/lib/module/skia/types/Video/Video.d.ts +3 -0
  61. package/lib/module/skia/types/Video/Video.js.map +1 -1
  62. package/lib/module/skia/web/JsiVideo.d.ts +3 -0
  63. package/lib/module/skia/web/JsiVideo.js +9 -0
  64. package/lib/module/skia/web/JsiVideo.js.map +1 -1
  65. package/lib/module/sksg/Container.web.js +1 -0
  66. package/lib/module/sksg/Container.web.js.map +1 -1
  67. package/lib/module/sksg/HostConfig.js +4 -1
  68. package/lib/module/sksg/HostConfig.js.map +1 -1
  69. package/lib/module/sksg/Reconciler.js +6 -6
  70. package/lib/module/sksg/Reconciler.js.map +1 -1
  71. package/lib/module/sksg/StaticContainer.js +1 -0
  72. package/lib/module/sksg/StaticContainer.js.map +1 -1
  73. package/lib/typescript/lib/commonjs/skia/web/JsiVideo.d.ts +3 -0
  74. package/lib/typescript/lib/commonjs/sksg/HostConfig.d.ts +2 -0
  75. package/lib/typescript/lib/module/skia/web/JsiVideo.d.ts +3 -0
  76. package/lib/typescript/lib/module/sksg/HostConfig.d.ts +2 -0
  77. package/lib/typescript/src/skia/types/Video/Video.d.ts +3 -0
  78. package/lib/typescript/src/skia/web/JsiVideo.d.ts +3 -0
  79. package/package.json +1 -1
  80. package/src/external/reanimated/useVideo.ts +32 -32
  81. package/src/renderer/Offscreen.tsx +1 -0
  82. package/src/skia/types/Video/Video.ts +3 -0
  83. package/src/skia/web/JsiVideo.ts +12 -0
  84. package/src/sksg/Container.web.ts +1 -0
  85. package/src/sksg/HostConfig.ts +4 -0
  86. package/src/sksg/Reconciler.ts +5 -6
  87. package/src/sksg/StaticContainer.ts +1 -0
@@ -1,10 +1,10 @@
1
1
  #pragma once
2
2
 
3
3
  #include <jsi/jsi.h>
4
+ #include <memory>
5
+ #include <string>
4
6
  #include <utility>
5
7
  #include <vector>
6
- #include <string>
7
- #include <memory>
8
8
 
9
9
  namespace rnwgpu {
10
10
 
@@ -12,24 +12,26 @@ namespace jsi = facebook::jsi;
12
12
 
13
13
  class Promise {
14
14
  public:
15
- Promise(jsi::Runtime& runtime, jsi::Function&& resolver, jsi::Function&& rejecter);
15
+ Promise(jsi::Runtime &runtime, jsi::Function &&resolver,
16
+ jsi::Function &&rejecter);
16
17
 
17
- void resolve(jsi::Value&& result);
18
+ void resolve(jsi::Value &&result);
18
19
  void reject(std::string error);
19
20
 
20
21
  public:
21
- jsi::Runtime& runtime;
22
+ jsi::Runtime &runtime;
22
23
 
23
24
  private:
24
25
  jsi::Function _resolver;
25
26
  jsi::Function _rejecter;
26
27
 
27
28
  public:
28
- using RunPromise = std::function<void(jsi::Runtime& runtime, std::shared_ptr<Promise> promise)>;
29
+ using RunPromise = std::function<void(jsi::Runtime &runtime,
30
+ std::shared_ptr<Promise> promise)>;
29
31
  /**
30
32
  Create a new Promise and runs the given `run` function.
31
33
  */
32
- static jsi::Value createPromise(jsi::Runtime& runtime, RunPromise run);
34
+ static jsi::Value createPromise(jsi::Runtime &runtime, RunPromise run);
33
35
  };
34
36
 
35
37
  } // namespace rnwgpu
@@ -175,20 +175,15 @@ public:
175
175
  }
176
176
 
177
177
  // Get the wgpu::Instance for WebGPU bindings
178
- wgpu::Instance getWGPUInstance() {
179
- return wgpu::Instance(instance->Get());
180
- }
178
+ wgpu::Instance getWGPUInstance() { return wgpu::Instance(instance->Get()); }
181
179
 
182
180
  // Get the wgpu::Device for WebGPU bindings
183
- wgpu::Device getWGPUDevice() {
184
- return backendContext.fDevice;
185
- }
181
+ wgpu::Device getWGPUDevice() { return backendContext.fDevice; }
186
182
 
187
183
  // Create an SkImage from a WebGPU texture
188
184
  // The texture must have TextureBinding usage
189
185
  sk_sp<SkImage> MakeImageFromTexture(wgpu::Texture texture, int width,
190
- int height,
191
- wgpu::TextureFormat format) {
186
+ int height, wgpu::TextureFormat format) {
192
187
  if (!texture) {
193
188
  return nullptr;
194
189
  }
@@ -77,16 +77,21 @@ void RNSkManager::installBindings() {
77
77
  rnwgpu::GPU::installConstructor(*_jsRuntime);
78
78
  // Create and expose navigator.gpu using DawnContext's instance
79
79
  auto &dawnContext = DawnContext::getInstance();
80
- auto gpu = std::make_shared<rnwgpu::GPU>(*_jsRuntime, dawnContext.getWGPUInstance());
81
- auto navigatorValue = _jsRuntime->global().getProperty(*_jsRuntime, "navigator");
80
+ auto gpu =
81
+ std::make_shared<rnwgpu::GPU>(*_jsRuntime, dawnContext.getWGPUInstance());
82
+ auto navigatorValue =
83
+ _jsRuntime->global().getProperty(*_jsRuntime, "navigator");
82
84
  if (navigatorValue.isObject()) {
83
85
  auto navigator = navigatorValue.asObject(*_jsRuntime);
84
- navigator.setProperty(*_jsRuntime, "gpu", rnwgpu::GPU::create(*_jsRuntime, gpu));
86
+ navigator.setProperty(*_jsRuntime, "gpu",
87
+ rnwgpu::GPU::create(*_jsRuntime, gpu));
85
88
  } else {
86
89
  // Create navigator object if it doesn't exist
87
90
  jsi::Object navigator(*_jsRuntime);
88
- navigator.setProperty(*_jsRuntime, "gpu", rnwgpu::GPU::create(*_jsRuntime, gpu));
89
- _jsRuntime->global().setProperty(*_jsRuntime, "navigator", std::move(navigator));
91
+ navigator.setProperty(*_jsRuntime, "gpu",
92
+ rnwgpu::GPU::create(*_jsRuntime, gpu));
93
+ _jsRuntime->global().setProperty(*_jsRuntime, "navigator",
94
+ std::move(navigator));
90
95
  }
91
96
 
92
97
  // Install WebGPU constant objects as plain JS objects
@@ -98,8 +103,9 @@ void RNSkManager::installBindings() {
98
103
  rnwgpu::GPUMapMode::create(*_jsRuntime));
99
104
  _jsRuntime->global().setProperty(*_jsRuntime, "GPUShaderStage",
100
105
  rnwgpu::GPUShaderStage::create(*_jsRuntime));
101
- _jsRuntime->global().setProperty(*_jsRuntime, "GPUTextureUsage",
102
- rnwgpu::GPUTextureUsage::create(*_jsRuntime));
106
+ _jsRuntime->global().setProperty(
107
+ *_jsRuntime, "GPUTextureUsage",
108
+ rnwgpu::GPUTextureUsage::create(*_jsRuntime));
103
109
  #endif
104
110
  }
105
111
  } // namespace RNSkia
@@ -17,12 +17,15 @@ public:
17
17
  virtual sk_sp<SkImage> nextImage(double *timeStamp = nullptr) = 0;
18
18
  virtual double duration() = 0;
19
19
  virtual double framerate() = 0;
20
+ virtual double currentTime() = 0;
20
21
  virtual void seek(double timestamp) = 0;
21
22
  virtual float getRotationInDegrees() = 0;
22
23
  virtual SkISize getSize() = 0;
23
24
  virtual void play() = 0;
24
25
  virtual void pause() = 0;
25
26
  virtual void setVolume(float volume) = 0;
27
+ virtual void setLooping(bool looping) = 0;
28
+ virtual bool isPlaying() = 0;
26
29
  };
27
30
 
28
31
  } // namespace RNSkia
@@ -41,8 +41,7 @@ async::AsyncTaskHandle GPUAdapter::requestDevice(
41
41
  }
42
42
  std::string msg =
43
43
  message.length ? std::string(message.data, message.length) : "";
44
- fprintf(stderr, "GPU Device Lost (%s): %s\n", lostReason,
45
- msg.c_str());
44
+ fprintf(stderr, "GPU Device Lost (%s): %s\n", lostReason, msg.c_str());
46
45
  if (auto deviceHost = deviceLostBinding->lock()) {
47
46
  deviceHost->notifyDeviceLost(reason, std::move(msg));
48
47
  }
@@ -103,36 +102,36 @@ async::AsyncTaskHandle GPUAdapter::requestDevice(
103
102
  return;
104
103
  }
105
104
 
106
- device.SetLoggingCallback([creationRuntime](
107
- wgpu::LoggingType type,
108
- wgpu::StringView msg) {
109
- if (creationRuntime == nullptr) {
110
- return;
111
- }
112
- const char *logLevel = "";
113
- switch (type) {
114
- case wgpu::LoggingType::Warning:
115
- logLevel = "Warning";
116
- fprintf(stderr, "WebGPU Warning: %.*s\n",
117
- static_cast<int>(msg.length), msg.data);
118
- break;
119
- case wgpu::LoggingType::Error:
120
- logLevel = "Error";
121
- fprintf(stderr, "WebGPU Error: %.*s\n",
122
- static_cast<int>(msg.length), msg.data);
123
- break;
124
- case wgpu::LoggingType::Verbose:
125
- logLevel = "Verbose";
126
- break;
127
- case wgpu::LoggingType::Info:
128
- logLevel = "Info";
129
- break;
130
- default:
131
- logLevel = "Unknown";
132
- fprintf(stderr, "%s: %.*s\n", logLevel,
133
- static_cast<int>(msg.length), msg.data);
134
- }
135
- });
105
+ device.SetLoggingCallback(
106
+ [creationRuntime](wgpu::LoggingType type,
107
+ wgpu::StringView msg) {
108
+ if (creationRuntime == nullptr) {
109
+ return;
110
+ }
111
+ const char *logLevel = "";
112
+ switch (type) {
113
+ case wgpu::LoggingType::Warning:
114
+ logLevel = "Warning";
115
+ fprintf(stderr, "WebGPU Warning: %.*s\n",
116
+ static_cast<int>(msg.length), msg.data);
117
+ break;
118
+ case wgpu::LoggingType::Error:
119
+ logLevel = "Error";
120
+ fprintf(stderr, "WebGPU Error: %.*s\n",
121
+ static_cast<int>(msg.length), msg.data);
122
+ break;
123
+ case wgpu::LoggingType::Verbose:
124
+ logLevel = "Verbose";
125
+ break;
126
+ case wgpu::LoggingType::Info:
127
+ logLevel = "Info";
128
+ break;
129
+ default:
130
+ logLevel = "Unknown";
131
+ fprintf(stderr, "%s: %.*s\n", logLevel,
132
+ static_cast<int>(msg.length), msg.data);
133
+ }
134
+ });
136
135
 
137
136
  auto deviceHost = std::make_shared<GPUDevice>(std::move(device),
138
137
  asyncRunner, label);
@@ -15,8 +15,8 @@
15
15
 
16
16
  #include "GPUAdapterInfo.h"
17
17
  #include "GPUDevice.h"
18
- #include "descriptors/GPUDeviceDescriptor.h"
19
18
  #include "GPUSupportedLimits.h"
19
+ #include "descriptors/GPUDeviceDescriptor.h"
20
20
 
21
21
  namespace rnwgpu {
22
22
 
@@ -12,14 +12,14 @@ GPUBuffer::getMappedRange(std::optional<size_t> o, std::optional<size_t> size) {
12
12
  auto offset = o.value_or(0);
13
13
  uint64_t s = size.has_value() ? size.value() : (_instance.GetSize() - offset);
14
14
 
15
- //uint64_t start = offset;
16
- //uint64_t end = offset + s;
17
- // for (auto& mapping : mappings_) {
18
- // if (mapping.Intersects(start, end)) {
19
- // Errors::OperationError(env).ThrowAsJavaScriptException();
20
- // return {};
21
- // }
22
- // }
15
+ // uint64_t start = offset;
16
+ // uint64_t end = offset + s;
17
+ // for (auto& mapping : mappings_) {
18
+ // if (mapping.Intersects(start, end)) {
19
+ // Errors::OperationError(env).ThrowAsJavaScriptException();
20
+ // return {};
21
+ // }
22
+ // }
23
23
 
24
24
  auto *ptr =
25
25
  (_instance.GetUsage() & wgpu::BufferUsage::MapWrite)
@@ -11,15 +11,15 @@
11
11
 
12
12
  #include "GPUBuffer.h"
13
13
  #include "GPUCommandBuffer.h"
14
- #include "descriptors/GPUCommandBufferDescriptor.h"
15
- #include "descriptors/GPUComputePassDescriptor.h"
16
14
  #include "GPUComputePassEncoder.h"
17
15
  #include "GPUExtent3D.h"
16
+ #include "GPUQuerySet.h"
17
+ #include "GPURenderPassEncoder.h"
18
+ #include "descriptors/GPUCommandBufferDescriptor.h"
19
+ #include "descriptors/GPUComputePassDescriptor.h"
18
20
  #include "descriptors/GPUImageCopyBuffer.h"
19
21
  #include "descriptors/GPUImageCopyTexture.h"
20
- #include "GPUQuerySet.h"
21
22
  #include "descriptors/GPURenderPassDescriptor.h"
22
- #include "GPURenderPassEncoder.h"
23
23
 
24
24
  namespace rnwgpu {
25
25
 
@@ -17,34 +17,34 @@
17
17
  #include "webgpu/webgpu_cpp.h"
18
18
 
19
19
  #include "GPUBindGroup.h"
20
- #include "descriptors/GPUBindGroupDescriptor.h"
21
20
  #include "GPUBindGroupLayout.h"
22
- #include "descriptors/GPUBindGroupLayoutDescriptor.h"
23
21
  #include "GPUBuffer.h"
24
- #include "descriptors/GPUBufferDescriptor.h"
25
22
  #include "GPUCommandEncoder.h"
26
- #include "descriptors/GPUCommandEncoderDescriptor.h"
27
23
  #include "GPUComputePipeline.h"
28
- #include "descriptors/GPUComputePipelineDescriptor.h"
29
24
  #include "GPUDeviceLostInfo.h"
30
25
  #include "GPUError.h"
31
26
  #include "GPUExternalTexture.h"
32
- #include "descriptors/GPUExternalTextureDescriptor.h"
33
27
  #include "GPUPipelineLayout.h"
34
- #include "descriptors/GPUPipelineLayoutDescriptor.h"
35
28
  #include "GPUQuerySet.h"
36
- #include "descriptors/GPUQuerySetDescriptor.h"
37
29
  #include "GPUQueue.h"
38
30
  #include "GPURenderBundleEncoder.h"
39
- #include "descriptors/GPURenderBundleEncoderDescriptor.h"
40
31
  #include "GPURenderPipeline.h"
41
- #include "descriptors/GPURenderPipelineDescriptor.h"
42
32
  #include "GPUSampler.h"
43
- #include "descriptors/GPUSamplerDescriptor.h"
44
33
  #include "GPUShaderModule.h"
45
- #include "descriptors/GPUShaderModuleDescriptor.h"
46
34
  #include "GPUSupportedLimits.h"
47
35
  #include "GPUTexture.h"
36
+ #include "descriptors/GPUBindGroupDescriptor.h"
37
+ #include "descriptors/GPUBindGroupLayoutDescriptor.h"
38
+ #include "descriptors/GPUBufferDescriptor.h"
39
+ #include "descriptors/GPUCommandEncoderDescriptor.h"
40
+ #include "descriptors/GPUComputePipelineDescriptor.h"
41
+ #include "descriptors/GPUExternalTextureDescriptor.h"
42
+ #include "descriptors/GPUPipelineLayoutDescriptor.h"
43
+ #include "descriptors/GPUQuerySetDescriptor.h"
44
+ #include "descriptors/GPURenderBundleEncoderDescriptor.h"
45
+ #include "descriptors/GPURenderPipelineDescriptor.h"
46
+ #include "descriptors/GPUSamplerDescriptor.h"
47
+ #include "descriptors/GPUShaderModuleDescriptor.h"
48
48
  #include "descriptors/GPUTextureDescriptor.h"
49
49
 
50
50
  namespace rnwgpu {
@@ -103,50 +103,51 @@ void GPUQueue::copyExternalImageToTexture(
103
103
  std::shared_ptr<GPUImageCopyExternalImage> source,
104
104
  std::shared_ptr<GPUImageCopyTextureTagged> destination,
105
105
  std::shared_ptr<GPUExtent3D> size) {
106
- // wgpu::TexelCopyTextureInfo dst{};
107
- // wgpu::TexelCopyBufferLayout layout{};
108
- // wgpu::Extent3D sz{};
109
- // Convertor conv;
110
- // uint32_t bytesPerPixel =
111
- // source->source->getSize() /
112
- // (source->source->getWidth() * source->source->getHeight());
113
- // auto dataLayout = std::make_shared<GPUImageDataLayout>(GPUImageDataLayout{
114
- // std::optional<double>{0.0},
115
- // std::optional<double>{
116
- // static_cast<double>(bytesPerPixel * source->source->getWidth())},
117
- // std::optional<double>{static_cast<double>(source->source->getHeight())}});
118
- // if (!conv(dst.aspect, destination->aspect) ||
119
- // !conv(dst.mipLevel, destination->mipLevel) ||
120
- // !conv(dst.origin, destination->origin) ||
121
- // !conv(dst.texture, destination->texture) ||
122
- // !conv(layout, dataLayout) || //
123
- // !conv(sz, size)) {
124
- // throw std::runtime_error("Invalid input for GPUQueue::writeTexture()");
125
- // }
126
- //
127
- // if (source->flipY) {
128
- // // Calculate the row size and total size
129
- // uint32_t rowSize = bytesPerPixel * source->source->getWidth();
130
- // uint32_t totalSize = source->source->getSize();
131
- //
132
- // // Create a new buffer for the flipped data
133
- // std::vector<uint8_t> flippedData(totalSize);
134
- //
135
- // // Flip the data vertically
136
- // for (uint32_t row = 0; row < source->source->getHeight(); ++row) {
137
- // std::memcpy(flippedData.data() +
138
- // (source->source->getHeight() - 1 - row) * rowSize,
139
- // static_cast<const uint8_t *>(source->source->getData()) +
140
- // row * rowSize,
141
- // rowSize);
142
- // }
143
- // // Use the flipped data for writing to texture
144
- // _instance.WriteTexture(&dst, flippedData.data(), totalSize, &layout, &sz);
145
- // } else {
146
- //
147
- // _instance.WriteTexture(&dst, source->source->getData(),
148
- // source->source->getSize(), &layout, &sz);
149
- // }
106
+ // wgpu::TexelCopyTextureInfo dst{};
107
+ // wgpu::TexelCopyBufferLayout layout{};
108
+ // wgpu::Extent3D sz{};
109
+ // Convertor conv;
110
+ // uint32_t bytesPerPixel =
111
+ // source->source->getSize() /
112
+ // (source->source->getWidth() * source->source->getHeight());
113
+ // auto dataLayout = std::make_shared<GPUImageDataLayout>(GPUImageDataLayout{
114
+ // std::optional<double>{0.0},
115
+ // std::optional<double>{
116
+ // static_cast<double>(bytesPerPixel * source->source->getWidth())},
117
+ // std::optional<double>{static_cast<double>(source->source->getHeight())}});
118
+ // if (!conv(dst.aspect, destination->aspect) ||
119
+ // !conv(dst.mipLevel, destination->mipLevel) ||
120
+ // !conv(dst.origin, destination->origin) ||
121
+ // !conv(dst.texture, destination->texture) ||
122
+ // !conv(layout, dataLayout) || //
123
+ // !conv(sz, size)) {
124
+ // throw std::runtime_error("Invalid input for GPUQueue::writeTexture()");
125
+ // }
126
+ //
127
+ // if (source->flipY) {
128
+ // // Calculate the row size and total size
129
+ // uint32_t rowSize = bytesPerPixel * source->source->getWidth();
130
+ // uint32_t totalSize = source->source->getSize();
131
+ //
132
+ // // Create a new buffer for the flipped data
133
+ // std::vector<uint8_t> flippedData(totalSize);
134
+ //
135
+ // // Flip the data vertically
136
+ // for (uint32_t row = 0; row < source->source->getHeight(); ++row) {
137
+ // std::memcpy(flippedData.data() +
138
+ // (source->source->getHeight() - 1 - row) * rowSize,
139
+ // static_cast<const uint8_t *>(source->source->getData()) +
140
+ // row * rowSize,
141
+ // rowSize);
142
+ // }
143
+ // // Use the flipped data for writing to texture
144
+ // _instance.WriteTexture(&dst, flippedData.data(), totalSize, &layout,
145
+ // &sz);
146
+ // } else {
147
+ //
148
+ // _instance.WriteTexture(&dst, source->source->getData(),
149
+ // source->source->getSize(), &layout, &sz);
150
+ // }
150
151
  }
151
152
 
152
153
  void GPUQueue::writeTexture(std::shared_ptr<GPUImageCopyTexture> destination,
@@ -13,7 +13,6 @@
13
13
 
14
14
  #include "webgpu/webgpu_cpp.h"
15
15
 
16
- #include "rnwgpu/ArrayBuffer.h"
17
16
  #include "GPUBuffer.h"
18
17
  #include "GPUCommandBuffer.h"
19
18
  #include "GPUExtent3D.h"
@@ -21,6 +20,7 @@
21
20
  #include "descriptors/GPUImageCopyTexture.h"
22
21
  #include "descriptors/GPUImageCopyTextureTagged.h"
23
22
  #include "descriptors/GPUImageDataLayout.h"
23
+ #include "rnwgpu/ArrayBuffer.h"
24
24
 
25
25
  namespace rnwgpu {
26
26
 
@@ -15,8 +15,8 @@
15
15
  #include "GPUBindGroup.h"
16
16
  #include "GPUBuffer.h"
17
17
  #include "GPURenderBundle.h"
18
- #include "descriptors/GPURenderBundleDescriptor.h"
19
18
  #include "GPURenderPipeline.h"
19
+ #include "descriptors/GPURenderBundleDescriptor.h"
20
20
 
21
21
  namespace rnwgpu {
22
22
 
@@ -14,9 +14,9 @@
14
14
 
15
15
  #include "GPUBindGroup.h"
16
16
  #include "GPUBuffer.h"
17
- #include "descriptors/GPUColor.h"
18
17
  #include "GPURenderBundle.h"
19
18
  #include "GPURenderPipeline.h"
19
+ #include "descriptors/GPUColor.h"
20
20
 
21
21
  namespace rnwgpu {
22
22
 
@@ -6,10 +6,10 @@
6
6
  #include "webgpu/webgpu_cpp.h"
7
7
 
8
8
  #include "GPUBufferBinding.h"
9
+ #include "jsi2/JSIConverter.h"
9
10
  #include "rnwgpu/api/GPUExternalTexture.h"
10
11
  #include "rnwgpu/api/GPUSampler.h"
11
12
  #include "rnwgpu/api/GPUTextureView.h"
12
- #include "jsi2/JSIConverter.h"
13
13
 
14
14
  namespace jsi = facebook::jsi;
15
15
 
@@ -7,8 +7,8 @@
7
7
 
8
8
  #include "jsi2/JSIConverter.h"
9
9
 
10
- #include "rnwgpu/api/GPUPipelineLayout.h"
11
10
  #include "GPUProgrammableStage.h"
11
+ #include "rnwgpu/api/GPUPipelineLayout.h"
12
12
 
13
13
  namespace jsi = facebook::jsi;
14
14
 
@@ -17,7 +17,7 @@ namespace jsi = facebook::jsi;
17
17
  namespace rnwgpu {
18
18
 
19
19
  struct GPUImageCopyExternalImage {
20
- //std::shared_ptr<ImageBitmap> source; // GPUImageCopyExternalImageSource
20
+ // std::shared_ptr<ImageBitmap> source; // GPUImageCopyExternalImageSource
21
21
  std::optional<std::shared_ptr<GPUOrigin2D>> origin; // GPUOrigin2DStrict
22
22
  std::optional<bool> flipY; // boolean
23
23
  };
@@ -33,11 +33,12 @@ struct JSIConverter<std::shared_ptr<rnwgpu::GPUImageCopyExternalImage>> {
33
33
  auto result = std::make_unique<rnwgpu::GPUImageCopyExternalImage>();
34
34
  if (!outOfBounds && arg.isObject()) {
35
35
  auto obj = arg.getObject(runtime);
36
- // if (obj.hasProperty(runtime, "source")) {
37
- // auto prop = obj.getProperty(runtime, "source");
38
- // result->source = JSIConverter<std::shared_ptr<ImageBitmap>>::fromJSI(
39
- // runtime, prop, false);
40
- // }
36
+ // if (obj.hasProperty(runtime, "source")) {
37
+ // auto prop = obj.getProperty(runtime, "source");
38
+ // result->source =
39
+ // JSIConverter<std::shared_ptr<ImageBitmap>>::fromJSI(
40
+ // runtime, prop, false);
41
+ // }
41
42
  if (obj.hasProperty(runtime, "origin")) {
42
43
  auto prop = obj.getProperty(runtime, "origin");
43
44
  result->origin = JSIConverter<std::shared_ptr<GPUOrigin2D>>::fromJSI(
@@ -9,10 +9,10 @@
9
9
 
10
10
  #include "jsi2/JSIConverter.h"
11
11
 
12
- #include "rnwgpu/api/GPUQuerySet.h"
13
12
  #include "GPURenderPassColorAttachment.h"
14
13
  #include "GPURenderPassDepthStencilAttachment.h"
15
14
  #include "GPURenderPassTimestampWrites.h"
15
+ #include "rnwgpu/api/GPUQuerySet.h"
16
16
 
17
17
  namespace jsi = facebook::jsi;
18
18
 
@@ -10,9 +10,9 @@
10
10
  #include "GPUDepthStencilState.h"
11
11
  #include "GPUFragmentState.h"
12
12
  #include "GPUMultisampleState.h"
13
- #include "rnwgpu/api/GPUPipelineLayout.h"
14
13
  #include "GPUPrimitiveState.h"
15
14
  #include "GPUVertexState.h"
15
+ #include "rnwgpu/api/GPUPipelineLayout.h"
16
16
 
17
17
  namespace jsi = facebook::jsi;
18
18
 
@@ -10,8 +10,8 @@
10
10
 
11
11
  #include "jsi2/JSIConverter.h"
12
12
 
13
- #include "rnwgpu/api/GPUShaderModule.h"
14
13
  #include "GPUVertexBufferLayout.h"
14
+ #include "rnwgpu/api/GPUShaderModule.h"
15
15
 
16
16
  namespace jsi = facebook::jsi;
17
17
 
@@ -10,7 +10,8 @@ namespace rnwgpu::async {
10
10
 
11
11
  // Static member definitions
12
12
  std::mutex AsyncRunner::_runnersMutex;
13
- std::unordered_map<jsi::Runtime *, std::shared_ptr<AsyncRunner>> AsyncRunner::_runners;
13
+ std::unordered_map<jsi::Runtime *, std::shared_ptr<AsyncRunner>>
14
+ AsyncRunner::_runners;
14
15
 
15
16
  AsyncRunner::AsyncRunner(wgpu::Instance instance,
16
17
  std::shared_ptr<AsyncDispatcher> dispatcher)
@@ -43,7 +43,8 @@ public:
43
43
 
44
44
  private:
45
45
  static std::mutex _runnersMutex;
46
- static std::unordered_map<jsi::Runtime *, std::shared_ptr<AsyncRunner>> _runners;
46
+ static std::unordered_map<jsi::Runtime *, std::shared_ptr<AsyncRunner>>
47
+ _runners;
47
48
 
48
49
  wgpu::Instance _instance;
49
50
  std::shared_ptr<AsyncDispatcher> _dispatcher;