@shopify/react-native-skia 2.3.8 → 2.3.10
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/cpp/api/JsiNativeBuffer.h +4 -0
- package/cpp/api/JsiSkAnimatedImage.h +70 -1
- package/cpp/api/JsiSkAnimatedImageFactory.h +4 -0
- package/cpp/api/JsiSkApi.h +2 -0
- package/cpp/api/JsiSkCanvas.h +2 -0
- package/cpp/api/JsiSkColorFilter.h +2 -0
- package/cpp/api/JsiSkColorFilterFactory.h +4 -0
- package/cpp/api/JsiSkContourMeasure.h +2 -0
- package/cpp/api/JsiSkContourMeasureIter.h +4 -0
- package/cpp/api/JsiSkData.h +2 -0
- package/cpp/api/JsiSkDataFactory.h +2 -0
- package/cpp/api/JsiSkFont.h +2 -0
- package/cpp/api/JsiSkFontMgr.h +2 -0
- package/cpp/api/JsiSkFontMgrFactory.h +2 -0
- package/cpp/api/JsiSkFontStyle.h +2 -0
- package/cpp/api/JsiSkHostObjects.h +50 -0
- package/cpp/api/JsiSkImage.h +3 -1
- package/cpp/api/JsiSkImageFactory.h +2 -0
- package/cpp/api/JsiSkImageFilter.h +3 -1
- package/cpp/api/JsiSkImageFilterFactory.h +4 -0
- package/cpp/api/JsiSkImageInfo.h +2 -0
- package/cpp/api/JsiSkMaskFilter.h +2 -0
- package/cpp/api/JsiSkMaskFilterFactory.h +4 -0
- package/cpp/api/JsiSkMatrix.h +2 -0
- package/cpp/api/JsiSkPaint.h +2 -0
- package/cpp/api/JsiSkParagraph.h +3 -1
- package/cpp/api/JsiSkParagraphBuilder.h +3 -1
- package/cpp/api/JsiSkParagraphBuilderFactory.h +5 -1
- package/cpp/api/JsiSkPath.h +2 -0
- package/cpp/api/JsiSkPathEffect.h +2 -0
- package/cpp/api/JsiSkPathEffectFactory.h +4 -0
- package/cpp/api/JsiSkPathFactory.h +2 -0
- package/cpp/api/JsiSkPicture.h +2 -0
- package/cpp/api/JsiSkPictureFactory.h +10 -0
- package/cpp/api/JsiSkPictureRecorder.h +3 -3
- package/cpp/api/JsiSkPoint.h +2 -0
- package/cpp/api/JsiSkRRect.h +2 -0
- package/cpp/api/JsiSkRSXform.h +2 -0
- package/cpp/api/JsiSkRect.h +2 -0
- package/cpp/api/JsiSkRuntimeEffect.h +2 -0
- package/cpp/api/JsiSkRuntimeEffectFactory.h +4 -0
- package/cpp/api/JsiSkRuntimeShaderBuilder.h +4 -0
- package/cpp/api/JsiSkSVG.h +2 -0
- package/cpp/api/JsiSkSVGFactory.h +2 -0
- package/cpp/api/JsiSkShader.h +3 -1
- package/cpp/api/JsiSkShaderFactory.h +2 -0
- package/cpp/api/JsiSkSkottie.h +2 -0
- package/cpp/api/JsiSkSurface.h +51 -7
- package/cpp/api/JsiSkSurfaceFactory.h +2 -0
- package/cpp/api/JsiSkTextBlob.h +2 -0
- package/cpp/api/JsiSkTextBlobFactory.h +2 -0
- package/cpp/api/JsiSkTypeface.h +2 -0
- package/cpp/api/JsiSkTypefaceFactory.h +2 -0
- package/cpp/api/JsiSkTypefaceFontProvider.h +4 -0
- package/cpp/api/JsiSkTypefaceFontProviderFactory.h +4 -0
- package/cpp/api/JsiSkVertices.h +2 -0
- package/cpp/api/JsiSkiaContext.h +3 -1
- package/cpp/api/JsiSkottieFactory.h +2 -0
- package/cpp/api/JsiVideo.h +2 -0
- package/cpp/api/recorder/JsiRecorder.h +42 -7
- package/cpp/jsi/ViewProperty.h +3 -39
- package/cpp/rnskia/RNSkJsiViewApi.h +0 -5
- package/cpp/rnskia/RNSkPictureView.h +1 -24
- package/cpp/rnskia/RNSkView.h +0 -7
- package/lib/commonjs/renderer/Canvas.js +19 -14
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/skia/types/Picture/PictureFactory.d.ts +1 -1
- package/lib/commonjs/skia/types/Picture/PictureFactory.js.map +1 -1
- package/lib/commonjs/skia/types/Recorder.d.ts +2 -1
- package/lib/commonjs/skia/types/Recorder.js.map +1 -1
- package/lib/commonjs/sksg/Container.native.d.ts +4 -0
- package/lib/commonjs/sksg/Container.native.js +18 -6
- package/lib/commonjs/sksg/Container.native.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +1 -0
- package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js +4 -0
- package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
- package/lib/module/renderer/Canvas.js +19 -14
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/skia/types/Picture/PictureFactory.d.ts +1 -1
- package/lib/module/skia/types/Picture/PictureFactory.js.map +1 -1
- package/lib/module/skia/types/Recorder.d.ts +2 -1
- package/lib/module/skia/types/Recorder.js.map +1 -1
- package/lib/module/sksg/Container.native.d.ts +4 -0
- package/lib/module/sksg/Container.native.js +18 -6
- package/lib/module/sksg/Container.native.js.map +1 -1
- package/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +1 -0
- package/lib/module/sksg/Recorder/ReanimatedRecorder.js +4 -0
- package/lib/module/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
- package/lib/typescript/lib/commonjs/sksg/Container.native.d.ts +5 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +1 -0
- package/lib/typescript/lib/module/sksg/Container.native.d.ts +5 -0
- package/lib/typescript/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +1 -0
- package/lib/typescript/src/skia/types/Picture/PictureFactory.d.ts +1 -1
- package/lib/typescript/src/skia/types/Recorder.d.ts +2 -1
- package/lib/typescript/src/sksg/Container.native.d.ts +4 -0
- package/lib/typescript/src/sksg/Recorder/ReanimatedRecorder.d.ts +1 -0
- package/package.json +1 -1
- package/src/renderer/Canvas.tsx +16 -15
- package/src/skia/types/Picture/PictureFactory.ts +1 -1
- package/src/skia/types/Recorder.ts +2 -1
- package/src/sksg/Container.native.ts +25 -7
- package/src/sksg/Recorder/ReanimatedRecorder.ts +5 -0
package/cpp/api/JsiSkSkottie.h
CHANGED
package/cpp/api/JsiSkSurface.h
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
+
#include <algorithm>
|
|
4
|
+
#include <limits>
|
|
3
5
|
#include <memory>
|
|
4
6
|
#include <utility>
|
|
5
7
|
|
|
@@ -116,17 +118,59 @@ public:
|
|
|
116
118
|
|
|
117
119
|
size_t getMemoryPressure() const override {
|
|
118
120
|
auto surface = getObject();
|
|
119
|
-
if (!surface)
|
|
121
|
+
if (!surface) {
|
|
120
122
|
return 0;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const auto safeAdd = [](size_t a, size_t b) {
|
|
126
|
+
if (std::numeric_limits<size_t>::max() - a < b) {
|
|
127
|
+
return std::numeric_limits<size_t>::max();
|
|
128
|
+
}
|
|
129
|
+
return a + b;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
SkImageInfo info = surface->imageInfo();
|
|
133
|
+
size_t pixelBytes = info.computeMinByteSize();
|
|
134
|
+
if (pixelBytes == 0) {
|
|
135
|
+
auto width = std::max(info.width(), surface->width());
|
|
136
|
+
auto height = std::max(info.height(), surface->height());
|
|
137
|
+
int bytesPerPixel = info.bytesPerPixel();
|
|
138
|
+
if (bytesPerPixel <= 0) {
|
|
139
|
+
bytesPerPixel = 4;
|
|
140
|
+
}
|
|
141
|
+
if (width > 0 && height > 0) {
|
|
142
|
+
pixelBytes = static_cast<size_t>(width) * static_cast<size_t>(height) *
|
|
143
|
+
static_cast<size_t>(bytesPerPixel);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (pixelBytes == 0) {
|
|
148
|
+
return 0;
|
|
149
|
+
}
|
|
121
150
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
151
|
+
size_t estimated = pixelBytes;
|
|
152
|
+
|
|
153
|
+
auto canvas = surface->getCanvas();
|
|
154
|
+
const bool isGpuBacked =
|
|
155
|
+
surface->recordingContext() != nullptr ||
|
|
156
|
+
surface->recorder() != nullptr ||
|
|
157
|
+
(canvas && (canvas->recordingContext() != nullptr ||
|
|
158
|
+
canvas->recorder() != nullptr));
|
|
159
|
+
|
|
160
|
+
if (isGpuBacked) {
|
|
161
|
+
// Account for a resolved texture and depth/stencil attachments.
|
|
162
|
+
estimated = safeAdd(estimated, pixelBytes); // resolve/texture copy
|
|
163
|
+
estimated = safeAdd(estimated, pixelBytes / 2); // depth-stencil buffers
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Add a small overhead buffer for bookkeeping allocations.
|
|
167
|
+
estimated = safeAdd(estimated, 128 * 1024);
|
|
168
|
+
|
|
169
|
+
return estimated;
|
|
128
170
|
}
|
|
129
171
|
|
|
172
|
+
std::string getObjectType() const override { return "JsiSkSurface"; }
|
|
173
|
+
|
|
130
174
|
JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkSurface, width),
|
|
131
175
|
JSI_EXPORT_FUNC(JsiSkSurface, height),
|
|
132
176
|
JSI_EXPORT_FUNC(JsiSkSurface, getCanvas),
|
|
@@ -55,6 +55,8 @@ public:
|
|
|
55
55
|
|
|
56
56
|
size_t getMemoryPressure() const override { return 2048; }
|
|
57
57
|
|
|
58
|
+
std::string getObjectType() const override { return "JsiSkSurfaceFactory"; }
|
|
59
|
+
|
|
58
60
|
explicit JsiSkSurfaceFactory(std::shared_ptr<RNSkPlatformContext> context)
|
|
59
61
|
: JsiSkHostObject(std::move(context)) {}
|
|
60
62
|
};
|
package/cpp/api/JsiSkTextBlob.h
CHANGED
|
@@ -111,6 +111,8 @@ public:
|
|
|
111
111
|
|
|
112
112
|
size_t getMemoryPressure() const override { return 2048; }
|
|
113
113
|
|
|
114
|
+
std::string getObjectType() const override { return "JsiSkTextBlobFactory"; }
|
|
115
|
+
|
|
114
116
|
explicit JsiSkTextBlobFactory(std::shared_ptr<RNSkPlatformContext> context)
|
|
115
117
|
: JsiSkHostObject(std::move(context)) {}
|
|
116
118
|
};
|
package/cpp/api/JsiSkTypeface.h
CHANGED
|
@@ -27,6 +27,10 @@ public:
|
|
|
27
27
|
|
|
28
28
|
size_t getMemoryPressure() const override { return 2048; }
|
|
29
29
|
|
|
30
|
+
std::string getObjectType() const override {
|
|
31
|
+
return "JsiSkTypefaceFontProviderFactory";
|
|
32
|
+
}
|
|
33
|
+
|
|
30
34
|
explicit JsiSkTypefaceFontProviderFactory(
|
|
31
35
|
std::shared_ptr<RNSkPlatformContext> context)
|
|
32
36
|
: JsiSkHostObject(std::move(context)) {}
|
package/cpp/api/JsiSkVertices.h
CHANGED
|
@@ -47,6 +47,8 @@ public:
|
|
|
47
47
|
return vertices->approximateSize();
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
std::string getObjectType() const override { return "JsiSkVertices"; }
|
|
51
|
+
|
|
50
52
|
JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkVertices, bounds),
|
|
51
53
|
JSI_EXPORT_FUNC(JsiSkVertices, uniqueID),
|
|
52
54
|
JSI_EXPORT_FUNC(JsiSkVertices, dispose))
|
package/cpp/api/JsiSkiaContext.h
CHANGED
|
@@ -55,7 +55,9 @@ public:
|
|
|
55
55
|
std::shared_ptr<WindowContext> ctx)
|
|
56
56
|
: JsiSkWrappingSharedPtrHostObject(std::move(context), std::move(ctx)) {}
|
|
57
57
|
|
|
58
|
-
size_t getMemoryPressure() const override { return
|
|
58
|
+
size_t getMemoryPressure() const override { return 10 * 1024 * 1024; }
|
|
59
|
+
|
|
60
|
+
std::string getObjectType() const override { return "JsiSkiaContext"; }
|
|
59
61
|
|
|
60
62
|
/**
|
|
61
63
|
* Creates the function for construction a new instance of the SkFont
|
|
@@ -61,6 +61,8 @@ public:
|
|
|
61
61
|
|
|
62
62
|
size_t getMemoryPressure() const override { return 4096; }
|
|
63
63
|
|
|
64
|
+
std::string getObjectType() const override { return "JsiSkottieFactory"; }
|
|
65
|
+
|
|
64
66
|
explicit JsiSkottieFactory(std::shared_ptr<RNSkPlatformContext> context)
|
|
65
67
|
: JsiSkHostObject(std::move(context)) {}
|
|
66
68
|
};
|
package/cpp/api/JsiVideo.h
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
#include "JsiSkCanvas.h"
|
|
9
9
|
#include "JsiSkHostObjects.h"
|
|
10
|
+
#include "JsiSkPicture.h"
|
|
10
11
|
|
|
11
12
|
#include "DrawingCtx.h"
|
|
12
13
|
#include "RNRecorder.h"
|
|
@@ -53,17 +54,39 @@ public:
|
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
JSI_HOST_FUNCTION(play) {
|
|
57
|
+
// Check if a picture parameter was provided
|
|
58
|
+
if (count < 1 || arguments[0].isUndefined() || arguments[0].isNull()) {
|
|
59
|
+
throw jsi::JSError(runtime, "play() requires a Picture parameter");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Get the JsiSkPicture from the argument
|
|
63
|
+
auto pictureObject = arguments[0].asObject(runtime);
|
|
64
|
+
auto pictureHostObject = pictureObject.asHostObject<JsiSkPicture>(runtime);
|
|
65
|
+
if (!pictureHostObject) {
|
|
66
|
+
throw jsi::JSError(runtime, "Invalid Picture object provided to play()");
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Create a new picture recorder to record into
|
|
56
70
|
SkPictureRecorder pictureRecorder;
|
|
57
71
|
SkISize size = SkISize::Make(2'000'000, 2'000'000);
|
|
58
72
|
SkRect rect = SkRect::Make(size);
|
|
59
73
|
auto canvas = pictureRecorder.beginRecording(rect, nullptr);
|
|
74
|
+
|
|
75
|
+
// Play the recorded commands into the canvas
|
|
60
76
|
DrawingCtx ctx(canvas);
|
|
61
77
|
getObject()->play(&ctx);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
78
|
+
|
|
79
|
+
// Finish recording and get the new picture
|
|
80
|
+
auto newPicture = pictureRecorder.finishRecordingAsPicture();
|
|
81
|
+
|
|
82
|
+
// Update the existing JsiSkPicture object with the new SkPicture
|
|
83
|
+
// This reuses the existing JavaScript object instead of creating a new one
|
|
84
|
+
pictureHostObject->setObject(std::move(newPicture));
|
|
85
|
+
auto memoryPressure = pictureHostObject->getMemoryPressure();
|
|
86
|
+
pictureObject.setExternalMemoryPressure(runtime, memoryPressure);
|
|
87
|
+
|
|
88
|
+
// Return undefined since we're modifying the passed-in object
|
|
89
|
+
return jsi::Value::undefined();
|
|
67
90
|
}
|
|
68
91
|
|
|
69
92
|
JSI_HOST_FUNCTION(applyUpdates) {
|
|
@@ -271,6 +294,13 @@ public:
|
|
|
271
294
|
return jsi::Value::undefined();
|
|
272
295
|
}
|
|
273
296
|
|
|
297
|
+
JSI_HOST_FUNCTION(reset) {
|
|
298
|
+
auto newRecorder = std::make_shared<Recorder>();
|
|
299
|
+
newRecorder->_context = getContext();
|
|
300
|
+
setObject(newRecorder);
|
|
301
|
+
return jsi::Value::undefined();
|
|
302
|
+
}
|
|
303
|
+
|
|
274
304
|
EXPORT_JSI_API_TYPENAME(JsiRecorder, Recorder)
|
|
275
305
|
|
|
276
306
|
JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiRecorder, saveGroup),
|
|
@@ -314,9 +344,14 @@ public:
|
|
|
314
344
|
JSI_EXPORT_FUNC(JsiRecorder, drawAtlas),
|
|
315
345
|
JSI_EXPORT_FUNC(JsiRecorder, drawSkottie),
|
|
316
346
|
JSI_EXPORT_FUNC(JsiRecorder, play),
|
|
317
|
-
JSI_EXPORT_FUNC(JsiRecorder, applyUpdates)
|
|
347
|
+
JSI_EXPORT_FUNC(JsiRecorder, applyUpdates),
|
|
348
|
+
JSI_EXPORT_FUNC(JsiRecorder, reset))
|
|
349
|
+
|
|
350
|
+
// This has no basis in reality but since since these are private long-lived
|
|
351
|
+
// objects, we think it is more than fine.
|
|
352
|
+
size_t getMemoryPressure() const override { return 10 * 1024 * 1024; }
|
|
318
353
|
|
|
319
|
-
|
|
354
|
+
std::string getObjectType() const override { return "JsiRecorder"; }
|
|
320
355
|
|
|
321
356
|
static const jsi::HostFunctionType
|
|
322
357
|
createCtor(std::shared_ptr<RNSkPlatformContext> context) {
|
package/cpp/jsi/ViewProperty.h
CHANGED
|
@@ -27,9 +27,7 @@ public:
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
void onRuntimeDestroyed(jsi::Runtime *) override {
|
|
31
|
-
_runtime.store(nullptr);
|
|
32
|
-
}
|
|
30
|
+
void onRuntimeDestroyed(jsi::Runtime *) override { _runtime.store(nullptr); }
|
|
33
31
|
|
|
34
32
|
jsi::Runtime *getRuntime() const { return _runtime.load(); }
|
|
35
33
|
|
|
@@ -55,47 +53,13 @@ public:
|
|
|
55
53
|
|
|
56
54
|
template <typename PlatformContext>
|
|
57
55
|
ViewProperty(jsi::Runtime &runtime, const jsi::Value &value,
|
|
58
|
-
PlatformContext platformContext, size_t nativeId) {
|
|
59
|
-
// Set the onSize callback with all the necessary context
|
|
60
|
-
auto runtimeGuard = std::make_shared<RuntimeAwareRuntimeGuard>(runtime);
|
|
61
|
-
_value = std::function<void(int, int)>(
|
|
62
|
-
[runtimeGuard, platformContext, nativeId](int width, int height) {
|
|
63
|
-
auto runtimePtr = runtimeGuard->getRuntime();
|
|
64
|
-
if (runtimePtr == nullptr) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
jsi::Runtime &runtime = *runtimePtr;
|
|
69
|
-
jsi::Object size(runtime);
|
|
70
|
-
auto pd = platformContext->getPixelDensity();
|
|
71
|
-
size.setProperty(runtime, "width", jsi::Value(width / pd));
|
|
72
|
-
size.setProperty(runtime, "height", jsi::Value(height / pd));
|
|
73
|
-
|
|
74
|
-
// Get the stored shared value from global
|
|
75
|
-
std::string globalKey =
|
|
76
|
-
"__onSize_" + std::to_string(static_cast<int>(nativeId));
|
|
77
|
-
auto globalProp =
|
|
78
|
-
runtime.global().getProperty(runtime, globalKey.c_str());
|
|
79
|
-
if (!globalProp.isUndefined()) {
|
|
80
|
-
globalProp.asObject(runtime).setProperty(runtime, "value", size);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
}
|
|
56
|
+
PlatformContext platformContext, size_t nativeId) {}
|
|
84
57
|
|
|
85
58
|
bool isNull() { return std::holds_alternative<std::nullptr_t>(_value); }
|
|
86
59
|
|
|
87
60
|
sk_sp<SkPicture> getPicture() { return std::get<sk_sp<SkPicture>>(_value); }
|
|
88
61
|
|
|
89
|
-
std::variant<std::nullptr_t, std::function<void(int, int)>>
|
|
90
|
-
getOnSize() const {
|
|
91
|
-
if (std::holds_alternative<std::function<void(int, int)>>(_value)) {
|
|
92
|
-
return std::get<std::function<void(int, int)>>(_value);
|
|
93
|
-
}
|
|
94
|
-
return nullptr;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
62
|
private:
|
|
98
|
-
std::variant<std::nullptr_t, sk_sp<SkPicture
|
|
99
|
-
_value = nullptr;
|
|
63
|
+
std::variant<std::nullptr_t, sk_sp<SkPicture>> _value = nullptr;
|
|
100
64
|
};
|
|
101
65
|
} // namespace RNJsi
|
|
@@ -106,11 +106,6 @@ public:
|
|
|
106
106
|
info->props.insert_or_assign(
|
|
107
107
|
arguments[1].asString(runtime).utf8(runtime),
|
|
108
108
|
RNJsi::ViewProperty(runtime, arguments[2]));
|
|
109
|
-
if (info->props.find("onSize") == info->props.end()) {
|
|
110
|
-
info->props.insert_or_assign(
|
|
111
|
-
"onSize", RNJsi::ViewProperty(runtime, arguments[2],
|
|
112
|
-
_platformContext, nativeId));
|
|
113
|
-
}
|
|
114
109
|
// Now let's see if we have a view that we can update
|
|
115
110
|
if (info->view != nullptr) {
|
|
116
111
|
// Update view!
|
|
@@ -56,25 +56,8 @@ public:
|
|
|
56
56
|
_requestRedraw();
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
void setOnSize(
|
|
60
|
-
std::variant<std::nullptr_t, std::function<void(int, int)>> onSize) {
|
|
61
|
-
_onSize = onSize;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
59
|
private:
|
|
65
60
|
bool performDraw(std::shared_ptr<RNSkCanvasProvider> canvasProvider) {
|
|
66
|
-
// Call onSize callback only if the size has changed
|
|
67
|
-
int currentWidth = canvasProvider->getWidth();
|
|
68
|
-
int currentHeight = canvasProvider->getHeight();
|
|
69
|
-
|
|
70
|
-
if (std::holds_alternative<std::function<void(int, int)>>(_onSize)) {
|
|
71
|
-
if (_lastWidth != currentWidth || _lastHeight != currentHeight) {
|
|
72
|
-
_lastWidth = currentWidth;
|
|
73
|
-
_lastHeight = currentHeight;
|
|
74
|
-
std::get<std::function<void(int, int)>>(_onSize)(currentWidth,
|
|
75
|
-
currentHeight);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
61
|
return canvasProvider->renderToCanvas([=, this](SkCanvas *canvas) {
|
|
79
62
|
// Make sure to scale correctly
|
|
80
63
|
auto pd = _platformContext->getPixelDensity();
|
|
@@ -90,9 +73,6 @@ private:
|
|
|
90
73
|
|
|
91
74
|
std::shared_ptr<RNSkPlatformContext> _platformContext;
|
|
92
75
|
sk_sp<SkPicture> _picture;
|
|
93
|
-
std::variant<std::nullptr_t, std::function<void(int, int)>> _onSize = nullptr;
|
|
94
|
-
int _lastWidth = -1;
|
|
95
|
-
int _lastHeight = -1;
|
|
96
76
|
};
|
|
97
77
|
|
|
98
78
|
class RNSkPictureView : public RNSkView {
|
|
@@ -109,7 +89,7 @@ public:
|
|
|
109
89
|
|
|
110
90
|
void setJsiProperties(
|
|
111
91
|
std::unordered_map<std::string, RNJsi::ViewProperty> &props) override {
|
|
112
|
-
// Base implementation
|
|
92
|
+
// Base implementation
|
|
113
93
|
for (auto &prop : props) {
|
|
114
94
|
if (prop.first == "picture") {
|
|
115
95
|
if (prop.second.isNull()) {
|
|
@@ -121,9 +101,6 @@ public:
|
|
|
121
101
|
// Save picture
|
|
122
102
|
std::static_pointer_cast<RNSkPictureRenderer>(getRenderer())
|
|
123
103
|
->setPicture(prop.second.getPicture());
|
|
124
|
-
} else if (prop.first == "onSize") {
|
|
125
|
-
std::static_pointer_cast<RNSkPictureRenderer>(getRenderer())
|
|
126
|
-
->setOnSize(prop.second.getOnSize());
|
|
127
104
|
}
|
|
128
105
|
}
|
|
129
106
|
}
|
package/cpp/rnskia/RNSkView.h
CHANGED
|
@@ -148,13 +148,6 @@ public:
|
|
|
148
148
|
virtual void setJsiProperties(
|
|
149
149
|
std::unordered_map<std::string, RNJsi::ViewProperty> &props) = 0;
|
|
150
150
|
|
|
151
|
-
virtual void
|
|
152
|
-
setJsiProperties(std::unordered_map<std::string, RNJsi::ViewProperty> &props,
|
|
153
|
-
std::function<jsi::Object(int, int)> onSize) {
|
|
154
|
-
// Default implementation just calls the base method, ignoring onSize
|
|
155
|
-
setJsiProperties(props);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
151
|
void requestRedraw() {
|
|
159
152
|
if (!_redrawRequested) {
|
|
160
153
|
_redrawRequested = true;
|
|
@@ -20,6 +20,8 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
20
20
|
const useCanvasRef = () => (0, _react.useRef)(null);
|
|
21
21
|
exports.useCanvasRef = useCanvasRef;
|
|
22
22
|
const useReanimatedFrame = !_external.HAS_REANIMATED_3 ? () => {} : _ReanimatedProxy.default.useFrameCallback;
|
|
23
|
+
const measure = !_external.HAS_REANIMATED_3 ? null : _ReanimatedProxy.default.measure;
|
|
24
|
+
const useCanvasRefPriv = !_external.HAS_REANIMATED_3 ? _react.useRef : _ReanimatedProxy.default.useAnimatedRef;
|
|
23
25
|
const useCanvasSize = userRef => {
|
|
24
26
|
const ourRef = useCanvasRef();
|
|
25
27
|
const ref = userRef !== null && userRef !== void 0 ? userRef : ourRef;
|
|
@@ -63,7 +65,7 @@ const Canvas = ({
|
|
|
63
65
|
if (onLayout && isFabric) {
|
|
64
66
|
console.error("<Canvas onLayout={onLayout} /> is not supported on the new architecture, to fix the issue, see: https://shopify.github.io/react-native-skia/docs/canvas/overview/#getting-the-canvas-size");
|
|
65
67
|
}
|
|
66
|
-
const viewRef = (
|
|
68
|
+
const viewRef = useCanvasRefPriv(null);
|
|
67
69
|
// Native ID
|
|
68
70
|
const nativeId = (0, _react.useMemo)(() => {
|
|
69
71
|
return _SkiaViewNativeId.SkiaViewNativeId.current++;
|
|
@@ -73,20 +75,23 @@ const Canvas = ({
|
|
|
73
75
|
const root = (0, _react.useMemo)(() => new _Reconciler.SkiaSGRoot(_skia.Skia, nativeId), [nativeId]);
|
|
74
76
|
useReanimatedFrame(() => {
|
|
75
77
|
"worklet";
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
78
|
+
|
|
79
|
+
if (onSize && measure) {
|
|
80
|
+
const result = measure(viewRef);
|
|
81
|
+
if (result) {
|
|
82
|
+
const {
|
|
83
|
+
width,
|
|
84
|
+
height
|
|
85
|
+
} = result;
|
|
86
|
+
if (onSize.value.width !== width || onSize.value.height !== height) {
|
|
87
|
+
onSize.value = {
|
|
88
|
+
width,
|
|
89
|
+
height
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
87
93
|
}
|
|
88
|
-
|
|
89
|
-
}, [onSize, nativeId]);
|
|
94
|
+
}, !!onSize);
|
|
90
95
|
|
|
91
96
|
// Render effects
|
|
92
97
|
(0, _react.useLayoutEffect)(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_ReanimatedProxy","_interopRequireDefault","_SkiaViewNativeId","_SkiaPictureViewNativeComponent","_Reconciler","_skia","_Platform","_external","_global","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_extends","assign","bind","arguments","length","apply","useCanvasRef","useRef","exports","useReanimatedFrame","HAS_REANIMATED_3","Rea","useFrameCallback","useCanvasSize","userRef","ourRef","ref","size","setSize","useState","width","height","useLayoutEffect","current","measure","_x","_y","isFabric","Boolean","global","nativeFabricUIManager","Canvas","debug","opaque","children","onSize","colorSpace","onLayout","viewProps","console","error","viewRef","nativeId","useMemo","SkiaViewNativeId","root","SkiaSGRoot","Skia","useEffect","runOnUI","undefined","render","unmount","useImperativeHandle","makeImageSnapshot","rect","SkiaViewApi","makeImageSnapshotAsync","redraw","requestRedraw","getNativeId","callback","_viewRef$current","measureInWindow","_viewRef$current2","onLayoutWeb","useCallback","Platform","OS","nativeEvent","layout","value","createElement","collapsable","nativeID"],"sources":["Canvas.tsx"],"sourcesContent":["import type { FC, RefObject } from \"react\";\nimport React, {\n useCallback,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type {\n LayoutChangeEvent,\n MeasureInWindowOnSuccessCallback,\n MeasureOnSuccessCallback,\n View,\n ViewProps,\n} from \"react-native\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport Rea from \"../external/reanimated/ReanimatedProxy\";\nimport { SkiaViewNativeId } from \"../views/SkiaViewNativeId\";\nimport SkiaPictureViewNativeComponent from \"../specs/SkiaPictureViewNativeComponent\";\nimport type { SkImage, SkRect, SkSize } from \"../skia/types\";\nimport { SkiaSGRoot } from \"../sksg/Reconciler\";\nimport { Skia } from \"../skia\";\nimport { Platform } from \"../Platform\";\nimport { HAS_REANIMATED_3 } from \"../external\";\n\nexport interface CanvasRef extends FC<CanvasProps> {\n makeImageSnapshot(rect?: SkRect): SkImage;\n makeImageSnapshotAsync(rect?: SkRect): Promise<SkImage>;\n redraw(): void;\n getNativeId(): number;\n measure(callback: MeasureOnSuccessCallback): void;\n measureInWindow(callback: MeasureInWindowOnSuccessCallback): void;\n}\n\nexport const useCanvasRef = () => useRef<CanvasRef>(null);\n\nconst useReanimatedFrame = !HAS_REANIMATED_3 ? () => {} : Rea.useFrameCallback;\n\nexport const useCanvasSize = (userRef?: RefObject<CanvasRef | null>) => {\n const ourRef = useCanvasRef();\n const ref = userRef ?? ourRef;\n const [size, setSize] = useState<SkSize>({ width: 0, height: 0 });\n useLayoutEffect(() => {\n if (ref.current) {\n ref.current.measure((_x, _y, width, height) => {\n setSize({ width, height });\n });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n return { ref, size };\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const isFabric = Boolean((global as any)?.nativeFabricUIManager);\n\nexport interface CanvasProps extends Omit<ViewProps, \"onLayout\"> {\n debug?: boolean;\n opaque?: boolean;\n onSize?: SharedValue<SkSize>;\n colorSpace?: \"p3\" | \"srgb\";\n ref?: React.Ref<CanvasRef>;\n __destroyWebGLContextAfterRender?: boolean;\n}\n\nexport const Canvas = ({\n debug,\n opaque,\n children,\n onSize,\n colorSpace = \"p3\",\n ref,\n // Here know this is a type error but this is done on purpose to check it at runtime\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n onLayout,\n ...viewProps\n}: CanvasProps) => {\n if (onLayout && isFabric) {\n console.error(\n \"<Canvas onLayout={onLayout} /> is not supported on the new architecture, to fix the issue, see: https://shopify.github.io/react-native-skia/docs/canvas/overview/#getting-the-canvas-size\"\n );\n }\n const viewRef = useRef<View>(null);\n // Native ID\n const nativeId = useMemo(() => {\n return SkiaViewNativeId.current++;\n }, []);\n\n // Root\n const root = useMemo(() => new SkiaSGRoot(Skia, nativeId), [nativeId]);\n\n useReanimatedFrame(() => {\n \"worklet\";\n }, !!onSize);\n useEffect(() => {\n if (onSize) {\n Rea.runOnUI(() => {\n (global as Record<string, unknown>)[`__onSize_${nativeId}`] = onSize;\n })();\n return () => {\n Rea.runOnUI(() => {\n delete (global as Record<string, unknown>)[`__onSize_${nativeId}`];\n })();\n };\n }\n return undefined;\n }, [onSize, nativeId]);\n\n // Render effects\n useLayoutEffect(() => {\n root.render(children);\n }, [children, root, nativeId]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n // Component methods\n useImperativeHandle(\n ref,\n () =>\n ({\n makeImageSnapshot: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshot(nativeId, rect);\n },\n makeImageSnapshotAsync: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshotAsync(nativeId, rect);\n },\n redraw: () => {\n SkiaViewApi.requestRedraw(nativeId);\n },\n getNativeId: () => {\n return nativeId;\n },\n measure: (callback) => {\n viewRef.current?.measure(callback);\n },\n measureInWindow: (callback) => {\n viewRef.current?.measureInWindow(callback);\n },\n }) as CanvasRef\n );\n\n const onLayoutWeb = useCallback(\n (e: LayoutChangeEvent) => {\n if (onLayout) {\n onLayout(e);\n }\n if (Platform.OS === \"web\" && onSize) {\n const { width, height } = e.nativeEvent.layout;\n onSize.value = { width, height };\n }\n },\n [onLayout, onSize]\n );\n\n return (\n <SkiaPictureViewNativeComponent\n ref={viewRef}\n collapsable={false}\n nativeID={`${nativeId}`}\n debug={debug}\n opaque={opaque}\n colorSpace={colorSpace}\n onLayout={onLayoutWeb}\n {...viewProps}\n />\n );\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAkBA,IAAAC,gBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AACA,IAAAI,+BAAA,GAAAF,sBAAA,CAAAF,OAAA;AAEA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AAA+C,IAAAS,OAAA;AAAA,SAAAP,uBAAAQ,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAA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,GAAGzC,CAAC,CAACyF,WAAW,CAACC,MAAM;MAC9CnC,MAAM,CAACoC,KAAK,GAAG;QAAEnD,KAAK;QAAEC;MAAO,CAAC;IAClC;EACF,CAAC,EACD,CAACgB,QAAQ,EAAEF,MAAM,CACnB,CAAC;EAED,oBACEnE,MAAA,CAAAc,OAAA,CAAA0F,aAAA,CAAClG,+BAAA,CAAAQ,OAA8B,EAAAkB,QAAA;IAC7BgB,GAAG,EAAEyB,OAAQ;IACbgC,WAAW,EAAE,KAAM;IACnBC,QAAQ,EAAE,GAAGhC,QAAQ,EAAG;IACxBV,KAAK,EAAEA,KAAM;IACbC,MAAM,EAAEA,MAAO;IACfG,UAAU,EAAEA,UAAW;IACvBC,QAAQ,EAAE4B;EAAY,GAClB3B,SAAS,CACd,CAAC;AAEN,CAAC;AAAC9B,OAAA,CAAAuB,MAAA,GAAAA,MAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_ReanimatedProxy","_interopRequireDefault","_SkiaViewNativeId","_SkiaPictureViewNativeComponent","_Reconciler","_skia","_Platform","_external","_global","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_extends","assign","bind","arguments","length","apply","useCanvasRef","useRef","exports","useReanimatedFrame","HAS_REANIMATED_3","Rea","useFrameCallback","measure","useCanvasRefPriv","useAnimatedRef","useCanvasSize","userRef","ourRef","ref","size","setSize","useState","width","height","useLayoutEffect","current","_x","_y","isFabric","Boolean","global","nativeFabricUIManager","Canvas","debug","opaque","children","onSize","colorSpace","onLayout","viewProps","console","error","viewRef","nativeId","useMemo","SkiaViewNativeId","root","SkiaSGRoot","Skia","result","value","render","useEffect","unmount","useImperativeHandle","makeImageSnapshot","rect","SkiaViewApi","makeImageSnapshotAsync","redraw","requestRedraw","getNativeId","callback","_viewRef$current","measureInWindow","_viewRef$current2","onLayoutWeb","useCallback","Platform","OS","nativeEvent","layout","createElement","collapsable","nativeID"],"sources":["Canvas.tsx"],"sourcesContent":["import type { FC, RefObject } from \"react\";\nimport React, {\n useCallback,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type {\n LayoutChangeEvent,\n MeasureInWindowOnSuccessCallback,\n MeasureOnSuccessCallback,\n View,\n ViewProps,\n} from \"react-native\";\nimport type { AnimatedRef, SharedValue } from \"react-native-reanimated\";\n\nimport Rea from \"../external/reanimated/ReanimatedProxy\";\nimport { SkiaViewNativeId } from \"../views/SkiaViewNativeId\";\nimport SkiaPictureViewNativeComponent from \"../specs/SkiaPictureViewNativeComponent\";\nimport type { SkImage, SkRect, SkSize } from \"../skia/types\";\nimport { SkiaSGRoot } from \"../sksg/Reconciler\";\nimport { Skia } from \"../skia\";\nimport { Platform } from \"../Platform\";\nimport { HAS_REANIMATED_3 } from \"../external\";\n\nexport interface CanvasRef extends FC<CanvasProps> {\n makeImageSnapshot(rect?: SkRect): SkImage;\n makeImageSnapshotAsync(rect?: SkRect): Promise<SkImage>;\n redraw(): void;\n getNativeId(): number;\n measure(callback: MeasureOnSuccessCallback): void;\n measureInWindow(callback: MeasureInWindowOnSuccessCallback): void;\n}\n\nexport const useCanvasRef = () => useRef<CanvasRef>(null);\n\nconst useReanimatedFrame = !HAS_REANIMATED_3 ? () => {} : Rea.useFrameCallback;\nconst measure = !HAS_REANIMATED_3 ? null : Rea.measure;\n\nconst useCanvasRefPriv: typeof useRef<View> = !HAS_REANIMATED_3\n ? useRef\n : Rea.useAnimatedRef;\n\nexport const useCanvasSize = (userRef?: RefObject<CanvasRef | null>) => {\n const ourRef = useCanvasRef();\n const ref = userRef ?? ourRef;\n const [size, setSize] = useState<SkSize>({ width: 0, height: 0 });\n useLayoutEffect(() => {\n if (ref.current) {\n ref.current.measure((_x, _y, width, height) => {\n setSize({ width, height });\n });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n return { ref, size };\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const isFabric = Boolean((global as any)?.nativeFabricUIManager);\n\nexport interface CanvasProps extends Omit<ViewProps, \"onLayout\"> {\n debug?: boolean;\n opaque?: boolean;\n onSize?: SharedValue<SkSize>;\n colorSpace?: \"p3\" | \"srgb\";\n ref?: React.Ref<CanvasRef>;\n __destroyWebGLContextAfterRender?: boolean;\n}\n\nexport const Canvas = ({\n debug,\n opaque,\n children,\n onSize,\n colorSpace = \"p3\",\n ref,\n // Here know this is a type error but this is done on purpose to check it at runtime\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n onLayout,\n ...viewProps\n}: CanvasProps) => {\n if (onLayout && isFabric) {\n console.error(\n \"<Canvas onLayout={onLayout} /> is not supported on the new architecture, to fix the issue, see: https://shopify.github.io/react-native-skia/docs/canvas/overview/#getting-the-canvas-size\"\n );\n }\n const viewRef = useCanvasRefPriv(null);\n // Native ID\n const nativeId = useMemo(() => {\n return SkiaViewNativeId.current++;\n }, []);\n\n // Root\n const root = useMemo(() => new SkiaSGRoot(Skia, nativeId), [nativeId]);\n\n useReanimatedFrame(() => {\n \"worklet\";\n if (onSize && measure) {\n const result = measure(viewRef as AnimatedRef<View>);\n if (result) {\n const { width, height } = result;\n if (onSize.value.width !== width || onSize.value.height !== height) {\n onSize.value = { width, height };\n }\n }\n }\n }, !!onSize);\n\n // Render effects\n useLayoutEffect(() => {\n root.render(children);\n }, [children, root, nativeId]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n // Component methods\n useImperativeHandle(\n ref,\n () =>\n ({\n makeImageSnapshot: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshot(nativeId, rect);\n },\n makeImageSnapshotAsync: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshotAsync(nativeId, rect);\n },\n redraw: () => {\n SkiaViewApi.requestRedraw(nativeId);\n },\n getNativeId: () => {\n return nativeId;\n },\n measure: (callback) => {\n viewRef.current?.measure(callback);\n },\n measureInWindow: (callback) => {\n viewRef.current?.measureInWindow(callback);\n },\n }) as CanvasRef\n );\n\n const onLayoutWeb = useCallback(\n (e: LayoutChangeEvent) => {\n if (onLayout) {\n onLayout(e);\n }\n if (Platform.OS === \"web\" && onSize) {\n const { width, height } = e.nativeEvent.layout;\n onSize.value = { width, height };\n }\n },\n [onLayout, onSize]\n );\n\n return (\n <SkiaPictureViewNativeComponent\n ref={viewRef}\n collapsable={false}\n nativeID={`${nativeId}`}\n debug={debug}\n opaque={opaque}\n colorSpace={colorSpace}\n onLayout={onLayoutWeb}\n {...viewProps}\n />\n );\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAkBA,IAAAC,gBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AACA,IAAAI,+BAAA,GAAAF,sBAAA,CAAAF,OAAA;AAEA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AAA+C,IAAAS,OAAA;AAAA,SAAAP,uBAAAQ,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAX,wBAAAW,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAE,OAAA,EAAAF,CAAA,QAAAM,CAAA,GAAAH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AA8B,EAAAkB,QAAA;IAC7BmB,GAAG,EAAEwB,OAAQ;IACb+B,WAAW,EAAE,KAAM;IACnBC,QAAQ,EAAE,GAAG/B,QAAQ,EAAG;IACxBV,KAAK,EAAEA,KAAM;IACbC,MAAM,EAAEA,MAAO;IACfG,UAAU,EAAEA,UAAW;IACvBC,QAAQ,EAAE4B;EAAY,GAClB3B,SAAS,CACd,CAAC;AAEN,CAAC;AAAChC,OAAA,CAAAyB,MAAA,GAAAA,MAAA","ignoreList":[]}
|
|
@@ -4,5 +4,5 @@ export interface PictureFactory {
|
|
|
4
4
|
* Returns an SkPicture which has been serialized previously to the given bytes.
|
|
5
5
|
* @param bytes
|
|
6
6
|
*/
|
|
7
|
-
MakePicture(bytes: Uint8Array | ArrayBuffer): SkPicture | null;
|
|
7
|
+
MakePicture(bytes: Uint8Array | ArrayBuffer | null): SkPicture | null;
|
|
8
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["PictureFactory.ts"],"sourcesContent":["import type { SkPicture } from \"./Picture\";\n\nexport interface PictureFactory {\n /**\n * Returns an SkPicture which has been serialized previously to the given bytes.\n * @param bytes\n */\n MakePicture(bytes: Uint8Array | ArrayBuffer): SkPicture | null;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["PictureFactory.ts"],"sourcesContent":["import type { SkPicture } from \"./Picture\";\n\nexport interface PictureFactory {\n /**\n * Returns an SkPicture which has been serialized previously to the given bytes.\n * @param bytes\n */\n MakePicture(bytes: Uint8Array | ArrayBuffer | null): SkPicture | null;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -48,6 +48,7 @@ export interface BaseRecorder {
|
|
|
48
48
|
drawAtlas(props: AnimatedProps<AtlasProps>): void;
|
|
49
49
|
}
|
|
50
50
|
export interface JsiRecorder extends BaseRecorder {
|
|
51
|
-
play():
|
|
51
|
+
play(picture: SkPicture): void;
|
|
52
52
|
applyUpdates(variables: SharedValue<unknown>[]): void;
|
|
53
|
+
reset(): void;
|
|
53
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["Recorder.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport type {\n TextProps,\n AtlasProps,\n BlurMaskFilterProps,\n BoxProps,\n BoxShadowProps,\n CircleProps,\n CTMProps,\n DiffRectProps,\n GlyphsProps,\n ImageProps,\n ImageSVGProps,\n LineProps,\n NodeType,\n OvalProps,\n PaintProps,\n ParagraphProps,\n PatchProps,\n PathProps,\n PictureProps,\n PointsProps,\n RectProps,\n RoundedRectProps,\n TextBlobProps,\n TextPathProps,\n VerticesProps,\n SkottieProps,\n} from \"../../dom/types\";\nimport type { AnimatedProps } from \"../../renderer/processors/Animations/Animations\";\n\nimport type { SkPicture } from \"./Picture\";\n\nexport interface BaseRecorder {\n saveGroup(): void;\n restoreGroup(): void;\n savePaint(props: AnimatedProps<PaintProps>, standalone: boolean): void;\n restorePaint(): void;\n restorePaintDeclaration(): void;\n materializePaint(): void;\n pushPathEffect(pathEffectType: NodeType, props: AnimatedProps<unknown>): void;\n pushImageFilter(\n imageFilterType: NodeType,\n props: AnimatedProps<unknown>\n ): void;\n pushColorFilter(\n colorFilterType: NodeType,\n props: AnimatedProps<unknown>\n ): void;\n pushShader(\n shaderType: NodeType,\n props: AnimatedProps<unknown>,\n children: number\n ): void;\n pushBlurMaskFilter(props: AnimatedProps<BlurMaskFilterProps>): void;\n composePathEffect(): void;\n composeColorFilter(): void;\n composeImageFilter(): void;\n saveCTM(props: AnimatedProps<CTMProps>): void;\n restoreCTM(): void;\n drawPaint(): void;\n saveLayer(): void;\n saveBackdropFilter(): void;\n drawBox(\n boxProps: AnimatedProps<BoxProps>,\n shadows: {\n props: BoxShadowProps;\n animatedProps?: Record<string, SharedValue<unknown>>;\n }[]\n ): void;\n drawImage(props: AnimatedProps<ImageProps>): void;\n drawCircle(props: AnimatedProps<CircleProps>): void;\n drawPoints(props: AnimatedProps<PointsProps>): void;\n drawPath(props: AnimatedProps<PathProps>): void;\n drawRect(props: AnimatedProps<RectProps>): void;\n drawRRect(props: AnimatedProps<RoundedRectProps>): void;\n drawOval(props: AnimatedProps<OvalProps>): void;\n drawLine(props: AnimatedProps<LineProps>): void;\n drawPatch(props: AnimatedProps<PatchProps>): void;\n drawVertices(props: AnimatedProps<VerticesProps>): void;\n drawDiffRect(props: AnimatedProps<DiffRectProps>): void;\n drawText(props: AnimatedProps<TextProps>): void;\n drawTextPath(props: AnimatedProps<TextPathProps>): void;\n drawTextBlob(props: AnimatedProps<TextBlobProps>): void;\n drawGlyphs(props: AnimatedProps<GlyphsProps>): void;\n drawPicture(props: AnimatedProps<PictureProps>): void;\n drawImageSVG(props: AnimatedProps<ImageSVGProps>): void;\n drawParagraph(props: AnimatedProps<ParagraphProps>): void;\n drawSkottie(props: AnimatedProps<SkottieProps>): void;\n drawAtlas(props: AnimatedProps<AtlasProps>): void;\n}\n\nexport interface JsiRecorder extends BaseRecorder {\n play():
|
|
1
|
+
{"version":3,"names":[],"sources":["Recorder.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport type {\n TextProps,\n AtlasProps,\n BlurMaskFilterProps,\n BoxProps,\n BoxShadowProps,\n CircleProps,\n CTMProps,\n DiffRectProps,\n GlyphsProps,\n ImageProps,\n ImageSVGProps,\n LineProps,\n NodeType,\n OvalProps,\n PaintProps,\n ParagraphProps,\n PatchProps,\n PathProps,\n PictureProps,\n PointsProps,\n RectProps,\n RoundedRectProps,\n TextBlobProps,\n TextPathProps,\n VerticesProps,\n SkottieProps,\n} from \"../../dom/types\";\nimport type { AnimatedProps } from \"../../renderer/processors/Animations/Animations\";\n\nimport type { SkPicture } from \"./Picture\";\n\nexport interface BaseRecorder {\n saveGroup(): void;\n restoreGroup(): void;\n savePaint(props: AnimatedProps<PaintProps>, standalone: boolean): void;\n restorePaint(): void;\n restorePaintDeclaration(): void;\n materializePaint(): void;\n pushPathEffect(pathEffectType: NodeType, props: AnimatedProps<unknown>): void;\n pushImageFilter(\n imageFilterType: NodeType,\n props: AnimatedProps<unknown>\n ): void;\n pushColorFilter(\n colorFilterType: NodeType,\n props: AnimatedProps<unknown>\n ): void;\n pushShader(\n shaderType: NodeType,\n props: AnimatedProps<unknown>,\n children: number\n ): void;\n pushBlurMaskFilter(props: AnimatedProps<BlurMaskFilterProps>): void;\n composePathEffect(): void;\n composeColorFilter(): void;\n composeImageFilter(): void;\n saveCTM(props: AnimatedProps<CTMProps>): void;\n restoreCTM(): void;\n drawPaint(): void;\n saveLayer(): void;\n saveBackdropFilter(): void;\n drawBox(\n boxProps: AnimatedProps<BoxProps>,\n shadows: {\n props: BoxShadowProps;\n animatedProps?: Record<string, SharedValue<unknown>>;\n }[]\n ): void;\n drawImage(props: AnimatedProps<ImageProps>): void;\n drawCircle(props: AnimatedProps<CircleProps>): void;\n drawPoints(props: AnimatedProps<PointsProps>): void;\n drawPath(props: AnimatedProps<PathProps>): void;\n drawRect(props: AnimatedProps<RectProps>): void;\n drawRRect(props: AnimatedProps<RoundedRectProps>): void;\n drawOval(props: AnimatedProps<OvalProps>): void;\n drawLine(props: AnimatedProps<LineProps>): void;\n drawPatch(props: AnimatedProps<PatchProps>): void;\n drawVertices(props: AnimatedProps<VerticesProps>): void;\n drawDiffRect(props: AnimatedProps<DiffRectProps>): void;\n drawText(props: AnimatedProps<TextProps>): void;\n drawTextPath(props: AnimatedProps<TextPathProps>): void;\n drawTextBlob(props: AnimatedProps<TextBlobProps>): void;\n drawGlyphs(props: AnimatedProps<GlyphsProps>): void;\n drawPicture(props: AnimatedProps<PictureProps>): void;\n drawImageSVG(props: AnimatedProps<ImageSVGProps>): void;\n drawParagraph(props: AnimatedProps<ParagraphProps>): void;\n drawSkottie(props: AnimatedProps<SkottieProps>): void;\n drawAtlas(props: AnimatedProps<AtlasProps>): void;\n}\n\nexport interface JsiRecorder extends BaseRecorder {\n play(picture: SkPicture): void;\n applyUpdates(variables: SharedValue<unknown>[]): void;\n reset(): void;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -5,6 +5,10 @@ import "../views/api";
|
|
|
5
5
|
declare class NativeReanimatedContainer extends Container {
|
|
6
6
|
private nativeId;
|
|
7
7
|
private mapperId;
|
|
8
|
+
private picture;
|
|
9
|
+
private recorderA;
|
|
10
|
+
private recorderB;
|
|
11
|
+
private currentRecorder;
|
|
8
12
|
constructor(Skia: Skia, nativeId: number);
|
|
9
13
|
redraw(): void;
|
|
10
14
|
}
|