@shopify/react-native-skia 2.12.0-next.1 → 2.12.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 (202) hide show
  1. package/Package.swift +117 -0
  2. package/android/CMakeLists.txt +1 -2
  3. package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +0 -10
  4. package/android/src/main/java/com/shopify/reactnative/skia/ViewScreenshotService.java +9 -12
  5. package/apple/RNSkApplePlatformContext.h +0 -3
  6. package/apple/RNSkApplePlatformContext.mm +0 -11
  7. package/cpp/api/JsiSkApi.h +0 -6
  8. package/cpp/api/JsiSkFont.h +5 -10
  9. package/cpp/api/JsiSkMatrix.h +4 -2
  10. package/cpp/api/JsiSkSVGFactory.h +4 -0
  11. package/cpp/api/recorder/Convertor.h +5 -2
  12. package/cpp/api/recorder/Drawings.h +13 -3
  13. package/cpp/api/recorder/ImageFilters.h +15 -1
  14. package/cpp/api/recorder/Paint.h +8 -1
  15. package/cpp/jsi/JSICache.cpp +99 -0
  16. package/cpp/jsi/JSICache.h +90 -0
  17. package/cpp/jsi/NativeObject.h +38 -87
  18. package/cpp/jsi/ViewProperty.h +0 -24
  19. package/cpp/rnskia/RNDawnContext.h +2 -1
  20. package/cpp/rnskia/RNDawnWindowContext.h +22 -0
  21. package/cpp/rnskia/RNSkManager.cpp +0 -6
  22. package/cpp/rnskia/RNSkPlatformContext.h +0 -3
  23. package/cpp/skia/include/core/RasterContext.h +25 -0
  24. package/cpp/skia/include/core/SkCanvas.h +0 -1
  25. package/cpp/skia/include/core/SkContext.h +62 -0
  26. package/cpp/skia/include/core/SkContextOptions.h +15 -0
  27. package/cpp/skia/include/core/SkMilestone.h +1 -1
  28. package/cpp/skia/include/core/SkPicture.h +36 -18
  29. package/cpp/skia/include/core/SkRecorder.h +8 -0
  30. package/cpp/skia/include/core/SkSerialProcs.h +2 -6
  31. package/cpp/skia/include/effects/SkImageFilters.h +15 -2
  32. package/cpp/skia/include/gpu/ganesh/GrDirectContext.h +73 -47
  33. package/cpp/skia/include/gpu/ganesh/SkSurfaceGanesh.h +7 -4
  34. package/cpp/skia/include/gpu/ganesh/d3d/GrD3DDirectContext.h +12 -0
  35. package/cpp/skia/include/gpu/ganesh/gl/GrGLDirectContext.h +11 -0
  36. package/cpp/skia/include/gpu/ganesh/mtl/GrMtlDirectContext.h +11 -0
  37. package/cpp/skia/include/gpu/ganesh/vk/GrVkDirectContext.h +13 -0
  38. package/cpp/skia/include/gpu/graphite/ContextOptions.h +6 -0
  39. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +5 -4
  40. package/cpp/skia/include/gpu/graphite/PrecompileContext.h +9 -1
  41. package/cpp/skia/include/gpu/graphite/Recorder.h +0 -2
  42. package/cpp/skia/include/gpu/graphite/Recording.h +3 -0
  43. package/cpp/skia/include/gpu/graphite/dawn/DawnBackendContext.h +8 -0
  44. package/cpp/skia/include/gpu/graphite/mtl/MtlBackendContext.h +11 -0
  45. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteContext.h +11 -0
  46. package/cpp/skia/include/private/SkLog.h +1 -19
  47. package/cpp/skia/include/private/chromium/GrVkSecondaryCBDrawContext.h +2 -1
  48. package/cpp/skia/include/utils/SkLogHandler.h +53 -0
  49. package/cpp/skia/include/utils/SkNWayCanvas.h +1 -0
  50. package/cpp/skia/modules/skcms/src/Transform_inl.h +9 -10
  51. package/cpp/skia/modules/skcms/src/skcms_internals.h +8 -3
  52. package/cpp/skia/modules/skottie/include/SkottieProperty.h +2 -0
  53. package/cpp/skia/modules/skottie/include/TextShaper.h +1 -0
  54. package/cpp/skia/modules/skshaper/include/SkShaper.h +23 -1
  55. package/include/ReactNativeSkia.h +6 -0
  56. package/lib/commonjs/dom/nodes/datatypes/Rect.js +5 -1
  57. package/lib/commonjs/dom/nodes/datatypes/Rect.js.map +1 -1
  58. package/lib/commonjs/external/reanimated/useVideo.js +8 -2
  59. package/lib/commonjs/external/reanimated/useVideo.js.map +1 -1
  60. package/lib/commonjs/renderer/components/Mask.js +3 -9
  61. package/lib/commonjs/renderer/components/Mask.js.map +1 -1
  62. package/lib/commonjs/skia/types/JsiInstance.d.ts +1 -0
  63. package/lib/commonjs/skia/types/JsiInstance.js.map +1 -1
  64. package/lib/commonjs/skia/types/Matrix4.js +7 -2
  65. package/lib/commonjs/skia/types/Matrix4.js.map +1 -1
  66. package/lib/commonjs/skia/types/Skia.d.ts +1 -6
  67. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  68. package/lib/commonjs/skia/web/JsiSkCanvas.js +4 -4
  69. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  70. package/lib/commonjs/skia/web/JsiSkImage.js +6 -3
  71. package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
  72. package/lib/commonjs/skia/web/JsiSkPathBuilder.d.ts +1 -1
  73. package/lib/commonjs/skia/web/JsiSkPathBuilder.js +2 -2
  74. package/lib/commonjs/skia/web/JsiSkPathBuilder.js.map +1 -1
  75. package/lib/commonjs/skia/web/JsiSkTextStyle.js +5 -5
  76. package/lib/commonjs/skia/web/JsiSkTextStyle.js.map +1 -1
  77. package/lib/commonjs/skia/web/JsiSkia.js +0 -3
  78. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  79. package/lib/commonjs/skia/web/JsiSkottieAnimation.js +8 -8
  80. package/lib/commonjs/skia/web/JsiSkottieAnimation.js.map +1 -1
  81. package/lib/commonjs/sksg/Recorder/DrawingContext.d.ts +1 -0
  82. package/lib/commonjs/sksg/Recorder/DrawingContext.js +15 -0
  83. package/lib/commonjs/sksg/Recorder/DrawingContext.js.map +1 -1
  84. package/lib/commonjs/sksg/Recorder/Player.js +1 -1
  85. package/lib/commonjs/sksg/Recorder/Player.js.map +1 -1
  86. package/lib/commonjs/sksg/Recorder/Visitor.js +6 -1
  87. package/lib/commonjs/sksg/Recorder/Visitor.js.map +1 -1
  88. package/lib/commonjs/sksg/Recorder/commands/Drawing.js +12 -9
  89. package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
  90. package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js +15 -1
  91. package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js.map +1 -1
  92. package/lib/commonjs/sksg/Recorder/commands/Shaders.js +1 -1
  93. package/lib/commonjs/sksg/Recorder/commands/Shaders.js.map +1 -1
  94. package/lib/commonjs/views/SkiaPictureView.web.js +247 -57
  95. package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
  96. package/lib/module/dom/nodes/datatypes/Rect.js +5 -1
  97. package/lib/module/dom/nodes/datatypes/Rect.js.map +1 -1
  98. package/lib/module/external/reanimated/useVideo.js +8 -2
  99. package/lib/module/external/reanimated/useVideo.js.map +1 -1
  100. package/lib/module/renderer/components/Mask.js +3 -9
  101. package/lib/module/renderer/components/Mask.js.map +1 -1
  102. package/lib/module/skia/types/JsiInstance.d.ts +1 -0
  103. package/lib/module/skia/types/JsiInstance.js.map +1 -1
  104. package/lib/module/skia/types/Matrix4.js +7 -2
  105. package/lib/module/skia/types/Matrix4.js.map +1 -1
  106. package/lib/module/skia/types/Skia.d.ts +1 -6
  107. package/lib/module/skia/types/Skia.js.map +1 -1
  108. package/lib/module/skia/web/JsiSkCanvas.js +4 -4
  109. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  110. package/lib/module/skia/web/JsiSkImage.js +6 -3
  111. package/lib/module/skia/web/JsiSkImage.js.map +1 -1
  112. package/lib/module/skia/web/JsiSkPathBuilder.d.ts +1 -1
  113. package/lib/module/skia/web/JsiSkPathBuilder.js +2 -2
  114. package/lib/module/skia/web/JsiSkPathBuilder.js.map +1 -1
  115. package/lib/module/skia/web/JsiSkTextStyle.js +5 -5
  116. package/lib/module/skia/web/JsiSkTextStyle.js.map +1 -1
  117. package/lib/module/skia/web/JsiSkia.js +0 -3
  118. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  119. package/lib/module/skia/web/JsiSkottieAnimation.js +8 -8
  120. package/lib/module/skia/web/JsiSkottieAnimation.js.map +1 -1
  121. package/lib/module/sksg/Recorder/DrawingContext.d.ts +1 -0
  122. package/lib/module/sksg/Recorder/DrawingContext.js +15 -0
  123. package/lib/module/sksg/Recorder/DrawingContext.js.map +1 -1
  124. package/lib/module/sksg/Recorder/Player.js +1 -1
  125. package/lib/module/sksg/Recorder/Player.js.map +1 -1
  126. package/lib/module/sksg/Recorder/Visitor.js +6 -1
  127. package/lib/module/sksg/Recorder/Visitor.js.map +1 -1
  128. package/lib/module/sksg/Recorder/commands/Drawing.js +12 -9
  129. package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
  130. package/lib/module/sksg/Recorder/commands/ImageFilters.js +15 -1
  131. package/lib/module/sksg/Recorder/commands/ImageFilters.js.map +1 -1
  132. package/lib/module/sksg/Recorder/commands/Shaders.js +1 -1
  133. package/lib/module/sksg/Recorder/commands/Shaders.js.map +1 -1
  134. package/lib/module/views/SkiaPictureView.web.js +247 -57
  135. package/lib/module/views/SkiaPictureView.web.js.map +1 -1
  136. package/lib/typescript/lib/commonjs/skia/web/JsiSkPathBuilder.d.ts +1 -1
  137. package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +0 -1
  138. package/lib/typescript/lib/commonjs/sksg/Recorder/DrawingContext.d.ts +1 -0
  139. package/lib/typescript/lib/module/skia/Skia.web.d.ts +0 -1
  140. package/lib/typescript/lib/module/skia/web/JsiSkPathBuilder.d.ts +1 -1
  141. package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +0 -1
  142. package/lib/typescript/lib/module/sksg/Recorder/DrawingContext.d.ts +1 -0
  143. package/lib/typescript/react-native.config.d.ts +3 -0
  144. package/lib/typescript/src/skia/types/JsiInstance.d.ts +1 -0
  145. package/lib/typescript/src/skia/types/Skia.d.ts +1 -6
  146. package/lib/typescript/src/skia/web/JsiSkPathBuilder.d.ts +1 -1
  147. package/lib/typescript/src/sksg/Recorder/DrawingContext.d.ts +1 -0
  148. package/package.json +13 -10
  149. package/react-native.config.js +5 -0
  150. package/src/dom/nodes/datatypes/Rect.ts +6 -1
  151. package/src/external/reanimated/useVideo.ts +7 -2
  152. package/src/renderer/components/Mask.tsx +10 -3
  153. package/src/skia/types/JsiInstance.ts +2 -0
  154. package/src/skia/types/Matrix4.ts +6 -2
  155. package/src/skia/types/Skia.ts +1 -7
  156. package/src/skia/web/JsiSkCanvas.ts +11 -6
  157. package/src/skia/web/JsiSkImage.ts +6 -3
  158. package/src/skia/web/JsiSkPathBuilder.ts +2 -2
  159. package/src/skia/web/JsiSkTextStyle.ts +20 -15
  160. package/src/skia/web/JsiSkia.ts +0 -4
  161. package/src/skia/web/JsiSkottieAnimation.ts +8 -8
  162. package/src/sksg/Recorder/DrawingContext.ts +15 -0
  163. package/src/sksg/Recorder/Player.ts +1 -1
  164. package/src/sksg/Recorder/Visitor.ts +9 -6
  165. package/src/sksg/Recorder/commands/Drawing.ts +12 -9
  166. package/src/sksg/Recorder/commands/ImageFilters.ts +20 -1
  167. package/src/sksg/Recorder/commands/Shaders.ts +1 -1
  168. package/src/views/SkiaPictureView.web.tsx +245 -57
  169. package/cpp/api/JsiSkiaContext.h +0 -94
  170. package/cpp/dawn/include/dawn/dawn_proc.h +0 -53
  171. package/cpp/dawn/include/dawn/dawn_proc_table.h +0 -330
  172. package/cpp/dawn/include/dawn/dawn_thread_dispatch_proc.h +0 -47
  173. package/cpp/dawn/include/dawn/dawn_version.h +0 -41
  174. package/cpp/dawn/include/dawn/native/D3D11Backend.h +0 -65
  175. package/cpp/dawn/include/dawn/native/D3D12Backend.h +0 -103
  176. package/cpp/dawn/include/dawn/native/D3DBackend.h +0 -56
  177. package/cpp/dawn/include/dawn/native/DawnNative.h +0 -368
  178. package/cpp/dawn/include/dawn/native/MetalBackend.h +0 -56
  179. package/cpp/dawn/include/dawn/native/NullBackend.h +0 -39
  180. package/cpp/dawn/include/dawn/native/OpenGLBackend.h +0 -89
  181. package/cpp/dawn/include/dawn/native/VulkanBackend.h +0 -183
  182. package/cpp/dawn/include/dawn/native/WebGPUBackend.h +0 -49
  183. package/cpp/dawn/include/dawn/native/dawn_native_export.h +0 -49
  184. package/cpp/dawn/include/dawn/platform/DawnPlatform.h +0 -207
  185. package/cpp/dawn/include/dawn/platform/dawn_platform_export.h +0 -49
  186. package/cpp/dawn/include/dawn/replay/Replay.h +0 -99
  187. package/cpp/dawn/include/dawn/replay/dawn_replay_export.h +0 -49
  188. package/cpp/dawn/include/dawn/webgpu_cpp_print.h +0 -2856
  189. package/cpp/dawn/include/tint/tint.h +0 -91
  190. package/cpp/dawn/include/webgpu/webgpu.h +0 -5029
  191. package/cpp/dawn/include/webgpu/webgpu_cpp.h +0 -10353
  192. package/cpp/dawn/include/webgpu/webgpu_cpp_chained_struct.h +0 -57
  193. package/cpp/dawn/include/webgpu/webgpu_enum_class_bitmasks.h +0 -162
  194. package/cpp/dawn/include/webgpu/webgpu_glfw.h +0 -88
  195. package/cpp/jsi/RuntimeAwareCache.cpp +0 -7
  196. package/cpp/jsi/RuntimeAwareCache.h +0 -117
  197. package/cpp/jsi/RuntimeLifecycleMonitor.cpp +0 -72
  198. package/cpp/jsi/RuntimeLifecycleMonitor.h +0 -32
  199. package/cpp/skia/src/gpu/graphite/ContextOptionsPriv.h +0 -45
  200. package/cpp/skia/src/gpu/graphite/ResourceTypes.h +0 -360
  201. package/cpp/skia/src/gpu/graphite/TextureProxyView.h +0 -105
  202. package/libs/.graphite +0 -1
@@ -1,57 +0,0 @@
1
- // Copyright 2023 The Dawn & Tint Authors
2
- //
3
- // Redistribution and use in source and binary forms, with or without
4
- // modification, are permitted provided that the following conditions are met:
5
- //
6
- // 1. Redistributions of source code must retain the above copyright notice, this
7
- // list of conditions and the following disclaimer.
8
- //
9
- // 2. Redistributions in binary form must reproduce the above copyright notice,
10
- // this list of conditions and the following disclaimer in the documentation
11
- // and/or other materials provided with the distribution.
12
- //
13
- // 3. Neither the name of the copyright holder nor the names of its
14
- // contributors may be used to endorse or promote products derived from
15
- // this software without specific prior written permission.
16
- //
17
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
- // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
- // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
- // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21
- // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
- // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23
- // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24
- // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25
- // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
- // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
-
28
- #ifdef __EMSCRIPTEN__
29
- #error "Do not include this header. Use the headers provided by Emdawnwebgpu instead."
30
- #endif
31
-
32
- #ifndef WEBGPU_CPP_CHAINED_STRUCT_H_
33
- #define WEBGPU_CPP_CHAINED_STRUCT_H_
34
-
35
- #include <cstddef>
36
- #include <cstdint>
37
-
38
- // This header file declares the ChainedStruct structures separately from the WebGPU
39
- // headers so that dependencies can directly extend structures without including the larger header
40
- // which exposes capabilities that may require correctly set proc tables.
41
- namespace wgpu {
42
-
43
- enum class SType : uint32_t;
44
-
45
- struct ChainedStruct {
46
- ChainedStruct const * nextInChain = nullptr;
47
- SType sType = SType(0u);
48
- };
49
-
50
- struct ChainedStructOut {
51
- ChainedStructOut * nextInChain = nullptr;
52
- SType sType = SType(0u);
53
- };
54
-
55
- } // namespace wgpu}
56
-
57
- #endif // WEBGPU_CPP_CHAINED_STRUCT_H_
@@ -1,162 +0,0 @@
1
- // Copyright 2017 The Dawn & Tint Authors
2
- //
3
- // Redistribution and use in source and binary forms, with or without
4
- // modification, are permitted provided that the following conditions are met:
5
- //
6
- // 1. Redistributions of source code must retain the above copyright notice, this
7
- // list of conditions and the following disclaimer.
8
- //
9
- // 2. Redistributions in binary form must reproduce the above copyright notice,
10
- // this list of conditions and the following disclaimer in the documentation
11
- // and/or other materials provided with the distribution.
12
- //
13
- // 3. Neither the name of the copyright holder nor the names of its
14
- // contributors may be used to endorse or promote products derived from
15
- // this software without specific prior written permission.
16
- //
17
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
- // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
- // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
- // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21
- // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
- // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23
- // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24
- // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25
- // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
- // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
-
28
- #ifndef WEBGPU_ENUM_CLASS_BITMASKS_H_
29
- #define WEBGPU_ENUM_CLASS_BITMASKS_H_
30
-
31
- #include <type_traits>
32
-
33
- // The operators in wgpu:: namespace need be introduced into other namespaces with
34
- // using-declarations for C++ Argument Dependent Lookup to work.
35
- #define WGPU_IMPORT_BITMASK_OPERATORS \
36
- using wgpu::operator|; \
37
- using wgpu::operator&; \
38
- using wgpu::operator^; \
39
- using wgpu::operator~; \
40
- using wgpu::operator&=; \
41
- using wgpu::operator|=; \
42
- using wgpu::operator^=; \
43
- using wgpu::HasZeroOrOneBits;
44
-
45
- namespace wgpu {
46
-
47
- template <typename T>
48
- struct IsWGPUBitmask {
49
- static constexpr bool enable = false;
50
- };
51
-
52
- template <typename T, typename Enable = void>
53
- struct LowerBitmask {
54
- static constexpr bool enable = false;
55
- };
56
-
57
- template <typename T>
58
- struct LowerBitmask<T, typename std::enable_if<IsWGPUBitmask<T>::enable>::type> {
59
- static constexpr bool enable = true;
60
- using type = T;
61
- constexpr static T Lower(T t) { return t; }
62
- };
63
-
64
- template <typename T>
65
- struct BoolConvertible {
66
- using Integral = typename std::underlying_type<T>::type;
67
-
68
- explicit constexpr BoolConvertible(Integral value) : value(value) {}
69
- // NOLINTNEXTLINE(google-explicit-constructor)
70
- constexpr operator bool() const { return value != 0; }
71
- // NOLINTNEXTLINE(google-explicit-constructor)
72
- constexpr operator T() const { return static_cast<T>(value); }
73
-
74
- Integral value;
75
- };
76
-
77
- template <typename T>
78
- struct LowerBitmask<BoolConvertible<T>> {
79
- static constexpr bool enable = true;
80
- using type = T;
81
- static constexpr type Lower(BoolConvertible<T> t) { return t; }
82
- };
83
-
84
- template <
85
- typename T1,
86
- typename T2,
87
- typename = typename std::enable_if<LowerBitmask<T1>::enable && LowerBitmask<T2>::enable>::type>
88
- constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator|(T1 left, T2 right) {
89
- using T = typename LowerBitmask<T1>::type;
90
- using Integral = typename std::underlying_type<T>::type;
91
- return BoolConvertible<T>(static_cast<Integral>(LowerBitmask<T1>::Lower(left)) |
92
- static_cast<Integral>(LowerBitmask<T2>::Lower(right)));
93
- }
94
-
95
- template <
96
- typename T1,
97
- typename T2,
98
- typename = typename std::enable_if<LowerBitmask<T1>::enable && LowerBitmask<T2>::enable>::type>
99
- constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator&(T1 left, T2 right) {
100
- using T = typename LowerBitmask<T1>::type;
101
- using Integral = typename std::underlying_type<T>::type;
102
- return BoolConvertible<T>(static_cast<Integral>(LowerBitmask<T1>::Lower(left)) &
103
- static_cast<Integral>(LowerBitmask<T2>::Lower(right)));
104
- }
105
-
106
- template <
107
- typename T1,
108
- typename T2,
109
- typename = typename std::enable_if<LowerBitmask<T1>::enable && LowerBitmask<T2>::enable>::type>
110
- constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator^(T1 left, T2 right) {
111
- using T = typename LowerBitmask<T1>::type;
112
- using Integral = typename std::underlying_type<T>::type;
113
- return BoolConvertible<T>(static_cast<Integral>(LowerBitmask<T1>::Lower(left)) ^
114
- static_cast<Integral>(LowerBitmask<T2>::Lower(right)));
115
- }
116
-
117
- template <typename T1>
118
- constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator~(T1 t) {
119
- using T = typename LowerBitmask<T1>::type;
120
- using Integral = typename std::underlying_type<T>::type;
121
- return BoolConvertible<T>(~static_cast<Integral>(LowerBitmask<T1>::Lower(t)));
122
- }
123
-
124
- template <
125
- typename T,
126
- typename T2,
127
- typename = typename std::enable_if<IsWGPUBitmask<T>::enable && LowerBitmask<T2>::enable>::type>
128
- constexpr T& operator&=(T& l, T2 right) {
129
- T r = LowerBitmask<T2>::Lower(right);
130
- l = l & r;
131
- return l;
132
- }
133
-
134
- template <
135
- typename T,
136
- typename T2,
137
- typename = typename std::enable_if<IsWGPUBitmask<T>::enable && LowerBitmask<T2>::enable>::type>
138
- constexpr T& operator|=(T& l, T2 right) {
139
- T r = LowerBitmask<T2>::Lower(right);
140
- l = l | r;
141
- return l;
142
- }
143
-
144
- template <
145
- typename T,
146
- typename T2,
147
- typename = typename std::enable_if<IsWGPUBitmask<T>::enable && LowerBitmask<T2>::enable>::type>
148
- constexpr T& operator^=(T& l, T2 right) {
149
- T r = LowerBitmask<T2>::Lower(right);
150
- l = l ^ r;
151
- return l;
152
- }
153
-
154
- template <typename T>
155
- constexpr bool HasZeroOrOneBits(T value) {
156
- using Integral = typename std::underlying_type<T>::type;
157
- return (static_cast<Integral>(value) & (static_cast<Integral>(value) - 1)) == 0;
158
- }
159
-
160
- } // namespace wgpu
161
-
162
- #endif // WEBGPU_ENUM_CLASS_BITMASKS_H_
@@ -1,88 +0,0 @@
1
- // Copyright 2022 The Dawn & Tint Authors
2
- //
3
- // Redistribution and use in source and binary forms, with or without
4
- // modification, are permitted provided that the following conditions are met:
5
- //
6
- // 1. Redistributions of source code must retain the above copyright notice, this
7
- // list of conditions and the following disclaimer.
8
- //
9
- // 2. Redistributions in binary form must reproduce the above copyright notice,
10
- // this list of conditions and the following disclaimer in the documentation
11
- // and/or other materials provided with the distribution.
12
- //
13
- // 3. Neither the name of the copyright holder nor the names of its
14
- // contributors may be used to endorse or promote products derived from
15
- // this software without specific prior written permission.
16
- //
17
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
- // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
- // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
- // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21
- // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
- // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23
- // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24
- // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25
- // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
- // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
-
28
- #ifndef INCLUDE_WEBGPU_WEBGPU_GLFW_H_
29
- #define INCLUDE_WEBGPU_WEBGPU_GLFW_H_
30
-
31
- #ifdef __cplusplus
32
- #include <memory>
33
-
34
- #include "webgpu/webgpu_cpp.h"
35
- #else
36
- #include "webgpu/webgpu.h"
37
- #endif
38
-
39
- #if defined(WGPU_GLFW_SHARED_LIBRARY)
40
- #if defined(_WIN32)
41
- #if defined(WGPU_GLFW_IMPLEMENTATION)
42
- #define WGPU_GLFW_EXPORT __declspec(dllexport)
43
- #else
44
- #define WGPU_GLFW_EXPORT __declspec(dllimport)
45
- #endif
46
- #else // defined(_WIN32)
47
- #if defined(WGPU_GLFW_IMPLEMENTATION)
48
- #define WGPU_GLFW_EXPORT __attribute__((visibility("default")))
49
- #else
50
- #define WGPU_GLFW_EXPORT
51
- #endif
52
- #endif // defined(_WIN32)
53
- #else // defined(WGPU_GLFW_SHARED_LIBRARY)
54
- #define WGPU_GLFW_EXPORT
55
- #endif // defined(WGPU_GLFW_SHARED_LIBRARY)
56
-
57
- struct GLFWwindow;
58
-
59
- #ifdef __cplusplus
60
- extern "C" {
61
- #endif
62
-
63
- WGPU_GLFW_EXPORT WGPUSurface wgpuGlfwCreateSurfaceForWindow(const WGPUInstance instance,
64
- struct GLFWwindow* window);
65
-
66
- #ifdef __cplusplus
67
- }
68
-
69
- namespace wgpu::glfw {
70
-
71
- // Does the necessary setup on the GLFWwindow to allow creating a wgpu::Surface with it and
72
- // calls `instance.CreateSurface` with the correct descriptor for this window.
73
- // Returns a null wgpu::Surface on failure.
74
- WGPU_GLFW_EXPORT wgpu::Surface CreateSurfaceForWindow(const wgpu::Instance& instance,
75
- GLFWwindow* window);
76
-
77
- // Use for testing only. Does everything that CreateSurfaceForWindow does except the call to
78
- // CreateSurface. Useful to be able to modify the descriptor for testing, or when trying to
79
- // avoid using the global proc table.
80
- // NOLINTNEXTLINE(build/include_what_you_use)
81
- WGPU_GLFW_EXPORT std::unique_ptr<wgpu::ChainedStruct, void (*)(wgpu::ChainedStruct*)>
82
- SetupWindowAndGetSurfaceDescriptor(GLFWwindow* window);
83
-
84
- } // namespace wgpu::glfw
85
-
86
- #endif
87
-
88
- #endif // INCLUDE_WEBGPU_WEBGPU_GLFW_H_
@@ -1,7 +0,0 @@
1
- #include "RuntimeAwareCache.h"
2
-
3
- namespace RNJsi {
4
-
5
- std::atomic<jsi::Runtime *> BaseRuntimeAwareCache::_mainRuntime{nullptr};
6
-
7
- } // namespace RNJsi
@@ -1,117 +0,0 @@
1
- #pragma once
2
-
3
- #include <jsi/jsi.h>
4
-
5
- #include <atomic>
6
- #include <memory>
7
- #include <mutex>
8
- #include <unordered_map>
9
- #include <utility>
10
-
11
- #include "RuntimeLifecycleMonitor.h"
12
-
13
- namespace RNJsi {
14
-
15
- namespace jsi = facebook::jsi;
16
-
17
- class BaseRuntimeAwareCache {
18
- public:
19
- static void setMainJsRuntime(jsi::Runtime *rt) {
20
- // Atomic: hot reload rewrites this from the JS thread while worklet
21
- // runtime threads read it concurrently.
22
- _mainRuntime.store(rt, std::memory_order_release);
23
- }
24
- static jsi::Runtime *getMainJsRuntime() {
25
- auto *rt = _mainRuntime.load(std::memory_order_acquire);
26
- assert(rt != nullptr && "Expected main Javascript runtime to be set in the "
27
- "BaseRuntimeAwareCache class.");
28
-
29
- return rt;
30
- }
31
-
32
- private:
33
- static std::atomic<jsi::Runtime *> _mainRuntime;
34
- };
35
-
36
- /**
37
- * Provides a way to keep data specific to a jsi::Runtime instance that gets
38
- * cleaned up when that runtime is destroyed. This is necessary because JSI does
39
- * not allow for its associated objects to be retained past the runtime
40
- * lifetime. If an object (e.g. jsi::Values or jsi::Function instances) is kept
41
- * after the runtime is torn down, its destructor (once it is destroyed
42
- * eventually) will result in a crash (JSI objects keep a pointer to memory
43
- * managed by the runtime, accessing that portion of the memory after runtime is
44
- * deleted is the root cause of that crash).
45
- *
46
- * In order to provide an efficient implementation that does not add an overhead
47
- * for the cases when only a single runtiome is used, which is the primary
48
- * usecase, the following assumption has been made: Only for secondary runtimes
49
- * we track destruction and clean up the store associated with that runtime. For
50
- * the first runtime we assume that the object holding the store is destroyed
51
- * prior to the destruction of that runtime.
52
- *
53
- * The above assumption makes it work without any overhead when only single
54
- * runtime is in use. Specifically, we don't perform any additional operations
55
- * related to tracking runtime lifecycle when only a single runtime is used.
56
- */
57
- template <typename T>
58
- class RuntimeAwareCache : public BaseRuntimeAwareCache,
59
- public RuntimeLifecycleListener {
60
-
61
- public:
62
- void onRuntimeDestroyed(jsi::Runtime *rt) override {
63
- if (getMainJsRuntime() != rt) {
64
- // We are removing a secondary runtime. This is invoked by
65
- // RuntimeLifecycleMonitor on the destroyed runtime's thread, which may
66
- // run concurrently with get() on another runtime's thread.
67
- std::lock_guard<std::mutex> lock(_secondaryCachesMutex);
68
- _secondaryRuntimeCaches.erase(rt);
69
- }
70
- }
71
-
72
- ~RuntimeAwareCache() {
73
- for (auto &cache : _secondaryRuntimeCaches) {
74
- RuntimeLifecycleMonitor::removeListener(
75
- *static_cast<jsi::Runtime *>(cache.first), this);
76
- }
77
- }
78
-
79
- T &get(jsi::Runtime &rt) {
80
- // We check if we're accessing the main runtime - this is the happy path
81
- // to avoid us having to lookup by runtime for caches that only has a single
82
- // runtime
83
- if (getMainJsRuntime() == &rt) {
84
- return _primaryCache;
85
- } else {
86
- // Guard the secondary map: it can be mutated concurrently by get()
87
- // on a worklet runtime's thread and by onRuntimeDestroyed() when
88
- // another secondary runtime is torn down. The main-runtime path above
89
- // stays lock-free. References into the map remain valid after the
90
- // lock is released (unordered_map never invalidates references on
91
- // insert/erase of other keys, and this runtime's entry can only be
92
- // erased from this runtime's own thread).
93
- std::lock_guard<std::mutex> lock(_secondaryCachesMutex);
94
- if (_secondaryRuntimeCaches.count(&rt) == 0) {
95
- // we only add listener when the secondary runtime is used, this assumes
96
- // that the secondary runtime is terminated first. This lets us avoid
97
- // additional complexity for the majority of cases when objects are not
98
- // shared between runtimes. Otherwise we'd have to register all objecrts
99
- // with the RuntimeMonitor as opposed to only registering ones that are
100
- // used in secondary runtime. Note that we can't register listener here
101
- // with the primary runtime as it may run on a separate thread.
102
- RuntimeLifecycleMonitor::addListener(rt, this);
103
-
104
- T cache;
105
- _secondaryRuntimeCaches.emplace(&rt, std::move(cache));
106
- }
107
- return _secondaryRuntimeCaches.at(&rt);
108
- }
109
- }
110
-
111
- private:
112
- std::mutex _secondaryCachesMutex;
113
- std::unordered_map<void *, T> _secondaryRuntimeCaches;
114
- T _primaryCache;
115
- };
116
-
117
- } // namespace RNJsi
@@ -1,72 +0,0 @@
1
- #include "RuntimeLifecycleMonitor.h"
2
-
3
- #include <mutex>
4
- #include <unordered_map>
5
- #include <unordered_set>
6
- #include <utility>
7
-
8
- namespace RNJsi {
9
-
10
- static std::unordered_map<jsi::Runtime *,
11
- std::unordered_set<RuntimeLifecycleListener *>>
12
- listeners;
13
- static std::mutex listenersMutex;
14
-
15
- struct RuntimeLifecycleMonitorObject : public jsi::HostObject {
16
- jsi::Runtime *_rt;
17
- explicit RuntimeLifecycleMonitorObject(jsi::Runtime *rt) : _rt(rt) {}
18
- ~RuntimeLifecycleMonitorObject() {
19
- std::unordered_set<RuntimeLifecycleListener *> listenersCopy;
20
- {
21
- std::lock_guard<std::mutex> lock(listenersMutex);
22
- auto listenersSet = listeners.find(_rt);
23
- if (listenersSet != listeners.end()) {
24
- listenersCopy = listenersSet->second;
25
- listeners.erase(listenersSet);
26
- }
27
- }
28
- for (auto listener : listenersCopy) {
29
- listener->onRuntimeDestroyed(_rt);
30
- }
31
- }
32
- };
33
-
34
- void RuntimeLifecycleMonitor::addListener(jsi::Runtime &rt,
35
- RuntimeLifecycleListener *listener) {
36
- bool shouldInstallMonitor = false;
37
- {
38
- std::lock_guard<std::mutex> lock(listenersMutex);
39
- auto listenersSet = listeners.find(&rt);
40
- if (listenersSet == listeners.end()) {
41
- std::unordered_set<RuntimeLifecycleListener *> newSet;
42
- newSet.insert(listener);
43
- listeners.emplace(&rt, std::move(newSet));
44
- shouldInstallMonitor = true;
45
- } else {
46
- listenersSet->second.insert(listener);
47
- }
48
- }
49
- if (shouldInstallMonitor) {
50
- // We install a global host object in the provided runtime, this way we can
51
- // use that host object destructor to get notified when the runtime is being
52
- // terminated. We use a unique name for the object as it gets saved with the
53
- // runtime's global object.
54
- rt.global().setProperty(
55
- rt, "__rnskia_rt_lifecycle_monitor",
56
- jsi::Object::createFromHostObject(
57
- rt, std::make_shared<RuntimeLifecycleMonitorObject>(&rt)));
58
- }
59
- }
60
-
61
- void RuntimeLifecycleMonitor::removeListener(
62
- jsi::Runtime &rt, RuntimeLifecycleListener *listener) {
63
- std::lock_guard<std::mutex> lock(listenersMutex);
64
- auto listenersSet = listeners.find(&rt);
65
- if (listenersSet == listeners.end()) {
66
- // nothing to do here
67
- } else {
68
- listenersSet->second.erase(listener);
69
- }
70
- }
71
-
72
- } // namespace RNJsi
@@ -1,32 +0,0 @@
1
- #pragma once
2
-
3
- #include <jsi/jsi.h>
4
-
5
- #include <memory>
6
-
7
- namespace RNJsi {
8
-
9
- namespace jsi = facebook::jsi;
10
-
11
- /**
12
- * Listener interface that allows for getting notified when a jsi::Runtime
13
- * instance is destroyed.
14
- */
15
- struct RuntimeLifecycleListener {
16
- virtual ~RuntimeLifecycleListener() {}
17
- virtual void onRuntimeDestroyed(jsi::Runtime *) = 0;
18
- };
19
-
20
- /**
21
- * This class provides an API via static methods for registering and
22
- * unregistering runtime lifecycle listeners. The listeners can be used to
23
- * cleanup any data that references a given jsi::Runtime instance before it gets
24
- * destroyed.
25
- */
26
- struct RuntimeLifecycleMonitor {
27
- static void addListener(jsi::Runtime &rt, RuntimeLifecycleListener *listener);
28
- static void removeListener(jsi::Runtime &rt,
29
- RuntimeLifecycleListener *listener);
30
- };
31
-
32
- } // namespace RNJsi
@@ -1,45 +0,0 @@
1
- /*
2
- * Copyright 2023 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_ContextOptionsPriv_DEFINED
9
- #define skgpu_graphite_ContextOptionsPriv_DEFINED
10
-
11
- #include "include/private/SkMath.h"
12
-
13
- #include <optional>
14
-
15
- namespace skgpu::graphite {
16
-
17
- enum class PathRendererStrategy;
18
-
19
- /**
20
- * Private options that are only meant for testing within Skia's tools.
21
- */
22
- struct ContextOptionsPriv {
23
-
24
- int fMaxTextureSizeOverride = SK_MaxS32;
25
-
26
- /**
27
- * If true, will store a pointer in Recorder that points back to the Context
28
- * that created it. Used by readPixels() and other methods that normally require a Context.
29
- */
30
- bool fStoreContextRefInRecorder = false;
31
-
32
- /**
33
- * If true, enables layer based draw ordering.
34
- */
35
- bool fDrawListLayer = false;
36
-
37
- /**
38
- * Override Caps' default strategy heuristics to prioritize this one if set *and* is supported.
39
- */
40
- std::optional<PathRendererStrategy> fPathRendererStrategy;
41
- };
42
-
43
- } // namespace skgpu::graphite
44
-
45
- #endif // skgpu_graphite_ContextOptionsPriv_DEFINED