@shopify/react-native-skia 2.13.0 → 2.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/android/CMakeLists.txt +2 -0
  2. package/android/cpp/jni/include/JniSkiaPictureView.h +16 -15
  3. package/android/cpp/rnskia-android/OpenGLContext.h +1 -1
  4. package/android/cpp/rnskia-android/gl/Surface.h +1 -1
  5. package/apple/RNSkApplePlatformContext.h +3 -4
  6. package/apple/RNSkiaModule.h +11 -3
  7. package/apple/RNSkiaModule.mm +46 -19
  8. package/apple/SkiaPictureView.mm +2 -2
  9. package/apple/SkiaUIView.h +0 -1
  10. package/apple/SkiaUIView.mm +1 -1
  11. package/apple/ViewScreenshotService.h +2 -2
  12. package/apple/ViewScreenshotService.mm +5 -4
  13. package/cpp/api/JsiSkImage.h +1 -1
  14. package/cpp/api/JsiSkImageFilter.h +3 -1
  15. package/cpp/api/JsiSkParagraph.h +2 -1
  16. package/cpp/api/JsiSkParagraphBuilder.h +1 -1
  17. package/cpp/api/JsiSkParagraphBuilderFactory.h +1 -1
  18. package/cpp/api/JsiSkPath.h +11 -435
  19. package/cpp/api/JsiSkPathBuilder.h +11 -4
  20. package/cpp/api/JsiSkPictureRecorder.h +2 -1
  21. package/cpp/api/JsiSkShader.h +3 -1
  22. package/cpp/api/JsiSkSkottie.h +29 -28
  23. package/cpp/api/JsiSkStrutStyle.h +1 -1
  24. package/cpp/api/JsiSkSurfaceFactory.h +41 -0
  25. package/cpp/api/recorder/Command.h +1 -1
  26. package/cpp/api/recorder/Convertor.h +153 -132
  27. package/cpp/api/recorder/DataTypes.h +12 -12
  28. package/cpp/api/recorder/DrawingCtx.h +1 -1
  29. package/cpp/api/recorder/ImageFit.h +8 -5
  30. package/cpp/api/recorder/JsiRecorder.h +14 -31
  31. package/cpp/api/recorder/Paint.h +3 -3
  32. package/cpp/api/recorder/RNRecorder.h +56 -0
  33. package/cpp/api/third_party/base64.cpp +1 -1
  34. package/cpp/jsi/JSICache.cpp +23 -0
  35. package/cpp/jsi/JSICache.h +28 -1
  36. package/cpp/jsi/NativeObject.h +36 -7
  37. package/cpp/jsi/ViewProperty.cpp +23 -0
  38. package/cpp/jsi/ViewProperty.h +31 -10
  39. package/cpp/rnskia/RNDawnContext.h +34 -1
  40. package/cpp/rnskia/RNSkJsiViewApi.h +69 -2
  41. package/cpp/rnskia/RNSkPictureView.cpp +58 -0
  42. package/cpp/rnskia/RNSkPictureView.h +110 -24
  43. package/lib/commonjs/Platform/IPlatform.js.map +1 -1
  44. package/lib/commonjs/animation/functions/interpolate.js.map +1 -1
  45. package/lib/commonjs/animation/functions/interpolatePaths.js +18 -0
  46. package/lib/commonjs/animation/functions/interpolatePaths.js.map +1 -1
  47. package/lib/commonjs/skia/core/Image.js.map +1 -1
  48. package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -1
  49. package/lib/commonjs/skia/types/Path/Path.d.ts +2 -336
  50. package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
  51. package/lib/commonjs/skia/types/Recorder.d.ts +10 -0
  52. package/lib/commonjs/skia/types/Recorder.js.map +1 -1
  53. package/lib/commonjs/skia/types/Shader/Shader.js.map +1 -1
  54. package/lib/commonjs/skia/types/Surface/SurfaceFactory.d.ts +16 -0
  55. package/lib/commonjs/skia/types/Surface/SurfaceFactory.js.map +1 -1
  56. package/lib/commonjs/skia/web/JsiSkPath.d.ts +4 -38
  57. package/lib/commonjs/skia/web/JsiSkPath.js +3 -275
  58. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  59. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
  60. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js +3 -0
  61. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js.map +1 -1
  62. package/lib/commonjs/sksg/Container.native.d.ts +15 -1
  63. package/lib/commonjs/sksg/Container.native.js +34 -33
  64. package/lib/commonjs/sksg/Container.native.js.map +1 -1
  65. package/lib/commonjs/specs/NativeSkiaModule.web.js +4 -0
  66. package/lib/commonjs/specs/NativeSkiaModule.web.js.map +1 -1
  67. package/lib/commonjs/views/types.d.ts +9 -0
  68. package/lib/commonjs/views/types.js.map +1 -1
  69. package/lib/module/Platform/IPlatform.js.map +1 -1
  70. package/lib/module/animation/functions/interpolate.js.map +1 -1
  71. package/lib/module/animation/functions/interpolatePaths.js +18 -0
  72. package/lib/module/animation/functions/interpolatePaths.js.map +1 -1
  73. package/lib/module/skia/core/Image.js.map +1 -1
  74. package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -1
  75. package/lib/module/skia/types/Path/Path.d.ts +2 -336
  76. package/lib/module/skia/types/Path/Path.js.map +1 -1
  77. package/lib/module/skia/types/Recorder.d.ts +10 -0
  78. package/lib/module/skia/types/Recorder.js.map +1 -1
  79. package/lib/module/skia/types/Shader/Shader.js.map +1 -1
  80. package/lib/module/skia/types/Surface/SurfaceFactory.d.ts +16 -0
  81. package/lib/module/skia/types/Surface/SurfaceFactory.js.map +1 -1
  82. package/lib/module/skia/web/JsiSkPath.d.ts +4 -38
  83. package/lib/module/skia/web/JsiSkPath.js +4 -276
  84. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  85. package/lib/module/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
  86. package/lib/module/skia/web/JsiSkSurfaceFactory.js +4 -1
  87. package/lib/module/skia/web/JsiSkSurfaceFactory.js.map +1 -1
  88. package/lib/module/sksg/Container.native.d.ts +15 -1
  89. package/lib/module/sksg/Container.native.js +34 -33
  90. package/lib/module/sksg/Container.native.js.map +1 -1
  91. package/lib/module/specs/NativeSkiaModule.web.js +4 -0
  92. package/lib/module/specs/NativeSkiaModule.web.js.map +1 -1
  93. package/lib/module/views/types.d.ts +9 -0
  94. package/lib/module/views/types.js.map +1 -1
  95. package/lib/typescript/lib/commonjs/skia/web/JsiSkPath.d.ts +1 -35
  96. package/lib/typescript/lib/commonjs/skia/web/JsiSkSurfaceFactory.d.ts +1 -0
  97. package/lib/typescript/lib/commonjs/sksg/Container.native.d.ts +15 -1
  98. package/lib/typescript/lib/module/skia/web/JsiSkPath.d.ts +3 -37
  99. package/lib/typescript/lib/module/skia/web/JsiSkSurfaceFactory.d.ts +1 -0
  100. package/lib/typescript/lib/module/sksg/Container.native.d.ts +15 -1
  101. package/lib/typescript/src/skia/types/Path/Path.d.ts +2 -336
  102. package/lib/typescript/src/skia/types/Recorder.d.ts +10 -0
  103. package/lib/typescript/src/skia/types/Surface/SurfaceFactory.d.ts +16 -0
  104. package/lib/typescript/src/skia/web/JsiSkPath.d.ts +4 -38
  105. package/lib/typescript/src/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
  106. package/lib/typescript/src/sksg/Container.native.d.ts +15 -1
  107. package/lib/typescript/src/views/types.d.ts +9 -0
  108. package/package.json +2 -2
  109. package/src/Platform/IPlatform.ts +1 -4
  110. package/src/animation/functions/interpolate.ts +1 -4
  111. package/src/animation/functions/interpolatePaths.ts +24 -0
  112. package/src/skia/core/Image.ts +1 -2
  113. package/src/skia/types/NativeBuffer/NativeBufferFactory.ts +2 -5
  114. package/src/skia/types/Path/Path.ts +2 -420
  115. package/src/skia/types/Recorder.ts +10 -0
  116. package/src/skia/types/Shader/Shader.ts +1 -5
  117. package/src/skia/types/Surface/SurfaceFactory.ts +17 -0
  118. package/src/skia/web/JsiSkPath.ts +4 -495
  119. package/src/skia/web/JsiSkSurfaceFactory.ts +6 -2
  120. package/src/sksg/Container.native.ts +34 -37
  121. package/src/specs/NativeSkiaModule.web.ts +4 -0
  122. package/src/views/types.ts +13 -0
  123. package/apple/SkiaManager.h +0 -23
  124. package/apple/SkiaManager.mm +0 -63
@@ -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
@@ -51,4 +51,14 @@ export interface JsiRecorder extends BaseRecorder {
51
51
  play(picture: SkPicture): void;
52
52
  applyUpdates(variables: SharedValue<unknown>[]): void;
53
53
  reset(): void;
54
+ /**
55
+ * Unique id of the native recording, used to tag the updates sent to the
56
+ * view that owns it.
57
+ */
58
+ getId(): number;
59
+ /**
60
+ * Releases the wrapper's reference to the native recorder. A recording
61
+ * that a view owns stays alive until the view replaces it or is torn down.
62
+ */
63
+ dispose(): void;
54
64
  }
@@ -23,4 +23,20 @@ export interface SurfaceFactory {
23
23
  * @param opts - optional surface options (e.g. colorSpace: "display-p3" | "srgb").
24
24
  */
25
25
  MakeOffscreen: (width: number, height: number, opts?: SurfaceOptions) => SkSurface | null;
26
+ /**
27
+ * Creates a GPU backed surface that draws directly into a WebGPU texture
28
+ * (zero-copy). The texture must be created on Skia's device
29
+ * (importDevice(Skia.getNativeDevice())) with RENDER_ATTACHMENT usage; add
30
+ * TEXTURE_BINDING to sample what Skia drew from WebGPU after each flush().
31
+ * The surface holds its own reference to the texture and keeps it alive
32
+ * for its lifetime, so the caller may release the GPUTexture once the
33
+ * surface exists. Calling destroy() on the GPUTexture still invalidates
34
+ * the surface.
35
+ *
36
+ * Note: This method is only available when the Graphite backend is enabled.
37
+ *
38
+ * @param pointer - The WGPUTexture pointer (texture.nativePointer)
39
+ * @returns An SkSurface rendering into the texture, or throws if the texture is invalid
40
+ */
41
+ MakeFromNativeTexture: (pointer: bigint) => SkSurface;
26
42
  }
@@ -1,11 +1,11 @@
1
1
  import type { CanvasKit, PathBuilder as CKPathBuilder } from "canvaskit-wasm";
2
- import type { FillType, PathCommand, PathOp, SkMatrix, SkPath, SkPoint, SkRect, InputRRect, StrokeOpts, InputMatrix } from "../types";
2
+ import type { FillType, PathCommand, SkPath, SkPoint, SkRect, InputMatrix } from "../types";
3
3
  import { HostObject } from "./Host";
4
4
  import { JsiSkRect } from "./JsiSkRect";
5
5
  export declare const toMatrix3x3: (m: InputMatrix) => number[];
6
6
  /**
7
- * SkPath wraps a CK PathBuilder internally, providing both mutable building
8
- * methods and immutable query methods. Use snapshot() internally to get
7
+ * SkPath wraps a CK PathBuilder internally, providing immutable query
8
+ * methods. Use snapshot() internally to get
9
9
  * an immutable CK Path for read-only operations.
10
10
  */
11
11
  export declare class JsiSkPath extends HostObject<CKPathBuilder, "Path"> implements SkPath {
@@ -14,40 +14,6 @@ export declare class JsiSkPath extends HostObject<CKPathBuilder, "Path"> impleme
14
14
  private asPath;
15
15
  /** Extract an immutable CK Path from a JsiSkPath value (for CK interop). */
16
16
  static pathFromValue(value: SkPath): import("canvaskit-wasm").Path;
17
- addPath(src: SkPath, matrix?: SkMatrix, extend?: boolean): this;
18
- addArc(oval: SkRect, startAngleInDegrees: number, sweepAngleInDegrees: number): this;
19
- addOval(oval: SkRect, isCCW?: boolean, startIndex?: number): this;
20
- addPoly(points: SkPoint[], close: boolean): this;
21
- addRect(rect: SkRect, isCCW?: boolean): this;
22
- addRRect(rrect: InputRRect, isCCW?: boolean): this;
23
- addCircle(x: number, y: number, r: number): this;
24
- moveTo(x: number, y: number): this;
25
- rMoveTo(x: number, y: number): this;
26
- lineTo(x: number, y: number): this;
27
- rLineTo(x: number, y: number): this;
28
- quadTo(x1: number, y1: number, x2: number, y2: number): this;
29
- rQuadTo(x1: number, y1: number, x2: number, y2: number): this;
30
- conicTo(x1: number, y1: number, x2: number, y2: number, w: number): this;
31
- rConicTo(x1: number, y1: number, x2: number, y2: number, w: number): this;
32
- cubicTo(cpx1: number, cpy1: number, cpx2: number, cpy2: number, x: number, y: number): this;
33
- rCubicTo(cpx1: number, cpy1: number, cpx2: number, cpy2: number, x: number, y: number): this;
34
- close(): this;
35
- reset(): this;
36
- rewind(): this;
37
- arcToOval(oval: SkRect, startAngleInDegrees: number, sweepAngleInDegrees: number, forceMoveTo: boolean): this;
38
- arcToRotated(rx: number, ry: number, xAxisRotateInDegrees: number, useSmallArc: boolean, isCCW: boolean, x: number, y: number): this;
39
- rArcTo(rx: number, ry: number, xAxisRotateInDegrees: number, useSmallArc: boolean, isCCW: boolean, dx: number, dy: number): this;
40
- arcToTangent(x1: number, y1: number, x2: number, y2: number, radius: number): this;
41
- setFillType(fill: FillType): this;
42
- setIsVolatile(_volatile: boolean): this;
43
- offset(dx: number, dy: number): this;
44
- transform(m: InputMatrix): this;
45
- makeAsWinding(): this | null;
46
- simplify(): boolean;
47
- op(path: SkPath, op: PathOp): boolean;
48
- dash(on: number, off: number, phase: number): boolean;
49
- stroke(opts?: StrokeOpts): this | null;
50
- trim(start: number, stop: number, isComplement: boolean): this | null;
51
17
  countPoints(): number;
52
18
  computeTightBounds(): SkRect;
53
19
  contains(x: number, y: number): boolean;
@@ -64,6 +30,6 @@ export declare class JsiSkPath extends HostObject<CKPathBuilder, "Path"> impleme
64
30
  };
65
31
  toSVGString(): string;
66
32
  isInterpolatable(path2: SkPath): boolean;
67
- interpolate(end: SkPath, weight: number, output?: SkPath): SkPath | null;
33
+ interpolate(end: SkPath, weight: number): SkPath | null;
68
34
  toCmds(): PathCommand[];
69
35
  }
@@ -1,9 +1,10 @@
1
1
  import type { CanvasKit } from "canvaskit-wasm";
2
- import type { SurfaceFactory } from "../types";
2
+ import type { SkSurface, SurfaceFactory } from "../types";
3
3
  import { Host } from "./Host";
4
4
  import { JsiSkSurface } from "./JsiSkSurface";
5
5
  export declare class JsiSkSurfaceFactory extends Host implements SurfaceFactory {
6
6
  constructor(CanvasKit: CanvasKit);
7
7
  Make(width: number, height: number): JsiSkSurface;
8
8
  MakeOffscreen(width: number, height: number): JsiSkSurface | null;
9
+ MakeFromNativeTexture(_pointer: bigint): SkSurface;
9
10
  }
@@ -2,11 +2,25 @@ import type { Skia } from "../skia/types";
2
2
  import { Container, StaticContainer } from "./StaticContainer";
3
3
  import "../skia/NativeSetup";
4
4
  import "../views/api";
5
+ /**
6
+ * Records the scene graph on the JS thread and hands the native recorder to
7
+ * the view, which owns it and replays it on every draw. The Reanimated mapper
8
+ * only pushes the shared values into that recorder through the view id: no
9
+ * Skia object is captured by a worklet, so nothing on the UI runtime holds
10
+ * native memory. The JS wrapper is disposed right after the handoff, so the
11
+ * view is the sole owner and the resources referenced by the recording
12
+ * (images, pictures) are released when the view replaces it or is torn down,
13
+ * not when a garbage collector gets around to a wrapper.
14
+ *
15
+ * Unmounting does not clear the view: the native view can outlive the React
16
+ * tree (exit animations, screen transitions) and keeps showing its last frame
17
+ * until it is torn down, which is when the recording is released.
18
+ */
5
19
  declare class NativeReanimatedContainer extends Container {
6
20
  private nativeId;
7
21
  private mapperId;
8
- private picture;
9
22
  constructor(Skia: Skia, nativeId: number);
23
+ private stopMapper;
10
24
  unmount(): void;
11
25
  redraw(): void;
12
26
  }
@@ -1,4 +1,5 @@
1
1
  import type { ViewProps } from "react-native";
2
+ import type { SharedValue } from "react-native-reanimated";
2
3
  import type { SkImage, SkPicture, SkRect, SkSize } from "../skia/types";
3
4
  export type NativeSkiaViewProps = ViewProps & {
4
5
  debug?: boolean;
@@ -22,6 +23,14 @@ export interface ISkiaViewApi {
22
23
  web?: boolean;
23
24
  setJsiProperty: <T>(nativeId: number, name: string, value: T) => void;
24
25
  requestRedraw: (nativeId: number) => void;
26
+ /**
27
+ * Reads the shared values into the recording held for the view and
28
+ * schedules a redraw. Native only; called from a worklet on every frame.
29
+ * Until the view registers, the recording is queued for it and kept
30
+ * current all the same. Ignored when the recording `recorderId` is neither
31
+ * held by the view nor queued for it.
32
+ */
33
+ applyUpdates: (nativeId: number, recorderId: number, values: SharedValue<unknown>[]) => void;
25
34
  makeImageSnapshot: (nativeId: number, rect?: SkRect) => SkImage;
26
35
  makeImageSnapshotAsync: (nativeId: number, rect?: SkRect) => Promise<SkImage>;
27
36
  size: (nativeId: number) => SkSize;
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "setup-skia-web": "scripts/setup-canvaskit.js"
9
9
  },
10
10
  "title": "React Native Skia",
11
- "version": "2.13.0",
11
+ "version": "2.14.0",
12
12
  "description": "High-performance React Native Graphics using Skia",
13
13
  "main": "lib/module/index.js",
14
14
  "react-native": "src/index.ts",
@@ -115,7 +115,7 @@
115
115
  "@types/react-reconciler": "0.28.9",
116
116
  "@types/ws": "8.5.3",
117
117
  "eslint": "9.36.0",
118
- "eslint-config-react-native-wcandillon": "4.0.1",
118
+ "eslint-config-react-native-wcandillon": "5.0.0",
119
119
  "eslint-plugin-import": "2.32.0",
120
120
  "eslint-plugin-react-hooks": "^5.2.0",
121
121
  "extract-zip": "^2.0.1",
@@ -8,10 +8,7 @@ export interface IPlatform {
8
8
  PixelRatio: number;
9
9
  findNodeHandle: (
10
10
  componentOrHandle:
11
- | null
12
- | number
13
- | React.Component<any, any>
14
- | React.ComponentClass<any>
11
+ null | number | React.Component<any, any> | React.ComponentClass<any>
15
12
  ) => null | NodeHandle;
16
13
  resolveAsset: (source: DataModule) => string;
17
14
  View: typeof ViewComponent;
@@ -22,10 +22,7 @@ interface RequiredExtrapolationConfig {
22
22
  }
23
23
 
24
24
  export type ExtrapolationType =
25
- | ExtrapolationConfig
26
- | Extrapolate
27
- | string
28
- | undefined;
25
+ ExtrapolationConfig | Extrapolate | string | undefined;
29
26
 
30
27
  function getVal(
31
28
  type: Extrapolate,
@@ -12,6 +12,12 @@ const lerp = (
12
12
  p2: SkPath
13
13
  ) => {
14
14
  "worklet";
15
+ // Zero-width segment (duplicate input stops): t would be NaN or Infinity.
16
+ // Return the segment's end path (p2), i.e. the value jumps to p2 at the stop.
17
+ // reanimated's interpolate has no explicit guard here, so this is our choice.
18
+ if (to === from) {
19
+ return p2;
20
+ }
15
21
  const t = (value - from) / (to - from);
16
22
  // interpolate returns a new path (immutable operation)
17
23
  return p2.interpolate(p1, t)!;
@@ -41,12 +47,25 @@ export const interpolatePaths = (
41
47
  _output?: SkPath
42
48
  ) => {
43
49
  "worklet";
50
+ if (input.length < 2 || input.length !== outputRange.length) {
51
+ throw new Error(
52
+ `interpolatePaths() requires input and outputRange to have the same length and at least 2 entries, received ${input.length} and ${outputRange.length}`
53
+ );
54
+ }
55
+ if (Number.isNaN(value)) {
56
+ throw new Error("interpolatePaths() received NaN as value");
57
+ }
44
58
  const extrapolation = validateInterpolationOptions(options);
45
59
  if (value < input[0]) {
46
60
  switch (extrapolation.extrapolateLeft) {
47
61
  case Extrapolate.CLAMP:
48
62
  return outputRange[0];
49
63
  case Extrapolate.EXTEND:
64
+ if (!Number.isFinite(value)) {
65
+ throw new Error(
66
+ "interpolatePaths() cannot extend with an infinite value, use clamp extrapolation instead"
67
+ );
68
+ }
50
69
  return lerp(value, input[0], input[1], outputRange[0], outputRange[1]);
51
70
  case Extrapolate.IDENTITY:
52
71
  throw new Error(
@@ -60,6 +79,11 @@ export const interpolatePaths = (
60
79
  case Extrapolate.CLAMP:
61
80
  return outputRange[outputRange.length - 1];
62
81
  case Extrapolate.EXTEND:
82
+ if (!Number.isFinite(value)) {
83
+ throw new Error(
84
+ "interpolatePaths() cannot extend with an infinite value, use clamp extrapolation instead"
85
+ );
86
+ }
63
87
  return lerp(
64
88
  value,
65
89
  input[input.length - 2],
@@ -33,8 +33,7 @@ export const makeImageFromView = <
33
33
  >(
34
34
  viewRef: React.RefObject<T>,
35
35
  callback:
36
- | null
37
- | ((viewRef: React.RefObject<T>) => Promise<SkImage | null>) = null
36
+ null | ((viewRef: React.RefObject<T>) => Promise<SkImage | null>) = null
38
37
  ) => {
39
38
  // In web implementation we just delegate the work to the provided callback
40
39
  if (Platform.OS === "web") {