@shopify/react-native-skia 2.13.1 → 2.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/android/CMakeLists.txt +2 -0
  2. package/android/cpp/jni/include/JniSkiaPictureView.h +16 -15
  3. package/apple/RNSkApplePlatformContext.h +3 -4
  4. package/apple/RNSkiaModule.h +11 -3
  5. package/apple/RNSkiaModule.mm +46 -19
  6. package/apple/SkiaPictureView.mm +2 -2
  7. package/apple/SkiaUIView.h +0 -1
  8. package/apple/SkiaUIView.mm +1 -1
  9. package/apple/ViewScreenshotService.h +2 -2
  10. package/apple/ViewScreenshotService.mm +5 -4
  11. package/cpp/api/JsiSkPath.h +0 -431
  12. package/cpp/api/JsiSkSkottie.h +2 -3
  13. package/cpp/api/JsiSkStrutStyle.h +1 -1
  14. package/cpp/api/JsiSkSurfaceFactory.h +41 -0
  15. package/cpp/api/recorder/Convertor.h +152 -131
  16. package/cpp/api/recorder/DataTypes.h +11 -11
  17. package/cpp/api/recorder/ImageFit.h +8 -5
  18. package/cpp/api/recorder/JsiRecorder.h +9 -29
  19. package/cpp/api/recorder/Paint.h +3 -3
  20. package/cpp/api/recorder/RNRecorder.h +56 -0
  21. package/cpp/jsi/ViewProperty.cpp +23 -0
  22. package/cpp/jsi/ViewProperty.h +31 -10
  23. package/cpp/rnskia/RNDawnContext.h +33 -0
  24. package/cpp/rnskia/RNSkJsiViewApi.h +69 -2
  25. package/cpp/rnskia/RNSkPictureView.cpp +58 -0
  26. package/cpp/rnskia/RNSkPictureView.h +110 -24
  27. package/lib/commonjs/Platform/IPlatform.js.map +1 -1
  28. package/lib/commonjs/animation/functions/interpolate.js.map +1 -1
  29. package/lib/commonjs/skia/core/Image.js.map +1 -1
  30. package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -1
  31. package/lib/commonjs/skia/types/Path/Path.d.ts +2 -336
  32. package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
  33. package/lib/commonjs/skia/types/Recorder.d.ts +10 -0
  34. package/lib/commonjs/skia/types/Recorder.js.map +1 -1
  35. package/lib/commonjs/skia/types/Shader/Shader.js.map +1 -1
  36. package/lib/commonjs/skia/types/Surface/SurfaceFactory.d.ts +16 -0
  37. package/lib/commonjs/skia/types/Surface/SurfaceFactory.js.map +1 -1
  38. package/lib/commonjs/skia/web/JsiSkPath.d.ts +4 -38
  39. package/lib/commonjs/skia/web/JsiSkPath.js +3 -275
  40. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  41. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
  42. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js +3 -0
  43. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js.map +1 -1
  44. package/lib/commonjs/sksg/Container.native.d.ts +15 -1
  45. package/lib/commonjs/sksg/Container.native.js +34 -33
  46. package/lib/commonjs/sksg/Container.native.js.map +1 -1
  47. package/lib/commonjs/specs/NativeSkiaModule.web.js +4 -0
  48. package/lib/commonjs/specs/NativeSkiaModule.web.js.map +1 -1
  49. package/lib/commonjs/views/types.d.ts +9 -0
  50. package/lib/commonjs/views/types.js.map +1 -1
  51. package/lib/module/Platform/IPlatform.js.map +1 -1
  52. package/lib/module/animation/functions/interpolate.js.map +1 -1
  53. package/lib/module/skia/core/Image.js.map +1 -1
  54. package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -1
  55. package/lib/module/skia/types/Path/Path.d.ts +2 -336
  56. package/lib/module/skia/types/Path/Path.js.map +1 -1
  57. package/lib/module/skia/types/Recorder.d.ts +10 -0
  58. package/lib/module/skia/types/Recorder.js.map +1 -1
  59. package/lib/module/skia/types/Shader/Shader.js.map +1 -1
  60. package/lib/module/skia/types/Surface/SurfaceFactory.d.ts +16 -0
  61. package/lib/module/skia/types/Surface/SurfaceFactory.js.map +1 -1
  62. package/lib/module/skia/web/JsiSkPath.d.ts +4 -38
  63. package/lib/module/skia/web/JsiSkPath.js +4 -276
  64. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  65. package/lib/module/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
  66. package/lib/module/skia/web/JsiSkSurfaceFactory.js +4 -1
  67. package/lib/module/skia/web/JsiSkSurfaceFactory.js.map +1 -1
  68. package/lib/module/sksg/Container.native.d.ts +15 -1
  69. package/lib/module/sksg/Container.native.js +34 -33
  70. package/lib/module/sksg/Container.native.js.map +1 -1
  71. package/lib/module/specs/NativeSkiaModule.web.js +4 -0
  72. package/lib/module/specs/NativeSkiaModule.web.js.map +1 -1
  73. package/lib/module/views/types.d.ts +9 -0
  74. package/lib/module/views/types.js.map +1 -1
  75. package/lib/typescript/lib/commonjs/skia/web/JsiSkPath.d.ts +1 -35
  76. package/lib/typescript/lib/commonjs/skia/web/JsiSkSurfaceFactory.d.ts +1 -0
  77. package/lib/typescript/lib/commonjs/sksg/Container.native.d.ts +15 -1
  78. package/lib/typescript/lib/module/skia/web/JsiSkPath.d.ts +3 -37
  79. package/lib/typescript/lib/module/skia/web/JsiSkSurfaceFactory.d.ts +1 -0
  80. package/lib/typescript/lib/module/sksg/Container.native.d.ts +15 -1
  81. package/lib/typescript/src/skia/types/Path/Path.d.ts +2 -336
  82. package/lib/typescript/src/skia/types/Recorder.d.ts +10 -0
  83. package/lib/typescript/src/skia/types/Surface/SurfaceFactory.d.ts +16 -0
  84. package/lib/typescript/src/skia/web/JsiSkPath.d.ts +4 -38
  85. package/lib/typescript/src/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
  86. package/lib/typescript/src/sksg/Container.native.d.ts +15 -1
  87. package/lib/typescript/src/views/types.d.ts +9 -0
  88. package/package.json +2 -2
  89. package/src/Platform/IPlatform.ts +1 -4
  90. package/src/animation/functions/interpolate.ts +1 -4
  91. package/src/skia/core/Image.ts +1 -2
  92. package/src/skia/types/NativeBuffer/NativeBufferFactory.ts +2 -5
  93. package/src/skia/types/Path/Path.ts +2 -420
  94. package/src/skia/types/Recorder.ts +10 -0
  95. package/src/skia/types/Shader/Shader.ts +1 -5
  96. package/src/skia/types/Surface/SurfaceFactory.ts +17 -0
  97. package/src/skia/web/JsiSkPath.ts +4 -495
  98. package/src/skia/web/JsiSkSurfaceFactory.ts +6 -2
  99. package/src/sksg/Container.native.ts +34 -37
  100. package/src/specs/NativeSkiaModule.web.ts +4 -0
  101. package/src/views/types.ts +13 -0
  102. package/apple/SkiaManager.h +0 -23
  103. package/apple/SkiaManager.mm +0 -63
@@ -35,6 +35,24 @@ namespace RNSkia {
35
35
 
36
36
  namespace jsi = facebook::jsi;
37
37
 
38
+ class Recorder;
39
+
40
+ /**
41
+ * Draws either an SkPicture (imperative API, or a recording without shared
42
+ * values, played once into a picture) or a Recorder (declarative <Canvas>
43
+ * driven by Reanimated shared values). The recorder is owned by the
44
+ * renderer, not by a JS wrapper: its commands hold every native resource the
45
+ * canvas draws (images, pictures, paths), and tying their lifetime to the
46
+ * garbage collector of a runtime that rarely allocates (the UI runtime) kept
47
+ * them resident long after unmount. Here they are released as soon as the
48
+ * recorder is replaced, or when the host view is torn down (see clear()).
49
+ *
50
+ * Threading: setPicture/setRecorder run on the JS thread (React commit),
51
+ * applyUpdates on the UI thread (Reanimated mapper), drawInto on the main
52
+ * thread (onscreen draws) or the JS thread (snapshots). _mutex only guards
53
+ * the two pointers, so a commit never waits for a draw; the recorder
54
+ * serializes its replay against its updates on its own.
55
+ */
38
56
  class RNSkPictureRenderer
39
57
  : public RNSkRenderer,
40
58
  public std::enable_shared_from_this<RNSkPictureRenderer> {
@@ -52,31 +70,102 @@ public:
52
70
  }
53
71
 
54
72
  void setPicture(sk_sp<SkPicture> picture) {
55
- _picture = picture;
73
+ {
74
+ std::lock_guard<std::mutex> lock(_mutex);
75
+ _picture = picture;
76
+ _recorder = nullptr;
77
+ }
56
78
  _requestRedraw();
57
79
  }
58
80
 
59
- sk_sp<SkPicture> getPicture() const { return _picture; }
81
+ /**
82
+ * Takes ownership of a recorder. A recording without shared values is
83
+ * played once into a picture here (and its commands released): nothing
84
+ * will ever update it, and drawing a picture on every redraw (resize,
85
+ * foreground, ref.redraw(), snapshots) is cheaper than replaying commands.
86
+ * The previous recorder (and the resources its commands reference) is
87
+ * released here; Recorder's destructor moves the commands to the main
88
+ * thread before destroying them so GPU-backed resources are freed on the
89
+ * thread that used them.
90
+ */
91
+ void setRecorder(std::shared_ptr<Recorder> recorder);
92
+
93
+ /**
94
+ * Drops the recorder and the picture without scheduling a redraw. Called
95
+ * when the host view is torn down, so that the resources go away with the
96
+ * view rather than with the garbage collection of its host object (on
97
+ * Android the native view is only destroyed when the Java view is
98
+ * finalized).
99
+ */
100
+ void clear() {
101
+ std::shared_ptr<Recorder> retired;
102
+ sk_sp<SkPicture> picture;
103
+ {
104
+ std::lock_guard<std::mutex> lock(_mutex);
105
+ retired = std::move(_recorder);
106
+ picture = std::move(_picture);
107
+ }
108
+ // Both are destroyed here, outside the lock.
109
+ }
110
+
111
+ /**
112
+ * Reads the shared values on the calling runtime into the recorder's
113
+ * commands. Returns false when there is no recorder to update, or when the
114
+ * view holds a different recording than recorderId (a stale mapper whose
115
+ * values would otherwise land in the new recording's slots).
116
+ */
117
+ bool applyUpdates(jsi::Runtime &runtime, double recorderId,
118
+ const jsi::Array &values);
119
+
120
+ /**
121
+ * Same as applyUpdates(), for a recording that no view owns yet (one
122
+ * queued in the view registry until its view registers).
123
+ */
124
+ static bool applyUpdatesTo(const std::shared_ptr<Recorder> &recorder,
125
+ jsi::Runtime &runtime, double recorderId,
126
+ const jsi::Array &values);
127
+
128
+ /**
129
+ * Draws the current content (recorder or picture) into the canvas, scaled
130
+ * by the pixel density. Used for onscreen draws, snapshots and the Android
131
+ * bitmap export.
132
+ */
133
+ void drawInto(SkCanvas *canvas, float pixelDensity) {
134
+ // Copy the content under the lock and draw from the copies: a React
135
+ // commit swapping the content must only ever wait for a pointer swap,
136
+ // never for a draw. If the recorder is replaced mid-draw, this frame
137
+ // finishes with the old one and the swap schedules the next frame.
138
+ std::shared_ptr<Recorder> recorder;
139
+ sk_sp<SkPicture> picture;
140
+ {
141
+ std::lock_guard<std::mutex> lock(_mutex);
142
+ recorder = _recorder;
143
+ picture = _picture;
144
+ }
145
+ canvas->clear(SK_ColorTRANSPARENT);
146
+ canvas->save();
147
+ canvas->scale(pixelDensity, pixelDensity);
148
+ if (recorder != nullptr) {
149
+ replay(canvas, recorder.get());
150
+ } else if (picture != nullptr) {
151
+ canvas->drawPicture(picture);
152
+ }
153
+ canvas->restore();
154
+ }
60
155
 
61
156
  private:
157
+ void replay(SkCanvas *canvas, Recorder *recorder);
158
+
62
159
  bool performDraw(std::shared_ptr<RNSkCanvasProvider> canvasProvider) {
63
- // Capture picture pointer to ensure thread safety - _picture can be
64
- // modified from the JS thread while we're drawing on the render thread
65
- sk_sp<SkPicture> picture = _picture;
66
160
  auto pd = _platformContext->getPixelDensity();
67
- return canvasProvider->renderToCanvas([=](SkCanvas *canvas) {
68
- canvas->clear(SK_ColorTRANSPARENT);
69
- canvas->save();
70
- canvas->scale(pd, pd);
71
- if (picture != nullptr) {
72
- canvas->drawPicture(picture);
73
- }
74
- canvas->restore();
75
- });
161
+ return canvasProvider->renderToCanvas(
162
+ [this, pd](SkCanvas *canvas) { drawInto(canvas, pd); });
76
163
  }
77
164
 
78
165
  std::shared_ptr<RNSkPlatformContext> _platformContext;
166
+ mutable std::mutex _mutex;
79
167
  sk_sp<SkPicture> _picture;
168
+ std::shared_ptr<Recorder> _recorder;
80
169
  };
81
170
 
82
171
  class RNSkPictureView : public RNSkView {
@@ -93,18 +182,15 @@ public:
93
182
 
94
183
  void setJsiProperties(
95
184
  std::unordered_map<std::string, RNJsi::ViewProperty> &props) override {
96
- // Base implementation
185
+ auto renderer =
186
+ std::static_pointer_cast<RNSkPictureRenderer>(getRenderer());
97
187
  for (auto &prop : props) {
98
188
  if (prop.first == "picture") {
99
- if (prop.second.isNull()) {
100
- // Clear picture
101
- std::static_pointer_cast<RNSkPictureRenderer>(getRenderer())
102
- ->setPicture(nullptr);
103
- continue;
104
- }
105
- // Save picture
106
- std::static_pointer_cast<RNSkPictureRenderer>(getRenderer())
107
- ->setPicture(prop.second.getPicture());
189
+ renderer->setPicture(prop.second.isPicture() ? prop.second.getPicture()
190
+ : nullptr);
191
+ } else if (prop.first == "recorder") {
192
+ renderer->setRecorder(
193
+ prop.second.isRecorder() ? prop.second.getRecorder() : nullptr);
108
194
  }
109
195
  }
110
196
  }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["IPlatform.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { NodeHandle, ViewComponent } from \"react-native\";\n\nimport type { DataModule } from \"../skia/types\";\n\nexport interface IPlatform {\n OS: string;\n PixelRatio: number;\n findNodeHandle: (\n componentOrHandle:\n | null\n | number\n | React.Component<any, any>\n | React.ComponentClass<any>\n ) => null | NodeHandle;\n resolveAsset: (source: DataModule) => string;\n View: typeof ViewComponent;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["IPlatform.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { NodeHandle, ViewComponent } from \"react-native\";\n\nimport type { DataModule } from \"../skia/types\";\n\nexport interface IPlatform {\n OS: string;\n PixelRatio: number;\n findNodeHandle: (\n componentOrHandle:\n null | number | React.Component<any, any> | React.ComponentClass<any>\n ) => null | NodeHandle;\n resolveAsset: (source: DataModule) => string;\n View: typeof ViewComponent;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["Extrapolate","exports","getVal","type","coef","val","leftEdgeOutput","rightEdgeOutput","x","IDENTITY","CLAMP","EXTEND","isExtrapolate","value","validateInterpolationOptions","extrapolationConfig","extrapolateLeft","extrapolateRight","Error","Object","assign","internalInterpolate","narrowedInput","leftEdgeInput","rightEdgeInput","progress","interpolate","input","output","length","i"],"sources":["interpolate.ts"],"sourcesContent":["export enum Extrapolate {\n IDENTITY = \"identity\",\n CLAMP = \"clamp\",\n EXTEND = \"extend\",\n}\n\ninterface InterpolationNarrowedInput {\n leftEdgeInput: number;\n rightEdgeInput: number;\n leftEdgeOutput: number;\n rightEdgeOutput: number;\n}\n\nexport interface ExtrapolationConfig {\n extrapolateLeft?: Extrapolate | string;\n extrapolateRight?: Extrapolate | string;\n}\n\ninterface RequiredExtrapolationConfig {\n extrapolateLeft: Extrapolate;\n extrapolateRight: Extrapolate;\n}\n\nexport type ExtrapolationType =\n | ExtrapolationConfig\n | Extrapolate\n | string\n | undefined;\n\nfunction getVal(\n type: Extrapolate,\n coef: number,\n val: number,\n leftEdgeOutput: number,\n rightEdgeOutput: number,\n x: number\n): number {\n \"worklet\";\n switch (type) {\n case Extrapolate.IDENTITY:\n return x;\n case Extrapolate.CLAMP:\n if (coef * val < coef * leftEdgeOutput) {\n return leftEdgeOutput;\n }\n return rightEdgeOutput;\n case Extrapolate.EXTEND:\n default:\n return val;\n }\n}\n\nfunction isExtrapolate(value: string): value is Extrapolate {\n \"worklet\";\n return (\n value === Extrapolate.EXTEND ||\n value === Extrapolate.CLAMP ||\n value === Extrapolate.IDENTITY\n );\n}\n\n// validates extrapolations type\n// if type is correct, converts it to ExtrapolationConfig\nexport function validateInterpolationOptions(\n type: ExtrapolationType\n): RequiredExtrapolationConfig {\n \"worklet\";\n // initialize extrapolationConfig with default extrapolation\n const extrapolationConfig: RequiredExtrapolationConfig = {\n extrapolateLeft: Extrapolate.EXTEND,\n extrapolateRight: Extrapolate.EXTEND,\n };\n\n if (!type) {\n return extrapolationConfig;\n }\n\n if (typeof type === \"string\") {\n if (!isExtrapolate(type)) {\n throw new Error(\n `No supported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], \"clamp\")`\n );\n }\n extrapolationConfig.extrapolateLeft = type;\n extrapolationConfig.extrapolateRight = type;\n return extrapolationConfig;\n }\n\n // otherwise type is extrapolation config object\n if (\n (type.extrapolateLeft && !isExtrapolate(type.extrapolateLeft)) ||\n (type.extrapolateRight && !isExtrapolate(type.extrapolateRight))\n ) {\n throw new Error(\n `No supported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], {\n extrapolateLeft: Extrapolation.CLAMP,\n extrapolateRight: Extrapolation.IDENTITY\n }})`\n );\n }\n\n Object.assign(extrapolationConfig, type);\n return extrapolationConfig;\n}\n\nfunction internalInterpolate(\n x: number,\n narrowedInput: InterpolationNarrowedInput,\n extrapolationConfig: RequiredExtrapolationConfig\n) {\n \"worklet\";\n const { leftEdgeInput, rightEdgeInput, leftEdgeOutput, rightEdgeOutput } =\n narrowedInput;\n if (rightEdgeInput - leftEdgeInput === 0) {\n return leftEdgeOutput;\n }\n const progress = (x - leftEdgeInput) / (rightEdgeInput - leftEdgeInput);\n const val = leftEdgeOutput + progress * (rightEdgeOutput - leftEdgeOutput);\n const coef = rightEdgeOutput >= leftEdgeOutput ? 1 : -1;\n\n if (coef * val < coef * leftEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateLeft,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n } else if (coef * val > coef * rightEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateRight,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n }\n\n return val;\n}\n\n// e.g. function interpolate(x, input, output, type = Extrapolatation.CLAMP)\nexport function interpolate(\n x: number,\n input: readonly number[],\n output: readonly number[],\n type?: ExtrapolationType\n): number {\n \"worklet\";\n if (input.length < 2 || output.length < 2) {\n throw Error(\n \"Interpolation input and output should contain at least two values.\"\n );\n }\n\n const extrapolationConfig = validateInterpolationOptions(type);\n const { length } = input;\n const narrowedInput: InterpolationNarrowedInput = {\n leftEdgeInput: input[0],\n rightEdgeInput: input[1],\n leftEdgeOutput: output[0],\n rightEdgeOutput: output[1],\n };\n if (length > 2) {\n if (x > input[length - 1]) {\n narrowedInput.leftEdgeInput = input[length - 2];\n narrowedInput.rightEdgeInput = input[length - 1];\n narrowedInput.leftEdgeOutput = output[length - 2];\n narrowedInput.rightEdgeOutput = output[length - 1];\n } else {\n for (let i = 1; i < length; ++i) {\n if (x <= input[i]) {\n narrowedInput.leftEdgeInput = input[i - 1];\n narrowedInput.rightEdgeInput = input[i];\n narrowedInput.leftEdgeOutput = output[i - 1];\n narrowedInput.rightEdgeOutput = output[i];\n break;\n }\n }\n }\n }\n\n return internalInterpolate(x, narrowedInput, extrapolationConfig);\n}\n"],"mappings":";;;;;;;;IAAYA,WAAW,GAAAC,OAAA,CAAAD,WAAA,0BAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAA,OAAXA,WAAW;AAAA;AA6BvB,SAASE,MAAMA,CACbC,IAAiB,EACjBC,IAAY,EACZC,GAAW,EACXC,cAAsB,EACtBC,eAAuB,EACvBC,CAAS,EACD;EACR,SAAS;;EACT,QAAQL,IAAI;IACV,KAAKH,WAAW,CAACS,QAAQ;MACvB,OAAOD,CAAC;IACV,KAAKR,WAAW,CAACU,KAAK;MACpB,IAAIN,IAAI,GAAGC,GAAG,GAAGD,IAAI,GAAGE,cAAc,EAAE;QACtC,OAAOA,cAAc;MACvB;MACA,OAAOC,eAAe;IACxB,KAAKP,WAAW,CAACW,MAAM;IACvB;MACE,OAAON,GAAG;EACd;AACF;AAEA,SAASO,aAAaA,CAACC,KAAa,EAAwB;EAC1D,SAAS;;EACT,OACEA,KAAK,KAAKb,WAAW,CAACW,MAAM,IAC5BE,KAAK,KAAKb,WAAW,CAACU,KAAK,IAC3BG,KAAK,KAAKb,WAAW,CAACS,QAAQ;AAElC;;AAEA;AACA;AACO,SAASK,4BAA4BA,CAC1CX,IAAuB,EACM;EAC7B,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a,CAAChB,cAAc,GAAGsB,MAAM,CAACC,MAAM,GAAG,CAAC,CAAC;MACjDP,aAAa,CAACf,eAAe,GAAGqB,MAAM,CAACC,MAAM,GAAG,CAAC,CAAC;IACpD,CAAC,MAAM;MACL,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,MAAM,EAAE,EAAEC,CAAC,EAAE;QAC/B,IAAItB,CAAC,IAAImB,KAAK,CAACG,CAAC,CAAC,EAAE;UACjBR,aAAa,CAACC,aAAa,GAAGI,KAAK,CAACG,CAAC,GAAG,CAAC,CAAC;UAC1CR,aAAa,CAACE,cAAc,GAAGG,KAAK,CAACG,CAAC,CAAC;UACvCR,aAAa,CAAChB,cAAc,GAAGsB,MAAM,CAACE,CAAC,GAAG,CAAC,CAAC;UAC5CR,aAAa,CAACf,eAAe,GAAGqB,MAAM,CAACE,CAAC,CAAC;UACzC;QACF;MACF;IACF;EACF;EAEA,OAAOT,mBAAmB,CAACb,CAAC,EAAEc,aAAa,EAAEP,mBAAmB,CAAC;AACnE","ignoreList":[]}
1
+ {"version":3,"names":["Extrapolate","exports","getVal","type","coef","val","leftEdgeOutput","rightEdgeOutput","x","IDENTITY","CLAMP","EXTEND","isExtrapolate","value","validateInterpolationOptions","extrapolationConfig","extrapolateLeft","extrapolateRight","Error","Object","assign","internalInterpolate","narrowedInput","leftEdgeInput","rightEdgeInput","progress","interpolate","input","output","length","i"],"sources":["interpolate.ts"],"sourcesContent":["export enum Extrapolate {\n IDENTITY = \"identity\",\n CLAMP = \"clamp\",\n EXTEND = \"extend\",\n}\n\ninterface InterpolationNarrowedInput {\n leftEdgeInput: number;\n rightEdgeInput: number;\n leftEdgeOutput: number;\n rightEdgeOutput: number;\n}\n\nexport interface ExtrapolationConfig {\n extrapolateLeft?: Extrapolate | string;\n extrapolateRight?: Extrapolate | string;\n}\n\ninterface RequiredExtrapolationConfig {\n extrapolateLeft: Extrapolate;\n extrapolateRight: Extrapolate;\n}\n\nexport type ExtrapolationType =\n ExtrapolationConfig | Extrapolate | string | undefined;\n\nfunction getVal(\n type: Extrapolate,\n coef: number,\n val: number,\n leftEdgeOutput: number,\n rightEdgeOutput: number,\n x: number\n): number {\n \"worklet\";\n switch (type) {\n case Extrapolate.IDENTITY:\n return x;\n case Extrapolate.CLAMP:\n if (coef * val < coef * leftEdgeOutput) {\n return leftEdgeOutput;\n }\n return rightEdgeOutput;\n case Extrapolate.EXTEND:\n default:\n return val;\n }\n}\n\nfunction isExtrapolate(value: string): value is Extrapolate {\n \"worklet\";\n return (\n value === Extrapolate.EXTEND ||\n value === Extrapolate.CLAMP ||\n value === Extrapolate.IDENTITY\n );\n}\n\n// validates extrapolations type\n// if type is correct, converts it to ExtrapolationConfig\nexport function validateInterpolationOptions(\n type: ExtrapolationType\n): RequiredExtrapolationConfig {\n \"worklet\";\n // initialize extrapolationConfig with default extrapolation\n const extrapolationConfig: RequiredExtrapolationConfig = {\n extrapolateLeft: Extrapolate.EXTEND,\n extrapolateRight: Extrapolate.EXTEND,\n };\n\n if (!type) {\n return extrapolationConfig;\n }\n\n if (typeof type === \"string\") {\n if (!isExtrapolate(type)) {\n throw new Error(\n `No supported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], \"clamp\")`\n );\n }\n extrapolationConfig.extrapolateLeft = type;\n extrapolationConfig.extrapolateRight = type;\n return extrapolationConfig;\n }\n\n // otherwise type is extrapolation config object\n if (\n (type.extrapolateLeft && !isExtrapolate(type.extrapolateLeft)) ||\n (type.extrapolateRight && !isExtrapolate(type.extrapolateRight))\n ) {\n throw new Error(\n `No supported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], {\n extrapolateLeft: Extrapolation.CLAMP,\n extrapolateRight: Extrapolation.IDENTITY\n }})`\n );\n }\n\n Object.assign(extrapolationConfig, type);\n return extrapolationConfig;\n}\n\nfunction internalInterpolate(\n x: number,\n narrowedInput: InterpolationNarrowedInput,\n extrapolationConfig: RequiredExtrapolationConfig\n) {\n \"worklet\";\n const { leftEdgeInput, rightEdgeInput, leftEdgeOutput, rightEdgeOutput } =\n narrowedInput;\n if (rightEdgeInput - leftEdgeInput === 0) {\n return leftEdgeOutput;\n }\n const progress = (x - leftEdgeInput) / (rightEdgeInput - leftEdgeInput);\n const val = leftEdgeOutput + progress * (rightEdgeOutput - leftEdgeOutput);\n const coef = rightEdgeOutput >= leftEdgeOutput ? 1 : -1;\n\n if (coef * val < coef * leftEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateLeft,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n } else if (coef * val > coef * rightEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateRight,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n }\n\n return val;\n}\n\n// e.g. function interpolate(x, input, output, type = Extrapolatation.CLAMP)\nexport function interpolate(\n x: number,\n input: readonly number[],\n output: readonly number[],\n type?: ExtrapolationType\n): number {\n \"worklet\";\n if (input.length < 2 || output.length < 2) {\n throw Error(\n \"Interpolation input and output should contain at least two values.\"\n );\n }\n\n const extrapolationConfig = validateInterpolationOptions(type);\n const { length } = input;\n const narrowedInput: InterpolationNarrowedInput = {\n leftEdgeInput: input[0],\n rightEdgeInput: input[1],\n leftEdgeOutput: output[0],\n rightEdgeOutput: output[1],\n };\n if (length > 2) {\n if (x > input[length - 1]) {\n narrowedInput.leftEdgeInput = input[length - 2];\n narrowedInput.rightEdgeInput = input[length - 1];\n narrowedInput.leftEdgeOutput = output[length - 2];\n narrowedInput.rightEdgeOutput = output[length - 1];\n } else {\n for (let i = 1; i < length; ++i) {\n if (x <= input[i]) {\n narrowedInput.leftEdgeInput = input[i - 1];\n narrowedInput.rightEdgeInput = input[i];\n narrowedInput.leftEdgeOutput = output[i - 1];\n narrowedInput.rightEdgeOutput = output[i];\n break;\n }\n }\n }\n }\n\n return internalInterpolate(x, narrowedInput, extrapolationConfig);\n}\n"],"mappings":";;;;;;;;IAAYA,WAAW,GAAAC,OAAA,CAAAD,WAAA,0BAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAA,OAAXA,WAAW;AAAA;AA0BvB,SAASE,MAAMA,CACbC,IAAiB,EACjBC,IAAY,EACZC,GAAW,EACXC,cAAsB,EACtBC,eAAuB,EACvBC,CAAS,EACD;EACR,SAAS;;EACT,QAAQL,IAAI;IACV,KAAKH,WAAW,CAACS,QAAQ;MACvB,OAAOD,CAAC;IACV,KAAKR,WAAW,CAACU,KAAK;MACpB,IAAIN,IAAI,GAAGC,GAAG,GAAGD,IAAI,GAAGE,cAAc,EAAE;QACtC,OAAOA,cAAc;MACvB;MACA,OAAOC,eAAe;IACxB,KAAKP,WAAW,CAACW,MAAM;IACvB;MACE,OAAON,GAAG;EACd;AACF;AAEA,SAASO,aAAaA,CAACC,KAAa,EAAwB;EAC1D,SAAS;;EACT,OACEA,KAAK,KAAKb,WAAW,CAACW,MAAM,IAC5BE,KAAK,KAAKb,WAAW,CAACU,KAAK,IAC3BG,KAAK,KAAKb,WAAW,CAACS,QAAQ;AAElC;;AAEA;AACA;AACO,SAASK,4BAA4BA,CAC1CX,IAAuB,EACM;EAC7B,SAAS;;EACT;EACA,MAAMY,mBAAgD,GAAG;IACvDC,eAAe,EAAEhB,WAAW,CAACW,MAAM;IACnCM,gBAAgB,EAAEjB,WAAW,CAACW;EAChC,CAAC;EAED,IAAI,CAACR,IAAI,EAAE;IACT,OAAOY,mBAAmB;EAC5B;EAEA,IAAI,OAAOZ,IAAI,KAAK,QAAQ,EAAE;IAC5B,IAAI,CAACS,aAAa,CAACT,IAAI,CAAC,EAAE;MACxB,MAAM,IAAIe,KAAK,CACb;AACR,iEACM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,GAAGI,KAAK,CAACG,CAAC,GAAG,CAAC,CAAC;UAC1CR,aAAa,CAACE,cAAc,GAAGG,KAAK,CAACG,CAAC,CAAC;UACvCR,aAAa,CAAChB,cAAc,GAAGsB,MAAM,CAACE,CAAC,GAAG,CAAC,CAAC;UAC5CR,aAAa,CAACf,eAAe,GAAGqB,MAAM,CAACE,CAAC,CAAC;UACzC;QACF;MACF;IACF;EACF;EAEA,OAAOT,mBAAmB,CAACb,CAAC,EAAEc,aAAa,EAAEP,mBAAmB,CAAC;AACnE","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_Platform","require","_Skia","_Data","imgFactory","Skia","Image","MakeImageFromEncoded","bind","useImage","source","onError","useRawData","exports","makeImageFromView","viewRef","callback","Platform","OS","Promise","reject","Error","viewTag","findNodeHandle","current","MakeImageFromViewTag"],"sources":["Image.ts"],"sourcesContent":["import { Platform } from \"../../Platform\";\nimport { Skia } from \"../Skia\";\nimport type { DataSourceParam, SkImage } from \"../types\";\n\nimport { useRawData } from \"./Data\";\n\nconst imgFactory = Skia.Image.MakeImageFromEncoded.bind(Skia.Image);\n\n/**\n * Returns a Skia Image object\n * */\nexport const useImage = (\n source: DataSourceParam,\n onError?: (err: Error) => void\n) => useRawData(source, imgFactory, onError);\n\n/**\n * Creates an image from a given view reference. NOTE: This method has different implementations\n * on web/native. On web, the callback is called with the view ref and the callback is expected to\n * return a promise that resolves to a Skia Image object. On native, the view ref is used to\n * find the view tag and the Skia Image object is created from the view tag. This means that on web\n * you will need to implement the logic to create the image from the view ref yourself.\n * @param viewRef Ref to the view we're creating an image from\n * @returns A promise that resolves to a Skia Image object or rejects\n * with an error id the view tag is invalid.\n */\nexport const makeImageFromView = <\n T extends\n | number\n | React.Component<unknown, unknown>\n | React.ComponentClass<unknown>\n | null,\n>(\n viewRef: React.RefObject<T>,\n callback:\n | null\n | ((viewRef: React.RefObject<T>) => Promise<SkImage | null>) = null\n) => {\n // In web implementation we just delegate the work to the provided callback\n if (Platform.OS === \"web\") {\n if (callback) {\n return callback(viewRef);\n } else {\n Promise.reject(\n new Error(\n \"Callback is required on web in the makeImageFromView function.\"\n )\n );\n }\n }\n const viewTag = Platform.findNodeHandle(viewRef.current);\n if (viewTag !== null && viewTag !== 0) {\n return Skia.Image.MakeImageFromViewTag(viewTag);\n }\n return Promise.reject(new Error(\"Invalid view tag\"));\n};\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAGA,IAAAE,KAAA,GAAAF,OAAA;AAEA,MAAMG,UAAU,GAAGC,UAAI,CAACC,KAAK,CAACC,oBAAoB,CAACC,IAAI,CAACH,UAAI,CAACC,KAAK,CAAC;;AAEnE;AACA;AACA;AACO,MAAMG,QAAQ,GAAGA,CACtBC,MAAuB,EACvBC,OAA8B,KAC3B,IAAAC,gBAAU,EAACF,MAAM,EAAEN,UAAU,EAAEO,OAAO,CAAC;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AATAE,OAAA,CAAAJ,QAAA,GAAAA,QAAA;AAUO,MAAMK,iBAAiB,GAAGA,CAO/BC,OAA2B,EAC3BC,QAE8D,GAAG,IAAI,KAClE;EACH;EACA,IAAIC,kBAAQ,CAACC,EAAE,KAAK,KAAK,EAAE;IACzB,IAAIF,QAAQ,EAAE;MACZ,OAAOA,QAAQ,CAACD,OAAO,CAAC;IAC1B,CAAC,MAAM;MACLI,OAAO,CAACC,MAAM,CACZ,IAAIC,KAAK,CACP,gEACF,CACF,CAAC;IACH;EACF;EACA,MAAMC,OAAO,GAAGL,kBAAQ,CAACM,cAAc,CAACR,OAAO,CAACS,OAAO,CAAC;EACxD,IAAIF,OAAO,KAAK,IAAI,IAAIA,OAAO,KAAK,CAAC,EAAE;IACrC,OAAOjB,UAAI,CAACC,KAAK,CAACmB,oBAAoB,CAACH,OAAO,CAAC;EACjD;EACA,OAAOH,OAAO,CAACC,MAAM,CAAC,IAAIC,KAAK,CAAC,kBAAkB,CAAC,CAAC;AACtD,CAAC;AAACR,OAAA,CAAAC,iBAAA,GAAAA,iBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_Platform","require","_Skia","_Data","imgFactory","Skia","Image","MakeImageFromEncoded","bind","useImage","source","onError","useRawData","exports","makeImageFromView","viewRef","callback","Platform","OS","Promise","reject","Error","viewTag","findNodeHandle","current","MakeImageFromViewTag"],"sources":["Image.ts"],"sourcesContent":["import { Platform } from \"../../Platform\";\nimport { Skia } from \"../Skia\";\nimport type { DataSourceParam, SkImage } from \"../types\";\n\nimport { useRawData } from \"./Data\";\n\nconst imgFactory = Skia.Image.MakeImageFromEncoded.bind(Skia.Image);\n\n/**\n * Returns a Skia Image object\n * */\nexport const useImage = (\n source: DataSourceParam,\n onError?: (err: Error) => void\n) => useRawData(source, imgFactory, onError);\n\n/**\n * Creates an image from a given view reference. NOTE: This method has different implementations\n * on web/native. On web, the callback is called with the view ref and the callback is expected to\n * return a promise that resolves to a Skia Image object. On native, the view ref is used to\n * find the view tag and the Skia Image object is created from the view tag. This means that on web\n * you will need to implement the logic to create the image from the view ref yourself.\n * @param viewRef Ref to the view we're creating an image from\n * @returns A promise that resolves to a Skia Image object or rejects\n * with an error id the view tag is invalid.\n */\nexport const makeImageFromView = <\n T extends\n | number\n | React.Component<unknown, unknown>\n | React.ComponentClass<unknown>\n | null,\n>(\n viewRef: React.RefObject<T>,\n callback:\n null | ((viewRef: React.RefObject<T>) => Promise<SkImage | null>) = null\n) => {\n // In web implementation we just delegate the work to the provided callback\n if (Platform.OS === \"web\") {\n if (callback) {\n return callback(viewRef);\n } else {\n Promise.reject(\n new Error(\n \"Callback is required on web in the makeImageFromView function.\"\n )\n );\n }\n }\n const viewTag = Platform.findNodeHandle(viewRef.current);\n if (viewTag !== null && viewTag !== 0) {\n return Skia.Image.MakeImageFromViewTag(viewTag);\n }\n return Promise.reject(new Error(\"Invalid view tag\"));\n};\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAGA,IAAAE,KAAA,GAAAF,OAAA;AAEA,MAAMG,UAAU,GAAGC,UAAI,CAACC,KAAK,CAACC,oBAAoB,CAACC,IAAI,CAACH,UAAI,CAACC,KAAK,CAAC;;AAEnE;AACA;AACA;AACO,MAAMG,QAAQ,GAAGA,CACtBC,MAAuB,EACvBC,OAA8B,KAC3B,IAAAC,gBAAU,EAACF,MAAM,EAAEN,UAAU,EAAEO,OAAO,CAAC;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AATAE,OAAA,CAAAJ,QAAA,GAAAA,QAAA;AAUO,MAAMK,iBAAiB,GAAGA,CAO/BC,OAA2B,EAC3BC,QACmE,GAAG,IAAI,KACvE;EACH;EACA,IAAIC,kBAAQ,CAACC,EAAE,KAAK,KAAK,EAAE;IACzB,IAAIF,QAAQ,EAAE;MACZ,OAAOA,QAAQ,CAACD,OAAO,CAAC;IAC1B,CAAC,MAAM;MACLI,OAAO,CAACC,MAAM,CACZ,IAAIC,KAAK,CACP,gEACF,CACF,CAAC;IACH;EACF;EACA,MAAMC,OAAO,GAAGL,kBAAQ,CAACM,cAAc,CAACR,OAAO,CAACS,OAAO,CAAC;EACxD,IAAIF,OAAO,KAAK,IAAI,IAAIA,OAAO,KAAK,CAAC,EAAE;IACrC,OAAOjB,UAAI,CAACC,KAAK,CAACmB,oBAAoB,CAACH,OAAO,CAAC;EACjD;EACA,OAAOH,OAAO,CAACC,MAAM,CAAC,IAAIC,KAAK,CAAC,kBAAkB,CAAC,CAAC;AACtD,CAAC;AAACR,OAAA,CAAAC,iBAAA,GAAAA,iBAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["CanvasKitWebGLBuffer","exports","isNativeBufferAddr","buffer","BigInt","isNativeBufferWeb","HTMLVideoElement","HTMLCanvasElement","ImageBitmap","OffscreenCanvas","VideoFrame","HTMLImageElement","SVGImageElement","isNativeBufferNode","ArrayBuffer"],"sources":["NativeBufferFactory.ts"],"sourcesContent":["import type { SkImage } from \"../Image\";\n\nexport abstract class CanvasKitWebGLBuffer {}\n\nexport type NativeBuffer<\n T extends\n | bigint\n | ArrayBuffer\n | CanvasImageSource\n | CanvasKitWebGLBuffer\n | unknown = unknown,\n> = T;\n\nexport type NativeBufferAddr = NativeBuffer<bigint>;\nexport type NativeBufferWeb = NativeBuffer<CanvasImageSource>;\nexport type NativeBufferNode = NativeBuffer<ArrayBuffer>;\n\nexport const isNativeBufferAddr = (\n buffer: NativeBuffer\n): buffer is NativeBufferAddr => buffer instanceof BigInt;\nexport const isNativeBufferWeb = (\n buffer: NativeBuffer\n): buffer is NativeBufferWeb =>\n buffer instanceof HTMLVideoElement ||\n buffer instanceof HTMLCanvasElement ||\n buffer instanceof ImageBitmap ||\n buffer instanceof OffscreenCanvas ||\n (typeof VideoFrame !== \"undefined\" && buffer instanceof VideoFrame) ||\n buffer instanceof HTMLImageElement ||\n buffer instanceof SVGImageElement ||\n buffer instanceof CanvasKitWebGLBuffer;\n\nexport const isNativeBufferNode = (\n buffer: NativeBuffer\n): buffer is NativeBufferNode => buffer instanceof ArrayBuffer;\n\nexport interface NativeBufferFactory {\n /**\n * Copy pixels to a native buffer.\n */\n MakeFromImage: (image: SkImage) => NativeBuffer;\n /**\n * Create a native buffer of the given size filled with a procedural test\n * pattern (RGB gradient + diagonal stripes), entirely on the CPU. Useful for\n * examples and tests that need a buffer to feed into\n * `GPUDevice.importExternalTexture` without a camera/video source. Release it\n * with `Release`.\n */\n MakeTestBuffer: (width: number, height: number) => NativeBuffer;\n /**\n * Release a native buffer that was created with `MakeFromImage` or\n * `MakeTestBuffer`.\n */\n Release: (nativeBuffer: NativeBuffer) => void;\n}\n"],"mappings":";;;;;;AAEO,MAAeA,oBAAoB,CAAC;AAAEC,OAAA,CAAAD,oBAAA,GAAAA,oBAAA;AAetC,MAAME,kBAAkB,GAC7BC,MAAoB,IACWA,MAAM,YAAYC,MAAM;AAACH,OAAA,CAAAC,kBAAA,GAAAA,kBAAA;AACnD,MAAMG,iBAAiB,GAC5BF,MAAoB,IAEpBA,MAAM,YAAYG,gBAAgB,IAClCH,MAAM,YAAYI,iBAAiB,IACnCJ,MAAM,YAAYK,WAAW,IAC7BL,MAAM,YAAYM,eAAe,IAChC,OAAOC,UAAU,KAAK,WAAW,IAAIP,MAAM,YAAYO,UAAW,IACnEP,MAAM,YAAYQ,gBAAgB,IAClCR,MAAM,YAAYS,eAAe,IACjCT,MAAM,YAAYH,oBAAoB;AAACC,OAAA,CAAAI,iBAAA,GAAAA,iBAAA;AAElC,MAAMQ,kBAAkB,GAC7BV,MAAoB,IACWA,MAAM,YAAYW,WAAW;AAACb,OAAA,CAAAY,kBAAA,GAAAA,kBAAA","ignoreList":[]}
1
+ {"version":3,"names":["CanvasKitWebGLBuffer","exports","isNativeBufferAddr","buffer","BigInt","isNativeBufferWeb","HTMLVideoElement","HTMLCanvasElement","ImageBitmap","OffscreenCanvas","VideoFrame","HTMLImageElement","SVGImageElement","isNativeBufferNode","ArrayBuffer"],"sources":["NativeBufferFactory.ts"],"sourcesContent":["import type { SkImage } from \"../Image\";\n\nexport abstract class CanvasKitWebGLBuffer {}\n\nexport type NativeBuffer<\n T extends\n bigint | ArrayBuffer | CanvasImageSource | CanvasKitWebGLBuffer | unknown =\n unknown,\n> = T;\n\nexport type NativeBufferAddr = NativeBuffer<bigint>;\nexport type NativeBufferWeb = NativeBuffer<CanvasImageSource>;\nexport type NativeBufferNode = NativeBuffer<ArrayBuffer>;\n\nexport const isNativeBufferAddr = (\n buffer: NativeBuffer\n): buffer is NativeBufferAddr => buffer instanceof BigInt;\nexport const isNativeBufferWeb = (\n buffer: NativeBuffer\n): buffer is NativeBufferWeb =>\n buffer instanceof HTMLVideoElement ||\n buffer instanceof HTMLCanvasElement ||\n buffer instanceof ImageBitmap ||\n buffer instanceof OffscreenCanvas ||\n (typeof VideoFrame !== \"undefined\" && buffer instanceof VideoFrame) ||\n buffer instanceof HTMLImageElement ||\n buffer instanceof SVGImageElement ||\n buffer instanceof CanvasKitWebGLBuffer;\n\nexport const isNativeBufferNode = (\n buffer: NativeBuffer\n): buffer is NativeBufferNode => buffer instanceof ArrayBuffer;\n\nexport interface NativeBufferFactory {\n /**\n * Copy pixels to a native buffer.\n */\n MakeFromImage: (image: SkImage) => NativeBuffer;\n /**\n * Create a native buffer of the given size filled with a procedural test\n * pattern (RGB gradient + diagonal stripes), entirely on the CPU. Useful for\n * examples and tests that need a buffer to feed into\n * `GPUDevice.importExternalTexture` without a camera/video source. Release it\n * with `Release`.\n */\n MakeTestBuffer: (width: number, height: number) => NativeBuffer;\n /**\n * Release a native buffer that was created with `MakeFromImage` or\n * `MakeTestBuffer`.\n */\n Release: (nativeBuffer: NativeBuffer) => void;\n}\n"],"mappings":";;;;;;AAEO,MAAeA,oBAAoB,CAAC;AAAEC,OAAA,CAAAD,oBAAA,GAAAA,oBAAA;AAYtC,MAAME,kBAAkB,GAC7BC,MAAoB,IACWA,MAAM,YAAYC,MAAM;AAACH,OAAA,CAAAC,kBAAA,GAAAA,kBAAA;AACnD,MAAMG,iBAAiB,GAC5BF,MAAoB,IAEpBA,MAAM,YAAYG,gBAAgB,IAClCH,MAAM,YAAYI,iBAAiB,IACnCJ,MAAM,YAAYK,WAAW,IAC7BL,MAAM,YAAYM,eAAe,IAChC,OAAOC,UAAU,KAAK,WAAW,IAAIP,MAAM,YAAYO,UAAW,IACnEP,MAAM,YAAYQ,gBAAgB,IAClCR,MAAM,YAAYS,eAAe,IACjCT,MAAM,YAAYH,oBAAoB;AAACC,OAAA,CAAAI,iBAAA,GAAAA,iBAAA;AAElC,MAAMQ,kBAAkB,GAC7BV,MAAoB,IACWA,MAAM,YAAYW,WAAW;AAACb,OAAA,CAAAY,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -1,8 +1,6 @@
1
1
  import type { SkRect } from "../Rect";
2
2
  import type { SkPoint } from "../Point";
3
- import type { InputRRect } from "../RRect";
4
3
  import type { StrokeJoin, StrokeCap } from "../Paint";
5
- import type { InputMatrix, SkMatrix } from "../Matrix";
6
4
  import type { SkJSIInstance } from "../JsiInstance";
7
5
  /**
8
6
  * Options used for Path.stroke(). If an option is omitted, a sensible default will be used.
@@ -43,166 +41,10 @@ export declare enum PathVerb {
43
41
  export type PathCommand = number[];
44
42
  export declare const isPath: (obj: SkJSIInstance<string> | null) => obj is SkPath;
45
43
  export interface SkPath extends SkJSIInstance<"Path"> {
46
- /**
47
- * Appends arc to Path, as the start of new contour. Arc added is part of ellipse
48
- * bounded by oval, from startAngle through sweepAngle. Both startAngle and
49
- * sweepAngle are measured in degrees, where zero degrees is aligned with the
50
- * positive x-axis, and positive sweeps extends arc clockwise.
51
- * Returns the modified path for easier chaining.
52
- * @param oval
53
- * @param startAngle
54
- * @param sweepAngle
55
- */
56
- addArc(oval: SkRect, startAngleInDegrees: number, sweepAngleInDegrees: number): SkPath;
57
- /**
58
- * Adds oval to Path, appending kMove_Verb, four kConic_Verb, and kClose_Verb.
59
- * Oval is upright ellipse bounded by Rect oval with radii equal to half oval width
60
- * and half oval height. Oval begins at start and continues clockwise by default.
61
- * Returns the modified path for easier chaining.
62
- * @param oval
63
- * @param isCCW - if the path should be drawn counter-clockwise or not
64
- * @param startIndex - index of initial point of ellipse
65
- */
66
- addOval(oval: SkRect, isCCW?: boolean, startIndex?: number): SkPath;
67
44
  /**
68
45
  * Returns the number of points in this path. Initially zero.
69
46
  */
70
47
  countPoints(): number;
71
- /**
72
- * Adds contour created from array of n points, adding (count - 1) line segments.
73
- * Contour added starts at pts[0], then adds a line for every additional point
74
- * in pts array. If close is true, appends kClose_Verb to Path, connecting
75
- * pts[count - 1] and pts[0].
76
- * Returns the modified path for easier chaining.
77
- * @param points
78
- * @param close - if true, will add a line connecting last point to the first point.
79
- */
80
- addPoly(points: SkPoint[], close: boolean): SkPath;
81
- /** Adds beginning of contour at SkPoint (x, y).
82
-
83
- @param x x-axis value of contour start
84
- @param y y-axis value of contour start
85
- @return reference to SkPath
86
-
87
- example: https://fiddle.skia.org/c/@Path_moveTo
88
- */
89
- moveTo(x: number, y: number): SkPath;
90
- /** Adds line from last point to (x, y). If SkPath is empty, or last SkPath::Verb is
91
- kClose_Verb, last point is set to (0, 0) before adding line.
92
-
93
- lineTo() appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed.
94
- lineTo() then appends kLine_Verb to verb array and (x, y) to SkPoint array.
95
-
96
- @param x end of added line on x-axis
97
- @param y end of added line on y-axis
98
- @return reference to SkPath
99
-
100
- example: https://fiddle.skia.org/c/@Path_lineTo
101
- */
102
- lineTo(x: number, y: number): SkPath;
103
- /**
104
- * Returns a new path that covers the same area as the original path, but with the
105
- * Winding FillType. This may re-draw some contours in the path as counter-clockwise
106
- * instead of clockwise to achieve that effect. If such a transformation cannot
107
- * be done, null is returned.
108
- */
109
- makeAsWinding(): SkPath | null;
110
- /**
111
- * Translates all the points in the path by dx, dy.
112
- * @param dx
113
- * @param dy
114
- */
115
- offset(dx: number, dy: number): SkPath;
116
- /**
117
- * Relative version of arcToRotated.
118
- * @param rx
119
- * @param ry
120
- * @param xAxisRotate
121
- * @param useSmallArc
122
- * @param isCCW
123
- * @param dx
124
- * @param dy
125
- */
126
- rArcTo(rx: number, ry: number, xAxisRotateInDegrees: number, useSmallArc: boolean, isCCW: boolean, dx: number, dy: number): SkPath;
127
- /**
128
- * Relative version of conicTo.
129
- * @param dx1
130
- * @param dy1
131
- * @param dx2
132
- * @param dy2
133
- * @param w
134
- */
135
- rConicTo(dx1: number, dy1: number, dx2: number, dy2: number, w: number): SkPath;
136
- /**
137
- * Relative version of cubicTo.
138
- * @param cpx1
139
- * @param cpy1
140
- * @param cpx2
141
- * @param cpy2
142
- * @param x
143
- * @param y
144
- */
145
- rCubicTo(cpx1: number, cpy1: number, cpx2: number, cpy2: number, x: number, y: number): SkPath;
146
- /**
147
- * Relative version of moveTo.
148
- * @param x
149
- * @param y
150
- */
151
- rMoveTo(x: number, y: number): SkPath;
152
- /**
153
- * Relative version of lineTo.
154
- * @param x
155
- * @param y
156
- */
157
- rLineTo(x: number, y: number): SkPath;
158
- /**
159
- * Relative version of quadTo.
160
- * @param x1
161
- * @param y1
162
- * @param x2
163
- * @param y2
164
- */
165
- rQuadTo(x1: number, y1: number, x2: number, y2: number): SkPath;
166
- /**
167
- * Sets FillType, the rule used to fill Path.
168
- * @param fill
169
- */
170
- setFillType(fill: FillType): SkPath;
171
- /**
172
- * Specifies whether Path is volatile; whether it will be altered or discarded
173
- * by the caller after it is drawn. Path by default have volatile set false.
174
- *
175
- * Mark animating or temporary paths as volatile to improve performance.
176
- * Mark unchanging Path non-volatile to improve repeated rendering.
177
- * @param volatile
178
- */
179
- setIsVolatile(volatile: boolean): SkPath;
180
- /**
181
- * Turns this path into the filled equivalent of the stroked path. Returns false if the operation
182
- * fails (e.g. the path is a hairline).
183
- * @param opts - describe how stroked path should look.
184
- * If such a transformation cannot be done, null is returned.
185
- */
186
- stroke(opts?: StrokeOpts): null | SkPath;
187
- /**
188
- * Appends CLOSE_VERB to Path. A closed contour connects the first and last point
189
- * with a line, forming a continuous loop.
190
- */
191
- close(): SkPath;
192
- /**
193
- * Sets Path to its initial state.
194
- * Removes verb array, point array, and weights, and sets FillType to Winding.
195
- * Internal storage associated with Path is released
196
- */
197
- reset(): SkPath;
198
- /**
199
- * Sets Path to its initial state.
200
- * Removes verb array, point array, and weights, and sets FillType to Winding.
201
- * Internal storage associated with Path is *not* released.
202
- * Use rewind() instead of reset() if Path storage will be reused and performance
203
- * is critical.
204
- */
205
- rewind(): SkPath;
206
48
  /**
207
49
  * Returns minimum and maximum axes values of the lines and curves in Path.
208
50
  * Returns (0, 0, 0, 0) if Path contains no points.
@@ -215,58 +57,6 @@ export interface SkPath extends SkJSIInstance<"Path"> {
215
57
  * and unlike getBounds(), does not cache the result.
216
58
  */
217
59
  computeTightBounds(): SkRect;
218
- /**
219
- * Appends arc to Path. Arc added is part of ellipse
220
- * bounded by oval, from startAngle through sweepAngle. Both startAngle and
221
- * sweepAngle are measured in degrees, where zero degrees is aligned with the
222
- * positive x-axis, and positive sweeps extends arc clockwise.
223
- * Returns the modified path for easier chaining.
224
- * @param oval
225
- * @param startAngleInDegrees
226
- * @param sweepAngleInDegrees
227
- * @param forceMoveTo
228
- */
229
- arcToOval(oval: SkRect, startAngleInDegrees: number, sweepAngleInDegrees: number, forceMoveTo: boolean): SkPath;
230
- /**
231
- * Appends arc to Path. Arc is implemented by one or more conics weighted to
232
- * describe part of oval with radii (rx, ry) rotated by xAxisRotate degrees. Arc
233
- * curves from last Path Point to (x, y), choosing one of four possible routes:
234
- * clockwise or counterclockwise, and smaller or larger. See SkPath.h for more details.
235
- * Returns the modified path for easier chaining.
236
- * @param rx
237
- * @param ry
238
- * @param xAxisRotate
239
- * @param useSmallArc
240
- * @param isCCW
241
- * @param x
242
- * @param y
243
- */
244
- arcToRotated(rx: number, ry: number, xAxisRotateInDegrees: number, useSmallArc: boolean, isCCW: boolean, x: number, y: number): SkPath;
245
- /**
246
- * Appends arc to Path, after appending line if needed. Arc is implemented by conic
247
- * weighted to describe part of circle. Arc is contained by tangent from
248
- * last Path point to (x1, y1), and tangent from (x1, y1) to (x2, y2). Arc
249
- * is part of circle sized to radius, positioned so it touches both tangent lines.
250
- * Returns the modified path for easier chaining.
251
- * @param x1
252
- * @param y1
253
- * @param x2
254
- * @param y2
255
- * @param radius
256
- */
257
- arcToTangent(x1: number, y1: number, x2: number, y2: number, radius: number): SkPath;
258
- /**
259
- * Adds conic from last point towards (x1, y1), to (x2, y2), weighted by w.
260
- * If Path is empty, or path is closed, the last point is set to (0, 0)
261
- * before adding conic.
262
- * Returns the modified path for easier chaining.
263
- * @param x1
264
- * @param y1
265
- * @param x2
266
- * @param y2
267
- * @param w
268
- */
269
- conicTo(x1: number, y1: number, x2: number, y2: number, w: number): SkPath;
270
60
  /**
271
61
  * Returns true if the point (x, y) is contained by Path, taking into
272
62
  * account FillType.
@@ -278,26 +68,6 @@ export interface SkPath extends SkJSIInstance<"Path"> {
278
68
  * Returns a copy of this Path.
279
69
  */
280
70
  copy(): SkPath;
281
- /**
282
- * Adds cubic from last point towards (x1, y1), then towards (x2, y2), ending at
283
- * (x3, y3). If Path is empty, or path is closed, the last point is set to
284
- * (0, 0) before adding cubic.
285
- * @param cpx1
286
- * @param cpy1
287
- * @param cpx2
288
- * @param cpy2
289
- * @param x
290
- * @param y
291
- */
292
- cubicTo(cpx1: number, cpy1: number, cpx2: number, cpy2: number, x: number, y: number): SkPath;
293
- /**
294
- * Changes this path to be the dashed version of itself. This is the same effect as creating
295
- * a DashPathEffect and calling filterPath on this path.
296
- * @param on
297
- * @param off
298
- * @param phase
299
- */
300
- dash(on: number, off: number, phase: number): boolean;
301
71
  /**
302
72
  * Returns true if other path is equal to this path.
303
73
  * @param other
@@ -313,54 +83,6 @@ export interface SkPath extends SkJSIInstance<"Path"> {
313
83
  * Return the FillType for this path.
314
84
  */
315
85
  getFillType(): FillType;
316
- /**
317
- Adds quad from last point towards (x1, y1), to (x2, y2).
318
-
319
- If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0) before adding quad.
320
-
321
- Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed; then appends kQuad_Verb to verb array;
322
- and (x1, y1), (x2, y2) to SkPoint array.
323
-
324
- Parameters
325
- x1 control SkPoint of quad on x-axis
326
- y1 control SkPoint of quad on y-axis
327
- x2 end SkPoint of quad on x-axis
328
- y2 end SkPoint of quad on y-axis
329
- Returns
330
- reference to SkPath
331
- example: https://fiddle.skia.org/c/@Path_quadTo
332
- */
333
- quadTo(x1: number, y1: number, x2: number, y2: number): SkPath;
334
- /**
335
- * Adds Rect to Path, appending kMove_Verb, three kLine_Verb, and kClose_Verb,
336
- * starting with top-left corner of Rect; followed by top-right, bottom-right,
337
- * and bottom-left if isCCW is false; or followed by bottom-left,
338
- * bottom-right, and top-right if isCCW is true.
339
- * Returns the modified path for easier chaining.
340
- * @param rect
341
- * @param isCCW
342
- */
343
- addRect(rect: SkRect, isCCW?: boolean): SkPath;
344
- /**
345
- * Adds rrect to Path, creating a new closed contour.
346
- * Returns the modified path for easier chaining.
347
- * @param rrect
348
- * @param isCCW
349
- */
350
- addRRect(rrect: InputRRect, isCCW?: boolean): SkPath;
351
- /** Appends src to SkPath, transformed by matrix. Transformed curves may have
352
- different verbs, SkPoint, and conic weights.
353
-
354
- If mode is kAppend_AddPathMode, src verb array, SkPoint array, and conic
355
- weights are added unaltered. If mode is kExtend_AddPathMode, add line
356
- before appending verbs, SkPoint, and conic weights.
357
-
358
- @param src SkPath verbs, SkPoint, and conic weights to add
359
- @param matrix transform applied to src
360
- @param extend extends path with line if true
361
- @return reference to SkPath
362
- */
363
- addPath(src: SkPath, matrix?: SkMatrix, extend?: boolean): SkPath;
364
86
  /**
365
87
  * Returns the Point at index in Point array. Valid range for index is
366
88
  * 0 to countPoints() - 1.
@@ -378,69 +100,14 @@ export interface SkPath extends SkJSIInstance<"Path"> {
378
100
  * may not speed repeated drawing.
379
101
  */
380
102
  isVolatile(): boolean;
381
- /** Adds circle centered at (x, y) of size radius to SkPath, appending kMove_Verb,
382
- four kConic_Verb, and kClose_Verb. Circle begins at: (x + radius, y), continuing
383
- clockwise if dir is kCW_Direction, and counterclockwise if dir is kCCW_Direction.
384
-
385
- Has no effect if radius is zero or negative.
386
-
387
- @param x center of circle
388
- @param y center of circle
389
- @param radius distance from center to edge
390
- @return reference to SkPath
391
- */
392
- addCircle(x: number, y: number, r: number): SkPath;
393
103
  getLastPt(): {
394
104
  x: number;
395
105
  y: number;
396
106
  };
397
- /** Set this path to the result of applying the Op to this path and the
398
- specified path: this = (this op operand).
399
- The resulting path will be constructed from non-overlapping contours.
400
- The curve order is reduced where possible so that cubics may be turned
401
- into quadratics, and quadratics maybe turned into lines.
402
-
403
- Returns true if operation was able to produce a result;
404
- otherwise, result is unmodified.
405
-
406
- @param path The second path (for difference, the subtrahend)
407
- @param op The operator to apply.
408
- @param result The product of the operands. The result may be one of the
409
- inputs.
410
- @return True if the operation succeeded.
411
- */
412
- op(path: SkPath, op: PathOp): boolean;
413
- /** Set this path to a set of non-overlapping contours that describe the
414
- same area as the original path.
415
- The curve order is reduced where possible so that cubics may
416
- be turned into quadratics, and quadratics maybe turned into lines.
417
-
418
- Returns true if operation was able to produce a result;
419
- otherwise, result is unmodified.
420
-
421
- @param result The simplified path. The result may be the input.
422
- @return True if simplification succeeded.
423
- */
424
- simplify(): boolean;
425
107
  /**
426
108
  * Returns this path as an SVG string.
427
109
  */
428
110
  toSVGString(): string;
429
- /**
430
- * Take start and stop "t" values (values between 0...1), and modify this path such that
431
- * it is a subset of the original path.
432
- * The trim values apply to the entire path, so if it contains several contours, all of them
433
- * are including in the calculation.
434
- * Null is returned if either input value is NaN.
435
- * @param startT - a value in the range [0.0, 1.0]. 0.0 is the beginning of the path.
436
- * @param stopT - a value in the range [0.0, 1.0]. 1.0 is the end of the path.
437
- * @param isComplement
438
- */
439
- trim(startT: number, stopT: number, isComplement: boolean): null | SkPath;
440
- /**
441
- * Transforms the path by the specified matrix.
442
- */
443
- transform(m3: InputMatrix): SkPath;
444
111
  /**
445
112
  * Interpolates between Path with point array of equal size.
446
113
  * Copy verb array and weights to result, and set result path to a weighted
@@ -457,11 +124,10 @@ export interface SkPath extends SkJSIInstance<"Path"> {
457
124
  * @param ending path to interpolate with
458
125
  * @param weight contribution of this path, and
459
126
  * one minus contribution of ending path
460
- * @param output path to be replaced with the interpolated averages
461
- * @return Path replaced by interpolated averages or null if
127
+ * @return New path of interpolated averages or null if
462
128
  * not interpolatable
463
129
  * */
464
- interpolate(end: SkPath, weight: number, output?: SkPath): SkPath | null;
130
+ interpolate(end: SkPath, weight: number): SkPath | null;
465
131
  /** Returns true if Path contain equal verbs and equal weights.
466
132
  * @param compare path to compare
467
133
  * @return true if Path can be interpolated equivalent