@shopify/react-native-skia 2.3.8 → 2.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/cpp/api/JsiNativeBuffer.h +4 -0
  2. package/cpp/api/JsiSkAnimatedImage.h +71 -1
  3. package/cpp/api/JsiSkAnimatedImageFactory.h +4 -0
  4. package/cpp/api/JsiSkApi.h +2 -0
  5. package/cpp/api/JsiSkCanvas.h +2 -0
  6. package/cpp/api/JsiSkColorFilter.h +2 -0
  7. package/cpp/api/JsiSkColorFilterFactory.h +4 -0
  8. package/cpp/api/JsiSkContourMeasure.h +2 -0
  9. package/cpp/api/JsiSkContourMeasureIter.h +4 -0
  10. package/cpp/api/JsiSkData.h +2 -0
  11. package/cpp/api/JsiSkDataFactory.h +2 -0
  12. package/cpp/api/JsiSkFont.h +2 -0
  13. package/cpp/api/JsiSkFontMgr.h +2 -0
  14. package/cpp/api/JsiSkFontMgrFactory.h +2 -0
  15. package/cpp/api/JsiSkFontStyle.h +2 -0
  16. package/cpp/api/JsiSkHostObjects.h +50 -0
  17. package/cpp/api/JsiSkImage.h +3 -1
  18. package/cpp/api/JsiSkImageFactory.h +2 -0
  19. package/cpp/api/JsiSkImageFilter.h +3 -1
  20. package/cpp/api/JsiSkImageFilterFactory.h +4 -0
  21. package/cpp/api/JsiSkImageInfo.h +2 -0
  22. package/cpp/api/JsiSkMaskFilter.h +2 -0
  23. package/cpp/api/JsiSkMaskFilterFactory.h +4 -0
  24. package/cpp/api/JsiSkMatrix.h +2 -0
  25. package/cpp/api/JsiSkPaint.h +2 -0
  26. package/cpp/api/JsiSkParagraph.h +3 -1
  27. package/cpp/api/JsiSkParagraphBuilder.h +3 -1
  28. package/cpp/api/JsiSkParagraphBuilderFactory.h +5 -1
  29. package/cpp/api/JsiSkPath.h +2 -0
  30. package/cpp/api/JsiSkPathEffect.h +2 -0
  31. package/cpp/api/JsiSkPathEffectFactory.h +4 -0
  32. package/cpp/api/JsiSkPathFactory.h +2 -0
  33. package/cpp/api/JsiSkPicture.h +2 -0
  34. package/cpp/api/JsiSkPictureFactory.h +10 -0
  35. package/cpp/api/JsiSkPictureRecorder.h +3 -3
  36. package/cpp/api/JsiSkPoint.h +2 -0
  37. package/cpp/api/JsiSkRRect.h +2 -0
  38. package/cpp/api/JsiSkRSXform.h +2 -0
  39. package/cpp/api/JsiSkRect.h +2 -0
  40. package/cpp/api/JsiSkRuntimeEffect.h +2 -0
  41. package/cpp/api/JsiSkRuntimeEffectFactory.h +4 -0
  42. package/cpp/api/JsiSkRuntimeShaderBuilder.h +4 -0
  43. package/cpp/api/JsiSkSVG.h +2 -0
  44. package/cpp/api/JsiSkSVGFactory.h +2 -0
  45. package/cpp/api/JsiSkShader.h +3 -1
  46. package/cpp/api/JsiSkShaderFactory.h +2 -0
  47. package/cpp/api/JsiSkSkottie.h +2 -0
  48. package/cpp/api/JsiSkSurface.h +50 -7
  49. package/cpp/api/JsiSkSurfaceFactory.h +2 -0
  50. package/cpp/api/JsiSkTextBlob.h +2 -0
  51. package/cpp/api/JsiSkTextBlobFactory.h +2 -0
  52. package/cpp/api/JsiSkTypeface.h +2 -0
  53. package/cpp/api/JsiSkTypefaceFactory.h +2 -0
  54. package/cpp/api/JsiSkTypefaceFontProvider.h +4 -0
  55. package/cpp/api/JsiSkTypefaceFontProviderFactory.h +4 -0
  56. package/cpp/api/JsiSkVertices.h +2 -0
  57. package/cpp/api/JsiSkiaContext.h +3 -1
  58. package/cpp/api/JsiSkottieFactory.h +2 -0
  59. package/cpp/api/JsiVideo.h +2 -0
  60. package/cpp/api/recorder/JsiRecorder.h +42 -7
  61. package/cpp/jsi/ViewProperty.h +1 -3
  62. package/lib/commonjs/skia/types/Picture/PictureFactory.d.ts +1 -1
  63. package/lib/commonjs/skia/types/Picture/PictureFactory.js.map +1 -1
  64. package/lib/commonjs/skia/types/Recorder.d.ts +2 -1
  65. package/lib/commonjs/skia/types/Recorder.js.map +1 -1
  66. package/lib/commonjs/sksg/Container.native.d.ts +4 -0
  67. package/lib/commonjs/sksg/Container.native.js +18 -6
  68. package/lib/commonjs/sksg/Container.native.js.map +1 -1
  69. package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +1 -0
  70. package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js +4 -0
  71. package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
  72. package/lib/module/skia/types/Picture/PictureFactory.d.ts +1 -1
  73. package/lib/module/skia/types/Picture/PictureFactory.js.map +1 -1
  74. package/lib/module/skia/types/Recorder.d.ts +2 -1
  75. package/lib/module/skia/types/Recorder.js.map +1 -1
  76. package/lib/module/sksg/Container.native.d.ts +4 -0
  77. package/lib/module/sksg/Container.native.js +18 -6
  78. package/lib/module/sksg/Container.native.js.map +1 -1
  79. package/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +1 -0
  80. package/lib/module/sksg/Recorder/ReanimatedRecorder.js +4 -0
  81. package/lib/module/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
  82. package/lib/typescript/lib/commonjs/sksg/Container.native.d.ts +5 -0
  83. package/lib/typescript/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +1 -0
  84. package/lib/typescript/lib/module/sksg/Container.native.d.ts +5 -0
  85. package/lib/typescript/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +1 -0
  86. package/lib/typescript/src/skia/types/Picture/PictureFactory.d.ts +1 -1
  87. package/lib/typescript/src/skia/types/Recorder.d.ts +2 -1
  88. package/lib/typescript/src/sksg/Container.native.d.ts +4 -0
  89. package/lib/typescript/src/sksg/Recorder/ReanimatedRecorder.d.ts +1 -0
  90. package/package.json +1 -1
  91. package/src/skia/types/Picture/PictureFactory.ts +1 -1
  92. package/src/skia/types/Recorder.ts +2 -1
  93. package/src/sksg/Container.native.ts +25 -7
  94. package/src/sksg/Recorder/ReanimatedRecorder.ts +5 -0
@@ -254,6 +254,8 @@ public:
254
254
 
255
255
  size_t getMemoryPressure() const override { return 1024; }
256
256
 
257
+ std::string getObjectType() const override { return "JsiSkShaderFactory"; }
258
+
257
259
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkShaderFactory, MakeLinearGradient),
258
260
  JSI_EXPORT_FUNC(JsiSkShaderFactory, MakeRadialGradient),
259
261
  JSI_EXPORT_FUNC(JsiSkShaderFactory, MakeSweepGradient),
@@ -615,5 +615,7 @@ public:
615
615
 
616
616
  return animationMemory + baseOverhead;
617
617
  }
618
+
619
+ std::string getObjectType() const override { return "JsiSkSkottie"; }
618
620
  };
619
621
  } // namespace RNSkia
@@ -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,58 @@ 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
- // Surface memory is primarily the pixel buffer: width × height × bytes per
123
- // pixel
124
- int width = surface->width();
125
- int height = surface->height();
126
- // Assume 4 bytes per pixel (RGBA) for most surfaces
127
- return width * height * 4;
151
+ size_t estimated = pixelBytes;
152
+
153
+ auto canvas = surface->getCanvas();
154
+ const bool isGpuBacked =
155
+ surface->recordingContext() != nullptr || surface->recorder() != nullptr ||
156
+ (canvas && (canvas->recordingContext() != nullptr ||
157
+ canvas->recorder() != nullptr));
158
+
159
+ if (isGpuBacked) {
160
+ // Account for a resolved texture and depth/stencil attachments.
161
+ estimated = safeAdd(estimated, pixelBytes); // resolve/texture copy
162
+ estimated = safeAdd(estimated, pixelBytes / 2); // depth-stencil buffers
163
+ }
164
+
165
+ // Add a small overhead buffer for bookkeeping allocations.
166
+ estimated = safeAdd(estimated, 128 * 1024);
167
+
168
+ return estimated;
128
169
  }
129
170
 
171
+ std::string getObjectType() const override { return "JsiSkSurface"; }
172
+
130
173
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkSurface, width),
131
174
  JSI_EXPORT_FUNC(JsiSkSurface, height),
132
175
  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
  };
@@ -37,6 +37,8 @@ public:
37
37
  1024; // Area estimation + base overhead
38
38
  }
39
39
 
40
+ std::string getObjectType() const override { return "JsiSkTextBlob"; }
41
+
40
42
  EXPORT_JSI_API_TYPENAME(JsiSkTextBlob, TextBlob)
41
43
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkTextBlob, dispose))
42
44
  };
@@ -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
  };
@@ -79,6 +79,8 @@ public:
79
79
  return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
80
80
  runtime, hostObjectInstance, context);
81
81
  }
82
+
83
+ std::string getObjectType() const override { return "JsiSkTypeface"; }
82
84
  };
83
85
 
84
86
  } // namespace RNSkia
@@ -30,6 +30,8 @@ public:
30
30
 
31
31
  size_t getMemoryPressure() const override { return 1024; }
32
32
 
33
+ std::string getObjectType() const override { return "JsiSkTypefaceFactory"; }
34
+
33
35
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkTypefaceFactory,
34
36
  MakeFreeTypeFaceFromData))
35
37
 
@@ -81,6 +81,10 @@ public:
81
81
 
82
82
  size_t getMemoryPressure() const override { return 4096; }
83
83
 
84
+ std::string getObjectType() const override {
85
+ return "JsiSkTypefaceFontProvider";
86
+ }
87
+
84
88
  /**
85
89
  Returns the jsi object from a host object of this type
86
90
  */
@@ -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)) {}
@@ -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))
@@ -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 8192; }
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
  };
@@ -100,6 +100,8 @@ public:
100
100
 
101
101
  size_t getMemoryPressure() const override { return 32768; }
102
102
 
103
+ std::string getObjectType() const override { return "JsiVideo"; }
104
+
103
105
  /**
104
106
  * Creates the function for construction a new instance of the SkFont
105
107
  * wrapper
@@ -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
- auto picture = pictureRecorder.finishRecordingAsPicture();
63
- auto hostObjectInstance =
64
- std::make_shared<JsiSkPicture>(getContext(), std::move(picture));
65
- return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
66
- runtime, hostObjectInstance, getContext());
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
- size_t getMemoryPressure() const override { return 16384; }
354
+ std::string getObjectType() const override { return "JsiRecorder"; }
320
355
 
321
356
  static const jsi::HostFunctionType
322
357
  createCtor(std::shared_ptr<RNSkPlatformContext> context) {
@@ -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
 
@@ -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(): SkPicture;
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(): SkPicture;\n applyUpdates(variables: SharedValue<unknown>[]): void;\n}\n"],"mappings":"","ignoreList":[]}
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
  }
@@ -15,11 +15,11 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
15
15
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
16
16
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
17
17
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
18
- const nativeDrawOnscreen = (nativeId, recorder) => {
18
+ const nativeDrawOnscreen = (nativeId, recorder, picture) => {
19
19
  "worklet";
20
20
 
21
21
  //const start = performance.now();
22
- const picture = recorder.play();
22
+ recorder.play(picture);
23
23
  //const end = performance.now();
24
24
  //console.log("Recording time: ", end - start);
25
25
  SkiaViewApi.setJsiProperty(nativeId, "picture", picture);
@@ -29,6 +29,14 @@ class NativeReanimatedContainer extends _StaticContainer.Container {
29
29
  super(Skia);
30
30
  this.nativeId = nativeId;
31
31
  _defineProperty(this, "mapperId", null);
32
+ _defineProperty(this, "picture", void 0);
33
+ _defineProperty(this, "recorderA", void 0);
34
+ _defineProperty(this, "recorderB", void 0);
35
+ _defineProperty(this, "currentRecorder", void 0);
36
+ this.recorderA = new _ReanimatedRecorder.ReanimatedRecorder(Skia);
37
+ this.recorderB = new _ReanimatedRecorder.ReanimatedRecorder(Skia);
38
+ this.currentRecorder = this.recorderA;
39
+ this.picture = Skia.Picture.MakePicture(null);
32
40
  }
33
41
  redraw() {
34
42
  if (this.mapperId !== null) {
@@ -37,25 +45,29 @@ class NativeReanimatedContainer extends _StaticContainer.Container {
37
45
  if (this.unmounted) {
38
46
  return;
39
47
  }
48
+
49
+ // Swap to the next recorder (double buffering)
50
+ const recorder = this.currentRecorder;
51
+ this.currentRecorder = this.currentRecorder === this.recorderA ? this.recorderB : this.recorderA;
40
52
  const {
41
53
  nativeId,
42
- Skia
54
+ picture
43
55
  } = this;
44
- const recorder = new _ReanimatedRecorder.ReanimatedRecorder(Skia);
56
+ recorder.reset();
45
57
  (0, _Visitor.visit)(recorder, this.root);
46
58
  const sharedValues = recorder.getSharedValues();
47
59
  const sharedRecorder = recorder.getRecorder();
48
60
  _ReanimatedProxy.default.runOnUI(() => {
49
61
  "worklet";
50
62
 
51
- nativeDrawOnscreen(nativeId, sharedRecorder);
63
+ nativeDrawOnscreen(nativeId, sharedRecorder, picture);
52
64
  })();
53
65
  if (sharedValues.length > 0) {
54
66
  this.mapperId = _ReanimatedProxy.default.startMapper(() => {
55
67
  "worklet";
56
68
 
57
69
  sharedRecorder.applyUpdates(sharedValues);
58
- nativeDrawOnscreen(nativeId, sharedRecorder);
70
+ nativeDrawOnscreen(nativeId, sharedRecorder, picture);
59
71
  }, sharedValues);
60
72
  }
61
73
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_ReanimatedProxy","_interopRequireDefault","require","_renderHelpers","_ReanimatedRecorder","_StaticContainer","_Visitor","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","nativeDrawOnscreen","nativeId","recorder","picture","play","SkiaViewApi","setJsiProperty","NativeReanimatedContainer","Container","constructor","Skia","redraw","mapperId","Rea","stopMapper","unmounted","ReanimatedRecorder","visit","root","sharedValues","getSharedValues","sharedRecorder","getRecorder","runOnUI","length","startMapper","applyUpdates","createContainer","HAS_REANIMATED_3","StaticContainer","exports"],"sources":["Container.native.ts"],"sourcesContent":["import Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia } from \"../skia/types\";\nimport { HAS_REANIMATED_3 } from \"../external/reanimated/renderHelpers\";\nimport type { JsiRecorder } from \"../skia/types/Recorder\";\n\nimport { ReanimatedRecorder } from \"./Recorder/ReanimatedRecorder\";\nimport { Container, StaticContainer } from \"./StaticContainer\";\nimport { visit } from \"./Recorder/Visitor\";\n\nimport \"../skia/NativeSetup\";\nimport \"../views/api\";\n\nconst nativeDrawOnscreen = (nativeId: number, recorder: JsiRecorder) => {\n \"worklet\";\n\n //const start = performance.now();\n const picture = recorder.play();\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n};\n\nclass NativeReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(\n Skia: Skia,\n private nativeId: number\n ) {\n super(Skia);\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n }\n if (this.unmounted) {\n return;\n }\n const { nativeId, Skia } = this;\n const recorder = new ReanimatedRecorder(Skia);\n visit(recorder, this.root);\n const sharedValues = recorder.getSharedValues();\n const sharedRecorder = recorder.getRecorder();\n Rea.runOnUI(() => {\n \"worklet\";\n nativeDrawOnscreen(nativeId, sharedRecorder);\n })();\n if (sharedValues.length > 0) {\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n sharedRecorder.applyUpdates(sharedValues);\n nativeDrawOnscreen(nativeId, sharedRecorder);\n }, sharedValues);\n }\n }\n}\n\nexport const createContainer = (Skia: Skia, nativeId: number) => {\n if (HAS_REANIMATED_3 && nativeId !== -1) {\n return new NativeReanimatedContainer(Skia, nativeId);\n } else {\n return new StaticContainer(Skia, nativeId);\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,cAAA,GAAAD,OAAA;AAGA,IAAAE,mBAAA,GAAAF,OAAA;AACA,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AAQ,CAAC;EAC5C;AACF,CAAC;AAAC6B,OAAA,CAAAH,eAAA,GAAAA,eAAA","ignoreList":[]}
1
+ {"version":3,"names":["_ReanimatedProxy","_interopRequireDefault","require","_renderHelpers","_ReanimatedRecorder","_StaticContainer","_Visitor","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","nativeDrawOnscreen","nativeId","recorder","picture","play","SkiaViewApi","setJsiProperty","NativeReanimatedContainer","Container","constructor","Skia","recorderA","ReanimatedRecorder","recorderB","currentRecorder","Picture","MakePicture","redraw","mapperId","Rea","stopMapper","unmounted","reset","visit","root","sharedValues","getSharedValues","sharedRecorder","getRecorder","runOnUI","length","startMapper","applyUpdates","createContainer","HAS_REANIMATED_3","StaticContainer","exports"],"sources":["Container.native.ts"],"sourcesContent":["import Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia, SkPicture } from \"../skia/types\";\nimport { HAS_REANIMATED_3 } from \"../external/reanimated/renderHelpers\";\nimport type { JsiRecorder } from \"../skia/types/Recorder\";\n\nimport { ReanimatedRecorder } from \"./Recorder/ReanimatedRecorder\";\nimport { Container, StaticContainer } from \"./StaticContainer\";\nimport { visit } from \"./Recorder/Visitor\";\n\nimport \"../skia/NativeSetup\";\nimport \"../views/api\";\n\nconst nativeDrawOnscreen = (\n nativeId: number,\n recorder: JsiRecorder,\n picture: SkPicture\n) => {\n \"worklet\";\n\n //const start = performance.now();\n recorder.play(picture);\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n};\n\nclass NativeReanimatedContainer extends Container {\n private mapperId: number | null = null;\n private picture: SkPicture;\n private recorderA: ReanimatedRecorder;\n private recorderB: ReanimatedRecorder;\n private currentRecorder: ReanimatedRecorder;\n\n constructor(\n Skia: Skia,\n private nativeId: number\n ) {\n super(Skia);\n this.recorderA = new ReanimatedRecorder(Skia);\n this.recorderB = new ReanimatedRecorder(Skia);\n this.currentRecorder = this.recorderA;\n this.picture = Skia.Picture.MakePicture(null)!;\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n }\n if (this.unmounted) {\n return;\n }\n\n // Swap to the next recorder (double buffering)\n const recorder = this.currentRecorder;\n this.currentRecorder =\n this.currentRecorder === this.recorderA ? this.recorderB : this.recorderA;\n\n const { nativeId, picture } = this;\n recorder.reset();\n visit(recorder, this.root);\n const sharedValues = recorder.getSharedValues();\n const sharedRecorder = recorder.getRecorder();\n Rea.runOnUI(() => {\n \"worklet\";\n nativeDrawOnscreen(nativeId, sharedRecorder, picture);\n })();\n if (sharedValues.length > 0) {\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n sharedRecorder.applyUpdates(sharedValues);\n nativeDrawOnscreen(nativeId, sharedRecorder, picture);\n }, sharedValues);\n }\n }\n}\n\nexport const createContainer = (Skia: Skia, nativeId: number) => {\n if (HAS_REANIMATED_3 && nativeId !== -1) {\n return new NativeReanimatedContainer(Skia, nativeId);\n } else {\n return new StaticContainer(Skia, nativeId);\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,cAAA,GAAAD,OAAA;AAGA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAEAA,OAAA;AACAA,OAAA;AAAsB,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,gBAAAH,CAAA,EAAAI,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAJ,CAAA,GAAAO,MAAA,CAAAC,cAAA,CAAAR,CAAA,EAAAI,CAAA,IAAAK,KAAA,EAAAJ,CAAA,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IM,yBAAyB,CAACG,IAAI,EAAET,QAAQ,CAAC;EACtD,CAAC,MAAM;IACL,OAAO,IAAIkC,gCAAe,CAACzB,IAAI,EAAET,QAAQ,CAAC;EAC5C;AACF,CAAC;AAACmC,OAAA,CAAAH,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -10,6 +10,7 @@ export declare class ReanimatedRecorder implements BaseRecorder {
10
10
  private values;
11
11
  private recorder;
12
12
  constructor(Skia: Skia);
13
+ reset(): void;
13
14
  private processAnimationValues;
14
15
  getRecorder(): JsiRecorder;
15
16
  getSharedValues(): SharedValue<unknown>[];
@@ -18,6 +18,10 @@ class ReanimatedRecorder {
18
18
  _defineProperty(this, "recorder", void 0);
19
19
  this.recorder = Skia.Recorder();
20
20
  }
21
+ reset() {
22
+ this.values.clear();
23
+ this.recorder.reset();
24
+ }
21
25
  processAnimationValues(props) {
22
26
  if (!props) {
23
27
  return;
@@ -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","standalone","restorePaint","restorePaintDeclaration","materializePaint","pushPathEffect","pathEffectType","pushImageFilter","imageFilterType","pushColorFilter","colorFilterType","pushShader","shaderType","children","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","drawSkottie","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 SkottieProps,\n} from \"../../dom/types\";\nimport type { AnimatedProps } from \"../../renderer\";\nimport { isSharedValue } from \"../utils\";\n\n/**\n * Currently the recorder only work if the GPU resources (e.g Images) are owned by the main thread.\n * It will crash otherwise on Ganesh (iOS/Android).\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(\n shaderType: NodeType,\n props: AnimatedProps<unknown>,\n children: number\n ): void {\n this.processAnimationValues(props);\n this.recorder.pushShader(shaderType, props, children);\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 drawSkottie(props: AnimatedProps<SkottieProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawSkottie(props);\n }\n}\n"],"mappings":";;;;;;AAgCA,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,SAAAA,CAAA,YAAAK,SAAA,yEAAAd,CAAA,GAAAe,MAAA,GAAAC,MAAA,EAAAf,CAAA;AAEzC;AACA;AACA;AACA;AACO,MAAMgB,kBAAkB,CAAyB;EAItDC,WAAWA,CAACC,IAAU,EAAE;IAAArB,eAAA,iBAHP,IAAIsB,GAAG,CAAuB,CAAC;IAAAtB,eAAA;IAI9C,IAAI,CAACuB,QAAQ,GAAGF,IAAI,CAACG,QAAQ,CAAC,CAAC;EACjC;EAEQC,sBAAsBA,CAACC,KAA+B,EAAE;IAC9D,IAAI,CAACA,KAAK,EAAE;MACV;IACF;IACArB,MAAM,CAACsB,M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toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","ReanimatedRecorder","constructor","Skia","Set","recorder","Recorder","reset","values","clear","processAnimationValues","props","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","children","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","drawSkottie","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 SkottieProps,\n} from \"../../dom/types\";\nimport type { AnimatedProps } from \"../../renderer\";\nimport { isSharedValue } from \"../utils\";\n\n/**\n * Currently the recorder only work if the GPU resources (e.g Images) are owned by the main thread.\n * It will crash otherwise on Ganesh (iOS/Android).\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 reset() {\n this.values.clear();\n this.recorder.reset();\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(\n shaderType: NodeType,\n props: AnimatedProps<unknown>,\n children: number\n ): void {\n this.processAnimationValues(props);\n this.recorder.pushShader(shaderType, props, children);\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 drawSkottie(props: AnimatedProps<SkottieProps>): void {\n this.processAnimationValues(props);\n this.recorder.drawSkottie(props);\n }\n}\n"],"mappings":";;;;;;AAgCA,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,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AI,CAACD,sBAAsB,CAACC,KAAK,CAAC;IAClC,IAAI,CAACN,QAAQ,CAAC+D,WAAW,CAACzD,KAAK,CAAC;EAClC;EAEA0D,YAAYA,CAAC1D,KAAmC,EAAQ;IACtD,IAAI,CAACD,sBAAsB,CAACC,KAAK,CAAC;IAClC,IAAI,CAACN,QAAQ,CAACgE,YAAY,CAAC1D,KAAK,CAAC;EACnC;EAEA2D,aAAaA,CAAC3D,KAAoC,EAAQ;IACxD,IAAI,CAACD,sBAAsB,CAACC,KAAK,CAAC;IAClC,IAAI,CAACN,QAAQ,CAACiE,aAAa,CAAC3D,KAAK,CAAC;EACpC;EAEA4D,SAASA,CAAC5D,KAAgC,EAAQ;IAChD,IAAI,CAACD,sBAAsB,CAACC,KAAK,CAAC;IAClC,IAAI,CAACN,QAAQ,CAACkE,SAAS,CAAC5D,KAAK,CAAC;EAChC;EAEA6D,WAAWA,CAAC7D,KAAkC,EAAQ;IACpD,IAAI,CAACD,sBAAsB,CAACC,KAAK,CAAC;IAClC,IAAI,CAACN,QAAQ,CAACmE,WAAW,CAAC7D,KAAK,CAAC;EAClC;AACF;AAAC8D,OAAA,CAAAxE,kBAAA,GAAAA,kBAAA","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(): SkPicture;
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(): SkPicture;\n applyUpdates(variables: SharedValue<unknown>[]): void;\n}\n"],"mappings":"","ignoreList":[]}
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
  }