@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.
- package/android/CMakeLists.txt +2 -0
- package/android/cpp/jni/include/JniSkiaPictureView.h +16 -15
- package/android/cpp/rnskia-android/OpenGLContext.h +1 -1
- package/android/cpp/rnskia-android/gl/Surface.h +1 -1
- package/apple/RNSkApplePlatformContext.h +3 -4
- package/apple/RNSkiaModule.h +11 -3
- package/apple/RNSkiaModule.mm +46 -19
- package/apple/SkiaPictureView.mm +2 -2
- package/apple/SkiaUIView.h +0 -1
- package/apple/SkiaUIView.mm +1 -1
- package/apple/ViewScreenshotService.h +2 -2
- package/apple/ViewScreenshotService.mm +5 -4
- package/cpp/api/JsiSkImage.h +1 -1
- package/cpp/api/JsiSkImageFilter.h +3 -1
- package/cpp/api/JsiSkParagraph.h +2 -1
- package/cpp/api/JsiSkParagraphBuilder.h +1 -1
- package/cpp/api/JsiSkParagraphBuilderFactory.h +1 -1
- package/cpp/api/JsiSkPath.h +11 -435
- package/cpp/api/JsiSkPathBuilder.h +11 -4
- package/cpp/api/JsiSkPictureRecorder.h +2 -1
- package/cpp/api/JsiSkShader.h +3 -1
- package/cpp/api/JsiSkSkottie.h +29 -28
- package/cpp/api/JsiSkStrutStyle.h +1 -1
- package/cpp/api/JsiSkSurfaceFactory.h +41 -0
- package/cpp/api/recorder/Command.h +1 -1
- package/cpp/api/recorder/Convertor.h +153 -132
- package/cpp/api/recorder/DataTypes.h +12 -12
- package/cpp/api/recorder/DrawingCtx.h +1 -1
- package/cpp/api/recorder/ImageFit.h +8 -5
- package/cpp/api/recorder/JsiRecorder.h +14 -31
- package/cpp/api/recorder/Paint.h +3 -3
- package/cpp/api/recorder/RNRecorder.h +56 -0
- package/cpp/api/third_party/base64.cpp +1 -1
- package/cpp/jsi/JSICache.cpp +23 -0
- package/cpp/jsi/JSICache.h +28 -1
- package/cpp/jsi/NativeObject.h +36 -7
- package/cpp/jsi/ViewProperty.cpp +23 -0
- package/cpp/jsi/ViewProperty.h +31 -10
- package/cpp/rnskia/RNDawnContext.h +34 -1
- package/cpp/rnskia/RNSkJsiViewApi.h +69 -2
- package/cpp/rnskia/RNSkPictureView.cpp +58 -0
- package/cpp/rnskia/RNSkPictureView.h +110 -24
- package/lib/commonjs/Platform/IPlatform.js.map +1 -1
- package/lib/commonjs/animation/functions/interpolate.js.map +1 -1
- package/lib/commonjs/animation/functions/interpolatePaths.js +18 -0
- package/lib/commonjs/animation/functions/interpolatePaths.js.map +1 -1
- package/lib/commonjs/skia/core/Image.js.map +1 -1
- package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -1
- package/lib/commonjs/skia/types/Path/Path.d.ts +2 -336
- package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
- package/lib/commonjs/skia/types/Recorder.d.ts +10 -0
- package/lib/commonjs/skia/types/Recorder.js.map +1 -1
- package/lib/commonjs/skia/types/Shader/Shader.js.map +1 -1
- package/lib/commonjs/skia/types/Surface/SurfaceFactory.d.ts +16 -0
- package/lib/commonjs/skia/types/Surface/SurfaceFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPath.d.ts +4 -38
- package/lib/commonjs/skia/web/JsiSkPath.js +3 -275
- package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
- package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js +3 -0
- package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js.map +1 -1
- package/lib/commonjs/sksg/Container.native.d.ts +15 -1
- package/lib/commonjs/sksg/Container.native.js +34 -33
- package/lib/commonjs/sksg/Container.native.js.map +1 -1
- package/lib/commonjs/specs/NativeSkiaModule.web.js +4 -0
- package/lib/commonjs/specs/NativeSkiaModule.web.js.map +1 -1
- package/lib/commonjs/views/types.d.ts +9 -0
- package/lib/commonjs/views/types.js.map +1 -1
- package/lib/module/Platform/IPlatform.js.map +1 -1
- package/lib/module/animation/functions/interpolate.js.map +1 -1
- package/lib/module/animation/functions/interpolatePaths.js +18 -0
- package/lib/module/animation/functions/interpolatePaths.js.map +1 -1
- package/lib/module/skia/core/Image.js.map +1 -1
- package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -1
- package/lib/module/skia/types/Path/Path.d.ts +2 -336
- package/lib/module/skia/types/Path/Path.js.map +1 -1
- package/lib/module/skia/types/Recorder.d.ts +10 -0
- package/lib/module/skia/types/Recorder.js.map +1 -1
- package/lib/module/skia/types/Shader/Shader.js.map +1 -1
- package/lib/module/skia/types/Surface/SurfaceFactory.d.ts +16 -0
- package/lib/module/skia/types/Surface/SurfaceFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkPath.d.ts +4 -38
- package/lib/module/skia/web/JsiSkPath.js +4 -276
- package/lib/module/skia/web/JsiSkPath.js.map +1 -1
- package/lib/module/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
- package/lib/module/skia/web/JsiSkSurfaceFactory.js +4 -1
- package/lib/module/skia/web/JsiSkSurfaceFactory.js.map +1 -1
- package/lib/module/sksg/Container.native.d.ts +15 -1
- package/lib/module/sksg/Container.native.js +34 -33
- package/lib/module/sksg/Container.native.js.map +1 -1
- package/lib/module/specs/NativeSkiaModule.web.js +4 -0
- package/lib/module/specs/NativeSkiaModule.web.js.map +1 -1
- package/lib/module/views/types.d.ts +9 -0
- package/lib/module/views/types.js.map +1 -1
- package/lib/typescript/lib/commonjs/skia/web/JsiSkPath.d.ts +1 -35
- package/lib/typescript/lib/commonjs/skia/web/JsiSkSurfaceFactory.d.ts +1 -0
- package/lib/typescript/lib/commonjs/sksg/Container.native.d.ts +15 -1
- package/lib/typescript/lib/module/skia/web/JsiSkPath.d.ts +3 -37
- package/lib/typescript/lib/module/skia/web/JsiSkSurfaceFactory.d.ts +1 -0
- package/lib/typescript/lib/module/sksg/Container.native.d.ts +15 -1
- package/lib/typescript/src/skia/types/Path/Path.d.ts +2 -336
- package/lib/typescript/src/skia/types/Recorder.d.ts +10 -0
- package/lib/typescript/src/skia/types/Surface/SurfaceFactory.d.ts +16 -0
- package/lib/typescript/src/skia/web/JsiSkPath.d.ts +4 -38
- package/lib/typescript/src/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
- package/lib/typescript/src/sksg/Container.native.d.ts +15 -1
- package/lib/typescript/src/views/types.d.ts +9 -0
- package/package.json +2 -2
- package/src/Platform/IPlatform.ts +1 -4
- package/src/animation/functions/interpolate.ts +1 -4
- package/src/animation/functions/interpolatePaths.ts +24 -0
- package/src/skia/core/Image.ts +1 -2
- package/src/skia/types/NativeBuffer/NativeBufferFactory.ts +2 -5
- package/src/skia/types/Path/Path.ts +2 -420
- package/src/skia/types/Recorder.ts +10 -0
- package/src/skia/types/Shader/Shader.ts +1 -5
- package/src/skia/types/Surface/SurfaceFactory.ts +17 -0
- package/src/skia/web/JsiSkPath.ts +4 -495
- package/src/skia/web/JsiSkSurfaceFactory.ts +6 -2
- package/src/sksg/Container.native.ts +34 -37
- package/src/specs/NativeSkiaModule.web.ts +4 -0
- package/src/views/types.ts +13 -0
- package/apple/SkiaManager.h +0 -23
- package/apple/SkiaManager.mm +0 -63
package/android/CMakeLists.txt
CHANGED
|
@@ -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,
|
|
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 {
|
|
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
|
-
|
|
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:
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
-
#import <React/
|
|
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
|
-
|
|
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]
|
|
34
|
+
[[ViewScreenshotService alloc] initWithViewRegistry:viewRegistry];
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
~RNSkApplePlatformContext() = default;
|
package/apple/RNSkiaModule.h
CHANGED
|
@@ -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
|
|
6
|
+
#include <memory>
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
#include "RNSkManager.h"
|
|
8
9
|
|
|
9
|
-
|
|
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
|
package/apple/RNSkiaModule.mm
CHANGED
|
@@ -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
|
-
|
|
7
|
-
|
|
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
|
-
|
|
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
|
-
|
|
25
|
+
- (std::shared_ptr<RNSkia::RNSkManager>)skManager {
|
|
26
|
+
return _skManager;
|
|
27
|
+
}
|
|
14
28
|
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
27
|
-
|
|
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 (
|
|
58
|
+
if (_skManager != nullptr) {
|
|
34
59
|
// Already initialized, ignore call.
|
|
35
60
|
return @true;
|
|
36
61
|
}
|
|
37
|
-
if (
|
|
38
|
-
NSLog(@"[RNSkiaModule] Failed to install
|
|
39
|
-
@"
|
|
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
|
-
|
|
43
|
-
|
|
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
|
|
package/apple/SkiaPictureView.mm
CHANGED
|
@@ -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 = [
|
|
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>>(
|
package/apple/SkiaUIView.h
CHANGED
package/apple/SkiaUIView.mm
CHANGED
|
@@ -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 = [
|
|
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/
|
|
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)
|
|
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
|
-
|
|
13
|
+
__weak RCTViewRegistry *_viewRegistry;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
- (instancetype)
|
|
16
|
+
- (instancetype)initWithViewRegistry:(RCTViewRegistry *)viewRegistry {
|
|
16
17
|
if (self = [super init]) {
|
|
17
|
-
|
|
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 = [
|
|
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;
|
package/cpp/api/JsiSkImage.h
CHANGED
|
@@ -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 = (
|
|
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
|
-
|
|
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);
|
package/cpp/api/JsiSkParagraph.h
CHANGED
|
@@ -277,7 +277,8 @@ public:
|
|
|
277
277
|
&JsiSkParagraph::extendedVisit);
|
|
278
278
|
}
|
|
279
279
|
|
|
280
|
-
|
|
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
|
|
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
|
|
50
|
+
size_t getMemoryPressure() override { return kMinMemoryPressure; }
|
|
51
51
|
|
|
52
52
|
explicit JsiSkParagraphBuilderFactory(
|
|
53
53
|
std::shared_ptr<RNSkPlatformContext> context)
|