@shopify/react-native-skia 2.6.0 → 2.6.2

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 (118) hide show
  1. package/android/CMakeLists.txt +0 -1
  2. package/android/cpp/jni/JniWebGPUView.cpp +3 -3
  3. package/android/cpp/rnskia-android/OpenGLContext.h +4 -5
  4. package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +1 -1
  5. package/apple/MetalContext.h +5 -6
  6. package/apple/MetalWindowContext.mm +3 -4
  7. package/apple/RNSkApplePlatformContext.h +1 -1
  8. package/apple/RNSkApplePlatformContext.mm +4 -3
  9. package/apple/SkiaCVPixelBufferUtils.h +1 -1
  10. package/apple/SkiaCVPixelBufferUtils.mm +31 -30
  11. package/apple/SkiaPlatformContext.mm +2 -2
  12. package/apple/SkiaUIView.mm +1 -1
  13. package/apple/SkiaWebGPUView.mm +8 -4
  14. package/apple/WebGPUMetalView.h +1 -1
  15. package/apple/WebGPUMetalView.mm +1 -1
  16. package/cpp/api/JsiSkColor.h +8 -4
  17. package/cpp/api/JsiSkContourMeasure.h +4 -3
  18. package/cpp/api/JsiSkImage.h +17 -9
  19. package/cpp/api/JsiSkParagraphBuilder.h +14 -1
  20. package/cpp/api/JsiSkPath.h +71 -81
  21. package/cpp/api/JsiSkPathEffectFactory.h +2 -1
  22. package/cpp/api/JsiSkPathFactory.h +48 -52
  23. package/cpp/api/JsiSkShader.h +1 -1
  24. package/cpp/api/JsiSkShaderFactory.h +50 -26
  25. package/cpp/api/JsiSkSurfaceFactory.h +2 -1
  26. package/cpp/api/recorder/Drawings.h +5 -7
  27. package/cpp/api/recorder/Shaders.h +77 -22
  28. package/cpp/jsi2/JSIConverter.h +1 -1
  29. package/cpp/rnskia/RNDawnContext.h +14 -15
  30. package/cpp/rnskia/RNDawnUtils.h +14 -17
  31. package/cpp/rnskia/RNDawnWindowContext.h +1 -1
  32. package/cpp/rnskia/RNSkManager.cpp +5 -4
  33. package/cpp/rnskia/RNSkPlatformContext.h +2 -2
  34. package/cpp/rnwgpu/api/GPU.cpp +21 -0
  35. package/cpp/rnwgpu/api/GPUCanvasContext.cpp +1 -1
  36. package/cpp/rnwgpu/api/GPUCanvasContext.h +2 -2
  37. package/cpp/rnwgpu/api/GPUFeatures.h +0 -9
  38. package/cpp/rnwgpu/api/GPUTexture.h +14 -2
  39. package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +3 -4
  40. package/cpp/rnwgpu/api/RNWebGPU.h +1 -1
  41. package/cpp/rnwgpu/api/descriptors/Unions.h +0 -15
  42. package/cpp/skia/include/android/SkImageAndroid.h +7 -2
  43. package/cpp/skia/include/android/vk/AndroidVulkanMemoryAllocator.h +31 -0
  44. package/cpp/skia/include/codec/SkCodec.h +42 -15
  45. package/cpp/skia/include/config/SkUserConfig.h +8 -0
  46. package/cpp/skia/include/core/SkBitmap.h +0 -5
  47. package/cpp/skia/include/core/SkCanvas.h +2 -39
  48. package/cpp/skia/include/core/SkColor.h +12 -0
  49. package/cpp/skia/include/core/SkColorSpace.h +9 -0
  50. package/cpp/skia/include/core/SkContourMeasure.h +1 -5
  51. package/cpp/skia/include/core/SkData.h +8 -0
  52. package/cpp/skia/include/core/SkFont.h +1 -55
  53. package/cpp/skia/include/core/SkFontArguments.h +15 -0
  54. package/cpp/skia/include/core/SkGraphics.h +0 -5
  55. package/cpp/skia/include/core/SkImage.h +0 -4
  56. package/cpp/skia/include/core/SkImageGenerator.h +1 -4
  57. package/cpp/skia/include/core/SkMatrix.h +0 -37
  58. package/cpp/skia/include/core/SkMilestone.h +1 -1
  59. package/cpp/skia/include/core/SkPath.h +11 -911
  60. package/cpp/skia/include/core/SkPathBuilder.h +42 -32
  61. package/cpp/skia/include/core/SkPathEffect.h +0 -9
  62. package/cpp/skia/include/core/SkPathMeasure.h +1 -4
  63. package/cpp/skia/include/core/SkPathUtils.h +0 -10
  64. package/cpp/skia/include/core/SkRect.h +0 -12
  65. package/cpp/skia/include/core/SkRegion.h +1 -6
  66. package/cpp/skia/include/core/SkSerialProcs.h +4 -5
  67. package/cpp/skia/include/core/SkSurfaceProps.h +6 -0
  68. package/cpp/skia/include/core/SkTextBlob.h +0 -22
  69. package/cpp/skia/include/core/SkTypeface.h +14 -32
  70. package/cpp/skia/include/core/SkTypes.h +0 -8
  71. package/cpp/skia/include/docs/SkPDFDocument.h +19 -17
  72. package/cpp/skia/include/effects/SkDashPathEffect.h +0 -6
  73. package/cpp/skia/include/effects/SkGradient.h +206 -0
  74. package/cpp/skia/include/effects/SkHighContrastFilter.h +2 -2
  75. package/cpp/skia/include/gpu/GpuTypes.h +2 -0
  76. package/cpp/skia/include/gpu/ganesh/GrBackendSemaphore.h +5 -35
  77. package/cpp/skia/include/gpu/ganesh/GrBackendSurface.h +7 -106
  78. package/cpp/skia/include/gpu/ganesh/GrContextOptions.h +0 -11
  79. package/cpp/skia/include/gpu/ganesh/GrDirectContext.h +0 -9
  80. package/cpp/skia/include/gpu/ganesh/d3d/GrD3DBackendSemaphore.h +20 -0
  81. package/cpp/skia/include/gpu/ganesh/d3d/GrD3DBackendSurface.h +59 -0
  82. package/cpp/skia/include/gpu/ganesh/d3d/GrD3DDirectContext.h +28 -0
  83. package/cpp/skia/include/gpu/ganesh/gl/GrGLFunctions.h +4 -1
  84. package/cpp/skia/include/gpu/graphite/ContextOptions.h +4 -20
  85. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +32 -46
  86. package/cpp/skia/include/gpu/graphite/Recorder.h +1 -1
  87. package/cpp/skia/include/gpu/graphite/Surface.h +31 -0
  88. package/cpp/skia/include/gpu/graphite/TextureInfo.h +3 -10
  89. package/cpp/skia/include/gpu/graphite/dawn/DawnGraphiteTypes.h +3 -3
  90. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +1 -1
  91. package/cpp/skia/include/gpu/graphite/precompile/PrecompileShader.h +6 -6
  92. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +5 -3
  93. package/cpp/skia/include/gpu/graphite/vk/precompile/VulkanPrecompileShader.h +1 -1
  94. package/cpp/skia/include/gpu/vk/VulkanBackendContext.h +1 -1
  95. package/cpp/skia/include/gpu/vk/VulkanPreferredFeatures.h +8 -0
  96. package/cpp/skia/include/private/SkEncodedInfo.h +43 -105
  97. package/cpp/skia/include/private/SkHdrMetadata.h +165 -2
  98. package/cpp/skia/include/private/SkPathRef.h +0 -457
  99. package/cpp/skia/include/private/base/SkFeatures.h +4 -0
  100. package/cpp/skia/include/private/base/SkFloatingPoint.h +1 -2
  101. package/cpp/skia/include/private/base/SkLoadUserConfig.h +2 -1
  102. package/cpp/skia/include/private/base/SkLog.h +68 -0
  103. package/cpp/skia/include/private/base/SkLogPriority.h +35 -0
  104. package/cpp/skia/include/private/base/SkMacros.h +9 -0
  105. package/cpp/skia/include/private/base/SkTArray.h +1 -1
  106. package/cpp/skia/include/private/gpu/ganesh/GrD3DTypesMinimal.h +10 -24
  107. package/cpp/skia/include/utils/SkEventTracer.h +5 -7
  108. package/cpp/skia/modules/skottie/include/TextShaper.h +0 -7
  109. package/cpp/skia/modules/skparagraph/include/FontCollection.h +6 -20
  110. package/cpp/skia/modules/skparagraph/include/ParagraphBuilder.h +0 -6
  111. package/cpp/skia/modules/skparagraph/include/ParagraphCache.h +4 -19
  112. package/cpp/skia/modules/skparagraph/include/TypefaceFontProvider.h +2 -3
  113. package/cpp/skia/modules/skunicode/include/SkUnicode_icu.h +18 -0
  114. package/cpp/skia/modules/skunicode/include/SkUnicode_libgrapheme.h +19 -0
  115. package/cpp/skia/src/base/SkMathPriv.h +27 -132
  116. package/package.json +5 -5
  117. package/cpp/skia/include/effects/SkGradientShader.h +0 -359
  118. package/cpp/skia/include/gpu/graphite/LogPriority.h +0 -36
@@ -214,7 +214,6 @@ 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
217
  if(SK_GRAPHITE)
219
218
  add_library(dawn_combined STATIC IMPORTED)
220
219
  set_property(TARGET dawn_combined PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_PATH}/libdawn_combined.a")
@@ -1,10 +1,10 @@
1
- #include <jni.h>
2
1
  #include <android/native_window_jni.h>
2
+ #include <jni.h>
3
3
 
4
4
  #ifdef SK_GRAPHITE
5
- #include "webgpu/webgpu_cpp.h"
6
- #include "rnwgpu/SurfaceRegistry.h"
7
5
  #include "rnskia/RNDawnContext.h"
6
+ #include "rnwgpu/SurfaceRegistry.h"
7
+ #include "webgpu/webgpu_cpp.h"
8
8
  #endif
9
9
 
10
10
  extern "C" JNIEXPORT void JNICALL
@@ -59,7 +59,7 @@ public:
59
59
  }
60
60
 
61
61
  sk_sp<SkSurface> MakeOffscreen(int width, int height,
62
- bool useP3ColorSpace = false) {
62
+ bool useP3ColorSpace = false) {
63
63
  auto colorType = kRGBA_8888_SkColorType;
64
64
 
65
65
  SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
@@ -91,10 +91,9 @@ public:
91
91
  .texture = texture};
92
92
 
93
93
  sk_sp<SkColorSpace> colorSpace =
94
- useP3ColorSpace
95
- ? SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB,
96
- SkNamedGamut::kDisplayP3)
97
- : nullptr;
94
+ useP3ColorSpace ? SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB,
95
+ SkNamedGamut::kDisplayP3)
96
+ : nullptr;
98
97
 
99
98
  // Create a SkSurface from the GrBackendTexture
100
99
  return SkSurfaces::WrapBackendTexture(
@@ -51,7 +51,7 @@ public:
51
51
  }
52
52
 
53
53
  sk_sp<SkSurface> makeOffscreenSurface(int width, int height,
54
- bool useP3ColorSpace = false) override {
54
+ bool useP3ColorSpace = false) override {
55
55
  #if defined(SK_GRAPHITE)
56
56
  return DawnContext::getInstance().MakeOffscreen(width, height,
57
57
  useP3ColorSpace);
@@ -5,6 +5,7 @@
5
5
 
6
6
  #include "include/core/SkSurface.h"
7
7
 
8
+ #include "include/core/SkColorSpace.h"
8
9
  #import <include/gpu/ganesh/GrBackendSurface.h>
9
10
  #import <include/gpu/ganesh/GrDirectContext.h>
10
11
  #import <include/gpu/ganesh/SkImageGanesh.h>
@@ -13,7 +14,6 @@
13
14
  #import <include/gpu/ganesh/mtl/GrMtlBackendSurface.h>
14
15
  #import <include/gpu/ganesh/mtl/GrMtlDirectContext.h>
15
16
  #import <include/gpu/ganesh/mtl/SkSurfaceMetal.h>
16
- #include "include/core/SkColorSpace.h"
17
17
 
18
18
  struct OffscreenRenderContext {
19
19
  id<MTLTexture> texture;
@@ -46,7 +46,7 @@ public:
46
46
  }
47
47
 
48
48
  sk_sp<SkSurface> MakeOffscreen(int width, int height,
49
- bool useP3ColorSpace = false) {
49
+ bool useP3ColorSpace = false) {
50
50
  auto device = _device;
51
51
  auto ctx = new OffscreenRenderContext(device, _directContext, _commandQueue,
52
52
  width, height);
@@ -58,10 +58,9 @@ public:
58
58
  GrBackendTextures::MakeMtl(width, height, skgpu::Mipmapped::kNo, info);
59
59
 
60
60
  sk_sp<SkColorSpace> colorSpace =
61
- useP3ColorSpace
62
- ? SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB,
63
- SkNamedGamut::kDisplayP3)
64
- : nullptr;
61
+ useP3ColorSpace ? SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB,
62
+ SkNamedGamut::kDisplayP3)
63
+ : nullptr;
65
64
 
66
65
  // Create a SkSurface from the GrBackendTexture
67
66
  auto surface = SkSurfaces::WrapBackendTexture(
@@ -72,10 +72,9 @@ sk_sp<SkSurface> MetalWindowContext::getSurface() {
72
72
  _layer.drawableSize.width, _layer.drawableSize.height, fbInfo);
73
73
 
74
74
  sk_sp<SkColorSpace> skColorSpace =
75
- _useP3ColorSpace
76
- ? SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB,
77
- SkNamedGamut::kDisplayP3)
78
- : nullptr;
75
+ _useP3ColorSpace ? SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB,
76
+ SkNamedGamut::kDisplayP3)
77
+ : nullptr;
79
78
  _skSurface = SkSurfaces::WrapBackendRenderTarget(
80
79
  _directContext, backendRT, kTopLeft_GrSurfaceOrigin,
81
80
  kBGRA_8888_SkColorType, skColorSpace, nullptr);
@@ -70,7 +70,7 @@ public:
70
70
 
71
71
  void raiseError(const std::exception &err) override;
72
72
  sk_sp<SkSurface> makeOffscreenSurface(int width, int height,
73
- bool useP3ColorSpace = false) override;
73
+ bool useP3ColorSpace = false) override;
74
74
 
75
75
  sk_sp<SkFontMgr> createFontMgr() override;
76
76
 
@@ -251,11 +251,12 @@ void RNSkApplePlatformContext::raiseError(const std::exception &err) {
251
251
  RCTFatal(RCTErrorWithMessage([NSString stringWithUTF8String:err.what()]));
252
252
  }
253
253
 
254
- sk_sp<SkSurface> RNSkApplePlatformContext::makeOffscreenSurface(
255
- int width, int height, bool useP3ColorSpace) {
254
+ sk_sp<SkSurface>
255
+ RNSkApplePlatformContext::makeOffscreenSurface(int width, int height,
256
+ bool useP3ColorSpace) {
256
257
  #if defined(SK_GRAPHITE)
257
258
  return DawnContext::getInstance().MakeOffscreen(width, height,
258
- useP3ColorSpace);
259
+ useP3ColorSpace);
259
260
  #else
260
261
  return MetalContext::getInstance().MakeOffscreen(width, height,
261
262
  useP3ColorSpace);
@@ -9,8 +9,8 @@
9
9
 
10
10
  #import <vector>
11
11
 
12
- #import <CoreVideo/CVPixelBuffer.h>
13
12
  #import <CoreVideo/CVMetalTextureCache.h>
13
+ #import <CoreVideo/CVPixelBuffer.h>
14
14
  #import <MetalKit/MetalKit.h>
15
15
 
16
16
  #pragma clang diagnostic push
@@ -31,16 +31,12 @@
31
31
  #include <cmath>
32
32
  #if TARGET_RT_BIG_ENDIAN
33
33
  #define FourCC2Str(fourcc) \
34
- (const char[]) { \
35
- *((char *)&fourcc), *(((char *)&fourcc) + 1), *(((char *)&fourcc) + 2), \
36
- *(((char *)&fourcc) + 3), 0 \
37
- }
34
+ (const char[]){*((char *)&fourcc), *(((char *)&fourcc) + 1), \
35
+ *(((char *)&fourcc) + 2), *(((char *)&fourcc) + 3), 0}
38
36
  #else
39
37
  #define FourCC2Str(fourcc) \
40
- (const char[]) { \
41
- *(((char *)&fourcc) + 3), *(((char *)&fourcc) + 2), \
42
- *(((char *)&fourcc) + 1), *(((char *)&fourcc) + 0), 0 \
43
- }
38
+ (const char[]){*(((char *)&fourcc) + 3), *(((char *)&fourcc) + 2), \
39
+ *(((char *)&fourcc) + 1), *(((char *)&fourcc) + 0), 0}
44
40
  #endif
45
41
 
46
42
  // pragma MARK: TextureHolder
@@ -270,19 +266,20 @@ SkiaCVPixelBufferUtils::YUV::getSubsampling(OSType pixelFormat) {
270
266
 
271
267
  // pragma MARK: YUV getColorspace()
272
268
 
273
- SkYUVColorSpace SkiaCVPixelBufferUtils::YUV::getColorspace(
274
- CVPixelBufferRef pixelBuffer) {
269
+ SkYUVColorSpace
270
+ SkiaCVPixelBufferUtils::YUV::getColorspace(CVPixelBufferRef pixelBuffer) {
275
271
  const OSType pixelFormat = CVPixelBufferGetPixelFormatType(pixelBuffer);
276
272
 
277
- CFTypeRef matrixAttachment =
278
- CVBufferCopyAttachment(pixelBuffer, kCVImageBufferYCbCrMatrixKey, nullptr);
273
+ CFTypeRef matrixAttachment = CVBufferCopyAttachment(
274
+ pixelBuffer, kCVImageBufferYCbCrMatrixKey, nullptr);
279
275
  CFStringRef matrix = nullptr;
280
276
  if (matrixAttachment != nullptr &&
281
277
  CFGetTypeID(matrixAttachment) == CFStringGetTypeID()) {
282
278
  matrix = reinterpret_cast<CFStringRef>(matrixAttachment);
283
279
  }
284
280
 
285
- SkYUVColorSpace colorspace = getSkYUVColorSpaceFromMatrix(matrix, pixelFormat);
281
+ SkYUVColorSpace colorspace =
282
+ getSkYUVColorSpaceFromMatrix(matrix, pixelFormat);
286
283
  if (matrixAttachment != nullptr) {
287
284
  CFRelease(matrixAttachment);
288
285
  }
@@ -320,8 +317,9 @@ bool SkiaCVPixelBufferUtils::YUV::isTenBitYUVFormat(OSType pixelFormat) {
320
317
  }
321
318
  }
322
319
 
323
- SkYUVColorSpace SkiaCVPixelBufferUtils::YUV::getSkYUVColorSpaceFromMatrix(
324
- CFStringRef matrix, OSType pixelFormat) {
320
+ SkYUVColorSpace
321
+ SkiaCVPixelBufferUtils::YUV::getSkYUVColorSpaceFromMatrix(CFStringRef matrix,
322
+ OSType pixelFormat) {
325
323
  const bool isFullRange = isFullRangeYUVFormat(pixelFormat);
326
324
  const bool isTenBit = isTenBitYUVFormat(pixelFormat);
327
325
 
@@ -381,10 +379,11 @@ TextureHolder *SkiaCVPixelBufferUtils::getSkiaTextureForCVPixelBufferPlane(
381
379
  "Requested out-of-bounds plane index " + std::to_string(planeIndex) +
382
380
  " for pixel buffer with " + std::to_string(planesCount) + " planes.");
383
381
  }
384
- size_t width = planesCount > 0 ? CVPixelBufferGetWidthOfPlane(pixelBuffer, planeIndex)
385
- : CVPixelBufferGetWidth(pixelBuffer);
386
- size_t height =
387
- planesCount > 0 ? CVPixelBufferGetHeightOfPlane(pixelBuffer, planeIndex)
382
+ size_t width = planesCount > 0
383
+ ? CVPixelBufferGetWidthOfPlane(pixelBuffer, planeIndex)
384
+ : CVPixelBufferGetWidth(pixelBuffer);
385
+ size_t height = planesCount > 0
386
+ ? CVPixelBufferGetHeightOfPlane(pixelBuffer, planeIndex)
388
387
  : CVPixelBufferGetHeight(pixelBuffer);
389
388
  MTLPixelFormat pixelFormat =
390
389
  getMTLPixelFormatForCVPixelBufferPlane(pixelBuffer, planeIndex);
@@ -424,12 +423,12 @@ SkiaCVPixelBufferUtils::getTextureCache(id<MTLDevice> device) {
424
423
  MTLPixelFormat SkiaCVPixelBufferUtils::getMTLPixelFormatForCVPixelBufferPlane(
425
424
  CVPixelBufferRef pixelBuffer, size_t planeIndex) {
426
425
  const OSType format = CVPixelBufferGetPixelFormatType(pixelBuffer);
427
- auto throwInvalidPlaneIndexForFormat = [&](size_t expectedPlanes)
428
- -> MTLPixelFormat {
426
+ auto throwInvalidPlaneIndexForFormat =
427
+ [&](size_t expectedPlanes) -> MTLPixelFormat {
429
428
  throw std::runtime_error(
430
429
  "Invalid plane index " + std::to_string(planeIndex) +
431
- " for pixel format " + std::string(FourCC2Str(format)) + " (expected 0.." +
432
- std::to_string(expectedPlanes - 1) + ").");
430
+ " for pixel format " + std::string(FourCC2Str(format)) +
431
+ " (expected 0.." + std::to_string(expectedPlanes - 1) + ").");
433
432
  };
434
433
 
435
434
  switch (format) {
@@ -495,17 +494,18 @@ MTLPixelFormat SkiaCVPixelBufferUtils::getMTLPixelFormatForCVPixelBufferPlane(
495
494
  planesCount > 0 ? CVPixelBufferGetWidthOfPlane(pixelBuffer, planeIndex)
496
495
  : CVPixelBufferGetWidth(pixelBuffer);
497
496
  const size_t bytesPerRow =
498
- planesCount > 0 ? CVPixelBufferGetBytesPerRowOfPlane(pixelBuffer, planeIndex)
499
- : CVPixelBufferGetBytesPerRow(pixelBuffer);
497
+ planesCount > 0
498
+ ? CVPixelBufferGetBytesPerRowOfPlane(pixelBuffer, planeIndex)
499
+ : CVPixelBufferGetBytesPerRow(pixelBuffer);
500
500
  if (width == 0) [[unlikely]] {
501
501
  throw std::runtime_error("Invalid plane width for pixel format " +
502
502
  std::string(FourCC2Str(format)) + "!");
503
503
  }
504
504
  if (bytesPerRow % width != 0) [[unlikely]] {
505
- throw std::runtime_error(
506
- "Invalid bytes per row! Bytes per row must be evenly divisible by width "
507
- "for pixel format " +
508
- std::string(FourCC2Str(format)) + "!");
505
+ throw std::runtime_error("Invalid bytes per row! Bytes per row must be "
506
+ "evenly divisible by width "
507
+ "for pixel format " +
508
+ std::string(FourCC2Str(format)) + "!");
509
509
  }
510
510
  const size_t bytesPerPixel = bytesPerRow / width;
511
511
  if (bytesPerPixel == 1) {
@@ -519,6 +519,7 @@ MTLPixelFormat SkiaCVPixelBufferUtils::getMTLPixelFormatForCVPixelBufferPlane(
519
519
  }
520
520
 
521
521
  [[unlikely]] throw std::runtime_error(
522
- "Invalid bytes per row! Expected 1 (R), 2 (RG) or 4 (RGBA), but received " +
522
+ "Invalid bytes per row! Expected 1 (R), 2 (RG) or 4 (RGBA), but "
523
+ "received " +
523
524
  std::to_string(bytesPerPixel));
524
525
  }
@@ -7,8 +7,8 @@
7
7
  namespace rnwgpu {
8
8
 
9
9
  wgpu::Surface SkiaPlatformContext::makeSurface(wgpu::Instance instance,
10
- void *surface, int width,
11
- int height) {
10
+ void *surface, int width,
11
+ int height) {
12
12
  wgpu::SurfaceSourceMetalLayer metalSurfaceDesc;
13
13
  metalSurfaceDesc.layer = surface;
14
14
  wgpu::SurfaceDescriptor surfaceDescriptor;
@@ -1,5 +1,5 @@
1
- #import <React/RCTBridge.h>
2
1
  #import <QuartzCore/CATransaction.h>
2
+ #import <React/RCTBridge.h>
3
3
 
4
4
  #import "RNSkiaModule.h"
5
5
  #import "SkiaUIView.h"
@@ -7,8 +7,8 @@
7
7
  #import <react/renderer/components/rnskia/Props.h>
8
8
  #import <react/renderer/components/rnskia/RCTComponentViewHelpers.h>
9
9
 
10
- #import "WebGPUMetalView.h"
11
10
  #import "RCTFabricComponentsPlugins.h"
11
+ #import "WebGPUMetalView.h"
12
12
 
13
13
  using namespace facebook::react;
14
14
 
@@ -16,14 +16,16 @@ using namespace facebook::react;
16
16
 
17
17
  - (instancetype)initWithFrame:(CGRect)frame {
18
18
  if (self = [super initWithFrame:frame]) {
19
- static const auto defaultProps = std::make_shared<const SkiaWebGPUViewProps>();
19
+ static const auto defaultProps =
20
+ std::make_shared<const SkiaWebGPUViewProps>();
20
21
  _props = defaultProps;
21
22
  }
22
23
  return self;
23
24
  }
24
25
 
25
26
  + (ComponentDescriptorProvider)componentDescriptorProvider {
26
- return concreteComponentDescriptorProvider<SkiaWebGPUViewComponentDescriptor>();
27
+ return concreteComponentDescriptorProvider<
28
+ SkiaWebGPUViewComponentDescriptor>();
27
29
  }
28
30
 
29
31
  - (void)prepareForRecycle {
@@ -72,6 +74,8 @@ using namespace facebook::react;
72
74
 
73
75
  @end
74
76
 
75
- Class<RCTComponentViewProtocol> SkiaWebGPUViewCls(void) { return SkiaWebGPUView.class; }
77
+ Class<RCTComponentViewProtocol> SkiaWebGPUViewCls(void) {
78
+ return SkiaWebGPUView.class;
79
+ }
76
80
 
77
81
  #endif // RCT_NEW_ARCH_ENABLED
@@ -4,7 +4,7 @@
4
4
 
5
5
  @interface WebGPUMetalView : RNSkPlatformView
6
6
 
7
- @property (nonatomic, strong) NSNumber *contextId;
7
+ @property(nonatomic, strong) NSNumber *contextId;
8
8
 
9
9
  - (void)configure;
10
10
  - (void)update;
@@ -5,8 +5,8 @@
5
5
  #import "webgpu/webgpu_cpp.h"
6
6
  #import <QuartzCore/CAMetalLayer.h>
7
7
 
8
- #import "rnwgpu/SurfaceRegistry.h"
9
8
  #import "rnskia/RNDawnContext.h"
9
+ #import "rnwgpu/SurfaceRegistry.h"
10
10
 
11
11
  @implementation WebGPUMetalView {
12
12
  BOOL _isConfigured;
@@ -103,10 +103,14 @@ public:
103
103
  "Expected array of length 4 for color, got " +
104
104
  std::to_string(arr.size(runtime)));
105
105
  }
106
- auto r = static_cast<float>(arr.getValueAtIndex(runtime, 0).asNumber());
107
- auto g = static_cast<float>(arr.getValueAtIndex(runtime, 1).asNumber());
108
- auto b = static_cast<float>(arr.getValueAtIndex(runtime, 2).asNumber());
109
- auto a = static_cast<float>(arr.getValueAtIndex(runtime, 3).asNumber());
106
+ auto r =
107
+ static_cast<float>(arr.getValueAtIndex(runtime, 0).asNumber());
108
+ auto g =
109
+ static_cast<float>(arr.getValueAtIndex(runtime, 1).asNumber());
110
+ auto b =
111
+ static_cast<float>(arr.getValueAtIndex(runtime, 2).asNumber());
112
+ auto a =
113
+ static_cast<float>(arr.getValueAtIndex(runtime, 3).asNumber());
110
114
 
111
115
  // Create Float32Array and populate
112
116
  auto result = runtime.global()
@@ -58,12 +58,13 @@ public:
58
58
  auto start = arguments[0].asNumber();
59
59
  auto end = arguments[1].asNumber();
60
60
  auto startWithMoveTo = arguments[2].getBool();
61
- SkPath path;
62
- auto result = getObject()->getSegment(start, end, &path, startWithMoveTo);
61
+ SkPathBuilder builder;
62
+ auto result =
63
+ getObject()->getSegment(start, end, &builder, startWithMoveTo);
63
64
  if (!result) {
64
65
  throw jsi::JSError(runtime, "getSegment() failed");
65
66
  }
66
- return JsiSkPath::toValue(runtime, getContext(), std::move(path));
67
+ return JsiSkPath::toValue(runtime, getContext(), builder.snapshot());
67
68
  }
68
69
 
69
70
  size_t getMemoryPressure() const override { return 1024; }
@@ -46,30 +46,35 @@
46
46
  // recognise the canonical Apple profile, not Skia's mathematically equivalent
47
47
  // but non-standard one. Pixel values are untouched — zero quality loss.
48
48
  static sk_sp<SkData> replaceJpegICCWithAppleP3(sk_sp<SkData> jpegData) {
49
- if (!jpegData || jpegData->size() < 4) return jpegData;
49
+ if (!jpegData || jpegData->size() < 4)
50
+ return jpegData;
50
51
 
51
52
  const uint8_t *src = jpegData->bytes();
52
53
  size_t srcLen = jpegData->size();
53
- if (src[0] != 0xFF || src[1] != 0xD8) return jpegData; // not a JPEG
54
+ if (src[0] != 0xFF || src[1] != 0xD8)
55
+ return jpegData; // not a JPEG
54
56
 
55
57
  CGColorSpaceRef p3 = CGColorSpaceCreateWithName(kCGColorSpaceDisplayP3);
56
- if (!p3) return jpegData;
58
+ if (!p3)
59
+ return jpegData;
57
60
  CFDataRef cfICC = CGColorSpaceCopyICCData(p3);
58
61
  CGColorSpaceRelease(p3);
59
- if (!cfICC) return jpegData;
62
+ if (!cfICC)
63
+ return jpegData;
60
64
 
61
65
  const uint8_t *iccBytes = CFDataGetBytePtr(cfICC);
62
66
  size_t iccLen = (size_t)CFDataGetLength(cfICC);
63
67
 
64
68
  // "ICC_PROFILE\0" APP2 marker signature (12 bytes)
65
69
  static const uint8_t iccSig[] = {0x49, 0x43, 0x43, 0x5F, 0x50, 0x52,
66
- 0x4F, 0x46, 0x49, 0x4C, 0x45, 0x00};
70
+ 0x4F, 0x46, 0x49, 0x4C, 0x45, 0x00};
67
71
 
68
72
  SkDynamicMemoryWStream out;
69
73
 
70
74
  out.write(src, 2); // SOI
71
75
 
72
- // Structure: marker(2) + length(2) + "ICC_PROFILE\0"(12) + chunk[1,1](2) + profile
76
+ // Structure: marker(2) + length(2) + "ICC_PROFILE\0"(12) + chunk[1,1](2) +
77
+ // profile
73
78
  size_t iccContentLen = sizeof(iccSig) + 2 + iccLen;
74
79
  size_t segLen = iccContentLen + 2; // length field includes itself
75
80
  uint8_t app2hdr[4] = {0xFF, 0xE2, (uint8_t)(segLen >> 8),
@@ -83,12 +88,15 @@ static sk_sp<SkData> replaceJpegICCWithAppleP3(sk_sp<SkData> jpegData) {
83
88
  // Copy all header segments except any existing ICC APP2
84
89
  size_t i = 2;
85
90
  while (i + 3 < srcLen) {
86
- if (src[i] != 0xFF) break;
91
+ if (src[i] != 0xFF)
92
+ break;
87
93
  uint8_t marker = src[i + 1];
88
- if (marker == 0xDA || marker == 0xD9) break; // SOS / EOI
94
+ if (marker == 0xDA || marker == 0xD9)
95
+ break; // SOS / EOI
89
96
  size_t segLenVal = (size_t(src[i + 2]) << 8) | src[i + 3];
90
97
  size_t end = i + 2 + segLenVal;
91
- if (end > srcLen) break;
98
+ if (end > srcLen)
99
+ break;
92
100
  bool isICC = marker == 0xE2 && end > i + 4 + sizeof(iccSig) &&
93
101
  memcmp(src + i + 4, iccSig, sizeof(iccSig)) == 0;
94
102
  if (!isICC) {
@@ -19,6 +19,12 @@
19
19
 
20
20
  #include "modules/skparagraph/include/ParagraphBuilder.h"
21
21
 
22
+ #ifdef __APPLE__
23
+ #include "modules/skunicode/include/SkUnicode_libgrapheme.h"
24
+ #else
25
+ #include "modules/skunicode/include/SkUnicode_icu.h"
26
+ #endif
27
+
22
28
  #pragma clang diagnostic pop
23
29
 
24
30
  namespace RNSkia {
@@ -125,7 +131,14 @@ public:
125
131
  _fontCollection->setAssetFontManager(fontManager);
126
132
  }
127
133
  _fontCollection->enableFontFallback();
128
- _builder = para::ParagraphBuilder::make(paragraphStyle, _fontCollection);
134
+ sk_sp<SkUnicode> unicode;
135
+ #ifdef __APPLE__
136
+ unicode = SkUnicodes::Libgrapheme::Make();
137
+ #else
138
+ unicode = SkUnicodes::ICU::Make();
139
+ #endif
140
+ _builder =
141
+ para::ParagraphBuilder::make(paragraphStyle, _fontCollection, unicode);
129
142
  }
130
143
 
131
144
  private: