@shopify/react-native-skia 2.4.7 → 2.4.14

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 (117) hide show
  1. package/android/cpp/jni/JniPlatformContext.cpp +1 -1
  2. package/android/src/main/java/com/shopify/reactnative/skia/ViewScreenshotService.java +11 -1
  3. package/apple/RNSkApplePlatformContext.h +4 -0
  4. package/apple/RNSkApplePlatformContext.mm +69 -0
  5. package/apple/SkiaCVPixelBufferUtils.mm +8 -4
  6. package/cpp/api/JsiSkFontMgr.h +30 -6
  7. package/cpp/api/JsiSkImageFilterFactory.h +4 -2
  8. package/cpp/api/JsiSkPictureFactory.h +9 -6
  9. package/cpp/api/recorder/RNRecorder.h +33 -55
  10. package/cpp/rnskia/RNSkPlatformContext.h +16 -0
  11. package/cpp/skia/include/codec/SkAndroidCodec.h +3 -2
  12. package/cpp/skia/include/codec/SkAvifDecoder.h +2 -2
  13. package/cpp/skia/include/codec/SkBmpDecoder.h +1 -1
  14. package/cpp/skia/include/codec/SkCodec.h +2 -8
  15. package/cpp/skia/include/codec/SkEncodedOrigin.h +17 -0
  16. package/cpp/skia/include/codec/SkGifDecoder.h +1 -1
  17. package/cpp/skia/include/codec/SkIcoDecoder.h +1 -1
  18. package/cpp/skia/include/codec/SkJpegDecoder.h +8 -1
  19. package/cpp/skia/include/codec/SkJpegxlDecoder.h +1 -1
  20. package/cpp/skia/include/codec/SkPngDecoder.h +8 -1
  21. package/cpp/skia/include/codec/SkRawDecoder.h +1 -1
  22. package/cpp/skia/include/codec/SkWbmpDecoder.h +1 -1
  23. package/cpp/skia/include/codec/SkWebpDecoder.h +8 -1
  24. package/cpp/skia/include/core/SkCPURecorder.h +1 -0
  25. package/cpp/skia/include/core/SkCanvas.h +3 -2
  26. package/cpp/skia/include/core/SkColorTable.h +1 -1
  27. package/cpp/skia/include/core/SkColorType.h +4 -0
  28. package/cpp/skia/include/core/SkDocument.h +1 -1
  29. package/cpp/skia/include/core/SkGraphics.h +7 -2
  30. package/cpp/skia/include/core/SkImage.h +5 -1
  31. package/cpp/skia/include/core/SkImageGenerator.h +5 -3
  32. package/cpp/skia/include/core/SkM44.h +3 -3
  33. package/cpp/skia/include/core/SkMatrix.h +0 -23
  34. package/cpp/skia/include/core/SkMilestone.h +1 -1
  35. package/cpp/skia/include/core/SkOverdrawCanvas.h +1 -1
  36. package/cpp/skia/include/core/SkPath.h +216 -185
  37. package/cpp/skia/include/core/SkPathBuilder.h +97 -47
  38. package/cpp/skia/include/core/SkPathTypes.h +7 -1
  39. package/cpp/skia/include/core/SkPixmap.h +8 -8
  40. package/cpp/skia/include/core/SkRRect.h +24 -3
  41. package/cpp/skia/include/core/SkRecorder.h +3 -1
  42. package/cpp/skia/include/core/SkScalar.h +1 -1
  43. package/cpp/skia/include/core/SkSerialProcs.h +8 -4
  44. package/cpp/skia/include/core/SkStream.h +16 -9
  45. package/cpp/skia/include/core/SkString.h +1 -1
  46. package/cpp/skia/include/core/SkStrokeRec.h +1 -1
  47. package/cpp/skia/include/core/SkYUVAInfo.h +3 -0
  48. package/cpp/skia/include/docs/SkPDFDocument.h +1 -1
  49. package/cpp/skia/include/docs/SkPDFJpegHelpers.h +1 -1
  50. package/cpp/skia/include/docs/SkXPSDocument.h +18 -2
  51. package/cpp/skia/include/effects/SkRuntimeEffect.h +3 -1
  52. package/cpp/skia/include/encode/SkPngRustEncoder.h +18 -0
  53. package/cpp/skia/include/gpu/ganesh/GrBackendSurface.h +1 -1
  54. package/cpp/skia/include/gpu/ganesh/GrExternalTextureGenerator.h +1 -1
  55. package/cpp/skia/include/gpu/ganesh/GrRecordingContext.h +7 -6
  56. package/cpp/skia/include/gpu/ganesh/gl/GrGLBackendSurface.h +6 -0
  57. package/cpp/skia/include/gpu/ganesh/vk/GrBackendDrawableInfo.h +2 -4
  58. package/cpp/skia/include/gpu/graphite/Context.h +15 -1
  59. package/cpp/skia/include/gpu/graphite/ContextOptions.h +52 -11
  60. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +44 -0
  61. package/cpp/skia/include/gpu/graphite/LogPriority.h +1 -1
  62. package/cpp/skia/include/gpu/graphite/PersistentPipelineStorage.h +45 -0
  63. package/cpp/skia/include/gpu/graphite/PrecompileContext.h +1 -1
  64. package/cpp/skia/include/gpu/graphite/Recorder.h +14 -0
  65. package/cpp/skia/include/gpu/graphite/TextureInfo.h +13 -5
  66. package/cpp/skia/include/gpu/graphite/dawn/DawnGraphiteTypes.h +1 -4
  67. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +1 -4
  68. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +2 -8
  69. package/cpp/skia/include/gpu/vk/VulkanExtensions.h +1 -1
  70. package/cpp/skia/include/gpu/vk/VulkanTypes.h +124 -9
  71. package/cpp/skia/include/ports/SkFontMgr_fuchsia.h +3 -1
  72. package/cpp/skia/include/ports/SkImageGeneratorCG.h +1 -1
  73. package/cpp/skia/include/ports/SkImageGeneratorNDK.h +1 -1
  74. package/cpp/skia/include/ports/SkImageGeneratorWIC.h +1 -1
  75. package/cpp/skia/include/ports/SkTypeface_fontations.h +1 -1
  76. package/cpp/skia/include/private/SkEncodedInfo.h +38 -29
  77. package/cpp/skia/include/private/SkJpegMetadataDecoder.h +18 -13
  78. package/cpp/skia/include/private/SkPathRef.h +3 -6
  79. package/cpp/skia/include/private/base/SkAlign.h +3 -7
  80. package/cpp/skia/include/private/base/SkContainers.h +1 -1
  81. package/cpp/skia/include/private/base/SkSpan_impl.h +29 -0
  82. package/cpp/skia/include/private/base/SkTArray.h +7 -8
  83. package/cpp/skia/include/private/base/SkTDArray.h +4 -4
  84. package/cpp/skia/include/private/base/SkTemplates.h +5 -5
  85. package/cpp/skia/include/private/chromium/GrDeferredDisplayListRecorder.h +1 -1
  86. package/cpp/skia/include/private/gpu/ganesh/GrContext_Base.h +1 -1
  87. package/cpp/skia/include/private/gpu/ganesh/GrImageContext.h +1 -1
  88. package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +6 -5
  89. package/cpp/skia/include/svg/SkSVGCanvas.h +21 -1
  90. package/cpp/skia/include/utils/SkNoDrawCanvas.h +1 -1
  91. package/cpp/skia/include/utils/SkPaintFilterCanvas.h +1 -1
  92. package/cpp/skia/modules/skcms/src/skcms_public.h +29 -4
  93. package/cpp/skia/modules/skottie/include/Skottie.h +11 -0
  94. package/cpp/skia/modules/skottie/include/SlotManager.h +1 -1
  95. package/cpp/skia/modules/skparagraph/include/Metrics.h +1 -1
  96. package/cpp/skia/modules/skparagraph/include/Paragraph.h +1 -1
  97. package/cpp/skia/modules/sksg/include/SkSGMerge.h +1 -1
  98. package/cpp/skia/modules/sksg/include/SkSGPath.h +1 -1
  99. package/cpp/skia/modules/skshaper/include/SkShaper.h +2 -0
  100. package/cpp/skia/modules/skunicode/include/SkUnicode.h +4 -4
  101. package/cpp/skia/modules/svg/include/SkSVGAttributeParser.h +1 -1
  102. package/cpp/skia/modules/svg/include/SkSVGFeComponentTransfer.h +1 -1
  103. package/cpp/skia/modules/svg/include/SkSVGNode.h +1 -1
  104. package/cpp/skia/modules/svg/include/SkSVGPoly.h +1 -1
  105. package/cpp/skia/modules/svg/include/SkSVGShape.h +1 -1
  106. package/cpp/skia/modules/svg/include/SkSVGTransformableNode.h +1 -1
  107. package/cpp/skia/modules/svg/include/SkSVGValue.h +1 -1
  108. package/lib/commonjs/skia/core/Font.js +7 -1
  109. package/lib/commonjs/skia/core/Font.js.map +1 -1
  110. package/lib/module/skia/core/Font.js +7 -1
  111. package/lib/module/skia/core/Font.js.map +1 -1
  112. package/lib/typescript/lib/commonjs/skia/core/Font.d.ts +1 -1
  113. package/lib/typescript/lib/module/mock/index.d.ts +1 -1
  114. package/lib/typescript/lib/module/skia/core/Font.d.ts +1 -1
  115. package/package.json +8 -8
  116. package/scripts/install-skia.mjs +74 -1
  117. package/src/skia/core/Font.ts +9 -4
@@ -31,10 +31,17 @@ SK_API bool IsPng(const void*, size_t);
31
31
  SK_API std::unique_ptr<SkCodec> Decode(std::unique_ptr<SkStream>,
32
32
  SkCodec::Result*,
33
33
  SkCodecs::DecodeContext = nullptr);
34
- SK_API std::unique_ptr<SkCodec> Decode(sk_sp<SkData>,
34
+ SK_API std::unique_ptr<SkCodec> Decode(sk_sp<const SkData>,
35
35
  SkCodec::Result*,
36
36
  SkCodecs::DecodeContext = nullptr);
37
37
 
38
+ // TODO: remove after client migration
39
+ inline std::unique_ptr<SkCodec> Decode(sk_sp<SkData> data,
40
+ SkCodec::Result* result,
41
+ SkCodecs::DecodeContext ctx = nullptr) {
42
+ return Decode(sk_sp<const SkData>(static_cast<const SkData*>(data.release())), result, ctx);
43
+ }
44
+
38
45
  inline constexpr SkCodecs::Decoder Decoder() {
39
46
  return { "png", IsPng, Decode };
40
47
  }
@@ -36,7 +36,7 @@ inline bool IsRaw(const void*, size_t) {
36
36
  SK_API std::unique_ptr<SkCodec> Decode(std::unique_ptr<SkStream>,
37
37
  SkCodec::Result*,
38
38
  SkCodecs::DecodeContext = nullptr);
39
- SK_API std::unique_ptr<SkCodec> Decode(sk_sp<SkData>,
39
+ SK_API std::unique_ptr<SkCodec> Decode(sk_sp<const SkData>,
40
40
  SkCodec::Result*,
41
41
  SkCodecs::DecodeContext = nullptr);
42
42
 
@@ -31,7 +31,7 @@ SK_API bool IsWbmp(const void*, size_t);
31
31
  SK_API std::unique_ptr<SkCodec> Decode(std::unique_ptr<SkStream>,
32
32
  SkCodec::Result*,
33
33
  SkCodecs::DecodeContext = nullptr);
34
- SK_API std::unique_ptr<SkCodec> Decode(sk_sp<SkData>,
34
+ SK_API std::unique_ptr<SkCodec> Decode(sk_sp<const SkData>,
35
35
  SkCodec::Result*,
36
36
  SkCodecs::DecodeContext = nullptr);
37
37
 
@@ -31,10 +31,17 @@ SK_API bool IsWebp(const void*, size_t);
31
31
  SK_API std::unique_ptr<SkCodec> Decode(std::unique_ptr<SkStream>,
32
32
  SkCodec::Result*,
33
33
  SkCodecs::DecodeContext = nullptr);
34
- SK_API std::unique_ptr<SkCodec> Decode(sk_sp<SkData>,
34
+ SK_API std::unique_ptr<SkCodec> Decode(sk_sp<const SkData>,
35
35
  SkCodec::Result*,
36
36
  SkCodecs::DecodeContext = nullptr);
37
37
 
38
+ // TODO: remove after client migration
39
+ inline std::unique_ptr<SkCodec> Decode(sk_sp<SkData> data,
40
+ SkCodec::Result* result,
41
+ SkCodecs::DecodeContext ctx = nullptr) {
42
+ return Decode(sk_sp<const SkData>(static_cast<const SkData*>(data.release())), result, ctx);
43
+ }
44
+
38
45
  inline constexpr SkCodecs::Decoder Decoder() {
39
46
  return { "webp", IsWebp, Decode };
40
47
  }
@@ -57,6 +57,7 @@ public:
57
57
  private:
58
58
  // TODO (b/412351769): Implement this so we can capture from a CPU Recorder.
59
59
  SkCanvas* makeCaptureCanvas(SkCanvas*) final { return nullptr; }
60
+ void createCaptureBreakpoint(SkSurface*) final {}
60
61
  };
61
62
 
62
63
  inline Recorder* AsRecorder(SkRecorder* recorder) {
@@ -2601,7 +2601,8 @@ private:
2601
2601
 
2602
2602
  protected:
2603
2603
  // For use by SkNoDrawCanvas (via SkCanvasVirtualEnforcer, which can't be a friend)
2604
- SkCanvas(const SkIRect& bounds);
2604
+ explicit SkCanvas(const SkIRect& bounds);
2605
+
2605
2606
  private:
2606
2607
  SkCanvas(const SkBitmap&, std::unique_ptr<SkRasterHandleAllocator>,
2607
2608
  SkRasterHandleAllocator::Handle, const SkSurfaceProps* props);
@@ -2748,7 +2749,7 @@ private:
2748
2749
  goes out of scope. Use this to guarantee that the canvas is restored to a known
2749
2750
  state.
2750
2751
  */
2751
- class SkAutoCanvasRestore {
2752
+ class [[nodiscard]] SkAutoCanvasRestore {
2752
2753
  public:
2753
2754
 
2754
2755
  /** Preserves SkCanvas::save() count. Optionally saves SkCanvas clip and SkCanvas matrix.
@@ -50,7 +50,7 @@ public:
50
50
  private:
51
51
  friend class SkTableColorFilter; // for bitmap()
52
52
 
53
- SkColorTable(const SkBitmap& table) : fTable(table) {}
53
+ explicit SkColorTable(const SkBitmap& table) : fTable(table) {}
54
54
 
55
55
  // The returned SkBitmap is immutable; attempting to modify its pixel data will trigger asserts
56
56
  // in debug builds and cause undefined behavior in release builds.
@@ -119,6 +119,10 @@ enum SkColorType : int {
119
119
  // Single channel data (16 bits) interpreted as alpha. RGB are 0.
120
120
  // Bits: [A:15..0]
121
121
  kA16_unorm_SkColorType,
122
+ // Single channel data (16 bits) interpreted as red. G and B are forced to 0, alpha is forced to
123
+ // opaque.
124
+ // Bits: [R:15..0]
125
+ kR16_unorm_SkColorType,
122
126
  // Two channel RG data (16 bits per channel) packed into a LE 32-bit word. B is forced to 0,
123
127
  // alpha is forced to opaque.
124
128
  // Bits: [G:31..16 R:15..0]
@@ -62,7 +62,7 @@ public:
62
62
  void abort();
63
63
 
64
64
  protected:
65
- SkDocument(SkWStream*);
65
+ explicit SkDocument(SkWStream*);
66
66
 
67
67
  // note: subclasses must call close() in their destructor, as the base class
68
68
  // cannot do this for them.
@@ -140,8 +140,13 @@ public:
140
140
  */
141
141
  static void PurgeAllCaches();
142
142
 
143
- typedef std::unique_ptr<SkImageGenerator>
144
- (*ImageGeneratorFromEncodedDataFactory)(sk_sp<SkData>);
143
+ #if defined(SK_DISABLE_LEGACY_NONCONST_ENCODED_IMAGE_DATA)
144
+ using ImageGeneratorFromEncodedDataFactory =
145
+ std::unique_ptr<SkImageGenerator> (*)(sk_sp<const SkData>);
146
+ #else
147
+ using ImageGeneratorFromEncodedDataFactory =
148
+ std::unique_ptr<SkImageGenerator> (*)(sk_sp<SkData>);
149
+ #endif
145
150
 
146
151
  /**
147
152
  * To instantiate images from encoded data, first looks at this runtime function-ptr. If it
@@ -103,7 +103,7 @@ SK_API sk_sp<SkImage> RasterFromCompressedTextureData(sk_sp<SkData> data,
103
103
 
104
104
  example: https://fiddle.skia.org/c/@Image_DeferredFromEncodedData
105
105
  */
106
- SK_API sk_sp<SkImage> DeferredFromEncodedData(sk_sp<SkData> encoded,
106
+ SK_API sk_sp<SkImage> DeferredFromEncodedData(sk_sp<const SkData> encoded,
107
107
  std::optional<SkAlphaType> alphaType = std::nullopt);
108
108
 
109
109
  /** Creates SkImage from data returned by imageGenerator. The image data will not be created
@@ -739,7 +739,11 @@ public:
739
739
 
740
740
  example: https://fiddle.skia.org/c/@Image_refEncodedData
741
741
  */
742
+ #if defined(SK_DISABLE_LEGACY_NONCONST_ENCODED_IMAGE_DATA)
743
+ sk_sp<const SkData> refEncodedData() const;
744
+ #else
742
745
  sk_sp<SkData> refEncodedData() const;
746
+ #endif
743
747
 
744
748
  struct RequiredProperties {
745
749
  bool fMipmapped = false;
@@ -37,9 +37,7 @@ public:
37
37
  * If non-NULL is returned, the caller is responsible for calling
38
38
  * unref() on the data when it is finished.
39
39
  */
40
- sk_sp<SkData> refEncodedData() {
41
- return this->onRefEncodedData();
42
- }
40
+ sk_sp<const SkData> refEncodedData() { return this->onRefEncodedData(); }
43
41
 
44
42
  /**
45
43
  * Return the ImageInfo associated with this generator.
@@ -118,7 +116,11 @@ protected:
118
116
 
119
117
  SkImageGenerator(const SkImageInfo& info, uint32_t uniqueId = kNeedNewImageUniqueID);
120
118
 
119
+ #if defined(SK_DISABLE_LEGACY_NONCONST_ENCODED_IMAGE_DATA)
120
+ virtual sk_sp<const SkData> onRefEncodedData() { return nullptr; }
121
+ #else
121
122
  virtual sk_sp<SkData> onRefEncodedData() { return nullptr; }
123
+ #endif
122
124
  struct Options {};
123
125
  virtual bool onGetPixels(const SkImageInfo&, void*, size_t, const Options&) { return false; }
124
126
  virtual bool onIsValid(SkRecorder*) const { return true; }
@@ -19,8 +19,8 @@ struct SkRect;
19
19
  struct SK_API SkV2 {
20
20
  float x, y;
21
21
 
22
- bool operator==(const SkV2 v) const { return x == v.x && y == v.y; }
23
- bool operator!=(const SkV2 v) const { return !(*this == v); }
22
+ bool operator==(SkV2 v) const { return x == v.x && y == v.y; }
23
+ bool operator!=(SkV2 v) const { return !(*this == v); }
24
24
 
25
25
  static SkScalar Dot(SkV2 a, SkV2 b) { return a.x * b.x + a.y * b.y; }
26
26
  static SkScalar Cross(SkV2 a, SkV2 b) { return a.x * b.y - a.y * b.x; }
@@ -166,7 +166,7 @@ public:
166
166
  enum Uninitialized_Constructor {
167
167
  kUninitialized_Constructor
168
168
  };
169
- SkM44(Uninitialized_Constructor) {}
169
+ explicit SkM44(Uninitialized_Constructor) {}
170
170
 
171
171
  enum NaN_Constructor {
172
172
  kNaN_Constructor
@@ -28,17 +28,6 @@ struct SkSize;
28
28
  // Remove when clients are updated to live without this
29
29
  #define SK_SUPPORT_LEGACY_MATRIX_RECTTORECT
30
30
 
31
- #ifndef SK_SUPPORT_LEGACY_APPLYPERSPECTIVECLIP
32
- #define SK_SUPPORT_LEGACY_APPLYPERSPECTIVECLIP
33
- #endif
34
-
35
- #ifdef SK_SUPPORT_LEGACY_APPLYPERSPECTIVECLIP
36
- enum class SkApplyPerspectiveClip {
37
- kNo, //!< Don't pre-clip the geometry before applying the (perspective) matrix
38
- kYes, //!< Do pre-clip the geometry before applying the (perspective) matrix
39
- };
40
- #endif
41
-
42
31
  /** \class SkMatrix
43
32
  SkMatrix holds a 3x3 matrix for transforming coordinates. This allows mapping
44
33
  SkPoint and vectors with translation, scaling, skewing, rotation, and
@@ -1506,18 +1495,6 @@ public:
1506
1495
  */
1507
1496
  bool mapRect(SkRect* dst, const SkRect& src) const;
1508
1497
 
1509
- #ifdef SK_SUPPORT_LEGACY_APPLYPERSPECTIVECLIP
1510
- bool mapRect(SkRect* dst, const SkRect& src, SkApplyPerspectiveClip) const {
1511
- return this->mapRect(dst, src);
1512
- }
1513
- bool mapRect(SkRect* rect, SkApplyPerspectiveClip) const {
1514
- return this->mapRect(rect, *rect);
1515
- }
1516
- SkRect mapRect(const SkRect& src, SkApplyPerspectiveClip) const {
1517
- return this->mapRect(src);
1518
- }
1519
- #endif
1520
-
1521
1498
  /** Sets rect to bounds of rect corners mapped by SkMatrix.
1522
1499
  Returns true if mapped corners are computed rect corners.
1523
1500
 
@@ -5,5 +5,5 @@
5
5
  * found in the LICENSE file.
6
6
  */
7
7
  #ifndef SK_MILESTONE
8
- #define SK_MILESTONE 142
8
+ #define SK_MILESTONE 144
9
9
  #endif
@@ -44,7 +44,7 @@ struct SkRect;
44
44
  class SK_API SkOverdrawCanvas : public SkCanvasVirtualEnforcer<SkNWayCanvas> {
45
45
  public:
46
46
  /* Does not take ownership of canvas */
47
- SkOverdrawCanvas(SkCanvas*);
47
+ explicit SkOverdrawCanvas(SkCanvas*);
48
48
 
49
49
  void onDrawTextBlob(const SkTextBlob*, SkScalar, SkScalar, const SkPaint&) override;
50
50
  void onDrawGlyphRunList(