@shopify/react-native-skia 0.1.236 → 0.1.237

Sign up to get free protection for your applications and to get access to all the features.
Files changed (198) hide show
  1. package/cpp/api/JsiSkApi.h +2 -0
  2. package/cpp/api/JsiSkCanvas.h +36 -0
  3. package/cpp/api/JsiSkRSXform.h +35 -7
  4. package/cpp/rnskia/dom/JsiDomApi.h +2 -0
  5. package/cpp/rnskia/dom/nodes/JsiAtlasNode.h +60 -0
  6. package/cpp/rnskia/dom/props/RSXformProp.h +52 -0
  7. package/cpp/rnskia/dom/props/RectProp.h +31 -0
  8. package/lib/commonjs/dom/nodes/JsiSkDOM.d.ts +2 -1
  9. package/lib/commonjs/dom/nodes/JsiSkDOM.js +4 -0
  10. package/lib/commonjs/dom/nodes/JsiSkDOM.js.map +1 -1
  11. package/lib/commonjs/dom/nodes/drawings/AtlasNode.d.ts +8 -0
  12. package/lib/commonjs/dom/nodes/drawings/AtlasNode.js +47 -0
  13. package/lib/commonjs/dom/nodes/drawings/AtlasNode.js.map +1 -0
  14. package/lib/commonjs/dom/nodes/drawings/index.d.ts +1 -0
  15. package/lib/commonjs/dom/nodes/drawings/index.js +13 -0
  16. package/lib/commonjs/dom/nodes/drawings/index.js.map +1 -1
  17. package/lib/commonjs/dom/types/Drawings.d.ts +7 -1
  18. package/lib/commonjs/dom/types/Drawings.js.map +1 -1
  19. package/lib/commonjs/dom/types/NodeType.d.ts +1 -0
  20. package/lib/commonjs/dom/types/NodeType.js +1 -0
  21. package/lib/commonjs/dom/types/NodeType.js.map +1 -1
  22. package/lib/commonjs/dom/types/SkDOM.d.ts +2 -1
  23. package/lib/commonjs/dom/types/SkDOM.js.map +1 -1
  24. package/lib/commonjs/external/reanimated/buffers.d.ts +5 -0
  25. package/lib/commonjs/external/reanimated/buffers.js +48 -0
  26. package/lib/commonjs/external/reanimated/buffers.js.map +1 -0
  27. package/lib/commonjs/external/reanimated/index.d.ts +1 -0
  28. package/lib/commonjs/external/reanimated/index.js +13 -0
  29. package/lib/commonjs/external/reanimated/index.js.map +1 -1
  30. package/lib/commonjs/external/reanimated/textures.js +3 -17
  31. package/lib/commonjs/external/reanimated/textures.js.map +1 -1
  32. package/lib/commonjs/external/reanimated/useAnimatedImageValue.js +8 -1
  33. package/lib/commonjs/external/reanimated/useAnimatedImageValue.js.map +1 -1
  34. package/lib/commonjs/mock/index.js +5 -0
  35. package/lib/commonjs/mock/index.js.map +1 -1
  36. package/lib/commonjs/renderer/HostComponents.d.ts +3 -1
  37. package/lib/commonjs/renderer/HostComponents.js +3 -0
  38. package/lib/commonjs/renderer/HostComponents.js.map +1 -1
  39. package/lib/commonjs/renderer/Offscreen.d.ts +4 -2
  40. package/lib/commonjs/renderer/Offscreen.js +23 -18
  41. package/lib/commonjs/renderer/Offscreen.js.map +1 -1
  42. package/lib/commonjs/renderer/components/shapes/Atlas.d.ts +4 -0
  43. package/lib/commonjs/renderer/components/shapes/Atlas.js +17 -0
  44. package/lib/commonjs/renderer/components/shapes/Atlas.js.map +1 -0
  45. package/lib/commonjs/renderer/components/shapes/index.d.ts +1 -0
  46. package/lib/commonjs/renderer/components/shapes/index.js +13 -0
  47. package/lib/commonjs/renderer/components/shapes/index.js.map +1 -1
  48. package/lib/commonjs/skia/core/AnimatedImage.d.ts +1 -1
  49. package/lib/commonjs/skia/core/AnimatedImage.js +4 -1
  50. package/lib/commonjs/skia/core/AnimatedImage.js.map +1 -1
  51. package/lib/commonjs/skia/core/Data.d.ts +1 -1
  52. package/lib/commonjs/skia/core/Data.js +11 -4
  53. package/lib/commonjs/skia/core/Data.js.map +1 -1
  54. package/lib/commonjs/skia/core/Rect.d.ts +2 -2
  55. package/lib/commonjs/skia/types/Canvas.d.ts +16 -1
  56. package/lib/commonjs/skia/types/Canvas.js.map +1 -1
  57. package/lib/commonjs/skia/types/Image/Image.d.ts +8 -0
  58. package/lib/commonjs/skia/types/Image/Image.js.map +1 -1
  59. package/lib/commonjs/skia/types/RSXform.d.ts +7 -1
  60. package/lib/commonjs/skia/types/RSXform.js.map +1 -1
  61. package/lib/commonjs/skia/types/Rect.d.ts +4 -0
  62. package/lib/commonjs/skia/types/Rect.js.map +1 -1
  63. package/lib/commonjs/skia/types/Skia.d.ts +3 -2
  64. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  65. package/lib/commonjs/skia/web/JsiSkCanvas.d.ts +2 -1
  66. package/lib/commonjs/skia/web/JsiSkCanvas.js +19 -0
  67. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  68. package/lib/commonjs/skia/web/JsiSkRSXform.d.ts +8 -2
  69. package/lib/commonjs/skia/web/JsiSkRSXform.js +33 -2
  70. package/lib/commonjs/skia/web/JsiSkRSXform.js.map +1 -1
  71. package/lib/commonjs/skia/web/JsiSkRect.d.ts +3 -2
  72. package/lib/commonjs/skia/web/JsiSkRect.js +7 -0
  73. package/lib/commonjs/skia/web/JsiSkRect.js.map +1 -1
  74. package/lib/commonjs/skia/web/JsiSkTextBlobFactory.js +2 -1
  75. package/lib/commonjs/skia/web/JsiSkTextBlobFactory.js.map +1 -1
  76. package/lib/commonjs/skia/web/JsiSkia.js +5 -0
  77. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  78. package/lib/module/dom/nodes/JsiSkDOM.d.ts +2 -1
  79. package/lib/module/dom/nodes/JsiSkDOM.js +5 -1
  80. package/lib/module/dom/nodes/JsiSkDOM.js.map +1 -1
  81. package/lib/module/dom/nodes/drawings/AtlasNode.d.ts +8 -0
  82. package/lib/module/dom/nodes/drawings/AtlasNode.js +34 -0
  83. package/lib/module/dom/nodes/drawings/AtlasNode.js.map +1 -0
  84. package/lib/module/dom/nodes/drawings/index.d.ts +1 -0
  85. package/lib/module/dom/nodes/drawings/index.js +1 -0
  86. package/lib/module/dom/nodes/drawings/index.js.map +1 -1
  87. package/lib/module/dom/types/Drawings.d.ts +7 -1
  88. package/lib/module/dom/types/Drawings.js.map +1 -1
  89. package/lib/module/dom/types/NodeType.d.ts +1 -0
  90. package/lib/module/dom/types/NodeType.js +1 -0
  91. package/lib/module/dom/types/NodeType.js.map +1 -1
  92. package/lib/module/dom/types/SkDOM.d.ts +2 -1
  93. package/lib/module/dom/types/SkDOM.js.map +1 -1
  94. package/lib/module/external/reanimated/buffers.d.ts +5 -0
  95. package/lib/module/external/reanimated/buffers.js +27 -0
  96. package/lib/module/external/reanimated/buffers.js.map +1 -0
  97. package/lib/module/external/reanimated/index.d.ts +1 -0
  98. package/lib/module/external/reanimated/index.js +1 -0
  99. package/lib/module/external/reanimated/index.js.map +1 -1
  100. package/lib/module/external/reanimated/textures.js +5 -16
  101. package/lib/module/external/reanimated/textures.js.map +1 -1
  102. package/lib/module/external/reanimated/useAnimatedImageValue.js +7 -1
  103. package/lib/module/external/reanimated/useAnimatedImageValue.js.map +1 -1
  104. package/lib/module/mock/index.js +5 -0
  105. package/lib/module/mock/index.js.map +1 -1
  106. package/lib/module/renderer/HostComponents.d.ts +3 -1
  107. package/lib/module/renderer/HostComponents.js +3 -0
  108. package/lib/module/renderer/HostComponents.js.map +1 -1
  109. package/lib/module/renderer/Offscreen.d.ts +4 -2
  110. package/lib/module/renderer/Offscreen.js +15 -13
  111. package/lib/module/renderer/Offscreen.js.map +1 -1
  112. package/lib/module/renderer/components/shapes/Atlas.d.ts +4 -0
  113. package/lib/module/renderer/components/shapes/Atlas.js +5 -0
  114. package/lib/module/renderer/components/shapes/Atlas.js.map +1 -0
  115. package/lib/module/renderer/components/shapes/index.d.ts +1 -0
  116. package/lib/module/renderer/components/shapes/index.js +1 -0
  117. package/lib/module/renderer/components/shapes/index.js.map +1 -1
  118. package/lib/module/skia/core/AnimatedImage.d.ts +1 -1
  119. package/lib/module/skia/core/AnimatedImage.js +4 -1
  120. package/lib/module/skia/core/AnimatedImage.js.map +1 -1
  121. package/lib/module/skia/core/Data.d.ts +1 -1
  122. package/lib/module/skia/core/Data.js +11 -4
  123. package/lib/module/skia/core/Data.js.map +1 -1
  124. package/lib/module/skia/core/Rect.d.ts +2 -2
  125. package/lib/module/skia/types/Canvas.d.ts +16 -1
  126. package/lib/module/skia/types/Canvas.js.map +1 -1
  127. package/lib/module/skia/types/Image/Image.d.ts +8 -0
  128. package/lib/module/skia/types/Image/Image.js.map +1 -1
  129. package/lib/module/skia/types/RSXform.d.ts +7 -1
  130. package/lib/module/skia/types/RSXform.js.map +1 -1
  131. package/lib/module/skia/types/Rect.d.ts +4 -0
  132. package/lib/module/skia/types/Rect.js.map +1 -1
  133. package/lib/module/skia/types/Skia.d.ts +3 -2
  134. package/lib/module/skia/types/Skia.js.map +1 -1
  135. package/lib/module/skia/web/JsiSkCanvas.d.ts +2 -1
  136. package/lib/module/skia/web/JsiSkCanvas.js +18 -0
  137. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  138. package/lib/module/skia/web/JsiSkRSXform.d.ts +8 -2
  139. package/lib/module/skia/web/JsiSkRSXform.js +34 -3
  140. package/lib/module/skia/web/JsiSkRSXform.js.map +1 -1
  141. package/lib/module/skia/web/JsiSkRect.d.ts +3 -2
  142. package/lib/module/skia/web/JsiSkRect.js +7 -0
  143. package/lib/module/skia/web/JsiSkRect.js.map +1 -1
  144. package/lib/module/skia/web/JsiSkTextBlobFactory.js +2 -1
  145. package/lib/module/skia/web/JsiSkTextBlobFactory.js.map +1 -1
  146. package/lib/module/skia/web/JsiSkia.js +5 -0
  147. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  148. package/lib/typescript/src/dom/nodes/JsiSkDOM.d.ts +2 -1
  149. package/lib/typescript/src/dom/nodes/drawings/AtlasNode.d.ts +8 -0
  150. package/lib/typescript/src/dom/nodes/drawings/index.d.ts +1 -0
  151. package/lib/typescript/src/dom/types/Drawings.d.ts +7 -1
  152. package/lib/typescript/src/dom/types/NodeType.d.ts +1 -0
  153. package/lib/typescript/src/dom/types/SkDOM.d.ts +2 -1
  154. package/lib/typescript/src/external/reanimated/buffers.d.ts +5 -0
  155. package/lib/typescript/src/external/reanimated/index.d.ts +1 -0
  156. package/lib/typescript/src/renderer/HostComponents.d.ts +3 -1
  157. package/lib/typescript/src/renderer/Offscreen.d.ts +4 -2
  158. package/lib/typescript/src/renderer/components/shapes/Atlas.d.ts +4 -0
  159. package/lib/typescript/src/renderer/components/shapes/index.d.ts +1 -0
  160. package/lib/typescript/src/skia/core/AnimatedImage.d.ts +1 -1
  161. package/lib/typescript/src/skia/core/Data.d.ts +1 -1
  162. package/lib/typescript/src/skia/core/Rect.d.ts +2 -2
  163. package/lib/typescript/src/skia/types/Canvas.d.ts +16 -1
  164. package/lib/typescript/src/skia/types/Image/Image.d.ts +8 -0
  165. package/lib/typescript/src/skia/types/RSXform.d.ts +7 -1
  166. package/lib/typescript/src/skia/types/Rect.d.ts +4 -0
  167. package/lib/typescript/src/skia/types/Skia.d.ts +3 -2
  168. package/lib/typescript/src/skia/web/JsiSkCanvas.d.ts +2 -1
  169. package/lib/typescript/src/skia/web/JsiSkRSXform.d.ts +8 -2
  170. package/lib/typescript/src/skia/web/JsiSkRect.d.ts +3 -2
  171. package/package.json +1 -1
  172. package/src/dom/nodes/JsiSkDOM.ts +8 -0
  173. package/src/dom/nodes/drawings/AtlasNode.ts +24 -0
  174. package/src/dom/nodes/drawings/index.ts +1 -0
  175. package/src/dom/types/Drawings.ts +9 -0
  176. package/src/dom/types/NodeType.ts +1 -0
  177. package/src/dom/types/SkDOM.ts +2 -0
  178. package/src/external/reanimated/buffers.ts +53 -0
  179. package/src/external/reanimated/index.ts +1 -0
  180. package/src/external/reanimated/textures.tsx +7 -19
  181. package/src/external/reanimated/useAnimatedImageValue.ts +15 -4
  182. package/src/mock/index.ts +5 -0
  183. package/src/renderer/HostComponents.ts +6 -1
  184. package/src/renderer/Offscreen.tsx +20 -16
  185. package/src/renderer/components/shapes/Atlas.tsx +8 -0
  186. package/src/renderer/components/shapes/index.ts +1 -0
  187. package/src/skia/core/AnimatedImage.ts +3 -2
  188. package/src/skia/core/Data.ts +8 -4
  189. package/src/skia/types/Canvas.ts +32 -1
  190. package/src/skia/types/Image/Image.ts +10 -0
  191. package/src/skia/types/RSXform.ts +7 -1
  192. package/src/skia/types/Rect.ts +6 -0
  193. package/src/skia/types/Skia.ts +10 -2
  194. package/src/skia/web/JsiSkCanvas.ts +60 -23
  195. package/src/skia/web/JsiSkRSXform.ts +28 -4
  196. package/src/skia/web/JsiSkRect.ts +12 -2
  197. package/src/skia/web/JsiSkTextBlobFactory.ts +5 -5
  198. package/src/skia/web/JsiSkia.ts +15 -0
@@ -1,4 +1,4 @@
1
- import type { PathProps, SkDOM, GroupProps, ImageProps, BlurImageFilterProps, MatrixColorFilterProps, CircleProps, BlurMaskFilterProps, LinearGradientProps, PaintProps, ShaderProps, ImageShaderProps, LineProps, OvalProps, PatchProps, PointsProps, RectProps, RoundedRectProps, VerticesProps, TextProps, DiffRectProps, OffsetImageFilterProps, BlendColorFilterProps, TextPathProps, TextBlobProps, GlyphsProps, TwoPointConicalGradientProps, TurbulenceProps, SweepGradientProps, RadialGradientProps, FractalNoiseProps, ColorProps, PictureProps, ImageSVGProps, LerpColorFilterProps, DrawingNodeProps, BoxProps, BoxShadowProps, ChildrenProps } from "../types";
1
+ import type { PathProps, SkDOM, GroupProps, ImageProps, BlurImageFilterProps, MatrixColorFilterProps, CircleProps, BlurMaskFilterProps, LinearGradientProps, PaintProps, ShaderProps, ImageShaderProps, LineProps, OvalProps, PatchProps, PointsProps, RectProps, RoundedRectProps, VerticesProps, TextProps, DiffRectProps, OffsetImageFilterProps, BlendColorFilterProps, TextPathProps, TextBlobProps, GlyphsProps, TwoPointConicalGradientProps, TurbulenceProps, SweepGradientProps, RadialGradientProps, FractalNoiseProps, ColorProps, PictureProps, ImageSVGProps, LerpColorFilterProps, DrawingNodeProps, BoxProps, BoxShadowProps, ChildrenProps, AtlasProps } from "../types";
2
2
  import type { BlendImageFilterProps, BlendProps, DisplacementMapImageFilterProps, DropShadowImageFilterProps, MorphologyImageFilterProps, RuntimeShaderImageFilterProps } from "../types/ImageFilters";
3
3
  import type { CornerPathEffectProps, DashPathEffectProps, DiscretePathEffectProps, Line2DPathEffectProps, Path1DPathEffectProps, Path2DPathEffectProps } from "../types/PathEffects";
4
4
  import type { ParagraphProps } from "../types/Paragraph";
@@ -28,6 +28,7 @@ export declare class JsiSkDOM implements SkDOM {
28
28
  Glyphs(props: GlyphsProps): import("../types").RenderNode<GlyphsProps>;
29
29
  DiffRect(props: DiffRectProps): import("../types").RenderNode<DiffRectProps>;
30
30
  Picture(props: PictureProps): import("../types").RenderNode<PictureProps>;
31
+ Atlas(props: AtlasProps): import("../types").RenderNode<AtlasProps>;
31
32
  ImageSVG(props: ImageSVGProps): import("../types").RenderNode<ImageSVGProps>;
32
33
  BlurMaskFilter(props: BlurMaskFilterProps): import("../types").DeclarationNode<BlurMaskFilterProps>;
33
34
  BlendImageFilter(props: BlendImageFilterProps): import("../types").DeclarationNode<BlendImageFilterProps>;
@@ -0,0 +1,8 @@
1
+ import type { AtlasProps, DrawingContext } from "../../types";
2
+ import { JsiDrawingNode } from "../DrawingNode";
3
+ import type { NodeContext } from "../Node";
4
+ export declare class AtlasNode extends JsiDrawingNode<AtlasProps, null> {
5
+ protected deriveProps(): null;
6
+ constructor(ctx: NodeContext, props: AtlasProps);
7
+ draw({ canvas, paint }: DrawingContext): void;
8
+ }
@@ -1,3 +1,4 @@
1
+ export * from "./AtlasNode";
1
2
  export * from "./CircleNode";
2
3
  export * from "./FillNode";
3
4
  export * from "./ImageNode";
@@ -1,4 +1,4 @@
1
- import type { FillType, SkImage, StrokeOpts, Vector, Color, SkPoint, BlendMode, PointMode, VertexMode, SkFont, SkRRect, SkTextBlob, SkPicture, SkSVG, SkPaint, SkRect } from "../../skia/types";
1
+ import type { FillType, SkImage, StrokeOpts, Vector, Color, SkPoint, BlendMode, PointMode, VertexMode, SkFont, SkRRect, SkTextBlob, SkPicture, SkSVG, SkPaint, SkRect, SkRSXform, SkColor } from "../../skia/types";
2
2
  import type { CircleDef, Fit, GroupProps, PathDef, RectDef, RRectDef, SkEnum } from "./Common";
3
3
  export interface DrawingNodeProps extends GroupProps {
4
4
  paint?: SkPaint;
@@ -22,6 +22,12 @@ export interface LineProps extends DrawingNodeProps {
22
22
  export type OvalProps = RectDef & DrawingNodeProps;
23
23
  export type RectProps = RectDef & DrawingNodeProps;
24
24
  export type RoundedRectProps = RRectDef & DrawingNodeProps;
25
+ export interface AtlasProps extends DrawingNodeProps {
26
+ image: SkImage | null;
27
+ sprites: SkRect[];
28
+ transforms: SkRSXform[];
29
+ colors?: SkColor[];
30
+ }
25
31
  export interface CubicBezierHandle {
26
32
  pos: Vector;
27
33
  c1: Vector;
@@ -54,6 +54,7 @@ export declare const enum NodeType {
54
54
  Glyphs = "skGlyphs",
55
55
  Picture = "skPicture",
56
56
  ImageSVG = "skImageSVG",
57
+ Atlas = "skAtlas",
57
58
  Paragraph = "skParagraph"
58
59
  }
59
60
  export declare const enum DeclarationType {
@@ -2,7 +2,7 @@ import type { ChildrenProps, GroupProps, PaintProps } from "./Common";
2
2
  import type { BlendImageFilterProps, BlurImageFilterProps, DropShadowImageFilterProps, OffsetImageFilterProps, RuntimeShaderImageFilterProps, DisplacementMapImageFilterProps, MorphologyImageFilterProps, BlendProps } from "./ImageFilters";
3
3
  import type { DeclarationNode, RenderNode } from "./Node";
4
4
  import type { BlendColorFilterProps, MatrixColorFilterProps, LerpColorFilterProps } from "./ColorFilters";
5
- import type { ImageProps, CircleProps, PathProps, LineProps, OvalProps, PatchProps, PointsProps, RectProps, RoundedRectProps, VerticesProps, TextProps, DiffRectProps, TextPathProps, TextBlobProps, GlyphsProps, PictureProps, ImageSVGProps, DrawingNodeProps, BoxProps, BoxShadowProps } from "./Drawings";
5
+ import type { ImageProps, CircleProps, PathProps, LineProps, OvalProps, PatchProps, PointsProps, RectProps, RoundedRectProps, VerticesProps, TextProps, DiffRectProps, TextPathProps, TextBlobProps, GlyphsProps, PictureProps, ImageSVGProps, DrawingNodeProps, BoxProps, BoxShadowProps, AtlasProps } from "./Drawings";
6
6
  import type { BlurMaskFilterProps } from "./MaskFilters";
7
7
  import type { FractalNoiseProps, SweepGradientProps, ImageShaderProps, LinearGradientProps, ShaderProps, TurbulenceProps, TwoPointConicalGradientProps, RadialGradientProps, ColorProps } from "./Shaders";
8
8
  import type { CornerPathEffectProps, DashPathEffectProps, DiscretePathEffectProps, Line2DPathEffectProps, Path1DPathEffectProps, Path2DPathEffectProps } from "./PathEffects";
@@ -33,6 +33,7 @@ export interface SkDOM {
33
33
  DiffRect(props: DiffRectProps): DrawingNode<DiffRectProps>;
34
34
  Picture(props: PictureProps): DrawingNode<PictureProps>;
35
35
  ImageSVG(props: ImageSVGProps): DrawingNode<ImageSVGProps>;
36
+ Atlas(props: AtlasProps): DrawingNode<AtlasProps>;
36
37
  BlurMaskFilter(props: BlurMaskFilterProps): DeclarationNode<BlurMaskFilterProps>;
37
38
  BlendImageFilter(props: BlendImageFilterProps): ImageFilterNode<BlendImageFilterProps>;
38
39
  BlurImageFilter(props: BlurImageFilterProps): ImageFilterNode<BlurImageFilterProps>;
@@ -0,0 +1,5 @@
1
+ import type { SkColor, SkHostRect, SkPoint, SkRSXform } from "../../skia/types";
2
+ export declare const useRectBuffer: (size: number, modifier: (input: SkHostRect, index: number) => void) => import("react-native-reanimated").SharedValue<SkHostRect[]>;
3
+ export declare const useRSXformBuffer: (size: number, modifier: (input: SkRSXform, index: number) => void) => import("react-native-reanimated").SharedValue<SkRSXform[]>;
4
+ export declare const usePointBuffer: (size: number, modifier: (input: SkPoint, index: number) => void) => import("react-native-reanimated").SharedValue<SkPoint[]>;
5
+ export declare const useColorBuffer: (size: number, modifier: (input: SkColor, index: number) => void) => import("react-native-reanimated").SharedValue<Float32Array[]>;
@@ -3,3 +3,4 @@ export * from "./useDerivedValueOnJS";
3
3
  export * from "./renderHelpers";
4
4
  export * from "./interpolators";
5
5
  export * from "./textures";
6
+ export * from "./buffers";
@@ -1,5 +1,5 @@
1
1
  import { NodeType } from "../dom/types";
2
- import type { DeclarationNode, FractalNoiseProps, RenderNode, CircleProps, DrawingNodeProps, ImageProps, PaintProps, PathProps, LineProps, OvalProps, DiffRectProps, PointsProps, RectProps, RoundedRectProps, TextProps, VerticesProps, BlurMaskFilterProps, BlendImageFilterProps, BlurImageFilterProps, DisplacementMapImageFilterProps, DropShadowImageFilterProps, OffsetImageFilterProps, RuntimeShaderImageFilterProps, MatrixColorFilterProps, ShaderProps, ImageShaderProps, LinearGradientProps, GroupProps, PatchProps, BlendColorFilterProps, DashPathEffectProps, DiscretePathEffectProps, CornerPathEffectProps, Line2DPathEffectProps, Path1DPathEffectProps, Path2DPathEffectProps, TextPathProps, TextBlobProps, GlyphsProps, TwoPointConicalGradientProps, TurbulenceProps, SweepGradientProps, RadialGradientProps, ColorProps, PictureProps, ImageSVGProps, LerpColorFilterProps, BoxProps, BoxShadowProps, ParagraphProps } from "../dom/types";
2
+ import type { DeclarationNode, FractalNoiseProps, RenderNode, CircleProps, DrawingNodeProps, ImageProps, PaintProps, PathProps, LineProps, OvalProps, DiffRectProps, PointsProps, RectProps, RoundedRectProps, TextProps, VerticesProps, BlurMaskFilterProps, BlendImageFilterProps, BlurImageFilterProps, DisplacementMapImageFilterProps, DropShadowImageFilterProps, OffsetImageFilterProps, RuntimeShaderImageFilterProps, MatrixColorFilterProps, ShaderProps, ImageShaderProps, LinearGradientProps, GroupProps, PatchProps, BlendColorFilterProps, DashPathEffectProps, DiscretePathEffectProps, CornerPathEffectProps, Line2DPathEffectProps, Path1DPathEffectProps, Path2DPathEffectProps, TextPathProps, TextBlobProps, GlyphsProps, TwoPointConicalGradientProps, TurbulenceProps, SweepGradientProps, RadialGradientProps, ColorProps, PictureProps, ImageSVGProps, LerpColorFilterProps, BoxProps, BoxShadowProps, ParagraphProps, AtlasProps } from "../dom/types";
3
3
  import type { ChildrenProps } from "../dom/types/Common";
4
4
  import type { BlendProps, MorphologyImageFilterProps } from "../dom/types/ImageFilters";
5
5
  import type { SkRect, SkRRect } from "../skia/types";
@@ -22,6 +22,7 @@ declare global {
22
22
  PatchNode: (props: PatchProps) => RenderNode<PatchProps>;
23
23
  PointsNode: (props: PointsProps) => RenderNode<PointsProps>;
24
24
  DiffRectNode: (props: DiffRectProps) => RenderNode<DiffRectProps>;
25
+ AtlasNode: (props: AtlasProps) => RenderNode<AtlasProps>;
25
26
  BlurMaskFilterNode: (props: BlurMaskFilterProps) => DeclarationNode<BlurMaskFilterProps>;
26
27
  DashPathEffectNode: (props: DashPathEffectProps) => DeclarationNode<DashPathEffectProps>;
27
28
  DiscretePathEffectNode: (props: DiscretePathEffectProps) => DeclarationNode<DiscretePathEffectProps>;
@@ -81,6 +82,7 @@ declare global {
81
82
  skPoints: SkiaProps<PointsProps>;
82
83
  skRect: SkiaProps<RectProps>;
83
84
  skRRect: SkiaProps<RoundedRectProps>;
85
+ skAtlas: SkiaProps<AtlasProps>;
84
86
  skVertices: SkiaProps<VerticesProps>;
85
87
  skText: SkiaProps<TextProps>;
86
88
  skTextPath: SkiaProps<TextPathProps>;
@@ -1,3 +1,5 @@
1
1
  import type { ReactElement } from "react";
2
- export declare const drawAsImage: (element: ReactElement, width: number, height: number) => import("../skia").SkImage;
3
- export declare const drawAsPicture: (element: ReactElement) => import("../skia").SkPicture;
2
+ import type { SkPicture, SkSize } from "../skia/types";
3
+ export declare const drawAsPicture: (element: ReactElement) => SkPicture;
4
+ export declare const drawAsImage: (element: ReactElement, size: SkSize) => import("../skia").SkImage;
5
+ export declare const drawAsImageFromPicture: (picture: SkPicture, size: SkSize) => import("../skia").SkImage;
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import type { AtlasProps } from "../../../dom/types";
3
+ import type { SkiaProps } from "../../processors";
4
+ export declare const Atlas: (props: SkiaProps<AtlasProps>) => React.JSX.Element;
@@ -11,3 +11,4 @@ export * from "./Vertices";
11
11
  export * from "./Fill";
12
12
  export * from "./FitBox";
13
13
  export * from "./Box";
14
+ export * from "./Atlas";
@@ -2,4 +2,4 @@ import type { DataSourceParam } from "../types";
2
2
  /**
3
3
  * Returns a Skia Animated Image object
4
4
  * */
5
- export declare const useAnimatedImage: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => import("../types").SkAnimatedImage | null;
5
+ export declare const useAnimatedImage: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined, managed?: boolean) => import("../types").SkAnimatedImage | null;
@@ -1,5 +1,5 @@
1
1
  import type { SkData, DataSourceParam, SkJSIInstance } from "../types";
2
2
  export declare const loadData: <T>(source: DataSourceParam, factory: (data: SkData) => T | null, onError?: ((err: Error) => void) | undefined) => Promise<T | null>;
3
3
  export declare const useCollectionLoading: <T extends SkJSIInstance<string>>(source: DataSourceParam[], loader: () => Promise<(T | null)[]>) => T[] | null;
4
- export declare const useRawData: <T extends SkJSIInstance<string>>(source: DataSourceParam, factory: (data: SkData) => T | null, onError?: ((err: Error) => void) | undefined) => T | null;
4
+ export declare const useRawData: <T extends SkJSIInstance<string>>(source: DataSourceParam, factory: (data: SkData) => T | null, onError?: ((err: Error) => void) | undefined, manage?: boolean) => T | null;
5
5
  export declare const useData: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => SkData | null;
@@ -1,6 +1,6 @@
1
1
  import type { SkRect, SkRRect } from "../types";
2
- export declare const rect: (x: number, y: number, width: number, height: number) => SkRect;
3
- export declare const bounds: (rects: SkRect[]) => SkRect;
2
+ export declare const rect: (x: number, y: number, width: number, height: number) => import("../types").SkHostRect;
3
+ export declare const bounds: (rects: SkRect[]) => import("../types").SkHostRect;
4
4
  export declare const topLeft: (r: SkRect | SkRRect) => import("../types").SkPoint;
5
5
  export declare const topRight: (r: SkRect | SkRRect) => import("../types").SkPoint;
6
6
  export declare const bottomLeft: (r: SkRect | SkRRect) => import("../types").SkPoint;
@@ -2,7 +2,7 @@ import type { SkPaint } from "./Paint";
2
2
  import type { SkRect } from "./Rect";
3
3
  import type { SkFont } from "./Font";
4
4
  import type { SkPath } from "./Path";
5
- import type { SkImage, MipmapMode, FilterMode, ImageInfo } from "./Image";
5
+ import type { SkImage, MipmapMode, FilterMode, ImageInfo, CubicResampler, FilterOptions } from "./Image";
6
6
  import type { SkSVG } from "./SVG";
7
7
  import type { SkColor } from "./Color";
8
8
  import type { InputRRect } from "./RRect";
@@ -13,6 +13,7 @@ import type { SkImageFilter } from "./ImageFilter";
13
13
  import type { SkVertices } from "./Vertices";
14
14
  import type { SkTextBlob } from "./TextBlob";
15
15
  import type { SkPicture } from "./Picture";
16
+ import type { SkRSXform } from "./RSXform";
16
17
  export declare enum ClipOp {
17
18
  Difference = 0,
18
19
  Intersect = 1
@@ -378,6 +379,20 @@ export interface SkCanvas {
378
379
  * @param skp
379
380
  */
380
381
  drawPicture(skp: SkPicture): void;
382
+ /**
383
+ * This method is used to draw an atlas on the canvas.
384
+ *
385
+ * @method drawAtlas
386
+ * @param {SkImage} atlas - The image to be drawn.
387
+ * @param {SkRect[]} srcs - The source rectangles.
388
+ * @param {SkRSXform[]} dsts - The destination transformations.
389
+ * @param {SkPaint} paint - The paint used for drawing.
390
+ * @param {BlendMode} [blendMode] - The blend mode used for drawing. Optional.
391
+ * @param {SkColor[]} [colors] - The colors used for drawing. Optional.
392
+ * @param {CubicResampler | FilterOptions} [sampling] - The sampling options. Optional.
393
+ * @returns {void} This method does not return anything.
394
+ */
395
+ drawAtlas(atlas: SkImage, srcs: SkRect[], dsts: SkRSXform[], paint: SkPaint, blendMode?: BlendMode, colors?: SkColor[], sampling?: CubicResampler | FilterOptions): void;
381
396
  /** Read Image pixels
382
397
  *
383
398
  * @param srcX - x-axis upper left corner of the rectangle to read from
@@ -3,6 +3,14 @@ import type { SkJSIInstance } from "../JsiInstance";
3
3
  import type { TileMode } from "../ImageFilter";
4
4
  import type { SkShader } from "../Shader";
5
5
  import type { ImageInfo } from "./ImageFactory";
6
+ export interface CubicResampler {
7
+ B: number;
8
+ C: number;
9
+ }
10
+ export interface FilterOptions {
11
+ filter: FilterMode;
12
+ mipmap?: MipmapMode;
13
+ }
6
14
  export declare enum FilterMode {
7
15
  Nearest = 0,
8
16
  Linear = 1
@@ -1,2 +1,8 @@
1
1
  import type { SkJSIInstance } from "./JsiInstance";
2
- export type SkRSXform = SkJSIInstance<"RSXform">;
2
+ export interface SkRSXform extends SkJSIInstance<"RSXform"> {
3
+ readonly scos: number;
4
+ readonly ssin: number;
5
+ readonly tx: number;
6
+ readonly ty: number;
7
+ set(scos: number, ssin: number, tx: number, ty: number): void;
8
+ }
@@ -1,7 +1,11 @@
1
+ import type { SkJSIInstance } from "./JsiInstance";
1
2
  export interface SkRect {
2
3
  readonly x: number;
3
4
  readonly y: number;
4
5
  readonly width: number;
5
6
  readonly height: number;
6
7
  }
8
+ export interface SkHostRect extends SkRect, SkJSIInstance<"Rect"> {
9
+ setXYWH(x: number, y: number, width: number, height: number): void;
10
+ }
7
11
  export declare const isRect: (def: unknown) => def is SkRect;
@@ -6,7 +6,7 @@ import type { SkTypeface, TypefaceFactory } from "./Typeface";
6
6
  import type { ImageFactory } from "./Image";
7
7
  import type { MaskFilterFactory } from "./MaskFilter";
8
8
  import type { SkPaint } from "./Paint";
9
- import type { SkRect } from "./Rect";
9
+ import type { SkHostRect, SkRect } from "./Rect";
10
10
  import type { SkRRect } from "./RRect";
11
11
  import type { RuntimeEffectFactory, SkRuntimeEffect, SkRuntimeShaderBuilder } from "./RuntimeEffect";
12
12
  import type { ShaderFactory } from "./Shader";
@@ -31,10 +31,11 @@ import type { ParagraphBuilderFactory } from "./Paragraph/ParagraphBuilder";
31
31
  */
32
32
  export interface Skia {
33
33
  Point: (x: number, y: number) => SkPoint;
34
- XYWHRect: (x: number, y: number, width: number, height: number) => SkRect;
34
+ XYWHRect: (x: number, y: number, width: number, height: number) => SkHostRect;
35
35
  RuntimeShaderBuilder: (rt: SkRuntimeEffect) => SkRuntimeShaderBuilder;
36
36
  RRectXY: (rect: SkRect, rx: number, ry: number) => SkRRect;
37
37
  RSXform: (scos: number, ssin: number, tx: number, ty: number) => SkRSXform;
38
+ RSXformFromRadians: (scale: number, radians: number, tx: number, ty: number, px: number, py: number) => SkRSXform;
38
39
  Color: (color: Color) => SkColor;
39
40
  ContourMeasureIter: (path: SkPath, forceClosed: boolean, resScale: number) => SkContourMeasureIter;
40
41
  Paint: () => SkPaint;
@@ -1,5 +1,5 @@
1
1
  import type { Canvas, CanvasKit } from "canvaskit-wasm";
2
- import type { BlendMode, ClipOp, FilterMode, MipmapMode, PointMode, SaveLayerFlag, ImageInfo, SkCanvas, SkColor, SkFont, SkImage, SkImageFilter, SkMatrix, SkPaint, SkPath, SkPicture, SkPoint, SkRect, InputRRect, SkSVG, SkTextBlob, SkVertices } from "../types";
2
+ import { type BlendMode, type ClipOp, type FilterMode, type MipmapMode, type PointMode, type SaveLayerFlag, type ImageInfo, type SkCanvas, type SkColor, type SkFont, type SkImage, type SkImageFilter, type SkMatrix, type SkPaint, type SkPath, type SkPicture, type SkPoint, type SkRect, type InputRRect, type SkSVG, type SkTextBlob, type SkVertices, type SkRSXform, type CubicResampler, type FilterOptions } from "../types";
3
3
  import { HostObject } from "./Host";
4
4
  export declare class JsiSkCanvas extends HostObject<Canvas, "Canvas"> implements SkCanvas {
5
5
  constructor(CanvasKit: CanvasKit, ref: Canvas);
@@ -42,5 +42,6 @@ export declare class JsiSkCanvas extends HostObject<Canvas, "Canvas"> implements
42
42
  clipRRect(rrect: InputRRect, op: ClipOp, doAntiAlias: boolean): void;
43
43
  concat(m: SkMatrix | number[]): void;
44
44
  drawPicture(skp: SkPicture): void;
45
+ drawAtlas(atlas: SkImage, srcs: SkRect[], dsts: SkRSXform[], paint: SkPaint, blendMode?: BlendMode, colors?: SkColor[], _sampling?: CubicResampler | FilterOptions): void;
45
46
  readPixels(srcX: number, srcY: number, imageInfo: ImageInfo): Float32Array | Uint8Array | null;
46
47
  }
@@ -1,8 +1,14 @@
1
1
  import type { CanvasKit } from "canvaskit-wasm";
2
2
  import type { SkRSXform } from "../types";
3
- import { HostObject } from "./Host";
3
+ import { BaseHostObject } from "./Host";
4
4
  export type RSXform = Float32Array;
5
- export declare class JsiSkRSXform extends HostObject<RSXform, "RSXform"> implements SkRSXform {
5
+ export declare class JsiSkRSXform extends BaseHostObject<RSXform, "RSXform"> implements SkRSXform {
6
+ static fromValue(rsxform: SkRSXform): Float32Array;
6
7
  constructor(CanvasKit: CanvasKit, ref: RSXform);
8
+ set(scos: number, ssin: number, tx: number, ty: number): void;
9
+ get scos(): number;
10
+ get ssin(): number;
11
+ get tx(): number;
12
+ get ty(): number;
7
13
  dispose: () => void;
8
14
  }
@@ -1,10 +1,11 @@
1
1
  import type { CanvasKit, Rect } from "canvaskit-wasm";
2
- import type { SkRect } from "../types";
2
+ import type { SkHostRect, SkRect } from "../types";
3
3
  import { BaseHostObject } from "./Host";
4
- export declare class JsiSkRect extends BaseHostObject<Rect, "Rect"> implements SkRect {
4
+ export declare class JsiSkRect extends BaseHostObject<Rect, "Rect"> implements SkHostRect {
5
5
  static fromValue(CanvasKit: CanvasKit, rect: SkRect): Float32Array;
6
6
  dispose: () => void;
7
7
  constructor(CanvasKit: CanvasKit, ref: Rect);
8
+ setXYWH(x: number, y: number, width: number, height: number): void;
8
9
  get x(): number;
9
10
  get y(): number;
10
11
  get width(): number;
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "setup-skia-web": "./scripts/setup-canvaskit.js"
8
8
  },
9
9
  "title": "React Native Skia",
10
- "version": "0.1.236",
10
+ "version": "0.1.237",
11
11
  "description": "High-performance React Native Graphics using Skia",
12
12
  "main": "lib/module/index.js",
13
13
  "files": [
@@ -38,6 +38,7 @@ import type {
38
38
  BoxProps,
39
39
  BoxShadowProps,
40
40
  ChildrenProps,
41
+ AtlasProps,
41
42
  } from "../types";
42
43
  import type {
43
44
  BlendImageFilterProps,
@@ -79,6 +80,7 @@ import {
79
80
  BackdropFilterNode,
80
81
  BoxNode,
81
82
  BoxShadowNode,
83
+ AtlasNode,
82
84
  } from "./drawings";
83
85
  import {
84
86
  BlendImageFilterNode,
@@ -247,6 +249,12 @@ export class JsiSkDOM implements SkDOM {
247
249
  : new PictureNode(this.ctx, props);
248
250
  }
249
251
 
252
+ Atlas(props: AtlasProps) {
253
+ return this.native
254
+ ? global.SkiaDomApi.AtlasNode(props)
255
+ : new AtlasNode(this.ctx, props);
256
+ }
257
+
250
258
  ImageSVG(props: ImageSVGProps) {
251
259
  return this.native
252
260
  ? global.SkiaDomApi.ImageSVGNode(props)
@@ -0,0 +1,24 @@
1
+ import { BlendMode } from "../../../skia/types";
2
+ import type { AtlasProps, DrawingContext } from "../../types";
3
+ import { NodeType } from "../../types";
4
+ import { JsiDrawingNode } from "../DrawingNode";
5
+ import type { NodeContext } from "../Node";
6
+ import { enumKey } from "../datatypes";
7
+
8
+ export class AtlasNode extends JsiDrawingNode<AtlasProps, null> {
9
+ protected deriveProps() {
10
+ return null;
11
+ }
12
+
13
+ constructor(ctx: NodeContext, props: AtlasProps) {
14
+ super(ctx, NodeType.Atlas, props);
15
+ }
16
+
17
+ draw({ canvas, paint }: DrawingContext) {
18
+ const { image, sprites, transforms, colors, blendMode } = this.props;
19
+ const blend = blendMode ? BlendMode[enumKey(blendMode)] : undefined;
20
+ if (image) {
21
+ canvas.drawAtlas(image, sprites, transforms, paint, blend, colors);
22
+ }
23
+ }
24
+ }
@@ -1,3 +1,4 @@
1
+ export * from "./AtlasNode";
1
2
  export * from "./CircleNode";
2
3
  export * from "./FillNode";
3
4
  export * from "./ImageNode";
@@ -15,6 +15,8 @@ import type {
15
15
  SkSVG,
16
16
  SkPaint,
17
17
  SkRect,
18
+ SkRSXform,
19
+ SkColor,
18
20
  } from "../../skia/types";
19
21
 
20
22
  import type {
@@ -58,6 +60,13 @@ export type RectProps = RectDef & DrawingNodeProps;
58
60
 
59
61
  export type RoundedRectProps = RRectDef & DrawingNodeProps;
60
62
 
63
+ export interface AtlasProps extends DrawingNodeProps {
64
+ image: SkImage | null;
65
+ sprites: SkRect[];
66
+ transforms: SkRSXform[];
67
+ colors?: SkColor[];
68
+ }
69
+
61
70
  export interface CubicBezierHandle {
62
71
  pos: Vector;
63
72
  c1: Vector;
@@ -67,6 +67,7 @@ export const enum NodeType {
67
67
  Glyphs = "skGlyphs",
68
68
  Picture = "skPicture",
69
69
  ImageSVG = "skImageSVG",
70
+ Atlas = "skAtlas",
70
71
 
71
72
  // Paragraph
72
73
  Paragraph = "skParagraph",
@@ -36,6 +36,7 @@ import type {
36
36
  DrawingNodeProps,
37
37
  BoxProps,
38
38
  BoxShadowProps,
39
+ AtlasProps,
39
40
  } from "./Drawings";
40
41
  import type { BlurMaskFilterProps } from "./MaskFilters";
41
42
  import type {
@@ -90,6 +91,7 @@ export interface SkDOM {
90
91
  DiffRect(props: DiffRectProps): DrawingNode<DiffRectProps>;
91
92
  Picture(props: PictureProps): DrawingNode<PictureProps>;
92
93
  ImageSVG(props: ImageSVGProps): DrawingNode<ImageSVGProps>;
94
+ Atlas(props: AtlasProps): DrawingNode<AtlasProps>;
93
95
 
94
96
  // BlurMaskFilters
95
97
  BlurMaskFilter(
@@ -0,0 +1,53 @@
1
+ import { useMemo } from "react";
2
+
3
+ import type { SkColor, SkHostRect, SkPoint, SkRSXform } from "../../skia/types";
4
+ import { Skia } from "../../skia";
5
+
6
+ import { useDerivedValue, useSharedValue } from "./moduleWrapper";
7
+ import { notifyChange } from "./interpolators";
8
+
9
+ const useBuffer = <T>(
10
+ size: number,
11
+ bufferInitializer: () => T,
12
+ modifier: (input: T, index: number) => void
13
+ ) => {
14
+ const buffer = useMemo(
15
+ () => new Array(size).fill(0).map(bufferInitializer),
16
+ // eslint-disable-next-line react-hooks/exhaustive-deps
17
+ [size]
18
+ );
19
+ const transforms = useSharedValue(buffer);
20
+
21
+ useDerivedValue(() => {
22
+ buffer.forEach((val, index) => {
23
+ modifier(val, index);
24
+ });
25
+ // Assuming notifyChange is a function that notifies about the change in transforms.
26
+ notifyChange(transforms);
27
+ });
28
+
29
+ return transforms;
30
+ };
31
+
32
+ export const useRectBuffer = (
33
+ size: number,
34
+ modifier: (input: SkHostRect, index: number) => void
35
+ ) => useBuffer(size, () => Skia.XYWHRect(0, 0, 0, 0), modifier);
36
+
37
+ // Usage for RSXform Buffer
38
+ export const useRSXformBuffer = (
39
+ size: number,
40
+ modifier: (input: SkRSXform, index: number) => void
41
+ ) => useBuffer(size, () => Skia.RSXform(1, 0, 0, 0), modifier);
42
+
43
+ // Usage for Point Buffer
44
+ export const usePointBuffer = (
45
+ size: number,
46
+ modifier: (input: SkPoint, index: number) => void
47
+ ) => useBuffer(size, () => Skia.Point(0, 0), modifier);
48
+
49
+ // Usage for Color Buffer
50
+ export const useColorBuffer = (
51
+ size: number,
52
+ modifier: (input: SkColor, index: number) => void
53
+ ) => useBuffer(size, () => Skia.Color("black"), modifier);
@@ -3,3 +3,4 @@ export * from "./useDerivedValueOnJS";
3
3
  export * from "./renderHelpers";
4
4
  export * from "./interpolators";
5
5
  export * from "./textures";
6
+ export * from "./buffers";
@@ -2,33 +2,21 @@ import { useEffect, useMemo } from "react";
2
2
  import type { ReactElement } from "react";
3
3
  import type { SharedValue } from "react-native-reanimated";
4
4
 
5
- import { Skia } from "../../skia";
6
5
  import type { SkImage, SkPicture, SkSize } from "../../skia/types";
7
- import { drawAsPicture } from "../../renderer/Offscreen";
6
+ import {
7
+ drawAsImageFromPicture,
8
+ drawAsPicture,
9
+ } from "../../renderer/Offscreen";
8
10
 
9
11
  import { runOnUI, useSharedValue } from "./moduleWrapper";
10
12
 
11
- // TODO: We're not sure yet why PixelRatio is not needed here.
12
- const pd = 1; //Platform.PixelRatio;
13
-
14
- const createTexture = (
13
+ const createTextureValue = (
15
14
  texture: SharedValue<SkImage | null>,
16
15
  picture: SkPicture,
17
16
  size: SkSize
18
17
  ) => {
19
18
  "worklet";
20
- const surface = Skia.Surface.MakeOffscreen(
21
- size.width * pd,
22
- size.height * pd
23
- )!;
24
- const canvas = surface.getCanvas();
25
- // see comment above
26
- //canvas.save();
27
- //canvas.scale(pd, pd);
28
- canvas.drawPicture(picture);
29
- //canvas.restore();
30
- surface.flush();
31
- texture.value = surface.makeImageSnapshot();
19
+ texture.value = drawAsImageFromPicture(picture, size);
32
20
  };
33
21
 
34
22
  export const useTextureValue = (element: ReactElement, size: SkSize) => {
@@ -44,7 +32,7 @@ export const useTextureValueFromPicture = (
44
32
  ) => {
45
33
  const texture = useSharedValue<SkImage | null>(null);
46
34
  useEffect(() => {
47
- runOnUI(createTexture)(texture, picture, size);
35
+ runOnUI(createTextureValue)(texture, picture, size);
48
36
  }, [texture, picture, size]);
49
37
  return texture;
50
38
  };
@@ -1,3 +1,4 @@
1
+ import { useEffect } from "react";
1
2
  import type { FrameInfo } from "react-native-reanimated";
2
3
 
3
4
  import { useAnimatedImage } from "../../skia/core/AnimatedImage";
@@ -15,10 +16,14 @@ export const useAnimatedImageValue = (source: DataSourceParam) => {
15
16
  throwOnMissingReanimated();
16
17
  const currentFrame = useSharedValue<null | SkImage>(null);
17
18
  const lastTimestamp = useSharedValue(0);
18
- const animatedImage = useAnimatedImage(source, (err) => {
19
- console.error(err);
20
- throw new Error(`Could not load animated image - got '${err.message}'`);
21
- });
19
+ const animatedImage = useAnimatedImage(
20
+ source,
21
+ (err) => {
22
+ console.error(err);
23
+ throw new Error(`Could not load animated image - got '${err.message}'`);
24
+ },
25
+ false
26
+ );
22
27
  const frameDuration =
23
28
  animatedImage?.currentFrameDuration() || DEFAULT_FRAME_DURATION;
24
29
 
@@ -47,5 +52,11 @@ export const useAnimatedImageValue = (source: DataSourceParam) => {
47
52
  lastTimestamp.value = timestamp;
48
53
  // eslint-disable-next-line react-hooks/exhaustive-deps
49
54
  }, true);
55
+ useEffect(() => {
56
+ return () => {
57
+ animatedImage?.dispose();
58
+ };
59
+ // eslint-disable-next-line react-hooks/exhaustive-deps
60
+ }, []);
50
61
  return currentFrame;
51
62
  };
package/src/mock/index.ts CHANGED
@@ -33,6 +33,11 @@ export const Mock = (CanvasKit: CanvasKit) => {
33
33
  usePathInterpolation: NoopSharedValue,
34
34
  useTextureValue: NoopSharedValue,
35
35
  useTextureValueFromPicture: NoopSharedValue,
36
+ useRSXformBuffer: NoopSharedValue,
37
+ usePointBuffer: NoopSharedValue,
38
+ useColorBuffer: NoopSharedValue,
39
+ useRectBuffer: NoopSharedValue,
40
+ useBuffer: NoopSharedValue,
36
41
  useRawData: Noop,
37
42
  useData: Noop,
38
43
  useFont: () => Skia.Font(undefined, 0),
@@ -50,6 +50,7 @@ import type {
50
50
  BoxProps,
51
51
  BoxShadowProps,
52
52
  ParagraphProps,
53
+ AtlasProps,
53
54
  } from "../dom/types";
54
55
  import type { ChildrenProps } from "../dom/types/Common";
55
56
  import type {
@@ -69,7 +70,6 @@ export const NATIVE_DOM = shouldUseJSDomOnNative ? false : !!global.SkiaDomApi;
69
70
 
70
71
  declare global {
71
72
  var SkiaDomApi: {
72
- // FIXME: We need a better type for this
73
73
  RectNode: (props: RectProps) => JsiDrawingNode<RectProps, SkRect>;
74
74
  RRectNode: (
75
75
  props: RoundedRectProps
@@ -85,6 +85,8 @@ declare global {
85
85
  PatchNode: (props: PatchProps) => RenderNode<PatchProps>;
86
86
  PointsNode: (props: PointsProps) => RenderNode<PointsProps>;
87
87
  DiffRectNode: (props: DiffRectProps) => RenderNode<DiffRectProps>;
88
+ AtlasNode: (props: AtlasProps) => RenderNode<AtlasProps>;
89
+
88
90
  // Mask filters
89
91
  BlurMaskFilterNode: (
90
92
  props: BlurMaskFilterProps
@@ -207,6 +209,7 @@ declare global {
207
209
  skPoints: SkiaProps<PointsProps>;
208
210
  skRect: SkiaProps<RectProps>;
209
211
  skRRect: SkiaProps<RoundedRectProps>;
212
+ skAtlas: SkiaProps<AtlasProps>;
210
213
  skVertices: SkiaProps<VerticesProps>;
211
214
  skText: SkiaProps<TextProps>;
212
215
  skTextPath: SkiaProps<TextPathProps>;
@@ -313,6 +316,8 @@ export const createNode = (
313
316
  return Sk.TextBlob(props);
314
317
  case NodeType.Glyphs:
315
318
  return Sk.Glyphs(props);
319
+ case NodeType.Atlas:
320
+ return Sk.Atlas(props);
316
321
  case NodeType.DiffRect:
317
322
  return Sk.DiffRect(props);
318
323
  case NodeType.Picture: