@shopify/react-native-skia 1.0.3 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. package/android/README.md +14 -0
  2. package/android/src/main/java/com/shopify/reactnative/skia/ViewScreenshotService.java +16 -1
  3. package/cpp/skia/include/private/base/README.md +4 -0
  4. package/cpp/skia/include/third_party/vulkan/LICENSE +29 -0
  5. package/cpp/skia/modules/skcms/README.chromium +6 -0
  6. package/cpp/skia/readme.txt +1 -0
  7. package/lib/commonjs/external/reanimated/buffers.js +6 -6
  8. package/lib/commonjs/external/reanimated/buffers.js.map +1 -1
  9. package/lib/commonjs/external/reanimated/moduleWrapper.d.ts +1 -0
  10. package/lib/commonjs/external/reanimated/moduleWrapper.js +4 -3
  11. package/lib/commonjs/external/reanimated/moduleWrapper.js.map +1 -1
  12. package/lib/commonjs/headless/index.d.ts +4 -2
  13. package/lib/commonjs/headless/index.js +11 -18
  14. package/lib/commonjs/headless/index.js.map +1 -1
  15. package/lib/commonjs/renderer/Offscreen.js +1 -0
  16. package/lib/commonjs/renderer/Offscreen.js.map +1 -1
  17. package/lib/commonjs/skia/web/JsiSkImage.d.ts +2 -1
  18. package/lib/commonjs/skia/web/JsiSkImage.js +27 -2
  19. package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
  20. package/lib/commonjs/skia/web/JsiSkSurface.d.ts +2 -1
  21. package/lib/commonjs/skia/web/JsiSkSurface.js +5 -1
  22. package/lib/commonjs/skia/web/JsiSkSurface.js.map +1 -1
  23. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js +13 -2
  24. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js.map +1 -1
  25. package/lib/module/external/reanimated/buffers.js +7 -7
  26. package/lib/module/external/reanimated/buffers.js.map +1 -1
  27. package/lib/module/external/reanimated/moduleWrapper.d.ts +1 -0
  28. package/lib/module/external/reanimated/moduleWrapper.js +3 -2
  29. package/lib/module/external/reanimated/moduleWrapper.js.map +1 -1
  30. package/lib/module/headless/index.d.ts +4 -2
  31. package/lib/module/headless/index.js +9 -3
  32. package/lib/module/headless/index.js.map +1 -1
  33. package/lib/module/renderer/Offscreen.js +1 -0
  34. package/lib/module/renderer/Offscreen.js.map +1 -1
  35. package/lib/module/skia/web/JsiSkImage.d.ts +2 -1
  36. package/lib/module/skia/web/JsiSkImage.js +27 -2
  37. package/lib/module/skia/web/JsiSkImage.js.map +1 -1
  38. package/lib/module/skia/web/JsiSkSurface.d.ts +2 -1
  39. package/lib/module/skia/web/JsiSkSurface.js +5 -1
  40. package/lib/module/skia/web/JsiSkSurface.js.map +1 -1
  41. package/lib/module/skia/web/JsiSkSurfaceFactory.js +13 -2
  42. package/lib/module/skia/web/JsiSkSurfaceFactory.js.map +1 -1
  43. package/lib/typescript/src/external/reanimated/moduleWrapper.d.ts +1 -0
  44. package/lib/typescript/src/headless/index.d.ts +4 -2
  45. package/lib/typescript/src/skia/web/JsiSkImage.d.ts +2 -1
  46. package/lib/typescript/src/skia/web/JsiSkSurface.d.ts +2 -1
  47. package/package.json +2 -3
  48. package/react-native-skia.podspec +1 -1
  49. package/src/external/reanimated/buffers.ts +11 -9
  50. package/src/external/reanimated/moduleWrapper.ts +2 -0
  51. package/src/headless/index.ts +9 -4
  52. package/src/renderer/Offscreen.tsx +1 -0
  53. package/src/skia/web/JsiSkImage.ts +36 -5
  54. package/src/skia/web/JsiSkSurface.ts +8 -1
  55. package/src/skia/web/JsiSkSurfaceFactory.ts +17 -2
@@ -11,12 +11,19 @@ export class JsiSkSurface
11
11
  extends HostObject<Surface, "Surface">
12
12
  implements SkSurface
13
13
  {
14
- constructor(CanvasKit: CanvasKit, ref: Surface) {
14
+ constructor(
15
+ CanvasKit: CanvasKit,
16
+ ref: Surface,
17
+ private releaseCtx?: () => void
18
+ ) {
15
19
  super(CanvasKit, ref, "Surface");
16
20
  }
17
21
 
18
22
  dispose = () => {
19
23
  this.ref.delete();
24
+ if (this.releaseCtx) {
25
+ this.releaseCtx();
26
+ }
20
27
  };
21
28
 
22
29
  flush() {
@@ -11,11 +11,26 @@ export class JsiSkSurfaceFactory extends Host implements SurfaceFactory {
11
11
  }
12
12
 
13
13
  Make(width: number, height: number) {
14
- const surface = this.CanvasKit.MakeSurface(width, height);
14
+ var pixelLen = width * height * 4;
15
+ const pixelPtr = this.CanvasKit.Malloc(Uint8Array, pixelLen);
16
+ const surface = this.CanvasKit.MakeRasterDirectSurface(
17
+ {
18
+ width: width,
19
+ height: height,
20
+ colorType: this.CanvasKit.ColorType.RGBA_8888,
21
+ alphaType: this.CanvasKit.AlphaType.Unpremul,
22
+ colorSpace: this.CanvasKit.ColorSpace.SRGB,
23
+ },
24
+ pixelPtr,
25
+ width * 4
26
+ );
15
27
  if (!surface) {
16
28
  return null;
17
29
  }
18
- return new JsiSkSurface(this.CanvasKit, surface);
30
+ surface.getCanvas().clear(this.CanvasKit.TRANSPARENT);
31
+ return new JsiSkSurface(this.CanvasKit, surface, () => {
32
+ this.CanvasKit.Free(pixelPtr);
33
+ });
19
34
  }
20
35
 
21
36
  MakeOffscreen(width: number, height: number) {