@shopify/react-native-skia 2.0.0-next.3 → 2.0.0-next.4

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 (139) hide show
  1. package/cpp/skia/include/codec/SkCodec.h +39 -1
  2. package/cpp/skia/include/config/SkUserConfig.h +1 -10
  3. package/cpp/skia/include/core/SkCanvas.h +8 -4
  4. package/cpp/skia/include/core/SkContourMeasure.h +2 -2
  5. package/cpp/skia/include/core/SkMilestone.h +1 -1
  6. package/cpp/skia/include/core/SkPaint.h +8 -5
  7. package/cpp/skia/include/core/SkStream.h +8 -3
  8. package/cpp/skia/include/core/SkTextBlob.h +9 -9
  9. package/cpp/skia/include/core/SkTypeface.h +4 -6
  10. package/cpp/skia/include/core/SkTypes.h +5 -0
  11. package/cpp/skia/include/docs/SkPDFDocument.h +47 -2
  12. package/cpp/skia/include/docs/SkPDFJpegHelpers.h +41 -0
  13. package/cpp/skia/include/effects/SkRuntimeEffect.h +5 -1
  14. package/cpp/skia/include/effects/SkTableMaskFilter.h +4 -0
  15. package/cpp/skia/include/gpu/graphite/BackendTexture.h +0 -2
  16. package/cpp/skia/include/gpu/graphite/ContextOptions.h +17 -0
  17. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +21 -18
  18. package/cpp/skia/include/gpu/graphite/PrecompileContext.h +24 -0
  19. package/cpp/skia/include/gpu/graphite/TextureInfo.h +87 -42
  20. package/cpp/skia/include/gpu/graphite/YUVABackendTextures.h +13 -4
  21. package/cpp/skia/include/gpu/graphite/dawn/DawnBackendContext.h +9 -0
  22. package/cpp/skia/include/gpu/graphite/dawn/DawnGraphiteTypes.h +166 -0
  23. package/cpp/skia/include/gpu/graphite/dawn/DawnTypes.h +3 -141
  24. package/cpp/skia/include/gpu/graphite/dawn/DawnUtils.h +2 -21
  25. package/cpp/skia/include/gpu/graphite/mtl/MtlBackendContext.h +4 -0
  26. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +30 -6
  27. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypesUtils.h +4 -42
  28. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes_cpp.h +50 -0
  29. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteUtils.h +2 -20
  30. package/cpp/skia/include/gpu/graphite/precompile/Precompile.h +14 -4
  31. package/cpp/skia/include/gpu/graphite/precompile/PrecompileShader.h +14 -6
  32. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteContext.h +31 -0
  33. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +36 -14
  34. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteUtils.h +3 -21
  35. package/cpp/skia/include/ports/SkTypeface_fontations.h +3 -0
  36. package/cpp/skia/include/private/SkJpegMetadataDecoder.h +7 -0
  37. package/cpp/skia/include/private/base/SkAnySubclass.h +6 -0
  38. package/cpp/skia/include/private/chromium/SkPMColor.h +38 -0
  39. package/cpp/skia/modules/skparagraph/include/Paragraph.h +2 -2
  40. package/cpp/skia/modules/skunicode/include/SkUnicode.h +10 -6
  41. package/cpp/skia/modules/svg/include/SkSVGDOM.h +1 -3
  42. package/cpp/skia/src/base/SkTInternalLList.h +1 -1
  43. package/cpp/skia/src/core/SkLRUCache.h +6 -3
  44. package/lib/commonjs/external/reanimated/textures.d.ts +2 -4
  45. package/lib/commonjs/external/reanimated/textures.js +8 -15
  46. package/lib/commonjs/external/reanimated/textures.js.map +1 -1
  47. package/lib/commonjs/sksg/HostConfig.js +2 -1
  48. package/lib/commonjs/sksg/HostConfig.js.map +1 -1
  49. package/lib/module/external/reanimated/textures.d.ts +2 -4
  50. package/lib/module/external/reanimated/textures.js +7 -12
  51. package/lib/module/external/reanimated/textures.js.map +1 -1
  52. package/lib/module/sksg/HostConfig.js +2 -1
  53. package/lib/module/sksg/HostConfig.js.map +1 -1
  54. package/lib/typescript/lib/commonjs/external/reanimated/textures.d.ts +1 -3
  55. package/lib/typescript/lib/commonjs/sksg/HostConfig.d.ts +1 -1
  56. package/lib/typescript/lib/module/external/reanimated/textures.d.ts +1 -3
  57. package/lib/typescript/lib/module/sksg/HostConfig.d.ts +1 -1
  58. package/lib/typescript/src/external/reanimated/textures.d.ts +2 -4
  59. package/libs/android/arm64-v8a/libskia.a +0 -0
  60. package/libs/android/arm64-v8a/libskottie.a +0 -0
  61. package/libs/android/arm64-v8a/libskparagraph.a +0 -0
  62. package/libs/android/arm64-v8a/libsksg.a +0 -0
  63. package/libs/android/arm64-v8a/libskshaper.a +0 -0
  64. package/libs/android/arm64-v8a/libskunicode_icu.a +0 -0
  65. package/libs/android/arm64-v8a/libsvg.a +0 -0
  66. package/libs/android/armeabi-v7a/libskia.a +0 -0
  67. package/libs/android/armeabi-v7a/libskottie.a +0 -0
  68. package/libs/android/armeabi-v7a/libskparagraph.a +0 -0
  69. package/libs/android/armeabi-v7a/libsksg.a +0 -0
  70. package/libs/android/armeabi-v7a/libskshaper.a +0 -0
  71. package/libs/android/armeabi-v7a/libskunicode_icu.a +0 -0
  72. package/libs/android/armeabi-v7a/libsvg.a +0 -0
  73. package/libs/android/x86/libskia.a +0 -0
  74. package/libs/android/x86/libskottie.a +0 -0
  75. package/libs/android/x86/libskparagraph.a +0 -0
  76. package/libs/android/x86/libsksg.a +0 -0
  77. package/libs/android/x86/libskshaper.a +0 -0
  78. package/libs/android/x86/libskunicode_icu.a +0 -0
  79. package/libs/android/x86/libsvg.a +0 -0
  80. package/libs/android/x86_64/libskia.a +0 -0
  81. package/libs/android/x86_64/libskottie.a +0 -0
  82. package/libs/android/x86_64/libskparagraph.a +0 -0
  83. package/libs/android/x86_64/libsksg.a +0 -0
  84. package/libs/android/x86_64/libskshaper.a +0 -0
  85. package/libs/android/x86_64/libskunicode_icu.a +0 -0
  86. package/libs/android/x86_64/libsvg.a +0 -0
  87. package/libs/apple/libskia.xcframework/Info.plist +15 -15
  88. package/libs/apple/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  89. package/libs/apple/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  90. package/libs/apple/libskia.xcframework/macos-arm64_x86_64/libskia.a +0 -0
  91. package/libs/apple/libskia.xcframework/tvos-arm64_arm64e/libskia.a +0 -0
  92. package/libs/apple/libskia.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  93. package/libs/apple/libskottie.xcframework/Info.plist +7 -7
  94. package/libs/apple/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
  95. package/libs/apple/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  96. package/libs/apple/libskottie.xcframework/macos-arm64_x86_64/libskottie.a +0 -0
  97. package/libs/apple/libskottie.xcframework/tvos-arm64_arm64e/libskottie.a +0 -0
  98. package/libs/apple/libskottie.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  99. package/libs/apple/libskparagraph.xcframework/Info.plist +13 -13
  100. package/libs/apple/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
  101. package/libs/apple/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
  102. package/libs/apple/libskparagraph.xcframework/macos-arm64_x86_64/libskparagraph.a +0 -0
  103. package/libs/apple/libskparagraph.xcframework/tvos-arm64_arm64e/libskparagraph.a +0 -0
  104. package/libs/apple/libskparagraph.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
  105. package/libs/apple/libsksg.xcframework/Info.plist +13 -13
  106. package/libs/apple/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
  107. package/libs/apple/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  108. package/libs/apple/libsksg.xcframework/macos-arm64_x86_64/libsksg.a +0 -0
  109. package/libs/apple/libsksg.xcframework/tvos-arm64_arm64e/libsksg.a +0 -0
  110. package/libs/apple/libsksg.xcframework/tvos-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  111. package/libs/apple/libskshaper.xcframework/Info.plist +14 -14
  112. package/libs/apple/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  113. package/libs/apple/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  114. package/libs/apple/libskshaper.xcframework/macos-arm64_x86_64/libskshaper.a +0 -0
  115. package/libs/apple/libskshaper.xcframework/tvos-arm64_arm64e/libskshaper.a +0 -0
  116. package/libs/apple/libskshaper.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  117. package/libs/apple/libskunicode_core.xcframework/Info.plist +12 -12
  118. package/libs/apple/libskunicode_core.xcframework/ios-arm64_arm64e/libskunicode_core.a +0 -0
  119. package/libs/apple/libskunicode_core.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_core.a +0 -0
  120. package/libs/apple/libskunicode_core.xcframework/macos-arm64_x86_64/libskunicode_core.a +0 -0
  121. package/libs/apple/libskunicode_core.xcframework/tvos-arm64_arm64e/libskunicode_core.a +0 -0
  122. package/libs/apple/libskunicode_core.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskunicode_core.a +0 -0
  123. package/libs/apple/libskunicode_libgrapheme.xcframework/Info.plist +15 -15
  124. package/libs/apple/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
  125. package/libs/apple/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_libgrapheme.a +0 -0
  126. package/libs/apple/libskunicode_libgrapheme.xcframework/macos-arm64_x86_64/libskunicode_libgrapheme.a +0 -0
  127. package/libs/apple/libskunicode_libgrapheme.xcframework/tvos-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
  128. package/libs/apple/libskunicode_libgrapheme.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskunicode_libgrapheme.a +0 -0
  129. package/libs/apple/libsvg.xcframework/Info.plist +8 -8
  130. package/libs/apple/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  131. package/libs/apple/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  132. package/libs/apple/libsvg.xcframework/macos-arm64_x86_64/libsvg.a +0 -0
  133. package/libs/apple/libsvg.xcframework/tvos-arm64_arm64e/libsvg.a +0 -0
  134. package/libs/apple/libsvg.xcframework/tvos-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  135. package/package.json +1 -1
  136. package/src/external/reanimated/textures.tsx +12 -20
  137. package/src/sksg/HostConfig.ts +2 -1
  138. package/cpp/skia/include/core/SkColorPriv.h +0 -165
  139. package/cpp/skia/include/private/SkColorData.h +0 -385
@@ -1,48 +1,10 @@
1
1
  /*
2
- * Copyright 2024 Google LLC
2
+ * Copyright 2022 Google LLC
3
3
  *
4
4
  * Use of this source code is governed by a BSD-style license that can be
5
5
  * found in the LICENSE file.
6
6
  */
7
7
 
8
- #ifndef skgpu_graphite_MtlGraphiteTypesUtils_DEFINED
9
- #define skgpu_graphite_MtlGraphiteTypesUtils_DEFINED
10
-
11
- #include "include/core/SkTypes.h"
12
-
13
- #include "include/gpu/graphite/BackendTexture.h"
14
- #include "include/gpu/graphite/TextureInfo.h"
15
- #include "include/private/base/SkAPI.h"
16
-
17
- #import <CoreFoundation/CoreFoundation.h>
18
-
19
- namespace skgpu::graphite {
20
-
21
- struct SK_API MtlTextureInfo;
22
-
23
- namespace TextureInfos {
24
- SK_API TextureInfo MakeMetal(const MtlTextureInfo&);
25
- SK_API TextureInfo MakeMetal(CFTypeRef mtlTexture);
26
-
27
- SK_API bool GetMtlTextureInfo(const TextureInfo&, MtlTextureInfo*);
28
- } // namespace TextureInfos
29
-
30
- namespace BackendTextures {
31
- // The BackendTexture will not call retain or release on the passed in CFTypeRef. Thus the
32
- // client must keep the CFTypeRef valid until they are no longer using the BackendTexture.
33
- SK_API BackendTexture MakeMetal(SkISize dimensions, CFTypeRef mtlTexture);
34
-
35
- SK_API CFTypeRef GetMtlTexture(const BackendTexture&);
36
- } // namespace BackendTextures
37
-
38
- namespace BackendSemaphores {
39
- // TODO(b/286088355) Determine creator's responsibility for setting refcnt.
40
- SK_API BackendSemaphore MakeMetal(CFTypeRef mtlEvent, uint64_t value);
41
-
42
- SK_API CFTypeRef GetMtlEvent(const BackendSemaphore&);
43
- SK_API uint64_t GetMtlValue(const BackendSemaphore&);
44
- } // namespace BackendSemaphores
45
-
46
- } // namespace skgpu::graphite
47
-
48
- #endif // skgpu_graphite_MtlGraphiteTypesUtils_DEFINED
8
+ // DEPRECRATED: MtlGraphiteTypesUtils.h will be removed in the future, please include
9
+ // MtlGraphiteTypes_cpp.h
10
+ #include "include/gpu/graphite/mtl/MtlGraphiteTypes_cpp.h"
@@ -0,0 +1,50 @@
1
+ /*
2
+ * Copyright 2024 Google LLC
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+
8
+ #ifndef skgpu_graphite_MtlGraphiteTypesUtils_DEFINED
9
+ #define skgpu_graphite_MtlGraphiteTypesUtils_DEFINED
10
+
11
+ #include "include/core/SkTypes.h"
12
+
13
+ #include "include/gpu/graphite/BackendTexture.h"
14
+ #include "include/gpu/graphite/TextureInfo.h"
15
+ #include "include/private/base/SkAPI.h"
16
+
17
+ #import <CoreFoundation/CoreFoundation.h>
18
+
19
+ namespace skgpu::graphite {
20
+
21
+ // MtlTextureInfo requires compiling with Objective-C, so this header is split to allow invoking
22
+ // the various backend wrapping APIs from a C++-only compilation unit.
23
+ class SK_API MtlTextureInfo;
24
+
25
+ namespace TextureInfos {
26
+ SK_API TextureInfo MakeMetal(const MtlTextureInfo&);
27
+ SK_API TextureInfo MakeMetal(CFTypeRef mtlTexture);
28
+
29
+ SK_API bool GetMtlTextureInfo(const TextureInfo&, MtlTextureInfo*);
30
+ } // namespace TextureInfos
31
+
32
+ namespace BackendTextures {
33
+ // The BackendTexture will not call retain or release on the passed in CFTypeRef. Thus the
34
+ // client must keep the CFTypeRef valid until they are no longer using the BackendTexture.
35
+ SK_API BackendTexture MakeMetal(SkISize dimensions, CFTypeRef mtlTexture);
36
+
37
+ SK_API CFTypeRef GetMtlTexture(const BackendTexture&);
38
+ } // namespace BackendTextures
39
+
40
+ namespace BackendSemaphores {
41
+ // TODO(b/286088355) Determine creator's responsibility for setting refcnt.
42
+ SK_API BackendSemaphore MakeMetal(CFTypeRef mtlEvent, uint64_t value);
43
+
44
+ SK_API CFTypeRef GetMtlEvent(const BackendSemaphore&);
45
+ SK_API uint64_t GetMtlValue(const BackendSemaphore&);
46
+ } // namespace BackendSemaphores
47
+
48
+ } // namespace skgpu::graphite
49
+
50
+ #endif // skgpu_graphite_MtlGraphiteTypesUtils_DEFINED
@@ -5,23 +5,5 @@
5
5
  * found in the LICENSE file.
6
6
  */
7
7
 
8
- #ifndef skgpu_graphite_MtlGraphiteUtils_DEFINED
9
- #define skgpu_graphite_MtlGraphiteUtils_DEFINED
10
-
11
- #include <memory>
12
-
13
- #include "include/private/base/SkAPI.h"
14
-
15
- namespace skgpu::graphite {
16
-
17
- class Context;
18
- struct ContextOptions;
19
- struct MtlBackendContext;
20
-
21
- namespace ContextFactory {
22
- SK_API std::unique_ptr<Context> MakeMetal(const MtlBackendContext&, const ContextOptions&);
23
- } // namespace ContextFactory
24
-
25
- } // namespace skgpu::graphite
26
-
27
- #endif // skgpu_graphite_MtlGraphiteUtils_DEFINED
8
+ // DEPRECRATED: MtlGraphiteUtils.h will be removed in the future, please include MtlBackendContext.h
9
+ #include "include/gpu/graphite/mtl/MtlBackendContext.h"
@@ -8,12 +8,13 @@
8
8
  #ifndef skgpu_graphite_precompile_Precompile_DEFINED
9
9
  #define skgpu_graphite_precompile_Precompile_DEFINED
10
10
 
11
+ #include "include/core/SkColorSpace.h"
12
+ #include "include/core/SkColorType.h"
11
13
  #include "include/core/SkSpan.h"
12
14
  #include "include/gpu/graphite/GraphiteTypes.h"
13
15
 
14
16
  namespace skgpu::graphite {
15
17
 
16
- class Context;
17
18
  class PaintOptions;
18
19
  class PrecompileContext;
19
20
 
@@ -23,9 +24,18 @@ class PrecompileContext;
23
24
  * a pipeline.
24
25
  */
25
26
  struct SK_API RenderPassProperties {
26
- DepthStencilFlags fDSFlags = DepthStencilFlags::kNone;
27
- SkColorType fDstCT = kRGBA_8888_SkColorType;
28
- bool fRequiresMSAA = false;
27
+ bool operator==(const RenderPassProperties& other) const {
28
+ return fDSFlags == other.fDSFlags &&
29
+ fDstCT == other.fDstCT &&
30
+ fRequiresMSAA == other.fRequiresMSAA &&
31
+ SkColorSpace::Equals(fDstCS.get(), other.fDstCS.get());
32
+ }
33
+ bool operator!= (const RenderPassProperties& other) const { return !(*this == other); }
34
+
35
+ DepthStencilFlags fDSFlags = DepthStencilFlags::kNone;
36
+ SkColorType fDstCT = kRGBA_8888_SkColorType;
37
+ sk_sp<SkColorSpace> fDstCS = nullptr;
38
+ bool fRequiresMSAA = false;
29
39
  };
30
40
 
31
41
  /**
@@ -11,6 +11,8 @@
11
11
  #include "include/gpu/graphite/precompile/PrecompileBase.h"
12
12
 
13
13
  #include "include/core/SkBlendMode.h"
14
+ #include "include/core/SkImageInfo.h"
15
+ #include "include/effects/SkGradientShader.h"
14
16
 
15
17
  class SkColorSpace;
16
18
 
@@ -109,11 +111,13 @@ namespace PrecompileShaders {
109
111
  // time this entry point allows the equivalent precompilation program structure to be created.
110
112
  // Note that this factory is for non-YUV SkImages, the YUVImage factory (below) should be used
111
113
  // to represent the shading and sampling required for YUV images.
112
- SK_API sk_sp<PrecompileShader> Image();
114
+ SK_API sk_sp<PrecompileShader> Image(SkSpan<const SkColorInfo> = {},
115
+ SkSpan<const SkTileMode> = {});
113
116
  // As with the above Image call, raw ImageShaders are usually created via an
114
117
  // SkImage::makeRawShader call. The RawImage call allows the equivalent precompilation
115
118
  // program structure to be created without needing the SkImage.
116
- SK_API sk_sp<PrecompileShader> RawImage();
119
+ SK_API sk_sp<PrecompileShader> RawImage(SkSpan<const SkColorInfo> = {},
120
+ SkSpan<const SkTileMode> = {});
117
121
 
118
122
  // In the main Skia API, the specifics of the SkImage used for the SkImage::makeShader call
119
123
  // can determine whether normal or YUV sampling is required. This entry point allows clients
@@ -126,10 +130,14 @@ namespace PrecompileShaders {
126
130
  SK_API sk_sp<PrecompileShader> MakeTurbulence();
127
131
 
128
132
  // --- This block of four matches all the factories in SkGradientShader (SkGradientShader.h)
129
- SK_API sk_sp<PrecompileShader> LinearGradient();
130
- SK_API sk_sp<PrecompileShader> RadialGradient();
131
- SK_API sk_sp<PrecompileShader> TwoPointConicalGradient();
132
- SK_API sk_sp<PrecompileShader> SweepGradient();
133
+ SK_API sk_sp<PrecompileShader> LinearGradient(
134
+ SkGradientShader::Interpolation = SkGradientShader::Interpolation());
135
+ SK_API sk_sp<PrecompileShader> RadialGradient(
136
+ SkGradientShader::Interpolation = SkGradientShader::Interpolation());
137
+ SK_API sk_sp<PrecompileShader> TwoPointConicalGradient(
138
+ SkGradientShader::Interpolation = SkGradientShader::Interpolation());
139
+ SK_API sk_sp<PrecompileShader> SweepGradient(
140
+ SkGradientShader::Interpolation = SkGradientShader::Interpolation());
133
141
 
134
142
  // Normally, SkPicture shaders are only created via SkPicture::makeShader. Since the
135
143
  // SkPicture to be drawn, most likely, won't be available at precompilation time, this
@@ -0,0 +1,31 @@
1
+ /*
2
+ * Copyright 2022 Google LLC
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+
8
+ #ifndef skgpu_graphite_VulkanGraphiteUtils_DEFINED
9
+ #define skgpu_graphite_VulkanGraphiteUtils_DEFINED
10
+
11
+ #include <memory>
12
+
13
+ #include "include/private/base/SkAPI.h"
14
+
15
+ // NOTE: Because there is already a VulkanBackendContext header shared between Ganesh and Graphite,
16
+ // this is named VulkanGraphiteContext.h to supply just the factory function (differing from the
17
+ // public headers exposed by other backends).
18
+ namespace skgpu { struct VulkanBackendContext; }
19
+
20
+ namespace skgpu::graphite {
21
+
22
+ class Context;
23
+ struct ContextOptions;
24
+
25
+ namespace ContextFactory {
26
+ SK_API std::unique_ptr<Context> MakeVulkan(const VulkanBackendContext&, const ContextOptions&);
27
+ } // namespace ContextFactory
28
+
29
+ } // namespace skgpu::graphite
30
+
31
+ #endif // skgpu_graphite_VulkanGraphiteUtils_DEFINED
@@ -13,20 +13,21 @@
13
13
  #include "include/gpu/graphite/TextureInfo.h"
14
14
  #include "include/gpu/vk/VulkanTypes.h"
15
15
 
16
- namespace skgpu::graphite {
16
+ class SkStream;
17
+ class SkWStream;
17
18
 
18
- struct VulkanTextureInfo {
19
- uint32_t fSampleCount = 1;
20
- Mipmapped fMipmapped = Mipmapped::kNo;
19
+ namespace skgpu::graphite {
21
20
 
21
+ class SK_API VulkanTextureInfo final : public TextureInfo::Data {
22
+ public:
22
23
  // VkImageCreateInfo properties
23
24
  // Currently the only supported flag is VK_IMAGE_CREATE_PROTECTED_BIT. Any other flag will not
24
25
  // be accepted
25
- VkImageCreateFlags fFlags = 0;
26
- VkFormat fFormat = VK_FORMAT_UNDEFINED;
27
- VkImageTiling fImageTiling = VK_IMAGE_TILING_OPTIMAL;
28
- VkImageUsageFlags fImageUsageFlags = 0;
29
- VkSharingMode fSharingMode = VK_SHARING_MODE_EXCLUSIVE;
26
+ VkImageCreateFlags fFlags = 0;
27
+ VkFormat fFormat = VK_FORMAT_UNDEFINED;
28
+ VkImageTiling fImageTiling = VK_IMAGE_TILING_OPTIMAL;
29
+ VkImageUsageFlags fImageUsageFlags = 0;
30
+ VkSharingMode fSharingMode = VK_SHARING_MODE_EXCLUSIVE;
30
31
 
31
32
  // Properties related to the image view and sampling. These are less inherent properties of the
32
33
  // VkImage but describe how the VkImage should be used within Skia.
@@ -35,8 +36,8 @@ struct VulkanTextureInfo {
35
36
  // However, if the VkImage is a Ycbcr format, the client can pass a specific plan here to have
36
37
  // Skia directly sample a plane. In that case the client should also pass in a VkFormat that is
37
38
  // compatible with the plane as described by the Vulkan spec.
38
- VkImageAspectFlags fAspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
39
- VulkanYcbcrConversionInfo fYcbcrConversionInfo;
39
+ VkImageAspectFlags fAspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
40
+ VulkanYcbcrConversionInfo fYcbcrConversionInfo;
40
41
 
41
42
  VulkanTextureInfo() = default;
42
43
  VulkanTextureInfo(uint32_t sampleCount,
@@ -48,8 +49,7 @@ struct VulkanTextureInfo {
48
49
  VkSharingMode sharingMode,
49
50
  VkImageAspectFlags aspectMask,
50
51
  VulkanYcbcrConversionInfo ycbcrConversionInfo)
51
- : fSampleCount(sampleCount)
52
- , fMipmapped(mipmapped)
52
+ : Data(sampleCount, mipmapped)
53
53
  , fFlags(flags)
54
54
  , fFormat(format)
55
55
  , fImageTiling(imageTiling)
@@ -57,6 +57,29 @@ struct VulkanTextureInfo {
57
57
  , fSharingMode(sharingMode)
58
58
  , fAspectMask(aspectMask)
59
59
  , fYcbcrConversionInfo(ycbcrConversionInfo) {}
60
+
61
+ private:
62
+ friend class TextureInfo;
63
+ friend class TextureInfoPriv;
64
+
65
+ // Non-virtual template API for TextureInfo::Data accessed directly when backend type is known.
66
+ static constexpr skgpu::BackendApi kBackend = skgpu::BackendApi::kVulkan;
67
+
68
+ Protected isProtected() const {
69
+ return fFlags & VK_IMAGE_CREATE_PROTECTED_BIT ? Protected::kYes : Protected::kNo;
70
+ }
71
+ TextureFormat viewFormat() const;
72
+
73
+ bool serialize(SkWStream*) const;
74
+ bool deserialize(SkStream*);
75
+
76
+ // Virtual API when the specific backend type is not available.
77
+ SkString toBackendString() const override;
78
+
79
+ void copyTo(TextureInfo::AnyTextureInfoData& dstData) const override {
80
+ dstData.emplace<VulkanTextureInfo>(*this);
81
+ }
82
+ bool isCompatible(const TextureInfo& that, bool requireExact) const override;
60
83
  };
61
84
 
62
85
  namespace TextureInfos {
@@ -78,7 +101,6 @@ namespace BackendSemaphores {
78
101
  SK_API BackendSemaphore MakeVulkan(VkSemaphore);
79
102
 
80
103
  SK_API VkSemaphore GetVkSemaphore(const BackendSemaphore&);
81
-
82
104
  } // namespace BackendSemaphores
83
105
 
84
106
  } // namespace skgpu::graphite
@@ -5,24 +5,6 @@
5
5
  * found in the LICENSE file.
6
6
  */
7
7
 
8
- #ifndef skgpu_graphite_VulkanGraphiteUtils_DEFINED
9
- #define skgpu_graphite_VulkanGraphiteUtils_DEFINED
10
-
11
- #include <memory>
12
-
13
- #include "include/private/base/SkAPI.h"
14
-
15
- namespace skgpu { struct VulkanBackendContext; }
16
-
17
- namespace skgpu::graphite {
18
-
19
- class Context;
20
- struct ContextOptions;
21
-
22
- namespace ContextFactory {
23
- SK_API std::unique_ptr<Context> MakeVulkan(const VulkanBackendContext&, const ContextOptions&);
24
- } // namespace ContextFactory
25
-
26
- } // namespace skgpu::graphite
27
-
28
- #endif // skgpu_graphite_VulkanGraphiteUtils_DEFINED
8
+ // DEPRECRATED: VulkanGraphiteUtils.h will be removed in the future, please include
9
+ // VulkanGraphiteContext.h
10
+ #include "include/gpu/graphite/vk/VulkanGraphiteContext.h"
@@ -18,4 +18,7 @@
18
18
  SK_API sk_sp<SkTypeface> SkTypeface_Make_Fontations(std::unique_ptr<SkStreamAsset> fontData,
19
19
  const SkFontArguments& args);
20
20
 
21
+ SK_API sk_sp<SkTypeface> SkTypeface_Make_Fontations(sk_sp<SkData> fontData,
22
+ const SkFontArguments& args);
23
+
21
24
  #endif
@@ -86,6 +86,13 @@ public:
86
86
  virtual bool findGainmapImage(sk_sp<SkData> baseImageData,
87
87
  sk_sp<SkData>& outGainmapImagedata,
88
88
  SkGainmapInfo& outGainmapInfo) = 0;
89
+
90
+ /**
91
+ * Return the first JUMBF superbox, if any, and nullptr otherwise. If |copyData| is false,
92
+ * then the returned SkData may directly reference the data provided when this object was
93
+ * created.
94
+ */
95
+ virtual sk_sp<SkData> getJUMBFMetadata(bool copyData) const = 0;
89
96
  };
90
97
 
91
98
  #endif
@@ -52,6 +52,9 @@ public:
52
52
  fValid = false;
53
53
  }
54
54
 
55
+ bool has_value() const { return fValid; }
56
+ explicit operator bool() const { return this->has_value(); }
57
+
55
58
  const Base* get() const {
56
59
  SkASSERT(fValid);
57
60
  return std::launder(reinterpret_cast<const Base*>(fData));
@@ -65,6 +68,9 @@ public:
65
68
  Base* operator->() { return this->get(); }
66
69
  const Base* operator->() const { return this->get(); }
67
70
 
71
+ Base& operator*() { return *this->get(); }
72
+ const Base& operator*() const { return *this->get(); }
73
+
68
74
  private:
69
75
  alignas(8) std::byte fData[Size];
70
76
  bool fValid = false;
@@ -0,0 +1,38 @@
1
+ /*
2
+ * Copyright 2025 Google LLC
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+
8
+ #ifndef SkPMColor_DEFINED
9
+ #define SkPMColor_DEFINED
10
+
11
+ #include "include/core/SkColor.h"
12
+ #include "include/private/base/SkAPI.h"
13
+
14
+ #include <cstdint>
15
+
16
+ /** Returns a SkPMColor value from already premultiplied 8-bit component values.
17
+
18
+ @param a amount of alpha, from fully transparent (0) to fully opaque (255)
19
+ @param r amount of red, from no red (0) to full red (255)
20
+ @param g amount of green, from no green (0) to full green (255)
21
+ @param b amount of blue, from no blue (0) to full blue (255)
22
+ @return premultiplied color
23
+ */
24
+ SK_API SkPMColor SkPMColorSetARGB(SkAlpha a, uint8_t r, uint8_t g, uint8_t b);
25
+
26
+ /** Returns alpha component of premultiplied color. */
27
+ SK_API SkAlpha SkPMColorGetA(SkPMColor);
28
+
29
+ /** Returns red component of premultiplied color. */
30
+ SK_API uint8_t SkPMColorGetR(SkPMColor);
31
+
32
+ /** Returns green component of premultiplied color. */
33
+ SK_API uint8_t SkPMColorGetG(SkPMColor);
34
+
35
+ /** Returns blue component of premultiplied color. */
36
+ SK_API uint8_t SkPMColorGetB(SkPMColor);
37
+
38
+ #endif
@@ -88,7 +88,7 @@ public:
88
88
  SkPoint origin;
89
89
  SkScalar advanceX;
90
90
  int count;
91
- const uint16_t* glyphs; // count values
91
+ const SkGlyphID* glyphs; // count values
92
92
  const SkPoint* positions; // count values
93
93
  const uint32_t* utf8Starts; // count+1 values
94
94
  unsigned flags;
@@ -103,7 +103,7 @@ public:
103
103
  SkPoint origin;
104
104
  SkSize advance;
105
105
  int count;
106
- const uint16_t* glyphs; // count values
106
+ const SkGlyphID* glyphs; // count values
107
107
  SkPoint* positions; // count values
108
108
  const SkRect* bounds; // count values
109
109
  const uint32_t* utf8Starts; // count+1 values
@@ -271,18 +271,22 @@ class SKUNICODE_API SkUnicode : public SkRefCnt {
271
271
 
272
272
  SkBidiIterator::Position pos16 = 0;
273
273
  while (pos16 <= iter->getLength()) {
274
- auto level = iter->getLevelAt(pos16);
275
- if (pos16 == 0) {
274
+ uint16_t nextPos16 = start16 - utf16;
275
+ auto level = iter->getLevelAt(nextPos16);
276
+ if (nextPos16 == 0) {
276
277
  currentLevel = level;
277
278
  } else if (level != currentLevel) {
278
- callback(pos16, start16 - utf16, currentLevel);
279
+ callback(pos16, nextPos16, currentLevel);
279
280
  currentLevel = level;
281
+ pos16 = nextPos16;
280
282
  }
281
283
  if (start16 == end16) {
282
- break;
284
+ if (pos16 != nextPos16) {
285
+ callback(pos16, nextPos16, currentLevel);
286
+ }
287
+ return;
283
288
  }
284
- SkUnichar u = SkUTF::NextUTF16(&start16, end16);
285
- pos16 += SkUTF::ToUTF16(u);
289
+ SkUTF::NextUTF16(&start16, end16);
286
290
  }
287
291
  }
288
292
 
@@ -53,9 +53,7 @@ public:
53
53
  sk_sp<SkShapers::Factory> fTextShapingFactory;
54
54
  };
55
55
 
56
- static sk_sp<SkSVGDOM> MakeFromStream(SkStream& str) {
57
- return Builder().make(str);
58
- }
56
+ static sk_sp<SkSVGDOM> MakeFromStream(SkStream& str);
59
57
 
60
58
  /**
61
59
  * Returns the root (outermost) SVG element.
@@ -238,7 +238,7 @@ public:
238
238
  /**
239
239
  * C++11 range-for interface.
240
240
  */
241
- bool operator!=(const Iter& that) { return fCurr != that.fCurr; }
241
+ bool operator!=(const Iter& that) const { return fCurr != that.fCurr; }
242
242
  T* operator*() { return this->get(); }
243
243
  void operator++() { this->next(); }
244
244
 
@@ -14,7 +14,7 @@
14
14
 
15
15
  struct SkNoOpPurge {
16
16
  template <typename K, typename V>
17
- void operator()(const K& /* k */, const V* /* v */) const {}
17
+ void operator()(void* /* context */, const K& /* k */, const V* /* v */) const {}
18
18
  };
19
19
 
20
20
  /**
@@ -35,7 +35,9 @@ private:
35
35
  };
36
36
 
37
37
  public:
38
- explicit SkLRUCache(int maxCount) : fMaxCount(maxCount) {}
38
+ explicit SkLRUCache(int maxCount, void* context = nullptr)
39
+ : fMaxCount(maxCount)
40
+ , fContext(context) {}
39
41
  SkLRUCache() = delete;
40
42
 
41
43
  ~SkLRUCache() {
@@ -111,7 +113,7 @@ public:
111
113
  SkASSERT(value);
112
114
  Entry* entry = *value;
113
115
  SkASSERT(key == entry->fKey);
114
- PurgeCB()(key, &entry->fValue);
116
+ PurgeCB()(fContext, key, &entry->fValue);
115
117
  fMap.remove(key);
116
118
  fLRU.remove(entry);
117
119
  delete entry;
@@ -131,6 +133,7 @@ private:
131
133
  int fMaxCount;
132
134
  skia_private::THashTable<Entry*, K, Traits> fMap;
133
135
  SkTInternalLList<Entry> fLRU;
136
+ void* fContext;
134
137
  };
135
138
 
136
139
  #endif
@@ -1,8 +1,6 @@
1
- import type { ReactElement } from "react";
1
+ import type { DependencyList, ReactElement } from "react";
2
2
  import type { SharedValue } from "react-native-reanimated";
3
3
  import type { DataSourceParam, SkImage, SkPicture, SkSize } from "../../skia/types";
4
- export declare const useTexture: (element: ReactElement, size: SkSize) => SharedValue<SkImage | null>;
5
- export declare const useTextureAsValue: (element: ReactElement, size: SkSize) => SharedValue<SkImage | null>;
6
- export declare const useTextureValueFromPicture: (picture: SkPicture | null, size: SkSize) => SharedValue<SkImage | null>;
4
+ export declare const useTexture: (element: ReactElement, size: SkSize, deps?: DependencyList) => SharedValue<SkImage | null>;
7
5
  export declare const usePictureAsTexture: (picture: SkPicture | null, size: SkSize) => SharedValue<SkImage | null>;
8
6
  export declare const useImageAsTexture: (source: DataSourceParam) => SharedValue<SkImage | null>;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useTextureValueFromPicture = exports.useTextureAsValue = exports.useTexture = exports.usePictureAsTexture = exports.useImageAsTexture = void 0;
6
+ exports.useTexture = exports.usePictureAsTexture = exports.useImageAsTexture = void 0;
7
7
  var _react = require("react");
8
8
  var _Offscreen = require("../../renderer/Offscreen");
9
9
  var _skia = require("../../skia");
@@ -14,7 +14,7 @@ const createTexture = (texture, picture, size) => {
14
14
 
15
15
  texture.value = (0, _Offscreen.drawAsImageFromPicture)(picture, size);
16
16
  };
17
- const useTexture = (element, size) => {
17
+ const useTexture = (element, size, deps) => {
18
18
  const {
19
19
  width,
20
20
  height
@@ -26,28 +26,21 @@ const useTexture = (element, size) => {
26
26
  y: 0,
27
27
  width,
28
28
  height
29
- }).then(pic => setPicture(pic));
30
- }, [element, width, height]);
29
+ }).then(pic => {
30
+ setPicture(pic);
31
+ });
32
+ // eslint-disable-next-line react-hooks/exhaustive-deps
33
+ }, deps !== null && deps !== void 0 ? deps : []);
31
34
  return usePictureAsTexture(picture, size);
32
35
  };
33
36
  exports.useTexture = useTexture;
34
- const useTextureAsValue = (element, size) => {
35
- console.warn("useTextureAsValue has been renamed to use useTexture");
36
- return useTexture(element, size);
37
- };
38
- exports.useTextureAsValue = useTextureAsValue;
39
- const useTextureValueFromPicture = (picture, size) => {
40
- console.warn("useTextureValueFromPicture has been renamed to use usePictureAsTexture");
41
- return usePictureAsTexture(picture, size);
42
- };
43
- exports.useTextureValueFromPicture = useTextureValueFromPicture;
44
37
  const usePictureAsTexture = (picture, size) => {
45
38
  const texture = _ReanimatedProxy.default.useSharedValue(null);
46
39
  (0, _react.useEffect)(() => {
47
40
  if (picture !== null) {
48
41
  _ReanimatedProxy.default.runOnUI(createTexture)(texture, picture, size);
49
42
  }
50
- }, [texture, picture, size]);
43
+ }, [picture, size, texture]);
51
44
  return texture;
52
45
  };
53
46
  exports.usePictureAsTexture = usePictureAsTexture;
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_Offscreen","_skia","_ReanimatedProxy","_interopRequireDefault","e","__esModule","default","createTexture","texture","picture","size","value","drawAsImageFromPicture","useTexture","element","width","height","setPicture","useState","useEffect","drawAsPicture","x","y","then","pic","usePictureAsTexture","exports","useTextureAsValue","console","warn","useTextureValueFromPicture","Rea","useSharedValue","runOnUI","useImageAsTexture","source","image","useImage","useMemo","recorder","Skia","PictureRecorder","canvas","beginRecording","drawImage","finishRecordingAsPicture"],"sources":["textures.tsx"],"sourcesContent":["import { useEffect, useMemo, useState } from \"react\";\nimport type { ReactElement } from \"react\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport type {\n DataSourceParam,\n SkImage,\n SkPicture,\n SkSize,\n} from \"../../skia/types\";\nimport {\n drawAsImageFromPicture,\n drawAsPicture,\n} from \"../../renderer/Offscreen\";\nimport { Skia, useImage } from \"../../skia\";\n\nimport Rea from \"./ReanimatedProxy\";\n\nconst createTexture = (\n texture: SharedValue<SkImage | null>,\n picture: SkPicture,\n size: SkSize\n) => {\n \"worklet\";\n texture.value = drawAsImageFromPicture(picture, size);\n};\n\nexport const useTexture = (element: ReactElement, size: SkSize) => {\n const { width, height } = size;\n const [picture, setPicture] = useState<SkPicture | null>(null);\n useEffect(() => {\n drawAsPicture(element, {\n x: 0,\n y: 0,\n width,\n height,\n }).then((pic) => setPicture(pic));\n }, [element, width, height]);\n return usePictureAsTexture(picture, size);\n};\n\nexport const useTextureAsValue = (element: ReactElement, size: SkSize) => {\n console.warn(\"useTextureAsValue has been renamed to use useTexture\");\n return useTexture(element, size);\n};\n\nexport const useTextureValueFromPicture = (\n picture: SkPicture | null,\n size: SkSize\n) => {\n console.warn(\n \"useTextureValueFromPicture has been renamed to use usePictureAsTexture\"\n );\n return usePictureAsTexture(picture, size);\n};\n\nexport const usePictureAsTexture = (\n picture: SkPicture | null,\n size: SkSize\n) => {\n const texture = Rea.useSharedValue<SkImage | null>(null);\n useEffect(() => {\n if (picture !== null) {\n Rea.runOnUI(createTexture)(texture, picture, size);\n }\n }, [texture, picture, size]);\n return texture;\n};\n\nexport const useImageAsTexture = (source: DataSourceParam) => {\n const image = useImage(source);\n const size = useMemo(() => {\n if (image) {\n return { width: image.width(), height: image.height() };\n }\n return { width: 0, height: 0 };\n }, [image]);\n const picture = useMemo(() => {\n if (image) {\n const recorder = Skia.PictureRecorder();\n const canvas = recorder.beginRecording({\n x: 0,\n y: 0,\n width: size.width,\n height: size.height,\n });\n canvas.drawImage(image, 0, 0);\n return recorder.finishRecordingAsPicture();\n } else {\n return null;\n }\n }, [size, image]);\n return usePictureAsTexture(picture, size);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAUA,IAAAC,UAAA,GAAAD,OAAA;AAIA,IAAAE,KAAA,GAAAF,OAAA;AAEA,IAAAG,gBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAAoC,SAAAI,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEpC,MAAMG,aAAa,GAAGA,CACpBC,OAAoC,EACpCC,OAAkB,EAClBC,IAAY,KACT;EACH,SAAS;;EACTF,OAAO,CAACG,KAAK,GAAG,IAAAC,iCAAsB,EAACH,OAAO,EAAEC,IAAI,CAAC;AACvD,CAAC;AAEM,MAAMG,UAAU,GAAGA,CAACC,OAAqB,EAAEJ,IAAY,KAAK;EACjE,MAAM;IAAEK,KAAK;IAAEC;EAAO,CAAC,GAAGN,IAAI;EAC9B,MAAM,CAACD,OAAO,EAAEQ,UAAU,CAAC,GAAG,IAAAC,eAAQ,EAAmB,IAAI,CAAC;EAC9D,IAAAC,gBAAS,EAAC,MAAM;IACd,IAAAC,wBAAa,EA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,MAAuB,IAAK;EAC5D,MAAMC,KAAK,GAAG,IAAAC,cAAQ,EAACF,MAAM,CAAC;EAC9B,MAAMzB,IAAI,GAAG,IAAA4B,cAAO,EAAC,MAAM;IACzB,IAAIF,KAAK,EAAE;MACT,OAAO;QAAErB,KAAK,EAAEqB,KAAK,CAACrB,KAAK,CAAC,CAAC;QAAEC,MAAM,EAAEoB,KAAK,CAACpB,MAAM,CAAC;MAAE,CAAC;IACzD;IACA,OAAO;MAAED,KAAK,EAAE,CAAC;MAAEC,MAAM,EAAE;IAAE,CAAC;EAChC,CAAC,EAAE,CAACoB,KAAK,CAAC,CAAC;EACX,MAAM3B,OAAO,GAAG,IAAA6B,cAAO,EAAC,MAAM;IAC5B,IAAIF,KAAK,EAAE;MACT,MAAMG,QAAQ,GAAGC,UAAI,CAACC,eAAe,CAAC,CAAC;MACvC,MAAMC,MAAM,GAAGH,QAAQ,CAACI,cAAc,CAAC;QACrCtB,CAAC,EAAE,CAAC;QACJC,CAAC,EAAE,CAAC;QACJP,KAAK,EAAEL,IAAI,CAACK,KAAK;QACjBC,MAAM,EAAEN,IAAI,CAACM;MACf,CAAC,CAAC;MACF0B,MAAM,CAACE,SAAS,CAACR,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;MAC7B,OAAOG,QAAQ,CAACM,wBAAwB,CAAC,CAAC;IAC5C,CAAC,MAAM;MACL,OAAO,IAAI;IACb;EACF,CAAC,EAAE,CAACnC,IAAI,EAAE0B,KAAK,CAAC,CAAC;EACjB,OAAOX,mBAAmB,CAAChB,OAAO,EAAEC,IAAI,CAAC;AAC3C,CAAC;AAACgB,OAAA,CAAAQ,iBAAA,GAAAA,iBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_react","require","_Offscreen","_skia","_ReanimatedProxy","_interopRequireDefault","e","__esModule","default","createTexture","texture","picture","size","value","drawAsImageFromPicture","useTexture","element","deps","width","height","setPicture","useState","useEffect","drawAsPicture","x","y","then","pic","usePictureAsTexture","exports","Rea","useSharedValue","runOnUI","useImageAsTexture","source","image","useImage","useMemo","recorder","Skia","PictureRecorder","canvas","beginRecording","drawImage","finishRecordingAsPicture"],"sources":["textures.tsx"],"sourcesContent":["import { useEffect, useMemo, useState } from \"react\";\nimport type { DependencyList, ReactElement } from \"react\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport type {\n DataSourceParam,\n SkImage,\n SkPicture,\n SkSize,\n} from \"../../skia/types\";\nimport {\n drawAsImageFromPicture,\n drawAsPicture,\n} from \"../../renderer/Offscreen\";\nimport { Skia, useImage } from \"../../skia\";\n\nimport Rea from \"./ReanimatedProxy\";\n\nconst createTexture = (\n texture: SharedValue<SkImage | null>,\n picture: SkPicture,\n size: SkSize\n) => {\n \"worklet\";\n texture.value = drawAsImageFromPicture(picture, size);\n};\n\nexport const useTexture = (\n element: ReactElement,\n size: SkSize,\n deps?: DependencyList\n) => {\n const { width, height } = size;\n const [picture, setPicture] = useState<SkPicture | null>(null);\n useEffect(() => {\n drawAsPicture(element, {\n x: 0,\n y: 0,\n width,\n height,\n }).then((pic) => {\n setPicture(pic);\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps ?? []);\n return usePictureAsTexture(picture, size);\n};\n\nexport const usePictureAsTexture = (\n picture: SkPicture | null,\n size: SkSize\n) => {\n const texture = Rea.useSharedValue<SkImage | null>(null);\n useEffect(() => {\n if (picture !== null) {\n Rea.runOnUI(createTexture)(texture, picture, size);\n }\n }, [picture, size, texture]);\n return texture;\n};\n\nexport const useImageAsTexture = (source: DataSourceParam) => {\n const image = useImage(source);\n const size = useMemo(() => {\n if (image) {\n return { width: image.width(), height: image.height() };\n }\n return { width: 0, height: 0 };\n }, [image]);\n const picture = useMemo(() => {\n if (image) {\n const recorder = Skia.PictureRecorder();\n const canvas = recorder.beginRecording({\n x: 0,\n y: 0,\n width: size.width,\n height: size.height,\n });\n canvas.drawImage(image, 0, 0);\n return recorder.finishRecordingAsPicture();\n } else {\n return null;\n }\n }, [size, image]);\n return us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