@shopify/react-native-skia 2.5.3 → 2.5.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.
@@ -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;
@@ -5,24 +5,24 @@ import com.facebook.react.uimanager.ThemedReactContext;
5
5
  import com.facebook.react.uimanager.annotations.ReactProp;
6
6
  import com.facebook.react.views.view.ReactViewGroup;
7
7
  import com.facebook.react.views.view.ReactViewManager;
8
- import com.facebook.react.viewmanagers.WebGPUViewManagerDelegate;
9
- import com.facebook.react.viewmanagers.WebGPUViewManagerInterface;
8
+ import com.facebook.react.viewmanagers.SkiaWebGPUViewManagerDelegate;
9
+ import com.facebook.react.viewmanagers.SkiaWebGPUViewManagerInterface;
10
10
 
11
11
  import androidx.annotation.NonNull;
12
12
  import androidx.annotation.Nullable;
13
13
 
14
14
  @ReactModule(name = WebGPUViewManager.NAME)
15
- public class WebGPUViewManager extends ReactViewManager implements WebGPUViewManagerInterface<WebGPUView> {
15
+ public class WebGPUViewManager extends ReactViewManager implements SkiaWebGPUViewManagerInterface<WebGPUView> {
16
16
 
17
- public static final String NAME = "WebGPUView";
17
+ public static final String NAME = "SkiaWebGPUView";
18
18
 
19
- protected WebGPUViewManagerDelegate mDelegate;
19
+ protected SkiaWebGPUViewManagerDelegate mDelegate;
20
20
 
21
21
  public WebGPUViewManager() {
22
- mDelegate = new WebGPUViewManagerDelegate(this);
22
+ mDelegate = new SkiaWebGPUViewManagerDelegate(this);
23
23
  }
24
24
 
25
- protected WebGPUViewManagerDelegate getDelegate() {
25
+ protected SkiaWebGPUViewManagerDelegate getDelegate() {
26
26
  return mDelegate;
27
27
  }
28
28
 
@@ -12,7 +12,7 @@
12
12
 
13
13
  NS_ASSUME_NONNULL_BEGIN
14
14
 
15
- @interface WebGPUView : RCTViewComponentView
15
+ @interface SkiaWebGPUView : RCTViewComponentView
16
16
  @end
17
17
 
18
18
  NS_ASSUME_NONNULL_END
@@ -1,6 +1,6 @@
1
1
  #ifdef RCT_NEW_ARCH_ENABLED
2
2
 
3
- #import "WebGPUView.h"
3
+ #import "SkiaWebGPUView.h"
4
4
 
5
5
  #import <react/renderer/components/rnskia/ComponentDescriptors.h>
6
6
  #import <react/renderer/components/rnskia/EventEmitters.h>
@@ -12,18 +12,18 @@
12
12
 
13
13
  using namespace facebook::react;
14
14
 
15
- @implementation WebGPUView
15
+ @implementation SkiaWebGPUView
16
16
 
17
17
  - (instancetype)initWithFrame:(CGRect)frame {
18
18
  if (self = [super initWithFrame:frame]) {
19
- static const auto defaultProps = std::make_shared<const WebGPUViewProps>();
19
+ static const auto defaultProps = std::make_shared<const SkiaWebGPUViewProps>();
20
20
  _props = defaultProps;
21
21
  }
22
22
  return self;
23
23
  }
24
24
 
25
25
  + (ComponentDescriptorProvider)componentDescriptorProvider {
26
- return concreteComponentDescriptorProvider<WebGPUViewComponentDescriptor>();
26
+ return concreteComponentDescriptorProvider<SkiaWebGPUViewComponentDescriptor>();
27
27
  }
28
28
 
29
29
  - (void)prepareForRecycle {
@@ -46,9 +46,9 @@ using namespace facebook::react;
46
46
  - (void)updateProps:(const Props::Shared &)props
47
47
  oldProps:(const Props::Shared &)oldProps {
48
48
  const auto &oldViewProps =
49
- *std::static_pointer_cast<const WebGPUViewProps>(_props);
49
+ *std::static_pointer_cast<const SkiaWebGPUViewProps>(_props);
50
50
  const auto &newViewProps =
51
- *std::static_pointer_cast<const WebGPUViewProps>(props);
51
+ *std::static_pointer_cast<const SkiaWebGPUViewProps>(props);
52
52
 
53
53
  if (newViewProps.contextId != oldViewProps.contextId) {
54
54
  /*
@@ -72,6 +72,6 @@ using namespace facebook::react;
72
72
 
73
73
  @end
74
74
 
75
- Class<RCTComponentViewProtocol> WebGPUViewCls(void) { return WebGPUView.class; }
75
+ Class<RCTComponentViewProtocol> SkiaWebGPUViewCls(void) { return SkiaWebGPUView.class; }
76
76
 
77
77
  #endif // RCT_NEW_ARCH_ENABLED
@@ -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();
@@ -7,5 +7,5 @@ exports.default = void 0;
7
7
  var _codegenNativeComponent = _interopRequireDefault(require("react-native/Libraries/Utilities/codegenNativeComponent"));
8
8
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
9
  // eslint-disable-next-line import/no-default-export
10
- var _default = exports.default = (0, _codegenNativeComponent.default)("WebGPUView");
10
+ var _default = exports.default = (0, _codegenNativeComponent.default)("SkiaWebGPUView");
11
11
  //# sourceMappingURL=WebGPUViewNativeComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_codegenNativeComponent","_interopRequireDefault","require","e","__esModule","default","_default","exports","codegenNativeComponent"],"sources":["WebGPUViewNativeComponent.ts"],"sourcesContent":["import codegenNativeComponent from \"react-native/Libraries/Utilities/codegenNativeComponent\";\nimport type { Int32 } from \"react-native/Libraries/Types/CodegenTypes\";\nimport type { ViewProps } from \"react-native\";\n\nexport interface NativeProps extends ViewProps {\n contextId: Int32;\n transparent: boolean;\n}\n\n// eslint-disable-next-line import/no-default-export\nexport default codegenNativeComponent<NativeProps>(\"WebGPUView\");\n"],"mappings":";;;;;;AAAA,IAAAA,uBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA6F,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAS7F;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GACe,IAAAG,+BAAsB,EAAc,YAAY,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_codegenNativeComponent","_interopRequireDefault","require","e","__esModule","default","_default","exports","codegenNativeComponent"],"sources":["WebGPUViewNativeComponent.ts"],"sourcesContent":["import codegenNativeComponent from \"react-native/Libraries/Utilities/codegenNativeComponent\";\nimport type { Int32 } from \"react-native/Libraries/Types/CodegenTypes\";\nimport type { ViewProps } from \"react-native\";\n\nexport interface NativeProps extends ViewProps {\n contextId: Int32;\n transparent: boolean;\n}\n\n// eslint-disable-next-line import/no-default-export\nexport default codegenNativeComponent<NativeProps>(\"SkiaWebGPUView\");\n"],"mappings":";;;;;;AAAA,IAAAA,uBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA6F,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAS7F;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GACe,IAAAG,+BAAsB,EAAc,gBAAgB,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
1
  import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
2
2
  // eslint-disable-next-line import/no-default-export
3
- export default codegenNativeComponent("WebGPUView");
3
+ export default codegenNativeComponent("SkiaWebGPUView");
4
4
  //# sourceMappingURL=WebGPUViewNativeComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["codegenNativeComponent"],"sources":["WebGPUViewNativeComponent.ts"],"sourcesContent":["import codegenNativeComponent from \"react-native/Libraries/Utilities/codegenNativeComponent\";\nimport type { Int32 } from \"react-native/Libraries/Types/CodegenTypes\";\nimport type { ViewProps } from \"react-native\";\n\nexport interface NativeProps extends ViewProps {\n contextId: Int32;\n transparent: boolean;\n}\n\n// eslint-disable-next-line import/no-default-export\nexport default codegenNativeComponent<NativeProps>(\"WebGPUView\");\n"],"mappings":"AAAA,OAAOA,sBAAsB,MAAM,yDAAyD;AAS5F;AACA,eAAeA,sBAAsB,CAAc,YAAY,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["codegenNativeComponent"],"sources":["WebGPUViewNativeComponent.ts"],"sourcesContent":["import codegenNativeComponent from \"react-native/Libraries/Utilities/codegenNativeComponent\";\nimport type { Int32 } from \"react-native/Libraries/Types/CodegenTypes\";\nimport type { ViewProps } from \"react-native\";\n\nexport interface NativeProps extends ViewProps {\n contextId: Int32;\n transparent: boolean;\n}\n\n// eslint-disable-next-line import/no-default-export\nexport default codegenNativeComponent<NativeProps>(\"SkiaWebGPUView\");\n"],"mappings":"AAAA,OAAOA,sBAAsB,MAAM,yDAAyD;AAS5F;AACA,eAAeA,sBAAsB,CAAc,gBAAgB,CAAC","ignoreList":[]}
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.5",
13
13
  "description": "High-performance React Native Graphics using Skia",
14
14
  "main": "lib/module/index.js",
15
15
  "react-native": "src/index.ts",
@@ -148,7 +148,7 @@
148
148
  "ios": {
149
149
  "componentProvider": {
150
150
  "SkiaPictureView": "SkiaPictureView",
151
- "WebGPUView": "WebGPUView"
151
+ "SkiaWebGPUView": "SkiaWebGPUView"
152
152
  }
153
153
  }
154
154
  },
@@ -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/");
@@ -8,4 +8,4 @@ export interface NativeProps extends ViewProps {
8
8
  }
9
9
 
10
10
  // eslint-disable-next-line import/no-default-export
11
- export default codegenNativeComponent<NativeProps>("WebGPUView");
11
+ export default codegenNativeComponent<NativeProps>("SkiaWebGPUView");