@shopify/react-native-skia 2.5.3 → 2.5.4

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.
@@ -214,6 +214,12 @@ set_property(TARGET pathops PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_PATH}/libpat
214
214
  add_library(jsonreader STATIC IMPORTED)
215
215
  set_property(TARGET jsonreader PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_PATH}/libjsonreader.a")
216
216
 
217
+ # Dawn library for Graphite builds (contains dawn::native symbols)
218
+ if(SK_GRAPHITE)
219
+ add_library(dawn_combined STATIC IMPORTED)
220
+ set_property(TARGET dawn_combined PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_PATH}/libdawn_combined.a")
221
+ endif()
222
+
217
223
  find_library(
218
224
  LOG_LIB
219
225
  log
@@ -386,6 +392,7 @@ endif()
386
392
  if(SK_GRAPHITE)
387
393
  target_link_libraries(${PACKAGE_NAME}
388
394
  ${COMMON_LIBS}
395
+ dawn_combined
389
396
  )
390
397
  else()
391
398
  target_link_libraries(${PACKAGE_NAME}
@@ -18,7 +18,7 @@ Java_com_shopify_reactnative_skia_WebGPUView_onSurfaceCreate(
18
18
  auto gpu = dawnContext.getWGPUInstance();
19
19
 
20
20
  // Create surface from ANativeWindow
21
- wgpu::SurfaceDescriptorFromAndroidNativeWindow androidSurfaceDesc;
21
+ wgpu::SurfaceSourceAndroidNativeWindow androidSurfaceDesc;
22
22
  androidSurfaceDesc.window = window;
23
23
  wgpu::SurfaceDescriptor surfaceDescriptor;
24
24
  surfaceDescriptor.nextInChain = &androidSurfaceDesc;
@@ -297,11 +297,11 @@ public:
297
297
  // 1. Create Surface
298
298
  wgpu::SurfaceDescriptor surfaceDescriptor;
299
299
  #ifdef __APPLE__
300
- wgpu::SurfaceDescriptorFromMetalLayer metalSurfaceDesc;
300
+ wgpu::SurfaceSourceMetalLayer metalSurfaceDesc;
301
301
  metalSurfaceDesc.layer = window;
302
302
  surfaceDescriptor.nextInChain = &metalSurfaceDesc;
303
303
  #else
304
- wgpu::SurfaceDescriptorFromAndroidNativeWindow androidSurfaceDesc;
304
+ wgpu::SurfaceSourceAndroidNativeWindow androidSurfaceDesc;
305
305
  androidSurfaceDesc.window = window;
306
306
  surfaceDescriptor.nextInChain = &androidSurfaceDesc;
307
307
  #endif
@@ -34,6 +34,9 @@ public:
34
34
  wgpu::SurfaceTexture surfaceTexture;
35
35
  _surface.GetCurrentTexture(&surfaceTexture);
36
36
  auto texture = surfaceTexture.texture;
37
+ if (!texture) {
38
+ return nullptr;
39
+ }
37
40
  skgpu::graphite::DawnTextureInfo info(
38
41
  /*sampleCount=*/1, skgpu::Mipmapped::kNo,
39
42
  DawnUtils::PreferredTextureFormat, texture.GetUsage(),
@@ -21,6 +21,9 @@ public:
21
21
  int getWidth() { return _width; }
22
22
  int getHeight() { return _height; }
23
23
 
24
+ void setWidth(int width) { _width = width; }
25
+ void setHeight(int height) { _height = height; }
26
+
24
27
  int getClientWidth() { return _clientWidth; }
25
28
  int getClientHeight() { return _clientHeight; }
26
29
 
@@ -28,8 +31,10 @@ public:
28
31
  void setClientHeight(int height) { _clientHeight = height; }
29
32
 
30
33
  static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
31
- installGetter(runtime, prototype, "width", &Canvas::getWidth);
32
- installGetter(runtime, prototype, "height", &Canvas::getHeight);
34
+ installGetterSetter(runtime, prototype, "width", &Canvas::getWidth,
35
+ &Canvas::setWidth);
36
+ installGetterSetter(runtime, prototype, "height", &Canvas::getHeight,
37
+ &Canvas::setHeight);
33
38
  installGetter(runtime, prototype, "clientWidth", &Canvas::getClientWidth);
34
39
  installGetter(runtime, prototype, "clientHeight", &Canvas::getClientHeight);
35
40
  }
@@ -88,6 +88,18 @@ std::unordered_set<std::string> GPU::getWgslLanguageFeatures() {
88
88
  case wgpu::WGSLLanguageFeatureName::PointerCompositeAccess:
89
89
  name = "pointer_composite_access";
90
90
  break;
91
+ case wgpu::WGSLLanguageFeatureName::UniformBufferStandardLayout:
92
+ name = "uniform_buffer_standard_layout";
93
+ break;
94
+ case wgpu::WGSLLanguageFeatureName::SubgroupId:
95
+ name = "subgroup_id";
96
+ break;
97
+ case wgpu::WGSLLanguageFeatureName::FragmentDepth:
98
+ name = "fragment_depth";
99
+ break;
100
+ case wgpu::WGSLLanguageFeatureName::ImmediateAddressSpace:
101
+ name = "immediate_address_space";
102
+ break;
91
103
  case wgpu::WGSLLanguageFeatureName::ChromiumTestingUnimplemented:
92
104
  name = "chromium_testing_unimplemented";
93
105
  break;
@@ -124,7 +124,7 @@ void GPUQueue::copyExternalImageToTexture(
124
124
  // throw std::runtime_error("Invalid input for GPUQueue::writeTexture()");
125
125
  // }
126
126
  //
127
- // if (source->flipY) {
127
+ // if (source->flipY.value_or(false)) {
128
128
  // // Calculate the row size and total size
129
129
  // uint32_t rowSize = bytesPerPixel * source->source->getWidth();
130
130
  // uint32_t totalSize = source->source->getSize();
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "setup-skia-web": "scripts/setup-canvaskit.js"
10
10
  },
11
11
  "title": "React Native Skia",
12
- "version": "2.5.3",
12
+ "version": "2.5.4",
13
13
  "description": "High-performance React Native Graphics using Skia",
14
14
  "main": "lib/module/index.js",
15
15
  "react-native": "src/index.ts",
@@ -18,6 +18,9 @@ framework_names = ['libskia', 'libsvg', 'libskshaper', 'libskparagraph',
18
18
  'libskunicode_core', 'libskunicode_libgrapheme',
19
19
  'libskottie', 'libsksg']
20
20
 
21
+ # Add Dawn library for Graphite builds (contains dawn::native symbols)
22
+ framework_names += ['libdawn_combined'] if use_graphite
23
+
21
24
  # Verify that prebuilt binaries have been installed by the postinstall script
22
25
  unless Dir.exist?(File.join(__dir__, 'libs', 'ios')) && Dir.exist?(File.join(__dir__, 'libs', 'macos'))
23
26
  Pod::UI.warn "#{'-' * 72}"
@@ -3,7 +3,6 @@
3
3
 
4
4
  const path = require("path");
5
5
  const fs = require("fs");
6
- const { execSync } = require("child_process");
7
6
 
8
7
  const useGraphite =
9
8
  process.env.SK_GRAPHITE === "1" ||
@@ -11,6 +10,21 @@ const useGraphite =
11
10
  const prefix = useGraphite ? "react-native-skia-graphite" : "react-native-skia";
12
11
  const libsDir = path.join(__dirname, "..", "libs");
13
12
 
13
+ function copySync(src, dest, options) {
14
+ if (!src.includes("*")) {
15
+ return fs.cpSync(src, dest, options);
16
+ }
17
+
18
+ const wildcardSplit = src.split("*");
19
+ const basePath = wildcardSplit[0];
20
+ const files = fs.readdirSync(basePath);
21
+ files
22
+ .filter(file => file.endsWith(wildcardSplit[1]))
23
+ .forEach((file) => {
24
+ return fs.cpSync(path.join(basePath, file), path.join(dest, file), options);
25
+ });
26
+ }
27
+
14
28
  // --- Apple platforms ---
15
29
 
16
30
  let iosPackage, macosPackage;
@@ -49,30 +63,14 @@ console.log("-- Skia iOS package: " + iosPackage);
49
63
  console.log("-- Skia macOS package: " + macosPackage);
50
64
 
51
65
  // Clean and copy Apple frameworks
52
- execSync(
53
- "rm -rf " +
54
- path.join(libsDir, "ios") +
55
- " " +
56
- path.join(libsDir, "macos") +
57
- " " +
58
- path.join(libsDir, "tvos")
59
- );
66
+ fs.rmSync(path.join(libsDir, "ios"), { recursive: true, force: true });
67
+ fs.rmSync(path.join(libsDir, "macos"), { recursive: true, force: true });
68
+ fs.rmSync(path.join(libsDir, "tvos"), { recursive: true, force: true });
60
69
  fs.mkdirSync(path.join(libsDir, "ios"), { recursive: true });
61
70
  fs.mkdirSync(path.join(libsDir, "macos"), { recursive: true });
62
- execSync(
63
- 'cp -R "' +
64
- iosPackage +
65
- '/libs/"*.xcframework "' +
66
- path.join(libsDir, "ios") +
67
- '/"'
68
- );
69
- execSync(
70
- 'cp -R "' +
71
- macosPackage +
72
- '/libs/"*.xcframework "' +
73
- path.join(libsDir, "macos") +
74
- '/"'
75
- );
71
+
72
+ copySync(iosPackage + '/libs/*.xcframework', path.join(libsDir, "ios"), {recursive: true});
73
+ copySync(macosPackage + '/libs/*.xcframework', path.join(libsDir, "macos"), {recursive: true});
76
74
 
77
75
  // Handle tvOS (non-Graphite only)
78
76
  if (!useGraphite) {
@@ -82,13 +80,7 @@ if (!useGraphite) {
82
80
  );
83
81
  console.log("-- Skia tvOS package: " + tvosPackage);
84
82
  fs.mkdirSync(path.join(libsDir, "tvos"), { recursive: true });
85
- execSync(
86
- 'cp -R "' +
87
- tvosPackage +
88
- '/libs/"*.xcframework "' +
89
- path.join(libsDir, "tvos") +
90
- '/"'
91
- );
83
+ copySync(tvosPackage + '/libs/*.xcframework', path.join(libsDir, "tvos"), {recursive: true});
92
84
  } catch (e) {
93
85
  console.log("-- tvOS package not found, skipping");
94
86
  }
@@ -125,7 +117,7 @@ console.log("-- Skia Android package: " + androidPackage);
125
117
 
126
118
  // Copy Android libs (per-ABI static libraries)
127
119
  const androidDest = path.join(libsDir, "android");
128
- execSync("rm -rf " + androidDest);
129
- execSync('cp -R "' + androidSrcLibs + '" "' + androidDest + '"');
120
+ fs.rmSync(androidDest, { recursive: true, force: true });
121
+ copySync(androidSrcLibs, androidDest, {recursive: true});
130
122
 
131
123
  console.log("-- Copied Android libs to libs/android/");