@shopify/react-native-skia 2.3.7 → 2.3.9

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 (94) hide show
  1. package/cpp/api/JsiNativeBuffer.h +4 -0
  2. package/cpp/api/JsiSkAnimatedImage.h +71 -1
  3. package/cpp/api/JsiSkAnimatedImageFactory.h +4 -0
  4. package/cpp/api/JsiSkApi.h +2 -0
  5. package/cpp/api/JsiSkCanvas.h +2 -0
  6. package/cpp/api/JsiSkColorFilter.h +2 -0
  7. package/cpp/api/JsiSkColorFilterFactory.h +4 -0
  8. package/cpp/api/JsiSkContourMeasure.h +2 -0
  9. package/cpp/api/JsiSkContourMeasureIter.h +4 -0
  10. package/cpp/api/JsiSkData.h +2 -0
  11. package/cpp/api/JsiSkDataFactory.h +2 -0
  12. package/cpp/api/JsiSkFont.h +2 -0
  13. package/cpp/api/JsiSkFontMgr.h +2 -0
  14. package/cpp/api/JsiSkFontMgrFactory.h +2 -0
  15. package/cpp/api/JsiSkFontStyle.h +2 -0
  16. package/cpp/api/JsiSkHostObjects.h +50 -0
  17. package/cpp/api/JsiSkImage.h +3 -1
  18. package/cpp/api/JsiSkImageFactory.h +2 -0
  19. package/cpp/api/JsiSkImageFilter.h +3 -1
  20. package/cpp/api/JsiSkImageFilterFactory.h +4 -0
  21. package/cpp/api/JsiSkImageInfo.h +2 -0
  22. package/cpp/api/JsiSkMaskFilter.h +2 -0
  23. package/cpp/api/JsiSkMaskFilterFactory.h +4 -0
  24. package/cpp/api/JsiSkMatrix.h +2 -0
  25. package/cpp/api/JsiSkPaint.h +2 -0
  26. package/cpp/api/JsiSkParagraph.h +3 -1
  27. package/cpp/api/JsiSkParagraphBuilder.h +3 -1
  28. package/cpp/api/JsiSkParagraphBuilderFactory.h +5 -1
  29. package/cpp/api/JsiSkPath.h +2 -0
  30. package/cpp/api/JsiSkPathEffect.h +2 -0
  31. package/cpp/api/JsiSkPathEffectFactory.h +4 -0
  32. package/cpp/api/JsiSkPathFactory.h +2 -0
  33. package/cpp/api/JsiSkPicture.h +2 -0
  34. package/cpp/api/JsiSkPictureFactory.h +10 -0
  35. package/cpp/api/JsiSkPictureRecorder.h +3 -3
  36. package/cpp/api/JsiSkPoint.h +2 -0
  37. package/cpp/api/JsiSkRRect.h +2 -0
  38. package/cpp/api/JsiSkRSXform.h +2 -0
  39. package/cpp/api/JsiSkRect.h +2 -0
  40. package/cpp/api/JsiSkRuntimeEffect.h +2 -0
  41. package/cpp/api/JsiSkRuntimeEffectFactory.h +4 -0
  42. package/cpp/api/JsiSkRuntimeShaderBuilder.h +4 -0
  43. package/cpp/api/JsiSkSVG.h +2 -0
  44. package/cpp/api/JsiSkSVGFactory.h +2 -0
  45. package/cpp/api/JsiSkShader.h +3 -1
  46. package/cpp/api/JsiSkShaderFactory.h +2 -0
  47. package/cpp/api/JsiSkSkottie.h +2 -0
  48. package/cpp/api/JsiSkSurface.h +50 -7
  49. package/cpp/api/JsiSkSurfaceFactory.h +2 -0
  50. package/cpp/api/JsiSkTextBlob.h +2 -0
  51. package/cpp/api/JsiSkTextBlobFactory.h +2 -0
  52. package/cpp/api/JsiSkTypeface.h +2 -0
  53. package/cpp/api/JsiSkTypefaceFactory.h +2 -0
  54. package/cpp/api/JsiSkTypefaceFontProvider.h +4 -0
  55. package/cpp/api/JsiSkTypefaceFontProviderFactory.h +4 -0
  56. package/cpp/api/JsiSkVertices.h +2 -0
  57. package/cpp/api/JsiSkiaContext.h +3 -1
  58. package/cpp/api/JsiSkottieFactory.h +2 -0
  59. package/cpp/api/JsiVideo.h +2 -0
  60. package/cpp/api/recorder/JsiRecorder.h +42 -7
  61. package/cpp/jsi/ViewProperty.h +32 -1
  62. package/lib/commonjs/skia/types/Picture/PictureFactory.d.ts +1 -1
  63. package/lib/commonjs/skia/types/Picture/PictureFactory.js.map +1 -1
  64. package/lib/commonjs/skia/types/Recorder.d.ts +2 -1
  65. package/lib/commonjs/skia/types/Recorder.js.map +1 -1
  66. package/lib/commonjs/sksg/Container.native.d.ts +4 -0
  67. package/lib/commonjs/sksg/Container.native.js +18 -6
  68. package/lib/commonjs/sksg/Container.native.js.map +1 -1
  69. package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +1 -0
  70. package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js +4 -0
  71. package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
  72. package/lib/module/skia/types/Picture/PictureFactory.d.ts +1 -1
  73. package/lib/module/skia/types/Picture/PictureFactory.js.map +1 -1
  74. package/lib/module/skia/types/Recorder.d.ts +2 -1
  75. package/lib/module/skia/types/Recorder.js.map +1 -1
  76. package/lib/module/sksg/Container.native.d.ts +4 -0
  77. package/lib/module/sksg/Container.native.js +18 -6
  78. package/lib/module/sksg/Container.native.js.map +1 -1
  79. package/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +1 -0
  80. package/lib/module/sksg/Recorder/ReanimatedRecorder.js +4 -0
  81. package/lib/module/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
  82. package/lib/typescript/lib/commonjs/sksg/Container.native.d.ts +5 -0
  83. package/lib/typescript/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +1 -0
  84. package/lib/typescript/lib/module/sksg/Container.native.d.ts +5 -0
  85. package/lib/typescript/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +1 -0
  86. package/lib/typescript/src/skia/types/Picture/PictureFactory.d.ts +1 -1
  87. package/lib/typescript/src/skia/types/Recorder.d.ts +2 -1
  88. package/lib/typescript/src/sksg/Container.native.d.ts +4 -0
  89. package/lib/typescript/src/sksg/Recorder/ReanimatedRecorder.d.ts +1 -0
  90. package/package.json +1 -1
  91. package/src/skia/types/Picture/PictureFactory.ts +1 -1
  92. package/src/skia/types/Recorder.ts +2 -1
  93. package/src/sksg/Container.native.ts +25 -7
  94. package/src/sksg/Recorder/ReanimatedRecorder.ts +5 -0
@@ -38,6 +38,10 @@ public:
38
38
 
39
39
  size_t getMemoryPressure() const override { return 1024; }
40
40
 
41
+ std::string getObjectType() const override {
42
+ return "JsiNativeBufferFactory";
43
+ }
44
+
41
45
  explicit JsiNativeBufferFactory(std::shared_ptr<RNSkPlatformContext> context)
42
46
  : JsiSkHostObject(std::move(context)) {}
43
47
  };
@@ -1,5 +1,8 @@
1
1
  #pragma once
2
2
 
3
+ #include <algorithm>
4
+ #include <cmath>
5
+ #include <limits>
3
6
  #include <memory>
4
7
  #include <string>
5
8
  #include <utility>
@@ -63,7 +66,74 @@ public:
63
66
  : JsiSkWrappingSkPtrHostObject<SkAnimatedImage>(std::move(context),
64
67
  std::move(image)) {}
65
68
 
66
- size_t getMemoryPressure() const override { return 8192; }
69
+ size_t getMemoryPressure() const override {
70
+ auto animation = getObject();
71
+ if (!animation) {
72
+ return 0;
73
+ }
74
+
75
+ const auto safeMul = [](size_t a, size_t b) {
76
+ if (a == 0 || b == 0) {
77
+ return static_cast<size_t>(0);
78
+ }
79
+ if (std::numeric_limits<size_t>::max() / a < b) {
80
+ return std::numeric_limits<size_t>::max();
81
+ }
82
+ return a * b;
83
+ };
84
+
85
+ const auto safeAdd = [](size_t a, size_t b) {
86
+ if (std::numeric_limits<size_t>::max() - a < b) {
87
+ return std::numeric_limits<size_t>::max();
88
+ }
89
+ return a + b;
90
+ };
91
+
92
+ SkRect bounds = animation->getBounds();
93
+ auto width = std::max<SkScalar>(0, bounds.width());
94
+ auto height = std::max<SkScalar>(0, bounds.height());
95
+ size_t frameWidth =
96
+ static_cast<size_t>(std::ceil(static_cast<double>(width)));
97
+ size_t frameHeight =
98
+ static_cast<size_t>(std::ceil(static_cast<double>(height)));
99
+
100
+ size_t frameBytes = safeMul(safeMul(frameWidth, frameHeight),
101
+ static_cast<size_t>(4)); // RGBA bytes
102
+ if (frameBytes == 0) {
103
+ if (auto frame = animation->getCurrentFrame()) {
104
+ auto frameInfo = frame->imageInfo();
105
+ size_t bytesPerPixel = static_cast<size_t>(frameInfo.bytesPerPixel());
106
+ if (bytesPerPixel == 0) {
107
+ bytesPerPixel = 4;
108
+ }
109
+ frameBytes =
110
+ safeMul(safeMul(static_cast<size_t>(frame->width()),
111
+ static_cast<size_t>(frame->height())),
112
+ bytesPerPixel);
113
+ }
114
+ }
115
+
116
+ if (frameBytes == 0) {
117
+ return 0;
118
+ }
119
+
120
+ int frameCount = animation->getFrameCount();
121
+ if (frameCount <= 0) {
122
+ frameCount = 1;
123
+ }
124
+
125
+ // Animated images keep display, decoding, and restore frames resident.
126
+ size_t cachedFrames =
127
+ static_cast<size_t>(std::min(frameCount, 3)); // triple buffering
128
+ size_t estimated = safeMul(frameBytes, cachedFrames);
129
+
130
+ // Include codec/metadata overhead.
131
+ estimated = safeAdd(estimated, 256 * 1024);
132
+
133
+ return estimated;
134
+ }
135
+
136
+ std::string getObjectType() const override { return "JsiSkAnimatedImage"; }
67
137
  };
68
138
 
69
139
  } // namespace RNSkia
@@ -31,6 +31,10 @@ public:
31
31
 
32
32
  size_t getMemoryPressure() const override { return 1024; }
33
33
 
34
+ std::string getObjectType() const override {
35
+ return "JsiSkAnimatedImageFactory";
36
+ }
37
+
34
38
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkAnimatedImageFactory,
35
39
  MakeAnimatedImageFromEncoded))
36
40
 
@@ -63,6 +63,8 @@ class JsiSkApi : public JsiSkHostObject {
63
63
  public:
64
64
  size_t getMemoryPressure() const override { return 8192; }
65
65
 
66
+ std::string getObjectType() const override { return "JsiSkApi"; }
67
+
66
68
  /**
67
69
  * Constructs the Skia Api object that can be installed into a runtime
68
70
  * and provide functions for accessing and creating the Skia wrapper objects
@@ -695,6 +695,8 @@ public:
695
695
 
696
696
  size_t getMemoryPressure() const override { return 1024; }
697
697
 
698
+ std::string getObjectType() const override { return "JsiSkCanvas"; }
699
+
698
700
  explicit JsiSkCanvas(std::shared_ptr<RNSkPlatformContext> context)
699
701
  : JsiSkHostObject(std::move(context)) {}
700
702
 
@@ -25,6 +25,8 @@ public:
25
25
 
26
26
  size_t getMemoryPressure() const override { return 2048; }
27
27
 
28
+ std::string getObjectType() const override { return "JsiSkColorFilter"; }
29
+
28
30
  EXPORT_JSI_API_TYPENAME(JsiSkColorFilter, ColorFilter)
29
31
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkColorFilter, dispose))
30
32
  };
@@ -94,6 +94,10 @@ public:
94
94
 
95
95
  size_t getMemoryPressure() const override { return 1024; }
96
96
 
97
+ std::string getObjectType() const override {
98
+ return "JsiSkColorFilterFactory";
99
+ }
100
+
97
101
  JSI_EXPORT_FUNCTIONS(
98
102
  JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeMatrix),
99
103
  JSI_EXPORT_FUNC(JsiSkColorFilterFactory, MakeBlend),
@@ -68,6 +68,8 @@ public:
68
68
 
69
69
  size_t getMemoryPressure() const override { return 1024; }
70
70
 
71
+ std::string getObjectType() const override { return "JsiSkContourMeasure"; }
72
+
71
73
  EXPORT_JSI_API_TYPENAME(JsiSkContourMeasure, ContourMeasure)
72
74
 
73
75
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkContourMeasure, getPosTan),
@@ -50,6 +50,10 @@ public:
50
50
  return sizeof(SkContourMeasureIter);
51
51
  }
52
52
 
53
+ std::string getObjectType() const override {
54
+ return "JsiSkContourMeasureIter";
55
+ }
56
+
53
57
  /**
54
58
  * Creates the function for construction a new instance of the
55
59
  * SkContourMeasureIter wrapper
@@ -29,6 +29,8 @@ public:
29
29
  return data ? data->size() : 0;
30
30
  }
31
31
 
32
+ std::string getObjectType() const override { return "JsiSkData"; }
33
+
32
34
  EXPORT_JSI_API_TYPENAME(JsiSkData, Data)
33
35
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkData, dispose))
34
36
  };
@@ -93,6 +93,8 @@ public:
93
93
 
94
94
  size_t getMemoryPressure() const override { return 1024; }
95
95
 
96
+ std::string getObjectType() const override { return "JsiSkDataFactory"; }
97
+
96
98
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkDataFactory, fromURI),
97
99
  JSI_EXPORT_FUNC(JsiSkDataFactory, fromBytes),
98
100
  JSI_EXPORT_FUNC(JsiSkDataFactory, fromBase64))
@@ -281,6 +281,8 @@ public:
281
281
 
282
282
  size_t getMemoryPressure() const override { return sizeof(SkFont); }
283
283
 
284
+ std::string getObjectType() const override { return "JsiSkFont"; }
285
+
284
286
  /**
285
287
  * Creates the function for construction a new instance of the SkFont
286
288
  * wrapper
@@ -50,6 +50,8 @@ public:
50
50
 
51
51
  size_t getMemoryPressure() const override { return 2048; }
52
52
 
53
+ std::string getObjectType() const override { return "JsiSkFontMgr"; }
54
+
53
55
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkFontMgr, countFamilies),
54
56
  JSI_EXPORT_FUNC(JsiSkFontMgr, getFamilyName),
55
57
  JSI_EXPORT_FUNC(JsiSkFontMgr, matchFamilyStyle))
@@ -41,6 +41,8 @@ public:
41
41
 
42
42
  size_t getMemoryPressure() const override { return 1024; }
43
43
 
44
+ std::string getObjectType() const override { return "JsiSkFontMgrFactory"; }
45
+
44
46
  explicit JsiSkFontMgrFactory(std::shared_ptr<RNSkPlatformContext> context)
45
47
  : JsiSkHostObject(std::move(context)) {}
46
48
  };
@@ -58,6 +58,8 @@ public:
58
58
 
59
59
  size_t getMemoryPressure() const override { return sizeof(SkFontStyle); }
60
60
 
61
+ std::string getObjectType() const override { return "JsiSkFontStyle"; }
62
+
61
63
  /**
62
64
  Returns the jsi object from a host object of this type
63
65
  */
@@ -1,9 +1,11 @@
1
1
  #pragma once
2
2
 
3
3
  #include <memory>
4
+ #include <string>
4
5
  #include <utility>
5
6
 
6
7
  #include "JsiHostObject.h"
8
+ #include "RNSkLog.h"
7
9
  #include "RNSkPlatformContext.h"
8
10
 
9
11
  namespace RNSkia {
@@ -29,6 +31,11 @@ public:
29
31
  */
30
32
  virtual size_t getMemoryPressure() const = 0;
31
33
 
34
+ /**
35
+ * Returns the type name of the host object.
36
+ */
37
+ virtual std::string getObjectType() const = 0;
38
+
32
39
  protected:
33
40
  /**
34
41
  * @return A pointer to the platform context
@@ -48,6 +55,48 @@ private:
48
55
  JSI_API_TYPENAME(TYPENAME) \
49
56
  JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(CLASS, __typename__))
50
57
 
58
+ // Define this macro to enable memory pressure debug logging
59
+ // #define RNSKIA_DEBUG_MEMORY_PRESSURE
60
+
61
+ #ifdef RNSKIA_DEBUG_MEMORY_PRESSURE
62
+ // Version with debug logging
63
+ #define JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE( \
64
+ runtime, hostObjectInstance, context) \
65
+ [&]() { \
66
+ auto result = \
67
+ jsi::Object::createFromHostObject(runtime, hostObjectInstance); \
68
+ auto memoryPressure = hostObjectInstance->getMemoryPressure(); \
69
+ const void *hostObjectId = \
70
+ static_cast<const void *>(hostObjectInstance.get()); \
71
+ const char *mpUnit = "bytes"; \
72
+ double mpValue = static_cast<double>(memoryPressure); \
73
+ if (memoryPressure >= 1024ULL * 1024ULL) { \
74
+ mpUnit = "MB"; \
75
+ mpValue /= (1024.0 * 1024.0); \
76
+ RNSkLogger::logToConsole( \
77
+ "Host object %s (id=%p) memory pressure %.2f %s", \
78
+ hostObjectInstance->getObjectType().c_str(), hostObjectId, mpValue, \
79
+ mpUnit); \
80
+ } else if (memoryPressure >= 1024ULL) { \
81
+ mpUnit = "KB"; \
82
+ mpValue /= 1024.0; \
83
+ RNSkLogger::logToConsole( \
84
+ "Host object %s (id=%p) memory pressure %.2f %s", \
85
+ hostObjectInstance->getObjectType().c_str(), hostObjectId, mpValue, \
86
+ mpUnit); \
87
+ } else { \
88
+ RNSkLogger::logToConsole( \
89
+ "Host object %s (id=%p) memory pressure %zu %s", \
90
+ hostObjectInstance->getObjectType().c_str(), hostObjectId, \
91
+ memoryPressure, mpUnit); \
92
+ } \
93
+ if (memoryPressure > 0) { \
94
+ result.setExternalMemoryPressure(runtime, memoryPressure); \
95
+ } \
96
+ return result; \
97
+ }()
98
+ #else
99
+ // Version without debug logging (optimized)
51
100
  #define JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE( \
52
101
  runtime, hostObjectInstance, context) \
53
102
  [&]() { \
@@ -59,6 +108,7 @@ private:
59
108
  } \
60
109
  return result; \
61
110
  }()
111
+ #endif
62
112
 
63
113
  template <typename T> class JsiSkWrappingHostObject : public JsiSkHostObject {
64
114
  public:
@@ -316,6 +316,8 @@ public:
316
316
  }
317
317
  return 0;
318
318
  }
319
+
320
+ std::string getObjectType() const override { return "JsiSkImage"; }
319
321
  };
320
322
 
321
- } // namespace RNSkia
323
+ } // namespace RNSkia
@@ -115,6 +115,8 @@ public:
115
115
 
116
116
  size_t getMemoryPressure() const override { return 1024; }
117
117
 
118
+ std::string getObjectType() const override { return "JsiSkImageFactory"; }
119
+
118
120
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkImageFactory, MakeImageFromEncoded),
119
121
  JSI_EXPORT_FUNC(JsiSkImageFactory, MakeImageFromViewTag),
120
122
  JSI_EXPORT_FUNC(JsiSkImageFactory,
@@ -25,7 +25,9 @@ public:
25
25
  : JsiSkWrappingSkPtrHostObject<SkImageFilter>(std::move(context),
26
26
  std::move(imageFilter)) {}
27
27
 
28
- size_t getMemoryPressure() const override { return 4096; }
28
+ size_t getMemoryPressure() const override { return 1024 * 1024; }
29
+
30
+ std::string getObjectType() const override { return "JsiSkImageFilter"; }
29
31
 
30
32
  EXPORT_JSI_API_TYPENAME(JsiSkImageFilter, ImageFilter)
31
33
  };
@@ -689,6 +689,10 @@ public:
689
689
 
690
690
  size_t getMemoryPressure() const override { return 2048; }
691
691
 
692
+ std::string getObjectType() const override {
693
+ return "JsiSkImageFilterFactory";
694
+ }
695
+
692
696
  explicit JsiSkImageFilterFactory(std::shared_ptr<RNSkPlatformContext> context)
693
697
  : JsiSkHostObject(std::move(context)) {}
694
698
  };
@@ -71,6 +71,8 @@ public:
71
71
 
72
72
  size_t getMemoryPressure() const override { return sizeof(SkImageInfo); }
73
73
 
74
+ std::string getObjectType() const override { return "JsiSkImageInfo"; }
75
+
74
76
  JSI_API_TYPENAME(ImageInfo);
75
77
 
76
78
  JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkImageInfo, width),
@@ -27,6 +27,8 @@ public:
27
27
 
28
28
  size_t getMemoryPressure() const override { return 2048; }
29
29
 
30
+ std::string getObjectType() const override { return "JsiSkMaskFilter"; }
31
+
30
32
  EXPORT_JSI_API_TYPENAME(JsiSkMaskFilter, MaskFilter)
31
33
  };
32
34
 
@@ -34,6 +34,10 @@ public:
34
34
 
35
35
  size_t getMemoryPressure() const override { return 1024; }
36
36
 
37
+ std::string getObjectType() const override {
38
+ return "JsiSkMaskFilterFactory";
39
+ }
40
+
37
41
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkMaskFilterFactory, MakeBlur))
38
42
 
39
43
  explicit JsiSkMaskFilterFactory(std::shared_ptr<RNSkPlatformContext> context)
@@ -168,6 +168,8 @@ public:
168
168
 
169
169
  size_t getMemoryPressure() const override { return sizeof(SkMatrix); }
170
170
 
171
+ std::string getObjectType() const override { return "JsiSkMatrix"; }
172
+
171
173
  static const jsi::HostFunctionType
172
174
  createCtor(std::shared_ptr<RNSkPlatformContext> context) {
173
175
  return JSI_HOST_FUNCTION_LAMBDA {
@@ -210,6 +210,8 @@ public:
210
210
 
211
211
  size_t getMemoryPressure() const override { return sizeof(SkPaint); }
212
212
 
213
+ std::string getObjectType() const override { return "JsiSkPaint"; }
214
+
213
215
  /**
214
216
  * Creates the function for construction a new instance of the SkPaint
215
217
  * wrapper
@@ -171,7 +171,9 @@ public:
171
171
  JSI_EXPORT_FUNC(JsiSkParagraph, getLineMetrics),
172
172
  JSI_EXPORT_FUNC(JsiSkParagraph, dispose))
173
173
 
174
- size_t getMemoryPressure() const override { return 8192; }
174
+ size_t getMemoryPressure() const override { return 1024 * 1024; }
175
+
176
+ std::string getObjectType() const override { return "JsiSkParagraph"; }
175
177
 
176
178
  explicit JsiSkParagraph(std::shared_ptr<RNSkPlatformContext> context,
177
179
  para::ParagraphBuilder *paragraphBuilder)
@@ -110,7 +110,9 @@ public:
110
110
  JSI_EXPORT_FUNC(JsiSkParagraphBuilder, pushStyle),
111
111
  JSI_EXPORT_FUNC(JsiSkParagraphBuilder, pop))
112
112
 
113
- size_t getMemoryPressure() const override { return 4096; }
113
+ size_t getMemoryPressure() const override { return 1024 * 1024; }
114
+
115
+ std::string getObjectType() const override { return "JsiSkParagraphBuilder"; }
114
116
 
115
117
  explicit JsiSkParagraphBuilder(std::shared_ptr<RNSkPlatformContext> context,
116
118
  para::ParagraphStyle paragraphStyle,
@@ -47,7 +47,11 @@ public:
47
47
 
48
48
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkParagraphBuilderFactory, Make))
49
49
 
50
- size_t getMemoryPressure() const override { return 3072; }
50
+ size_t getMemoryPressure() const override { return 1024 * 1024; }
51
+
52
+ std::string getObjectType() const override {
53
+ return "JsiSkParagraphBuilderFactory";
54
+ }
51
55
 
52
56
  explicit JsiSkParagraphBuilderFactory(
53
57
  std::shared_ptr<RNSkPlatformContext> context)
@@ -649,6 +649,8 @@ public:
649
649
  return path->approximateBytesUsed();
650
650
  }
651
651
 
652
+ std::string getObjectType() const override { return "JsiSkPath"; }
653
+
652
654
  static jsi::Value toValue(jsi::Runtime &runtime,
653
655
  std::shared_ptr<RNSkPlatformContext> context,
654
656
  const SkPath &path) {
@@ -27,6 +27,8 @@ public:
27
27
 
28
28
  size_t getMemoryPressure() const override { return 2048; }
29
29
 
30
+ std::string getObjectType() const override { return "JsiSkPathEffect"; }
31
+
30
32
  EXPORT_JSI_API_TYPENAME(JsiSkPathEffect, PathEffect)
31
33
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkPathEffect, dispose))
32
34
  };
@@ -126,6 +126,10 @@ public:
126
126
 
127
127
  size_t getMemoryPressure() const override { return 1024; }
128
128
 
129
+ std::string getObjectType() const override {
130
+ return "JsiSkPathEffectFactory";
131
+ }
132
+
129
133
  explicit JsiSkPathEffectFactory(std::shared_ptr<RNSkPlatformContext> context)
130
134
  : JsiSkHostObject(std::move(context)) {}
131
135
  };
@@ -172,6 +172,8 @@ public:
172
172
 
173
173
  size_t getMemoryPressure() const override { return 1024; }
174
174
 
175
+ std::string getObjectType() const override { return "JsiSkPathFactory"; }
176
+
175
177
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkPathFactory, Make),
176
178
  JSI_EXPORT_FUNC(JsiSkPathFactory, MakeFromSVGString),
177
179
  JSI_EXPORT_FUNC(JsiSkPathFactory, MakeFromOp),
@@ -99,5 +99,7 @@ public:
99
99
  auto bytesUsed = picture->approximateBytesUsed();
100
100
  return bytesUsed;
101
101
  }
102
+
103
+ std::string getObjectType() const override { return "JsiSkPicture"; }
102
104
  };
103
105
  } // namespace RNSkia
@@ -22,6 +22,14 @@ namespace jsi = facebook::jsi;
22
22
  class JsiSkPictureFactory : public JsiSkHostObject {
23
23
  public:
24
24
  JSI_HOST_FUNCTION(MakePicture) {
25
+ // Handle null case - create JsiSkPicture with nullptr
26
+ if (arguments[0].isNull()) {
27
+ auto hostObjectInstance =
28
+ std::make_shared<JsiSkPicture>(getContext(), nullptr);
29
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
30
+ runtime, hostObjectInstance, getContext());
31
+ }
32
+
25
33
  if (!arguments[0].isObject()) {
26
34
  throw jsi::JSError(runtime, "Expected arraybuffer as first parameter");
27
35
  }
@@ -48,6 +56,8 @@ public:
48
56
 
49
57
  size_t getMemoryPressure() const override { return 1024; }
50
58
 
59
+ std::string getObjectType() const override { return "JsiSkPictureFactory"; }
60
+
51
61
  explicit JsiSkPictureFactory(std::shared_ptr<RNSkPlatformContext> context)
52
62
  : JsiSkHostObject(std::move(context)) {}
53
63
  };
@@ -57,9 +57,9 @@ public:
57
57
  finishRecordingAsPicture),
58
58
  JSI_EXPORT_FUNC(JsiSkPictureRecorder, dispose))
59
59
 
60
- size_t getMemoryPressure() const override {
61
- return sizeof(SkPictureRecorder);
62
- }
60
+ size_t getMemoryPressure() const override { return 1024 * 1024; }
61
+
62
+ std::string getObjectType() const override { return "JsiSkPictureRecorder"; }
63
63
 
64
64
  static const jsi::HostFunctionType
65
65
  createCtor(std::shared_ptr<RNSkPlatformContext> context) {
@@ -64,6 +64,8 @@ public:
64
64
 
65
65
  size_t getMemoryPressure() const override { return sizeof(SkPoint); }
66
66
 
67
+ std::string getObjectType() const override { return "JsiSkPoint"; }
68
+
67
69
  /**
68
70
  * Creates the function for construction a new instance of the SkPoint
69
71
  * wrapper
@@ -108,6 +108,8 @@ public:
108
108
 
109
109
  size_t getMemoryPressure() const override { return sizeof(SkRRect); }
110
110
 
111
+ std::string getObjectType() const override { return "JsiSkRRect"; }
112
+
111
113
  /**
112
114
  * Creates the function for construction a new instance of the SkRect
113
115
  * wrapper
@@ -113,6 +113,8 @@ public:
113
113
  }
114
114
  size_t getMemoryPressure() const override { return sizeof(SkRSXform); }
115
115
 
116
+ std::string getObjectType() const override { return "JsiSkRSXform"; }
117
+
116
118
  /**
117
119
  * Creates the function for construction a new instance of the SkRSXform
118
120
  * wrapper
@@ -102,6 +102,8 @@ public:
102
102
 
103
103
  size_t getMemoryPressure() const override { return sizeof(SkRect); }
104
104
 
105
+ std::string getObjectType() const override { return "JsiSkRect"; }
106
+
105
107
  /**
106
108
  * Creates the function for construction a new instance of the SkRect
107
109
  * wrapper
@@ -144,6 +144,8 @@ public:
144
144
 
145
145
  size_t getMemoryPressure() const override { return 4096; }
146
146
 
147
+ std::string getObjectType() const override { return "JsiSkRuntimeEffect"; }
148
+
147
149
  static RuntimeEffectUniform fromUniform(const SkRuntimeEffect::Uniform &u) {
148
150
  RuntimeEffectUniform su;
149
151
  su.rows = u.count; // arrayLength
@@ -34,6 +34,10 @@ public:
34
34
 
35
35
  size_t getMemoryPressure() const override { return 1024; }
36
36
 
37
+ std::string getObjectType() const override {
38
+ return "JsiSkRuntimeEffectFactory";
39
+ }
40
+
37
41
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkRuntimeEffectFactory, Make))
38
42
 
39
43
  explicit JsiSkRuntimeEffectFactory(
@@ -66,6 +66,10 @@ public:
66
66
  return sizeof(SkRuntimeShaderBuilder);
67
67
  }
68
68
 
69
+ std::string getObjectType() const override {
70
+ return "JsiSkRuntimeShaderBuilder";
71
+ }
72
+
69
73
  /**
70
74
  * Creates the function for construction a new instance of the SkRect
71
75
  * wrapper
@@ -72,6 +72,8 @@ public:
72
72
  return (rasterBufferSize / 4) +
73
73
  baseOverhead; // Quarter of full raster + overhead
74
74
  }
75
+
76
+ std::string getObjectType() const override { return "JsiSkSVG"; }
75
77
  };
76
78
 
77
79
  } // namespace RNSkia
@@ -162,6 +162,8 @@ public:
162
162
 
163
163
  size_t getMemoryPressure() const override { return 512; }
164
164
 
165
+ std::string getObjectType() const override { return "JsiSkSVGFactory"; }
166
+
165
167
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkSVGFactory, MakeFromData),
166
168
  JSI_EXPORT_FUNC(JsiSkSVGFactory, MakeFromString))
167
169
 
@@ -26,7 +26,9 @@ public:
26
26
  : JsiSkWrappingSkPtrHostObject<SkShader>(std::move(context),
27
27
  std::move(shader)) {}
28
28
 
29
- size_t getMemoryPressure() const override { return 4096; }
29
+ size_t getMemoryPressure() const override { return 1024 * 1024; }
30
+
31
+ std::string getObjectType() const override { return "JsiSkShader"; }
30
32
 
31
33
  EXPORT_JSI_API_TYPENAME(JsiSkShader, Shader)
32
34
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkShader, dispose))