@shopify/react-native-skia 2.0.2 → 2.0.4
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/apple/SkiaManager.mm +0 -3
- package/cpp/api/recorder/DrawingCtx.h +3 -3
- package/cpp/api/recorder/JsiRecorder.h +2 -1
- package/cpp/api/recorder/Paint.h +8 -3
- package/cpp/api/recorder/RNRecorder.h +4 -3
- package/cpp/rnskia/RNSkJsiViewApi.h +95 -73
- package/cpp/rnskia/RNSkManager.cpp +3 -18
- package/cpp/rnskia/RNSkManager.h +0 -6
- package/lib/commonjs/skia/types/Recorder.d.ts +1 -1
- package/lib/commonjs/skia/types/Recorder.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Player.js +3 -1
- package/lib/commonjs/sksg/Recorder/Player.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
- package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js +2 -2
- package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Recorder.d.ts +1 -1
- package/lib/commonjs/sksg/Recorder/Recorder.js +3 -2
- package/lib/commonjs/sksg/Recorder/Recorder.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Visitor.js +2 -2
- package/lib/commonjs/sksg/Recorder/Visitor.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Paint.d.ts +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Paint.js +6 -2
- package/lib/commonjs/sksg/Recorder/commands/Paint.js.map +1 -1
- package/lib/module/skia/types/Recorder.d.ts +1 -1
- package/lib/module/skia/types/Recorder.js.map +1 -1
- package/lib/module/sksg/Recorder/Player.js +3 -1
- package/lib/module/sksg/Recorder/Player.js.map +1 -1
- package/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
- package/lib/module/sksg/Recorder/ReanimatedRecorder.js +2 -2
- package/lib/module/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
- package/lib/module/sksg/Recorder/Recorder.d.ts +1 -1
- package/lib/module/sksg/Recorder/Recorder.js +3 -2
- package/lib/module/sksg/Recorder/Recorder.js.map +1 -1
- package/lib/module/sksg/Recorder/Visitor.js +2 -2
- package/lib/module/sksg/Recorder/Visitor.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Paint.d.ts +1 -1
- package/lib/module/sksg/Recorder/commands/Paint.js +6 -2
- package/lib/module/sksg/Recorder/commands/Paint.js.map +1 -1
- package/lib/typescript/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
- package/lib/typescript/lib/commonjs/sksg/Recorder/Recorder.d.ts +1 -1
- package/lib/typescript/lib/commonjs/sksg/Recorder/commands/Paint.d.ts +1 -1
- package/lib/typescript/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
- package/lib/typescript/lib/module/sksg/Recorder/Recorder.d.ts +1 -1
- package/lib/typescript/lib/module/sksg/Recorder/commands/Paint.d.ts +1 -1
- package/lib/typescript/src/skia/types/Recorder.d.ts +1 -1
- package/lib/typescript/src/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
- package/lib/typescript/src/sksg/Recorder/Recorder.d.ts +1 -1
- package/lib/typescript/src/sksg/Recorder/commands/Paint.d.ts +1 -1
- package/package.json +1 -1
- package/src/__tests__/snapshots/drawings/semi-transparent-layer.png +0 -0
- package/src/__tests__/snapshots/drawings/transparent-layer.png +0 -0
- package/src/renderer/__tests__/e2e/Opacity.spec.tsx +23 -0
- package/src/skia/types/Recorder.ts +1 -1
- package/src/sksg/Recorder/Player.ts +7 -1
- package/src/sksg/Recorder/ReanimatedRecorder.ts +2 -2
- package/src/sksg/Recorder/Recorder.ts +2 -2
- package/src/sksg/Recorder/Visitor.ts +2 -2
- package/src/sksg/Recorder/commands/Paint.ts +7 -2
package/apple/SkiaManager.mm
CHANGED
@@ -60,17 +60,17 @@ public:
|
|
60
60
|
}
|
61
61
|
|
62
62
|
float getOpacity() const { return opacities.back(); }
|
63
|
-
|
63
|
+
|
64
64
|
void setOpacity(float newOpacity) {
|
65
65
|
opacities.back() = std::clamp(newOpacity, 0.0f, 1.0f);
|
66
66
|
}
|
67
67
|
|
68
|
-
void pushPaint(SkPaint &paint) {
|
68
|
+
void pushPaint(SkPaint &paint) {
|
69
69
|
paints.push_back(paint);
|
70
70
|
opacities.push_back(opacities.back());
|
71
71
|
}
|
72
72
|
|
73
|
-
void savePaint() {
|
73
|
+
void savePaint() {
|
74
74
|
paints.push_back(SkPaint(getPaint()));
|
75
75
|
opacities.push_back(opacities.back());
|
76
76
|
}
|
@@ -25,7 +25,8 @@ public:
|
|
25
25
|
std::make_shared<Recorder>()) {}
|
26
26
|
|
27
27
|
JSI_HOST_FUNCTION(savePaint) {
|
28
|
-
getObject()->savePaint(runtime, arguments[0].asObject(runtime)
|
28
|
+
getObject()->savePaint(runtime, arguments[0].asObject(runtime),
|
29
|
+
arguments[1].asBool());
|
29
30
|
return jsi::Value::undefined();
|
30
31
|
}
|
31
32
|
|
package/cpp/api/recorder/Paint.h
CHANGED
@@ -125,11 +125,12 @@ struct PaintCmdProps {
|
|
125
125
|
class SavePaintCmd : public Command {
|
126
126
|
private:
|
127
127
|
PaintCmdProps props;
|
128
|
+
bool standalone;
|
128
129
|
|
129
130
|
public:
|
130
131
|
SavePaintCmd(jsi::Runtime &runtime, const jsi::Object &object,
|
131
|
-
Variables &variables)
|
132
|
-
: Command(CommandType::SavePaint) {
|
132
|
+
Variables &variables, bool lStandalone)
|
133
|
+
: Command(CommandType::SavePaint), standalone(lStandalone) {
|
133
134
|
convertProperty(runtime, object, "color", props.color, variables);
|
134
135
|
convertProperty(runtime, object, "blendMode", props.blendMode, variables);
|
135
136
|
convertProperty(runtime, object, "style", props.style, variables);
|
@@ -153,7 +154,11 @@ public:
|
|
153
154
|
ctx->savePaint();
|
154
155
|
auto &paint = ctx->getPaint();
|
155
156
|
if (props.opacity.has_value()) {
|
156
|
-
|
157
|
+
if (standalone) {
|
158
|
+
paint.setAlphaf(paint.getAlphaf() * props.opacity.value());
|
159
|
+
} else {
|
160
|
+
ctx->setOpacity(ctx->getOpacity() * props.opacity.value());
|
161
|
+
}
|
157
162
|
}
|
158
163
|
if (props.color.has_value()) {
|
159
164
|
paint.setShader(nullptr);
|
@@ -28,9 +28,10 @@ public:
|
|
28
28
|
|
29
29
|
~Recorder() = default;
|
30
30
|
|
31
|
-
void savePaint(jsi::Runtime &runtime, const jsi::Object &props
|
31
|
+
void savePaint(jsi::Runtime &runtime, const jsi::Object &props,
|
32
|
+
bool standalone) {
|
32
33
|
commands.push_back(
|
33
|
-
std::make_unique<SavePaintCmd>(runtime, props, variables));
|
34
|
+
std::make_unique<SavePaintCmd>(runtime, props, variables, standalone));
|
34
35
|
}
|
35
36
|
|
36
37
|
void pushShader(jsi::Runtime &runtime, const std::string &nodeType,
|
@@ -294,7 +295,7 @@ public:
|
|
294
295
|
void play(DrawingCtx *ctx) {
|
295
296
|
for (const auto &cmd : commands) {
|
296
297
|
switch (cmd->type) {
|
297
|
-
|
298
|
+
|
298
299
|
case Group: {
|
299
300
|
// Do nothing here for now
|
300
301
|
break;
|
@@ -3,6 +3,7 @@
|
|
3
3
|
#include <functional>
|
4
4
|
#include <memory>
|
5
5
|
#include <mutex>
|
6
|
+
#include <shared_mutex>
|
6
7
|
#include <string>
|
7
8
|
#include <unordered_map>
|
8
9
|
#include <utility>
|
@@ -23,6 +24,48 @@ using RNSkViewInfo = struct RNSkViewInfo {
|
|
23
24
|
std::unordered_map<std::string, RNJsi::ViewProperty> props;
|
24
25
|
};
|
25
26
|
|
27
|
+
class ViewRegistry {
|
28
|
+
public:
|
29
|
+
static ViewRegistry &getInstance() {
|
30
|
+
static ViewRegistry instance;
|
31
|
+
return instance;
|
32
|
+
}
|
33
|
+
|
34
|
+
ViewRegistry(const ViewRegistry &) = delete;
|
35
|
+
ViewRegistry &operator=(const ViewRegistry &) = delete;
|
36
|
+
|
37
|
+
void removeViewInfo(size_t id) {
|
38
|
+
std::unique_lock<std::shared_mutex> lock(_mutex);
|
39
|
+
_registry.erase(id);
|
40
|
+
}
|
41
|
+
|
42
|
+
// Execute a function while holding the registry lock
|
43
|
+
template <typename F>
|
44
|
+
auto withViewInfo(size_t id, F &&func)
|
45
|
+
-> decltype(func(std::shared_ptr<RNSkViewInfo>())) {
|
46
|
+
std::unique_lock<std::shared_mutex> lock(_mutex);
|
47
|
+
auto it = _registry.find(id);
|
48
|
+
std::shared_ptr<RNSkViewInfo> info;
|
49
|
+
if (it != _registry.end()) {
|
50
|
+
info = it->second;
|
51
|
+
} else {
|
52
|
+
info = std::make_shared<RNSkViewInfo>();
|
53
|
+
_registry[id] = info;
|
54
|
+
}
|
55
|
+
return func(info);
|
56
|
+
}
|
57
|
+
|
58
|
+
void clear() {
|
59
|
+
std::unique_lock<std::shared_mutex> lock(_mutex);
|
60
|
+
_registry.clear();
|
61
|
+
}
|
62
|
+
|
63
|
+
private:
|
64
|
+
ViewRegistry() = default;
|
65
|
+
mutable std::shared_mutex _mutex;
|
66
|
+
std::unordered_map<size_t, std::shared_ptr<RNSkViewInfo>> _registry;
|
67
|
+
};
|
68
|
+
|
26
69
|
class RNSkJsiViewApi : public RNJsi::JsiHostObject,
|
27
70
|
public std::enable_shared_from_this<RNSkJsiViewApi> {
|
28
71
|
public:
|
@@ -53,19 +96,23 @@ public:
|
|
53
96
|
}
|
54
97
|
|
55
98
|
auto nativeId = arguments[0].asNumber();
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
99
|
+
|
100
|
+
// Safely execute operations while holding the registry lock
|
101
|
+
ViewRegistry::getInstance().withViewInfo(
|
102
|
+
nativeId, [&](std::shared_ptr<RNSkViewInfo> info) {
|
103
|
+
info->props.insert_or_assign(
|
104
|
+
arguments[1].asString(runtime).utf8(runtime),
|
105
|
+
RNJsi::ViewProperty(runtime, arguments[2]));
|
106
|
+
|
107
|
+
// Now let's see if we have a view that we can update
|
108
|
+
if (info->view != nullptr) {
|
109
|
+
// Update view!
|
110
|
+
info->view->setNativeId(nativeId);
|
111
|
+
info->view->setJsiProperties(info->props);
|
112
|
+
info->props.clear();
|
113
|
+
}
|
114
|
+
return nullptr; // Return type for template deduction
|
115
|
+
});
|
69
116
|
|
70
117
|
return jsi::Value::undefined();
|
71
118
|
}
|
@@ -88,11 +135,13 @@ public:
|
|
88
135
|
|
89
136
|
// find Skia View
|
90
137
|
int nativeId = arguments[0].asNumber();
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
138
|
+
ViewRegistry::getInstance().withViewInfo(
|
139
|
+
nativeId, [](std::shared_ptr<RNSkViewInfo> info) {
|
140
|
+
if (info->view != nullptr) {
|
141
|
+
info->view->requestRedraw();
|
142
|
+
}
|
143
|
+
return nullptr;
|
144
|
+
});
|
96
145
|
return jsi::Value::undefined();
|
97
146
|
}
|
98
147
|
|
@@ -113,12 +162,9 @@ public:
|
|
113
162
|
// find Skia view
|
114
163
|
int nativeId = arguments[0].asNumber();
|
115
164
|
sk_sp<SkImage> image;
|
116
|
-
std::shared_ptr<RNSkView> view
|
117
|
-
|
118
|
-
|
119
|
-
auto info = getEnsuredViewInfo(nativeId);
|
120
|
-
view = info->view;
|
121
|
-
}
|
165
|
+
std::shared_ptr<RNSkView> view = ViewRegistry::getInstance().withViewInfo(
|
166
|
+
nativeId,
|
167
|
+
[](std::shared_ptr<RNSkViewInfo> info) { return info->view; });
|
122
168
|
if (view != nullptr) {
|
123
169
|
if (count > 1 && !arguments[1].isUndefined() && !arguments[1].isNull()) {
|
124
170
|
auto rect = JsiSkRect::fromValue(runtime, arguments[1]);
|
@@ -154,12 +200,9 @@ public:
|
|
154
200
|
|
155
201
|
// find Skia view
|
156
202
|
int nativeId = arguments[0].asNumber();
|
157
|
-
std::shared_ptr<RNSkView> view
|
158
|
-
|
159
|
-
|
160
|
-
auto info = getEnsuredViewInfo(nativeId);
|
161
|
-
view = info->view;
|
162
|
-
}
|
203
|
+
std::shared_ptr<RNSkView> view = ViewRegistry::getInstance().withViewInfo(
|
204
|
+
nativeId,
|
205
|
+
[](std::shared_ptr<RNSkViewInfo> info) { return info->view; });
|
163
206
|
auto context = _platformContext;
|
164
207
|
auto bounds =
|
165
208
|
count > 1 && !arguments[1].isUndefined() && !arguments[1].isNull()
|
@@ -204,10 +247,7 @@ public:
|
|
204
247
|
/**
|
205
248
|
Call to remove all draw view infos
|
206
249
|
*/
|
207
|
-
void unregisterAll() {
|
208
|
-
std::lock_guard<std::mutex> lock(_mutex);
|
209
|
-
_viewInfos.clear();
|
210
|
-
}
|
250
|
+
void unregisterAll() { ViewRegistry::getInstance().clear(); }
|
211
251
|
|
212
252
|
/**
|
213
253
|
* Registers a skia view
|
@@ -215,12 +255,14 @@ public:
|
|
215
255
|
* @param view View to register
|
216
256
|
*/
|
217
257
|
void registerSkiaView(size_t nativeId, std::shared_ptr<RNSkView> view) {
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
258
|
+
ViewRegistry::getInstance().withViewInfo(
|
259
|
+
nativeId, [&](std::shared_ptr<RNSkViewInfo> info) {
|
260
|
+
info->view = view;
|
261
|
+
info->view->setNativeId(nativeId);
|
262
|
+
info->view->setJsiProperties(info->props);
|
263
|
+
info->props.clear();
|
264
|
+
return nullptr;
|
265
|
+
});
|
224
266
|
}
|
225
267
|
|
226
268
|
/**
|
@@ -228,14 +270,7 @@ public:
|
|
228
270
|
* @param nativeId View id
|
229
271
|
*/
|
230
272
|
void unregisterSkiaView(size_t nativeId) {
|
231
|
-
|
232
|
-
if (_viewInfos.count(nativeId) == 0) {
|
233
|
-
return;
|
234
|
-
}
|
235
|
-
auto info = getEnsuredViewInfo(nativeId);
|
236
|
-
|
237
|
-
info->view = nullptr;
|
238
|
-
_viewInfos.erase(nativeId);
|
273
|
+
ViewRegistry::getInstance().removeViewInfo(nativeId);
|
239
274
|
}
|
240
275
|
|
241
276
|
/**
|
@@ -245,34 +280,21 @@ public:
|
|
245
280
|
or a valid view, effectively toggling the view's availability.
|
246
281
|
*/
|
247
282
|
void setSkiaView(size_t nativeId, std::shared_ptr<RNSkView> view) {
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
283
|
+
ViewRegistry::getInstance().withViewInfo(
|
284
|
+
nativeId, [&](std::shared_ptr<RNSkViewInfo> info) {
|
285
|
+
if (view != nullptr) {
|
286
|
+
info->view = view;
|
287
|
+
info->view->setNativeId(nativeId);
|
288
|
+
info->view->setJsiProperties(info->props);
|
289
|
+
info->props.clear();
|
290
|
+
} else {
|
291
|
+
info->view = view; // Set to nullptr
|
292
|
+
}
|
293
|
+
return nullptr;
|
294
|
+
});
|
258
295
|
}
|
259
296
|
|
260
297
|
private:
|
261
|
-
/**
|
262
|
-
* Creates or returns the callback info object for the given view
|
263
|
-
* @param nativeId View id
|
264
|
-
* @return The callback info object for the requested view
|
265
|
-
*/
|
266
|
-
RNSkViewInfo *getEnsuredViewInfo(size_t nativeId) {
|
267
|
-
if (_viewInfos.count(nativeId) == 0) {
|
268
|
-
RNSkViewInfo info;
|
269
|
-
_viewInfos.emplace(nativeId, info);
|
270
|
-
}
|
271
|
-
return &_viewInfos.at(nativeId);
|
272
|
-
}
|
273
|
-
|
274
|
-
std::unordered_map<size_t, RNSkViewInfo> _viewInfos;
|
275
298
|
std::shared_ptr<RNSkPlatformContext> _platformContext;
|
276
|
-
std::mutex _mutex;
|
277
299
|
};
|
278
300
|
} // namespace RNSkia
|
@@ -30,7 +30,6 @@ RNSkManager::RNSkManager(
|
|
30
30
|
}
|
31
31
|
|
32
32
|
RNSkManager::~RNSkManager() {
|
33
|
-
invalidate();
|
34
33
|
// Free up any references
|
35
34
|
_viewApi = nullptr;
|
36
35
|
_jsRuntime = nullptr;
|
@@ -38,36 +37,22 @@ RNSkManager::~RNSkManager() {
|
|
38
37
|
_jsCallInvoker = nullptr;
|
39
38
|
}
|
40
39
|
|
41
|
-
void RNSkManager::invalidate() {
|
42
|
-
if (_isInvalidated) {
|
43
|
-
return;
|
44
|
-
}
|
45
|
-
_isInvalidated = true;
|
46
|
-
|
47
|
-
// Invalidate members
|
48
|
-
_viewApi->unregisterAll();
|
49
|
-
}
|
50
|
-
|
51
40
|
void RNSkManager::registerSkiaView(size_t nativeId,
|
52
41
|
std::shared_ptr<RNSkView> view) {
|
53
|
-
|
54
|
-
_viewApi->registerSkiaView(nativeId, std::move(view));
|
42
|
+
_viewApi->registerSkiaView(nativeId, std::move(view));
|
55
43
|
}
|
56
44
|
|
57
45
|
void RNSkManager::unregisterSkiaView(size_t nativeId) {
|
58
|
-
|
59
|
-
_viewApi->unregisterSkiaView(nativeId);
|
46
|
+
_viewApi->unregisterSkiaView(nativeId);
|
60
47
|
}
|
61
48
|
|
62
49
|
void RNSkManager::setSkiaView(size_t nativeId, std::shared_ptr<RNSkView> view) {
|
63
|
-
|
64
|
-
_viewApi->setSkiaView(nativeId, std::move(view));
|
50
|
+
_viewApi->setSkiaView(nativeId, std::move(view));
|
65
51
|
}
|
66
52
|
|
67
53
|
void RNSkManager::installBindings() {
|
68
54
|
// Create the API objects and install it on the global object in the
|
69
55
|
// provided runtime.
|
70
|
-
|
71
56
|
auto skiaApi = std::make_shared<JsiSkApi>(_platformContext);
|
72
57
|
_jsRuntime->global().setProperty(
|
73
58
|
*_jsRuntime, "SkiaApi",
|
package/cpp/rnskia/RNSkManager.h
CHANGED
@@ -33,11 +33,6 @@ public:
|
|
33
33
|
|
34
34
|
~RNSkManager();
|
35
35
|
|
36
|
-
/**
|
37
|
-
Invalidates the Skia Manager
|
38
|
-
*/
|
39
|
-
void invalidate();
|
40
|
-
|
41
36
|
/**
|
42
37
|
* Registers a RNSkView with the given native id
|
43
38
|
* @param nativeId Native view id
|
@@ -77,7 +72,6 @@ private:
|
|
77
72
|
std::shared_ptr<RNSkPlatformContext> _platformContext;
|
78
73
|
std::shared_ptr<facebook::react::CallInvoker> _jsCallInvoker;
|
79
74
|
std::shared_ptr<RNSkJsiViewApi> _viewApi;
|
80
|
-
std::atomic<bool> _isInvalidated = {false};
|
81
75
|
};
|
82
76
|
|
83
77
|
} // namespace RNSkia
|
@@ -5,7 +5,7 @@ import type { SkPicture } from "./Picture";
|
|
5
5
|
export interface BaseRecorder {
|
6
6
|
saveGroup(): void;
|
7
7
|
restoreGroup(): void;
|
8
|
-
savePaint(props: AnimatedProps<PaintProps
|
8
|
+
savePaint(props: AnimatedProps<PaintProps>, standalone: boolean): void;
|
9
9
|
restorePaint(): void;
|
10
10
|
restorePaintDeclaration(): void;
|
11
11
|
materializePaint(): void;
|
@@ -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} 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
|
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} 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(shaderType: NodeType, props: AnimatedProps<unknown>): 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 drawAtlas(props: AnimatedProps<AtlasProps>): void;\n}\n\nexport interface JsiRecorder extends BaseRecorder {\n play(): SkPicture;\n applyUpdates(variables: SharedValue<unknown>[]): void;\n}\n"],"mappings":"","ignoreList":[]}
|
@@ -32,7 +32,9 @@ function play(ctx, _command) {
|
|
32
32
|
ctx.paints.push(command.props.paint);
|
33
33
|
} else {
|
34
34
|
ctx.savePaint();
|
35
|
-
(0, _Paint.setPaintProperties)(ctx.Skia, ctx, command.props
|
35
|
+
(0, _Paint.setPaintProperties)(ctx.Skia, ctx, command.props,
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
37
|
+
command.standalone);
|
36
38
|
}
|
37
39
|
} else if ((0, _Core.isCommand)(command, _Core.CommandType.RestorePaint)) {
|
38
40
|
ctx.restorePaint();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_Drawing","require","_Box","_ColorFilters","_CTM","_ImageFilters","_Paint","_PathEffects","_Shaders","_Core","play","ctx","_command","isGroup","children","forEach","child","command","materializeCommand","isCommand","CommandType","SaveBackdropFilter","saveBackdropFilter","SaveLayer","materializePaint","paint","paintDeclarations","pop","canvas","saveLayer","isDrawCommand","SavePaint","props","paints","push","savePaint","setPaintProperties","Skia","RestorePaint","restorePaint","ComposeColorFilter","composeColorFilters","RestorePaintDeclaration","Error","MaterializePaint","isPushColorFilter","pushColorFilter","isPushShader","pushShader","isPushImageFilter","pushImageFilter","isPushPathEffect","pushPathEffect","ComposePathEffect","composePathEffects","ComposeImageFilter","composeImageFilters","PushBlurMaskFilter","setBlurMaskFilter","SaveCTM","saveCTM","RestoreCTM","restore","copy","setAlphaf","getAlphaf","getOpacity","p","isBoxCommand","drawBox","DrawPaint","drawPaint","DrawImage","drawImage","DrawCircle","drawCircle","DrawPoints","drawPoints","DrawPath","drawPath","DrawRect","drawRect","DrawRRect","drawRRect","DrawOval","drawOval","DrawLine","drawLine","DrawPatch","drawPatch","DrawVertices","drawVertices","DrawDiffRect","drawDiffRect","DrawText","drawText","DrawTextPath","drawTextPath","DrawTextBlob","drawTextBlob","DrawGlyphs","drawGlyphs","DrawPicture","drawPicture","DrawImageSVG","drawImageSVG","DrawParagraph","drawParagraph","DrawAtlas","drawAtlas","console","warn","type","replay","commands","exports"],"sources":["Player.ts"],"sourcesContent":["import {\n drawCircle,\n drawImage,\n drawOval,\n drawPath,\n drawPoints,\n drawRect,\n drawRRect,\n drawLine,\n drawAtlas,\n drawParagraph,\n drawImageSVG,\n drawPicture,\n drawGlyphs,\n drawTextBlob,\n drawTextPath,\n drawText,\n drawDiffRect,\n drawVertices,\n drawPatch,\n} from \"./commands/Drawing\";\nimport { drawBox, isBoxCommand } from \"./commands/Box\";\nimport {\n composeColorFilters,\n isPushColorFilter,\n pushColorFilter,\n} from \"./commands/ColorFilters\";\nimport { saveCTM } from \"./commands/CTM\";\nimport {\n setBlurMaskFilter,\n isPushImageFilter,\n pushImageFilter,\n composeImageFilters,\n} from \"./commands/ImageFilters\";\nimport { setPaintProperties } from \"./commands/Paint\";\nimport {\n composePathEffects,\n isPushPathEffect,\n pushPathEffect,\n} from \"./commands/PathEffects\";\nimport { isPushShader, pushShader } from \"./commands/Shaders\";\nimport {\n CommandType,\n isCommand,\n isDrawCommand,\n isGroup,\n materializeCommand,\n} from \"./Core\";\nimport type { Command } from \"./Core\";\nimport type { DrawingContext } from \"./DrawingContext\";\n\nfunction play(ctx: DrawingContext, _command: Command) {\n \"worklet\";\n if (isGroup(_command)) {\n _command.children.forEach((child) => play(ctx, child));\n return;\n }\n const command = materializeCommand(_command);\n if (isCommand(command, CommandType.SaveBackdropFilter)) {\n ctx.saveBackdropFilter();\n } else if (isCommand(command, CommandType.SaveLayer)) {\n ctx.materializePaint();\n const paint = ctx.paintDeclarations.pop();\n ctx.canvas.saveLayer(paint);\n } else if (isDrawCommand(command, CommandType.SavePaint)) {\n if (command.props.paint) {\n ctx.paints.push(command.props.paint);\n } else {\n ctx.savePaint();\n setPaintProperties(ctx.Skia, ctx, command.props);\n }\n } else if (isCommand(command, CommandType.RestorePaint)) {\n ctx.restorePaint();\n } else if (isCommand(command, CommandType.ComposeColorFilter)) {\n composeColorFilters(ctx);\n } else if (isCommand(command, CommandType.RestorePaintDeclaration)) {\n ctx.materializePaint();\n const paint = ctx.restorePaint();\n if (!paint) {\n throw new Error(\"No paint declaration to push\");\n }\n ctx.paintDeclarations.push(paint);\n } else if (isCommand(command, CommandType.MaterializePaint)) {\n ctx.materializePaint();\n } else if (isPushColorFilter(command)) {\n pushColorFilter(ctx, command);\n } else if (isPushShader(command)) {\n pushShader(ctx, command);\n } else if (isPushImageFilter(command)) {\n pushImageFilter(ctx, command);\n } else if (isPushPathEffect(command)) {\n pushPathEffect(ctx, command);\n } else if (isCommand(command, CommandType.ComposePathEffect)) {\n composePathEffects(ctx);\n } else if (isCommand(command, CommandType.ComposeImageFilter)) {\n composeImageFilters(ctx);\n } else if (isDrawCommand(command, CommandType.PushBlurMaskFilter)) {\n setBlurMaskFilter(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.SaveCTM)) {\n saveCTM(ctx, command.props);\n } else if (isCommand(command, CommandType.RestoreCTM)) {\n ctx.canvas.restore();\n } else {\n // TODO: is a copy needed here?\n // apply opacity to the current paint.\n const paint = ctx.paint.copy();\n paint.setAlphaf(paint.getAlphaf() * ctx.getOpacity());\n const paints = [paint, ...ctx.paintDeclarations];\n ctx.paintDeclarations = [];\n paints.forEach((p) => {\n ctx.paints.push(p);\n if (isBoxCommand(command)) {\n drawBox(ctx, command);\n } else if (isCommand(command, CommandType.DrawPaint)) {\n ctx.canvas.drawPaint(ctx.paint);\n } else if (isDrawCommand(command, CommandType.DrawImage)) {\n drawImage(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawCircle)) {\n drawCircle(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPoints)) {\n drawPoints(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPath)) {\n drawPath(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawRect)) {\n drawRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawRRect)) {\n drawRRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawOval)) {\n drawOval(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawLine)) {\n drawLine(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPatch)) {\n drawPatch(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawVertices)) {\n drawVertices(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawDiffRect)) {\n drawDiffRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawText)) {\n drawText(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawTextPath)) {\n drawTextPath(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawTextBlob)) {\n drawTextBlob(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawGlyphs)) {\n drawGlyphs(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPicture)) {\n drawPicture(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawImageSVG)) {\n drawImageSVG(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawParagraph)) {\n drawParagraph(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawAtlas)) {\n drawAtlas(ctx, command.props);\n } else {\n console.warn(`Unknown command: ${command.type}`);\n }\n ctx.paints.pop();\n });\n }\n}\n\nexport const replay = (ctx: DrawingContext, commands: Command[]) => {\n \"worklet\";\n commands.forEach((command) => {\n play(ctx, command);\n });\n};\n"],"mappings":";;;;;;AAAA,I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ignoreList":[]}
|
1
|
+
{"version":3,"names":["_Drawing","require","_Box","_ColorFilters","_CTM","_ImageFilters","_Paint","_PathEffects","_Shaders","_Core","play","ctx","_command","isGroup","children","forEach","child","command","materializeCommand","isCommand","CommandType","SaveBackdropFilter","saveBackdropFilter","SaveLayer","materializePaint","paint","paintDeclarations","pop","canvas","saveLayer","isDrawCommand","SavePaint","props","paints","push","savePaint","setPaintProperties","Skia","standalone","RestorePaint","restorePaint","ComposeColorFilter","composeColorFilters","RestorePaintDeclaration","Error","MaterializePaint","isPushColorFilter","pushColorFilter","isPushShader","pushShader","isPushImageFilter","pushImageFilter","isPushPathEffect","pushPathEffect","ComposePathEffect","composePathEffects","ComposeImageFilter","composeImageFilters","PushBlurMaskFilter","setBlurMaskFilter","SaveCTM","saveCTM","RestoreCTM","restore","copy","setAlphaf","getAlphaf","getOpacity","p","isBoxCommand","drawBox","DrawPaint","drawPaint","DrawImage","drawImage","DrawCircle","drawCircle","DrawPoints","drawPoints","DrawPath","drawPath","DrawRect","drawRect","DrawRRect","drawRRect","DrawOval","drawOval","DrawLine","drawLine","DrawPatch","drawPatch","DrawVertices","drawVertices","DrawDiffRect","drawDiffRect","DrawText","drawText","DrawTextPath","drawTextPath","DrawTextBlob","drawTextBlob","DrawGlyphs","drawGlyphs","DrawPicture","drawPicture","DrawImageSVG","drawImageSVG","DrawParagraph","drawParagraph","DrawAtlas","drawAtlas","console","warn","type","replay","commands","exports"],"sources":["Player.ts"],"sourcesContent":["import {\n drawCircle,\n drawImage,\n drawOval,\n drawPath,\n drawPoints,\n drawRect,\n drawRRect,\n drawLine,\n drawAtlas,\n drawParagraph,\n drawImageSVG,\n drawPicture,\n drawGlyphs,\n drawTextBlob,\n drawTextPath,\n drawText,\n drawDiffRect,\n drawVertices,\n drawPatch,\n} from \"./commands/Drawing\";\nimport { drawBox, isBoxCommand } from \"./commands/Box\";\nimport {\n composeColorFilters,\n isPushColorFilter,\n pushColorFilter,\n} from \"./commands/ColorFilters\";\nimport { saveCTM } from \"./commands/CTM\";\nimport {\n setBlurMaskFilter,\n isPushImageFilter,\n pushImageFilter,\n composeImageFilters,\n} from \"./commands/ImageFilters\";\nimport { setPaintProperties } from \"./commands/Paint\";\nimport {\n composePathEffects,\n isPushPathEffect,\n pushPathEffect,\n} from \"./commands/PathEffects\";\nimport { isPushShader, pushShader } from \"./commands/Shaders\";\nimport {\n CommandType,\n isCommand,\n isDrawCommand,\n isGroup,\n materializeCommand,\n} from \"./Core\";\nimport type { Command } from \"./Core\";\nimport type { DrawingContext } from \"./DrawingContext\";\n\nfunction play(ctx: DrawingContext, _command: Command) {\n \"worklet\";\n if (isGroup(_command)) {\n _command.children.forEach((child) => play(ctx, child));\n return;\n }\n const command = materializeCommand(_command);\n if (isCommand(command, CommandType.SaveBackdropFilter)) {\n ctx.saveBackdropFilter();\n } else if (isCommand(command, CommandType.SaveLayer)) {\n ctx.materializePaint();\n const paint = ctx.paintDeclarations.pop();\n ctx.canvas.saveLayer(paint);\n } else if (isDrawCommand(command, CommandType.SavePaint)) {\n if (command.props.paint) {\n ctx.paints.push(command.props.paint);\n } else {\n ctx.savePaint();\n setPaintProperties(\n ctx.Skia,\n ctx,\n command.props,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (command as any).standalone\n );\n }\n } else if (isCommand(command, CommandType.RestorePaint)) {\n ctx.restorePaint();\n } else if (isCommand(command, CommandType.ComposeColorFilter)) {\n composeColorFilters(ctx);\n } else if (isCommand(command, CommandType.RestorePaintDeclaration)) {\n ctx.materializePaint();\n const paint = ctx.restorePaint();\n if (!paint) {\n throw new Error(\"No paint declaration to push\");\n }\n ctx.paintDeclarations.push(paint);\n } else if (isCommand(command, CommandType.MaterializePaint)) {\n ctx.materializePaint();\n } else if (isPushColorFilter(command)) {\n pushColorFilter(ctx, command);\n } else if (isPushShader(command)) {\n pushShader(ctx, command);\n } else if (isPushImageFilter(command)) {\n pushImageFilter(ctx, command);\n } else if (isPushPathEffect(command)) {\n pushPathEffect(ctx, command);\n } else if (isCommand(command, CommandType.ComposePathEffect)) {\n composePathEffects(ctx);\n } else if (isCommand(command, CommandType.ComposeImageFilter)) {\n composeImageFilters(ctx);\n } else if (isDrawCommand(command, CommandType.PushBlurMaskFilter)) {\n setBlurMaskFilter(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.SaveCTM)) {\n saveCTM(ctx, command.props);\n } else if (isCommand(command, CommandType.RestoreCTM)) {\n ctx.canvas.restore();\n } else {\n // TODO: is a copy needed here?\n // apply opacity to the current paint.\n const paint = ctx.paint.copy();\n paint.setAlphaf(paint.getAlphaf() * ctx.getOpacity());\n const paints = [paint, ...ctx.paintDeclarations];\n ctx.paintDeclarations = [];\n paints.forEach((p) => {\n ctx.paints.push(p);\n if (isBoxCommand(command)) {\n drawBox(ctx, command);\n } else if (isCommand(command, CommandType.DrawPaint)) {\n ctx.canvas.drawPaint(ctx.paint);\n } else if (isDrawCommand(command, CommandType.DrawImage)) {\n drawImage(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawCircle)) {\n drawCircle(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPoints)) {\n drawPoints(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPath)) {\n drawPath(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawRect)) {\n drawRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawRRect)) {\n drawRRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawOval)) {\n drawOval(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawLine)) {\n drawLine(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPatch)) {\n drawPatch(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawVertices)) {\n drawVertices(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawDiffRect)) {\n drawDiffRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawText)) {\n drawText(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawTextPath)) {\n drawTextPath(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawTextBlob)) {\n drawTextBlob(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawGlyphs)) {\n drawGlyphs(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPicture)) {\n drawPicture(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawImageSVG)) {\n drawImageSVG(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawParagraph)) {\n drawParagraph(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawAtlas)) {\n drawAtlas(ctx, command.props);\n } else {\n console.warn(`Unknown command: ${command.type}`);\n }\n ctx.paints.pop();\n });\n }\n}\n\nexport const replay = (ctx: DrawingContext, commands: Command[]) => {\n \"worklet\";\n commands.forEach((command) => {\n play(ctx, command);\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAqBA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AAKA,IAAAG,IAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAMA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAKA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,KAAA,GAAAR,OAAA;AAUA,SAASS,IAAIA,CAACC,GAAmB,EAAEC,QAAiB,EAAE;EACpD,SAAS;;EACT,IAAI,IAAAC,aAAO,EAACD,QAAQ,CAAC,EAAE;IACrBA,QAAQ,CAACE,QAAQ,CAACC,OAAO,CAAEC,KAAK,IAAKN,IAAI,CAACC,GAAG,EAAEK,KAAK,CAAC,CAAC;IACtD;EACF;EACA,MAAMC,OAAO,GAAG,IAAAC,wBAAkB,EAACN,QAAQ,CAAC;EAC5C,IAAI,IAAAO,eAAS,EAACF,OAAO,EAAEG,iBAAW,CAACC,kBAAkB,CAAC,EAAE;IACtDV,GAAG,CAACW,kBAA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KAAK,CAAC;MACnC,CAAC,MAAM,IAAI,IAAAF,mBAAa,EAACb,OAAO,EAAEG,iBAAW,CAACyF,SAAS,CAAC,EAAE;QACxD,IAAAC,kBAAS,EAACnG,GAAG,EAAEM,OAAO,CAACe,KAAK,CAAC;MAC/B,CAAC,MAAM;QACL+E,OAAO,CAACC,IAAI,CAAC,oBAAoB/F,OAAO,CAACgG,IAAI,EAAE,CAAC;MAClD;MACAtG,GAAG,CAACsB,MAAM,CAACN,GAAG,CAAC,CAAC;IAClB,CAAC,CAAC;EACJ;AACF;AAEO,MAAMuF,MAAM,GAAGA,CAACvG,GAAmB,EAAEwG,QAAmB,KAAK;EAClE,SAAS;;EACTA,QAAQ,CAACpG,OAAO,CAAEE,OAAO,IAAK;IAC5BP,IAAI,CAACC,GAAG,EAAEM,OAAO,CAAC;EACpB,CAAC,CAAC;AACJ,CAAC;AAACmG,OAAA,CAAAF,MAAA,GAAAA,MAAA","ignoreList":[]}
|
@@ -11,7 +11,7 @@ export declare class ReanimatedRecorder implements BaseRecorder {
|
|
11
11
|
getSharedValues(): SharedValue<unknown>[];
|
12
12
|
saveGroup(): void;
|
13
13
|
restoreGroup(): void;
|
14
|
-
savePaint(props: AnimatedProps<PaintProps
|
14
|
+
savePaint(props: AnimatedProps<PaintProps>, standalone: boolean): void;
|
15
15
|
restorePaint(): void;
|
16
16
|
restorePaintDeclaration(): void;
|
17
17
|
materializePaint(): void;
|
@@ -39,9 +39,9 @@ class ReanimatedRecorder {
|
|
39
39
|
restoreGroup() {
|
40
40
|
this.recorder.restoreGroup();
|
41
41
|
}
|
42
|
-
savePaint(props) {
|
42
|
+
savePaint(props, standalone) {
|
43
43
|
this.processAnimationValues(props);
|
44
|
-
this.recorder.savePaint(props);
|
44
|
+
this.recorder.savePaint(props, standalone);
|
45
45
|
}
|
46
46
|
restorePaint() {
|
47
47
|
this.recorder.restorePaint();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_utils","require","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","ReanimatedRecorder","constructor","Skia","Set","recorder","Recorder","processAnimationValues","props","values","forEach","isSharedValue","has","name","size","add","getRecorder","getSharedValues","Array","from","saveGroup","restoreGroup","savePaint","restorePaint","restorePaintDeclaration","materializePaint","pushPathEffect","pathEffectType","pushImageFilter","imageFilterType","pushColorFilter","colorFilterType","pushShader","shaderType","pushBlurMaskFilter","composePathEffect","composeColorFilter","composeImageFilter","saveCTM","restoreCTM","drawPaint","saveLayer","saveBackdropFilter","drawBox","boxProps","shadows","shadow","map","s","drawImage","drawCircle","drawPoints","drawPath","drawRect","drawRRect","drawOval","drawLine","drawPatch","drawVertices","drawDiffRect","drawText","drawTextPath","drawTextBlob","drawGlyphs","drawPicture","drawImageSVG","drawParagraph","drawAtlas","exports"],"sources":["ReanimatedRecorder.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport type { BaseRecorder, JsiRecorder, Skia } from \"../../skia/types\";\nimport type {\n PaintProps,\n NodeType,\n BlurMaskFilterProps,\n CTMProps,\n BoxProps,\n BoxShadowProps,\n ImageProps,\n CircleProps,\n PointsProps,\n PathProps,\n RectProps,\n RoundedRectProps,\n OvalProps,\n LineProps,\n PatchProps,\n VerticesProps,\n DiffRectProps,\n TextProps,\n TextPathProps,\n TextBlobProps,\n GlyphsProps,\n PictureProps,\n ImageSVGProps,\n ParagraphProps,\n AtlasProps,\n} from \"../../dom/types\";\nimport type { AnimatedProps } from \"../../renderer\";\nimport { isSharedValue } from \"../utils\";\n\nexport class ReanimatedRecorder implements BaseRecorder {\n private values = new Set<SharedValue<unknown>>();\n private recorder: JsiRecorder;\n\n constructor(Skia: Skia) {\n this.recorder = Skia.Recorder();\n }\n\n private processAnimationValues(props?: Record<string, unknown>) {\n if (!props) {\n return;\n }\n Object.values(props).forEach((value) => {\n if (isSharedValue(value) && !this.values.has(value)) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n value.name = `variable${this.values.size}`;\n this.values.add(value as SharedValue<unknown>);\n }\n });\n }\n\n getRecorder() {\n return this.recorder;\n }\n\n getSharedValues() {\n return Array.from(this.values);\n }\n\n saveGroup(): void {\n this.recorder.saveGroup();\n }\n\n restoreGroup(): void {\n this.recorder.restoreGroup();\n }\n\n savePaint(props: AnimatedProps<PaintProps>): void {\n this.processAnimationValues(props);\n this.recorder.savePaint(props);\n }\n\n restorePaint(): void {\n this.recorder.restorePaint();\n }\n\n restorePaintDeclaration(): void {\n this.recorder.restorePaintDeclaration();\n }\n\n materializePaint(): void {\n this.recorder.materializePaint();\n }\n\n pushPathEffect(\n pathEffectType: NodeType,\n props: AnimatedProps<unknown>\n ): void {\n this.processAnimationValues(props);\n this.recorder.pushPathEffect(pathEffectType, props);\n }\n\n pushImageFilter(\n imageFilterType: NodeType,\n props: AnimatedProps<unknown>\n ): void {\n this.processAnimationValues(props);\n this.recorder.pushImageFilter(imageFilterType, props);\n }\n\n pushColorFilter(\n colorFilterType: NodeType,\n props: AnimatedProps<unknown>\n ): void {\n this.processAnimationValues(props);\n this.recorder.pushColorFilter(colorFilterType, props);\n }\n\n pushShader(shaderType: NodeType, props: AnimatedProps<unknown>): void {\n this.processAnimationValues(props);\n this.recorder.pushShader(shaderType, props);\n }\n\n pushBlurMaskFilter(props: AnimatedProps<BlurMaskFilterProps>): void {\n this.processAnimationValues(props);\n this.recorder.pushBlurMaskFilter(props);\n }\n\n composePathEffect(): void {\n this.recorder.composePathEffect();\n }\n\n composeColorFilter(): void {\n this.recorder.composeColorFilter();\n }\n\n composeImageFilter(): void {\n this.recorder.composeImageFilter();\n }\n\n saveCTM(props: AnimatedProps<CTMProps>): void {\n this.processAnimationValues(props);\n this.recorder.saveCTM(props);\n }\n\n restoreCTM(): void {\n this.recorder.restoreCTM();\n }\n\n drawPaint(): void {\n this.recorder.drawPaint();\n }\n\n saveLayer(): void {\n this.recorder.saveLayer();\n }\n\n saveBackdropFilter(): void {\n this.recorder.saveBackdropFilter();\n }\n\n drawBox(\n boxProps: AnimatedProps<BoxProps>,\n shadows: {\n props: BoxShadowProps;\n }[]\n ): void {\n this.processAnimationValues(boxProps);\n shadows.forEach((shadow) => {\n this.processAnimationValues(\n shadow.props as AnimatedProps<BoxShadowProps>\n );\n });\n this.recorder.drawBox(\n boxProps,\n // TODO: Fix this type BaseRecorder.drawBox()\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n shadows.map((s) => s.props)\n );\n }\n\n drawImage(props: AnimatedProps<ImageProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawImage(props);\n }\n\n drawCircle(props: AnimatedProps<CircleProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawCircle(props);\n }\n\n drawPoints(props: AnimatedProps<PointsProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawPoints(props);\n }\n\n drawPath(props: AnimatedProps<PathProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawPath(props);\n }\n\n drawRect(props: AnimatedProps<RectProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawRect(props);\n }\n\n drawRRect(props: AnimatedProps<RoundedRectProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawRRect(props);\n }\n\n drawOval(props: AnimatedProps<OvalProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawOval(props);\n }\n\n drawLine(props: AnimatedProps<LineProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawLine(props);\n }\n\n drawPatch(props: AnimatedProps<PatchProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawPatch(props);\n }\n\n drawVertices(props: AnimatedProps<VerticesProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawVertices(props);\n }\n\n drawDiffRect(props: AnimatedProps<DiffRectProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawDiffRect(props);\n }\n\n drawText(props: AnimatedProps<TextProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawText(props);\n }\n\n drawTextPath(props: AnimatedProps<TextPathProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawTextPath(props);\n }\n\n drawTextBlob(props: AnimatedProps<TextBlobProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawTextBlob(props);\n }\n\n drawGlyphs(props: AnimatedProps<GlyphsProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawGlyphs(props);\n }\n\n drawPicture(props: AnimatedProps<PictureProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawPicture(props);\n }\n\n drawImageSVG(props: AnimatedProps<ImageSVGProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawImageSVG(props);\n }\n\n drawParagraph(props: AnimatedProps<ParagraphProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawParagraph(props);\n }\n\n drawAtlas(props: AnimatedProps<AtlasProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawAtlas(props);\n }\n}\n"],"mappings":";;;;;;AA+BA,IAAAA,MAAA,GAAAC,OAAA;AAAyC,SAAAC,gBAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAD,CAAA,GAAAI,MAAA,CAAAC,cAAA,CAAAL,CAAA,EAAAC,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAT,CAAA,CAAAC,CAAA,IAAAC,CAAA,EAAAF,CAAA;AAAA,SAAAG,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAAA,CAAAT,CAAA,uCAAAQ,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAT,CAAA,EAAAD,CAAA,2BAAAC,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAF,CAAA,GAAAE,CAAA,CAAAU,MAAA,CAAAC,WAAA,kBAAAb,CAAA,QAAAU,CAAA,GAAAV,CAAA,CAAAc,IAAA,CAAAZ,CAAA,EAAAD,CAAA,uCAAAS,CAAA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CAAC;IAClC,IAAI,CAACH,QAAQ,CAAC8D,SAAS,CAAC3D,KAAK,CAAC;EAChC;AACF;AAAC4D,OAAA,CAAAnE,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
1
|
+
{"version":3,"names":["_utils","require","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","ReanimatedRecorder","constructor","Skia","Set","recorder","Recorder","processAnimationValues","props","values","forEach","isSharedValue","has","name","size","add","getRecorder","getSharedValues","Array","from","saveGroup","restoreGroup","savePaint","standalone","restorePaint","restorePaintDeclaration","materializePaint","pushPathEffect","pathEffectType","pushImageFilter","imageFilterType","pushColorFilter","colorFilterType","pushShader","shaderType","pushBlurMaskFilter","composePathEffect","composeColorFilter","composeImageFilter","saveCTM","restoreCTM","drawPaint","saveLayer","saveBackdropFilter","drawBox","boxProps","shadows","shadow","map","s","drawImage","drawCircle","drawPoints","drawPath","drawRect","drawRRect","drawOval","drawLine","drawPatch","drawVertices","drawDiffRect","drawText","drawTextPath","drawTextBlob","drawGlyphs","drawPicture","drawImageSVG","drawParagraph","drawAtlas","exports"],"sources":["ReanimatedRecorder.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport type { BaseRecorder, JsiRecorder, Skia } from \"../../skia/types\";\nimport type {\n PaintProps,\n NodeType,\n BlurMaskFilterProps,\n CTMProps,\n BoxProps,\n BoxShadowProps,\n ImageProps,\n CircleProps,\n PointsProps,\n PathProps,\n RectProps,\n RoundedRectProps,\n OvalProps,\n LineProps,\n PatchProps,\n VerticesProps,\n DiffRectProps,\n TextProps,\n TextPathProps,\n TextBlobProps,\n GlyphsProps,\n PictureProps,\n ImageSVGProps,\n ParagraphProps,\n AtlasProps,\n} from \"../../dom/types\";\nimport type { AnimatedProps } from \"../../renderer\";\nimport { isSharedValue } from \"../utils\";\n\nexport class ReanimatedRecorder implements BaseRecorder {\n private values = new Set<SharedValue<unknown>>();\n private recorder: JsiRecorder;\n\n constructor(Skia: Skia) {\n this.recorder = Skia.Recorder();\n }\n\n private processAnimationValues(props?: Record<string, unknown>) {\n if (!props) {\n return;\n }\n Object.values(props).forEach((value) => {\n if (isSharedValue(value) && !this.values.has(value)) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n value.name = `variable${this.values.size}`;\n this.values.add(value as SharedValue<unknown>);\n }\n });\n }\n\n getRecorder() {\n return this.recorder;\n }\n\n getSharedValues() {\n return Array.from(this.values);\n }\n\n saveGroup(): void {\n this.recorder.saveGroup();\n }\n\n restoreGroup(): void {\n this.recorder.restoreGroup();\n }\n\n savePaint(props: AnimatedProps<PaintProps>, standalone: boolean): void {\n this.processAnimationValues(props);\n this.recorder.savePaint(props, standalone);\n }\n\n restorePaint(): void {\n this.recorder.restorePaint();\n }\n\n restorePaintDeclaration(): void {\n this.recorder.restorePaintDeclaration();\n }\n\n materializePaint(): void {\n this.recorder.materializePaint();\n }\n\n pushPathEffect(\n pathEffectType: NodeType,\n props: AnimatedProps<unknown>\n ): void {\n this.processAnimationValues(props);\n this.recorder.pushPathEffect(pathEffectType, props);\n }\n\n pushImageFilter(\n imageFilterType: NodeType,\n props: AnimatedProps<unknown>\n ): void {\n this.processAnimationValues(props);\n this.recorder.pushImageFilter(imageFilterType, props);\n }\n\n pushColorFilter(\n colorFilterType: NodeType,\n props: AnimatedProps<unknown>\n ): void {\n this.processAnimationValues(props);\n this.recorder.pushColorFilter(colorFilterType, props);\n }\n\n pushShader(shaderType: NodeType, props: AnimatedProps<unknown>): void {\n this.processAnimationValues(props);\n this.recorder.pushShader(shaderType, props);\n }\n\n pushBlurMaskFilter(props: AnimatedProps<BlurMaskFilterProps>): void {\n this.processAnimationValues(props);\n this.recorder.pushBlurMaskFilter(props);\n }\n\n composePathEffect(): void {\n this.recorder.composePathEffect();\n }\n\n composeColorFilter(): void {\n this.recorder.composeColorFilter();\n }\n\n composeImageFilter(): void {\n this.recorder.composeImageFilter();\n }\n\n saveCTM(props: AnimatedProps<CTMProps>): void {\n this.processAnimationValues(props);\n this.recorder.saveCTM(props);\n }\n\n restoreCTM(): void {\n this.recorder.restoreCTM();\n }\n\n drawPaint(): void {\n this.recorder.drawPaint();\n }\n\n saveLayer(): void {\n this.recorder.saveLayer();\n }\n\n saveBackdropFilter(): void {\n this.recorder.saveBackdropFilter();\n }\n\n drawBox(\n boxProps: AnimatedProps<BoxProps>,\n shadows: {\n props: BoxShadowProps;\n }[]\n ): void {\n this.processAnimationValues(boxProps);\n shadows.forEach((shadow) => {\n this.processAnimationValues(\n shadow.props as AnimatedProps<BoxShadowProps>\n );\n });\n this.recorder.drawBox(\n boxProps,\n // TODO: Fix this type BaseRecorder.drawBox()\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n shadows.map((s) => s.props)\n );\n }\n\n drawImage(props: AnimatedProps<ImageProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawImage(props);\n }\n\n drawCircle(props: AnimatedProps<CircleProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawCircle(props);\n }\n\n drawPoints(props: AnimatedProps<PointsProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawPoints(props);\n }\n\n drawPath(props: AnimatedProps<PathProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawPath(props);\n }\n\n drawRect(props: AnimatedProps<RectProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawRect(props);\n }\n\n drawRRect(props: AnimatedProps<RoundedRectProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawRRect(props);\n }\n\n drawOval(props: AnimatedProps<OvalProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawOval(props);\n }\n\n drawLine(props: AnimatedProps<LineProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawLine(props);\n }\n\n drawPatch(props: AnimatedProps<PatchProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawPatch(props);\n }\n\n drawVertices(props: AnimatedProps<VerticesProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawVertices(props);\n }\n\n drawDiffRect(props: AnimatedProps<DiffRectProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawDiffRect(props);\n }\n\n drawText(props: AnimatedProps<TextProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawText(props);\n }\n\n drawTextPath(props: AnimatedProps<TextPathProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawTextPath(props);\n }\n\n drawTextBlob(props: AnimatedProps<TextBlobProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawTextBlob(props);\n }\n\n drawGlyphs(props: AnimatedProps<GlyphsProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawGlyphs(props);\n }\n\n drawPicture(props: AnimatedProps<PictureProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawPicture(props);\n }\n\n drawImageSVG(props: AnimatedProps<ImageSVGProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawImageSVG(props);\n }\n\n drawParagraph(props: AnimatedProps<ParagraphProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawParagraph(props);\n }\n\n drawAtlas(props: AnimatedProps<AtlasProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawAtlas(props);\n }\n}\n"],"mappings":";;;;;;AA+BA,IAAAA,MAAA,GAAAC,OAAA;AAAyC,SAAAC,gBAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAD,CAAA,GAAAI,MAAA,CAAAC,cAAA,CAAAL,CAAA,EAAAC,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAT,CAAA,CAAAC,CAAA,IAAAC,CAAA,EAAAF,CAAA;AAAA,SAAAG,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAAA,CAAAT,CAAA,uCAAAQ,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAT,CAAA,EAAA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nC;EAEA2D,aAAaA,CAAC3D,KAAoC,EAAQ;IACxD,IAAI,CAACD,sBAAsB,CAACC,KAAK,CAAC;IAClC,IAAI,CAACH,QAAQ,CAAC8D,aAAa,CAAC3D,KAAK,CAAC;EACpC;EAEA4D,SAASA,CAAC5D,KAAgC,EAAQ;IAChD,IAAI,CAACD,sBAAsB,CAACC,KAAK,CAAC;IAClC,IAAI,CAACH,QAAQ,CAAC+D,SAAS,CAAC5D,KAAK,CAAC;EAChC;AACF;AAAC6D,OAAA,CAAApE,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
@@ -21,7 +21,7 @@ export declare class Recorder implements BaseRecorder {
|
|
21
21
|
private add;
|
22
22
|
saveGroup(): void;
|
23
23
|
restoreGroup(): void;
|
24
|
-
savePaint(props: AnimatedProps<PaintProps
|
24
|
+
savePaint(props: AnimatedProps<PaintProps>, standalone: boolean): void;
|
25
25
|
restorePaint(): void;
|
26
26
|
restorePaintDeclaration(): void;
|
27
27
|
materializePaint(): void;
|