@shopify/react-native-skia 2.13.0 → 2.14.0

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 (124) hide show
  1. package/android/CMakeLists.txt +2 -0
  2. package/android/cpp/jni/include/JniSkiaPictureView.h +16 -15
  3. package/android/cpp/rnskia-android/OpenGLContext.h +1 -1
  4. package/android/cpp/rnskia-android/gl/Surface.h +1 -1
  5. package/apple/RNSkApplePlatformContext.h +3 -4
  6. package/apple/RNSkiaModule.h +11 -3
  7. package/apple/RNSkiaModule.mm +46 -19
  8. package/apple/SkiaPictureView.mm +2 -2
  9. package/apple/SkiaUIView.h +0 -1
  10. package/apple/SkiaUIView.mm +1 -1
  11. package/apple/ViewScreenshotService.h +2 -2
  12. package/apple/ViewScreenshotService.mm +5 -4
  13. package/cpp/api/JsiSkImage.h +1 -1
  14. package/cpp/api/JsiSkImageFilter.h +3 -1
  15. package/cpp/api/JsiSkParagraph.h +2 -1
  16. package/cpp/api/JsiSkParagraphBuilder.h +1 -1
  17. package/cpp/api/JsiSkParagraphBuilderFactory.h +1 -1
  18. package/cpp/api/JsiSkPath.h +11 -435
  19. package/cpp/api/JsiSkPathBuilder.h +11 -4
  20. package/cpp/api/JsiSkPictureRecorder.h +2 -1
  21. package/cpp/api/JsiSkShader.h +3 -1
  22. package/cpp/api/JsiSkSkottie.h +29 -28
  23. package/cpp/api/JsiSkStrutStyle.h +1 -1
  24. package/cpp/api/JsiSkSurfaceFactory.h +41 -0
  25. package/cpp/api/recorder/Command.h +1 -1
  26. package/cpp/api/recorder/Convertor.h +153 -132
  27. package/cpp/api/recorder/DataTypes.h +12 -12
  28. package/cpp/api/recorder/DrawingCtx.h +1 -1
  29. package/cpp/api/recorder/ImageFit.h +8 -5
  30. package/cpp/api/recorder/JsiRecorder.h +14 -31
  31. package/cpp/api/recorder/Paint.h +3 -3
  32. package/cpp/api/recorder/RNRecorder.h +56 -0
  33. package/cpp/api/third_party/base64.cpp +1 -1
  34. package/cpp/jsi/JSICache.cpp +23 -0
  35. package/cpp/jsi/JSICache.h +28 -1
  36. package/cpp/jsi/NativeObject.h +36 -7
  37. package/cpp/jsi/ViewProperty.cpp +23 -0
  38. package/cpp/jsi/ViewProperty.h +31 -10
  39. package/cpp/rnskia/RNDawnContext.h +34 -1
  40. package/cpp/rnskia/RNSkJsiViewApi.h +69 -2
  41. package/cpp/rnskia/RNSkPictureView.cpp +58 -0
  42. package/cpp/rnskia/RNSkPictureView.h +110 -24
  43. package/lib/commonjs/Platform/IPlatform.js.map +1 -1
  44. package/lib/commonjs/animation/functions/interpolate.js.map +1 -1
  45. package/lib/commonjs/animation/functions/interpolatePaths.js +18 -0
  46. package/lib/commonjs/animation/functions/interpolatePaths.js.map +1 -1
  47. package/lib/commonjs/skia/core/Image.js.map +1 -1
  48. package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -1
  49. package/lib/commonjs/skia/types/Path/Path.d.ts +2 -336
  50. package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
  51. package/lib/commonjs/skia/types/Recorder.d.ts +10 -0
  52. package/lib/commonjs/skia/types/Recorder.js.map +1 -1
  53. package/lib/commonjs/skia/types/Shader/Shader.js.map +1 -1
  54. package/lib/commonjs/skia/types/Surface/SurfaceFactory.d.ts +16 -0
  55. package/lib/commonjs/skia/types/Surface/SurfaceFactory.js.map +1 -1
  56. package/lib/commonjs/skia/web/JsiSkPath.d.ts +4 -38
  57. package/lib/commonjs/skia/web/JsiSkPath.js +3 -275
  58. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  59. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
  60. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js +3 -0
  61. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js.map +1 -1
  62. package/lib/commonjs/sksg/Container.native.d.ts +15 -1
  63. package/lib/commonjs/sksg/Container.native.js +34 -33
  64. package/lib/commonjs/sksg/Container.native.js.map +1 -1
  65. package/lib/commonjs/specs/NativeSkiaModule.web.js +4 -0
  66. package/lib/commonjs/specs/NativeSkiaModule.web.js.map +1 -1
  67. package/lib/commonjs/views/types.d.ts +9 -0
  68. package/lib/commonjs/views/types.js.map +1 -1
  69. package/lib/module/Platform/IPlatform.js.map +1 -1
  70. package/lib/module/animation/functions/interpolate.js.map +1 -1
  71. package/lib/module/animation/functions/interpolatePaths.js +18 -0
  72. package/lib/module/animation/functions/interpolatePaths.js.map +1 -1
  73. package/lib/module/skia/core/Image.js.map +1 -1
  74. package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -1
  75. package/lib/module/skia/types/Path/Path.d.ts +2 -336
  76. package/lib/module/skia/types/Path/Path.js.map +1 -1
  77. package/lib/module/skia/types/Recorder.d.ts +10 -0
  78. package/lib/module/skia/types/Recorder.js.map +1 -1
  79. package/lib/module/skia/types/Shader/Shader.js.map +1 -1
  80. package/lib/module/skia/types/Surface/SurfaceFactory.d.ts +16 -0
  81. package/lib/module/skia/types/Surface/SurfaceFactory.js.map +1 -1
  82. package/lib/module/skia/web/JsiSkPath.d.ts +4 -38
  83. package/lib/module/skia/web/JsiSkPath.js +4 -276
  84. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  85. package/lib/module/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
  86. package/lib/module/skia/web/JsiSkSurfaceFactory.js +4 -1
  87. package/lib/module/skia/web/JsiSkSurfaceFactory.js.map +1 -1
  88. package/lib/module/sksg/Container.native.d.ts +15 -1
  89. package/lib/module/sksg/Container.native.js +34 -33
  90. package/lib/module/sksg/Container.native.js.map +1 -1
  91. package/lib/module/specs/NativeSkiaModule.web.js +4 -0
  92. package/lib/module/specs/NativeSkiaModule.web.js.map +1 -1
  93. package/lib/module/views/types.d.ts +9 -0
  94. package/lib/module/views/types.js.map +1 -1
  95. package/lib/typescript/lib/commonjs/skia/web/JsiSkPath.d.ts +1 -35
  96. package/lib/typescript/lib/commonjs/skia/web/JsiSkSurfaceFactory.d.ts +1 -0
  97. package/lib/typescript/lib/commonjs/sksg/Container.native.d.ts +15 -1
  98. package/lib/typescript/lib/module/skia/web/JsiSkPath.d.ts +3 -37
  99. package/lib/typescript/lib/module/skia/web/JsiSkSurfaceFactory.d.ts +1 -0
  100. package/lib/typescript/lib/module/sksg/Container.native.d.ts +15 -1
  101. package/lib/typescript/src/skia/types/Path/Path.d.ts +2 -336
  102. package/lib/typescript/src/skia/types/Recorder.d.ts +10 -0
  103. package/lib/typescript/src/skia/types/Surface/SurfaceFactory.d.ts +16 -0
  104. package/lib/typescript/src/skia/web/JsiSkPath.d.ts +4 -38
  105. package/lib/typescript/src/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
  106. package/lib/typescript/src/sksg/Container.native.d.ts +15 -1
  107. package/lib/typescript/src/views/types.d.ts +9 -0
  108. package/package.json +2 -2
  109. package/src/Platform/IPlatform.ts +1 -4
  110. package/src/animation/functions/interpolate.ts +1 -4
  111. package/src/animation/functions/interpolatePaths.ts +24 -0
  112. package/src/skia/core/Image.ts +1 -2
  113. package/src/skia/types/NativeBuffer/NativeBufferFactory.ts +2 -5
  114. package/src/skia/types/Path/Path.ts +2 -420
  115. package/src/skia/types/Recorder.ts +10 -0
  116. package/src/skia/types/Shader/Shader.ts +1 -5
  117. package/src/skia/types/Surface/SurfaceFactory.ts +17 -0
  118. package/src/skia/web/JsiSkPath.ts +4 -495
  119. package/src/skia/web/JsiSkSurfaceFactory.ts +6 -2
  120. package/src/sksg/Container.native.ts +34 -37
  121. package/src/specs/NativeSkiaModule.web.ts +4 -0
  122. package/src/views/types.ts +13 -0
  123. package/apple/SkiaManager.h +0 -23
  124. package/apple/SkiaManager.mm +0 -63
@@ -81,8 +81,10 @@ add_library(
81
81
  "${PROJECT_SOURCE_DIR}/../cpp/jsi/JSICache.cpp"
82
82
  "${PROJECT_SOURCE_DIR}/../cpp/jsi/JsiPromises.cpp"
83
83
  "${PROJECT_SOURCE_DIR}/../cpp/jsi/Promise.cpp"
84
+ "${PROJECT_SOURCE_DIR}/../cpp/jsi/ViewProperty.cpp"
84
85
 
85
86
  "${PROJECT_SOURCE_DIR}/../cpp/rnskia/RNSkManager.cpp"
87
+ "${PROJECT_SOURCE_DIR}/../cpp/rnskia/RNSkPictureView.cpp"
86
88
 
87
89
  "${PROJECT_SOURCE_DIR}/../cpp/api/third_party/CSSColorParser.cpp"
88
90
  "${PROJECT_SOURCE_DIR}/../cpp/api/third_party/base64.cpp"
@@ -69,8 +69,8 @@ protected:
69
69
  highBitDepth);
70
70
  }
71
71
 
72
- void surfaceSizeChanged(jobject surface, int width, int height, bool isSurface,
73
- bool highBitDepth) override {
72
+ void surfaceSizeChanged(jobject surface, int width, int height,
73
+ bool isSurface, bool highBitDepth) override {
74
74
  JniSkiaBaseView::surfaceSizeChanged(surface, width, height, isSurface,
75
75
  highBitDepth);
76
76
  }
@@ -83,7 +83,18 @@ protected:
83
83
  JniSkiaBaseView::registerView(nativeId);
84
84
  }
85
85
 
86
- void unregisterView() override { JniSkiaBaseView::unregisterView(); }
86
+ void unregisterView() override {
87
+ JniSkiaBaseView::unregisterView();
88
+ // React drops the Java view here, but the native view behind it (and the
89
+ // recording it owns) is only destroyed when the Java object is finalized.
90
+ // Release the content now so it does not wait for the Java garbage
91
+ // collector.
92
+ if (_skiaAndroidView != nullptr) {
93
+ auto renderer = std::static_pointer_cast<RNSkia::RNSkPictureRenderer>(
94
+ _skiaAndroidView->getSkiaView()->getRenderer());
95
+ renderer->clear();
96
+ }
97
+ }
87
98
 
88
99
  jni::local_ref<jni::JArrayInt> getBitmap(int width, int height) override {
89
100
  // Get the RNSkPictureView from the android view
@@ -101,9 +112,6 @@ protected:
101
112
  return jni::JArrayInt::newArray(0);
102
113
  }
103
114
 
104
- // Get the SkPicture from the renderer
105
- sk_sp<SkPicture> picture = renderer->getPicture();
106
-
107
115
  const size_t pixelCount =
108
116
  static_cast<size_t>(width) * static_cast<size_t>(height);
109
117
  if (pixelCount == 0) {
@@ -126,15 +134,8 @@ protected:
126
134
  return jni::JArrayInt::newArray(0);
127
135
  }
128
136
 
129
- canvas->clear(SK_ColorTRANSPARENT);
130
-
131
- if (picture) {
132
- auto pd = pictureView->getPixelDensity();
133
- canvas->save();
134
- canvas->scale(pd, pd);
135
- canvas->drawPicture(picture);
136
- canvas->restore();
137
- }
137
+ // Draws whatever the view currently shows: a picture or a recorder.
138
+ renderer->drawInto(canvas, pictureView->getPixelDensity());
138
139
 
139
140
  sk_sp<SkImage> snapshot = surface->makeImageSnapshot();
140
141
  if (!snapshot) {
@@ -28,7 +28,7 @@ public:
28
28
 
29
29
  gl::Display *getDisplay() { return _glDisplay.get(); }
30
30
  gl::Context *getContext() { return _glContext.get(); }
31
- gl::Surface *getSurface() { return _glSurface.get(); };
31
+ gl::Surface *getSurface() { return _glSurface.get(); }
32
32
  EGLConfig getConfig() { return _glConfig; }
33
33
 
34
34
  private:
@@ -40,4 +40,4 @@ private:
40
40
  Surface &operator=(const Surface &) = delete;
41
41
  };
42
42
 
43
- } // Namespace gl
43
+ } // namespace gl
@@ -1,7 +1,6 @@
1
1
  #pragma once
2
2
 
3
- #import <React/RCTBridge+Private.h>
4
- #import <React/RCTBridge.h>
3
+ #import <React/RCTBridgeModule.h>
5
4
 
6
5
  #include <functional>
7
6
  #include <memory>
@@ -21,7 +20,7 @@ namespace RNSkia {
21
20
  class RNSkApplePlatformContext : public RNSkPlatformContext {
22
21
  public:
23
22
  RNSkApplePlatformContext(
24
- RCTBridge *bridge,
23
+ RCTViewRegistry *viewRegistry,
25
24
  std::shared_ptr<facebook::react::CallInvoker> jsCallInvoker)
26
25
  #if !TARGET_OS_OSX
27
26
  : RNSkPlatformContext(jsCallInvoker, [[UIScreen mainScreen] scale]) {
@@ -32,7 +31,7 @@ public:
32
31
 
33
32
  // Create screenshot manager
34
33
  _screenshotService =
35
- [[ViewScreenshotService alloc] initWithUiManager:bridge.uiManager];
34
+ [[ViewScreenshotService alloc] initWithViewRegistry:viewRegistry];
36
35
  }
37
36
 
38
37
  ~RNSkApplePlatformContext() = default;
@@ -1,11 +1,19 @@
1
1
  #pragma once
2
2
 
3
+ #import <ReactCommon/RCTTurboModuleWithJSIBindings.h>
3
4
  #import <rnskia/rnskia.h>
4
5
 
5
- #include "SkiaManager.h"
6
+ #include <memory>
6
7
 
7
- @interface RNSkiaModule : NSObject <NativeSkiaModuleSpec>
8
+ #include "RNSkManager.h"
8
9
 
9
- - (SkiaManager *)manager;
10
+ @interface RNSkiaModule
11
+ : NSObject <NativeSkiaModuleSpec, RCTTurboModuleWithJSIBindings>
12
+
13
+ - (std::shared_ptr<RNSkia::RNSkManager>)skManager;
14
+
15
+ // Fabric components do not have a better way to interact with TurboModules.
16
+ // Workaround to get the SkManager instance from singleton.
17
+ + (std::shared_ptr<RNSkia::RNSkManager>)latestActiveSkManager;
10
18
 
11
19
  @end
@@ -1,52 +1,79 @@
1
-
2
1
  #import "RNSkiaModule.h"
2
+
3
3
  #import <ReactCommon/RCTTurboModule.h>
4
4
 
5
+ #import "RNSkApplePlatformContext.h"
6
+
7
+ static __weak RNSkiaModule *sharedInstance = nil;
8
+
5
9
  @implementation RNSkiaModule {
6
- SkiaManager *skiaManager;
7
- std::shared_ptr<facebook::react::CallInvoker> jsInvoker;
10
+ // Handed to us by React Native when JS first requires the module (see
11
+ // installJSIBindingsWithRuntime:callInvoker:), which always happens before
12
+ // JS calls install(). Valid until invalidate.
13
+ facebook::jsi::Runtime *_runtime;
14
+ std::shared_ptr<facebook::react::CallInvoker> _jsInvoker;
15
+ std::shared_ptr<RNSkia::RNSkManager> _skManager;
8
16
  }
9
17
 
10
18
  RCT_EXPORT_MODULE()
11
- @synthesize bridge = _bridge;
19
+ // Injected by React Native (bridgeless included). It is how a module looks up
20
+ // a native view by react tag without touching RCTBridge or RCTUIManager.
21
+ @synthesize viewRegistry_DEPRECATED = _viewRegistry_DEPRECATED;
22
+
23
+ #pragma mark Accessors
12
24
 
13
- #pragma Accessors
25
+ - (std::shared_ptr<RNSkia::RNSkManager>)skManager {
26
+ return _skManager;
27
+ }
14
28
 
15
- - (SkiaManager *)manager {
16
- return skiaManager;
29
+ + (std::shared_ptr<RNSkia::RNSkManager>)latestActiveSkManager {
30
+ if (sharedInstance != nil) {
31
+ return [sharedInstance skManager];
32
+ }
33
+ return nullptr;
17
34
  }
18
35
 
19
- #pragma Setup and invalidation
36
+ #pragma mark Setup and invalidation
20
37
 
21
38
  + (BOOL)requiresMainQueueSetup {
22
39
  return YES;
23
40
  }
24
41
 
42
+ - (void)
43
+ installJSIBindingsWithRuntime:(facebook::jsi::Runtime &)runtime
44
+ callInvoker:
45
+ (const std::shared_ptr<facebook::react::CallInvoker>
46
+ &)callInvoker {
47
+ _runtime = &runtime;
48
+ _jsInvoker = callInvoker;
49
+ }
50
+
25
51
  - (void)invalidate {
26
- if (skiaManager != nil) {
27
- [skiaManager invalidate];
28
- }
29
- skiaManager = nil;
52
+ _skManager = nullptr;
53
+ _runtime = nullptr;
54
+ _jsInvoker = nullptr;
30
55
  }
31
56
 
32
57
  RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install) {
33
- if (skiaManager != nil) {
58
+ if (_skManager != nullptr) {
34
59
  // Already initialized, ignore call.
35
60
  return @true;
36
61
  }
37
- if (!jsInvoker) {
38
- NSLog(@"[RNSkiaModule] Failed to install SkiaManager: jsInvoker is not "
39
- @"initialized.");
62
+ if (_runtime == nullptr || _jsInvoker == nullptr) {
63
+ NSLog(@"[RNSkiaModule] Failed to install: the JS runtime has not been "
64
+ @"provided to the module yet.");
40
65
  return @false;
41
66
  }
42
- skiaManager = [[SkiaManager alloc] initWithBridge:self.bridge
43
- jsInvoker:jsInvoker];
67
+ sharedInstance = self;
68
+ _skManager = std::make_shared<RNSkia::RNSkManager>(
69
+ _runtime, _jsInvoker,
70
+ std::make_shared<RNSkia::RNSkApplePlatformContext>(
71
+ self.viewRegistry_DEPRECATED, _jsInvoker));
44
72
  return @true;
45
73
  }
46
74
 
47
75
  - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
48
76
  (const facebook::react::ObjCTurboModule::InitParams &)params {
49
- jsInvoker = params.jsInvoker;
50
77
  return std::make_shared<facebook::react::NativeSkiaModuleSpecJSI>(params);
51
78
  }
52
79
 
@@ -5,10 +5,10 @@
5
5
  #import "RNSkPlatformContext.h"
6
6
 
7
7
  #import "RNSkiaModule.h"
8
- #import "SkiaManager.h"
9
8
  #import "SkiaUIView.h"
10
9
 
11
10
  #import <React/RCTConversions.h>
11
+ #import <React/RCTConvert.h>
12
12
  #import <React/RCTFabricComponentsPlugins.h>
13
13
 
14
14
  #import <react/renderer/components/rnskia/ComponentDescriptors.h>
@@ -23,7 +23,7 @@ using namespace facebook::react;
23
23
  - (instancetype)initWithFrame:(CGRect)frame {
24
24
  if (self = [super initWithFrame:frame]) {
25
25
  // Pass SkManager as a raw pointer to avoid circular dependencies
26
- auto skManager = [SkiaManager latestActiveSkManager].get();
26
+ auto skManager = [RNSkiaModule latestActiveSkManager].get();
27
27
  [self initCommon:skManager
28
28
  factory:[](std::shared_ptr<RNSkia::RNSkPlatformContext> context) {
29
29
  return std::make_shared<RNSkAppleView<RNSkia::RNSkPictureView>>(
@@ -14,7 +14,6 @@
14
14
 
15
15
  #import "RNSkAppleView.h"
16
16
  #import "RNSkManager.h"
17
- #import "SkiaManager.h"
18
17
 
19
18
  @interface SkiaUIView : RCTViewComponentView
20
19
 
@@ -88,7 +88,7 @@
88
88
  // this flag is only set when the view is inserted and we want to set the
89
89
  // manager here since the view could be recycled or the app could be
90
90
  // refreshed and we would have a stale manager then
91
- _manager = [SkiaManager latestActiveSkManager].get();
91
+ _manager = [RNSkiaModule latestActiveSkManager].get();
92
92
  }
93
93
  }
94
94
 
@@ -7,7 +7,7 @@
7
7
  #import <Appkit/Appkit.h>
8
8
  #endif // !TARGET_OS_OSX
9
9
 
10
- #import <React/RCTUIManager.h>
10
+ #import <React/RCTBridgeModule.h>
11
11
 
12
12
  #pragma clang diagnostic push
13
13
  #pragma clang diagnostic ignored "-Wdocumentation"
@@ -19,7 +19,7 @@
19
19
  @interface ViewScreenshotService : NSObject {
20
20
  }
21
21
 
22
- - (instancetype)initWithUiManager:(RCTUIManager *)uiManager;
22
+ - (instancetype)initWithViewRegistry:(RCTViewRegistry *)viewRegistry;
23
23
  - (sk_sp<SkImage>)screenshotOfViewWithTag:(NSNumber *)viewTag;
24
24
 
25
25
  @end
@@ -1,5 +1,6 @@
1
1
  #import "ViewScreenshotService.h"
2
2
  #import <QuartzCore/QuartzCore.h>
3
+ #import <React/RCTUtils.h>
3
4
 
4
5
  #pragma clang diagnostic push
5
6
  #pragma clang diagnostic ignored "-Wdocumentation"
@@ -9,12 +10,12 @@
9
10
  #pragma clang diagnostic pop
10
11
 
11
12
  @implementation ViewScreenshotService {
12
- RCTUIManager *_uiManager;
13
+ __weak RCTViewRegistry *_viewRegistry;
13
14
  }
14
15
 
15
- - (instancetype)initWithUiManager:(RCTUIManager *)uiManager {
16
+ - (instancetype)initWithViewRegistry:(RCTViewRegistry *)viewRegistry {
16
17
  if (self = [super init]) {
17
- _uiManager = uiManager;
18
+ _viewRegistry = viewRegistry;
18
19
  }
19
20
  return self;
20
21
  }
@@ -22,7 +23,7 @@
22
23
  - (sk_sp<SkImage>)screenshotOfViewWithTag:(NSNumber *)viewTag {
23
24
  #if !TARGET_OS_OSX
24
25
  // Find view corresponding to the tag
25
- auto view = [_uiManager viewForReactTag:viewTag];
26
+ auto view = [_viewRegistry viewForReactTag:viewTag];
26
27
  if (view == NULL) {
27
28
  RCTFatal(RCTErrorWithMessage(@"Could not find view with tag"));
28
29
  return nullptr;
@@ -66,7 +66,7 @@ static sk_sp<SkData> replaceJpegICCWithAppleP3(sk_sp<SkData> jpegData) {
66
66
  return jpegData;
67
67
 
68
68
  const uint8_t *iccBytes = CFDataGetBytePtr(cfICC);
69
- size_t iccLen = (size_t)CFDataGetLength(cfICC);
69
+ size_t iccLen = static_cast<size_t>(CFDataGetLength(cfICC));
70
70
 
71
71
  // "ICC_PROFILE\0" APP2 marker signature (12 bytes)
72
72
  static const uint8_t iccSig[] = {0x49, 0x43, 0x43, 0x5F, 0x50, 0x52,
@@ -28,7 +28,9 @@ public:
28
28
  : JsiSkWrappingSkPtrNativeObject<JsiSkImageFilter, SkImageFilter>(
29
29
  std::move(context), std::move(imageFilter)) {}
30
30
 
31
- size_t getMemoryPressure() override { return 1024 * 1024; }
31
+ // A image filter node is a few hundred bytes; the images it may reference
32
+ // are reported by their own wrappers.
33
+ size_t getMemoryPressure() override { return kMinMemoryPressure; }
32
34
 
33
35
  static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
34
36
  installCommon(runtime, prototype);
@@ -277,7 +277,8 @@ public:
277
277
  &JsiSkParagraph::extendedVisit);
278
278
  }
279
279
 
280
- size_t getMemoryPressure() override { return 1024 * 1024; }
280
+ // Shaped glyph runs and line metrics; there is no exact API for this.
281
+ size_t getMemoryPressure() override { return 16 * 1024; }
281
282
 
282
283
  explicit JsiSkParagraph(std::shared_ptr<RNSkPlatformContext> context,
283
284
  para::ParagraphBuilder *paragraphBuilder)
@@ -93,7 +93,7 @@ public:
93
93
  &JsiSkParagraphBuilder::pop);
94
94
  }
95
95
 
96
- size_t getMemoryPressure() override { return 1024 * 1024; }
96
+ size_t getMemoryPressure() override { return kMinMemoryPressure; }
97
97
 
98
98
  explicit JsiSkParagraphBuilder(std::shared_ptr<RNSkPlatformContext> context,
99
99
  para::ParagraphStyle paragraphStyle,
@@ -47,7 +47,7 @@ public:
47
47
  &JsiSkParagraphBuilderFactory::Make);
48
48
  }
49
49
 
50
- size_t getMemoryPressure() override { return 1024 * 1024; }
50
+ size_t getMemoryPressure() override { return kMinMemoryPressure; }
51
51
 
52
52
  explicit JsiSkParagraphBuilderFactory(
53
53
  std::shared_ptr<RNSkPlatformContext> context)