@shopify/react-native-skia 2.11.0 → 2.11.2-next.1
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.
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +0 -10
- package/android/src/main/java/com/shopify/reactnative/skia/ViewScreenshotService.java +9 -12
- package/apple/RNSkApplePlatformContext.h +0 -3
- package/apple/RNSkApplePlatformContext.mm +0 -11
- package/cpp/api/JsiSkApi.h +0 -6
- package/cpp/api/JsiSkFont.h +5 -10
- package/cpp/api/JsiSkMatrix.h +4 -2
- package/cpp/api/recorder/Convertor.h +5 -2
- package/cpp/api/recorder/Drawings.h +13 -3
- package/cpp/api/recorder/ImageFilters.h +15 -1
- package/cpp/api/recorder/Paint.h +8 -1
- package/cpp/dawn/include/dawn/dawn_proc.h +53 -0
- package/cpp/dawn/include/dawn/dawn_proc_table.h +330 -0
- package/cpp/dawn/include/dawn/dawn_thread_dispatch_proc.h +47 -0
- package/cpp/dawn/include/dawn/dawn_version.h +41 -0
- package/cpp/dawn/include/dawn/native/D3D11Backend.h +65 -0
- package/cpp/dawn/include/dawn/native/D3D12Backend.h +103 -0
- package/cpp/dawn/include/dawn/native/D3DBackend.h +56 -0
- package/cpp/dawn/include/dawn/native/DawnNative.h +368 -0
- package/cpp/dawn/include/dawn/native/MetalBackend.h +56 -0
- package/cpp/dawn/include/dawn/native/NullBackend.h +39 -0
- package/cpp/dawn/include/dawn/native/OpenGLBackend.h +89 -0
- package/cpp/dawn/include/dawn/native/VulkanBackend.h +183 -0
- package/cpp/dawn/include/dawn/native/WebGPUBackend.h +49 -0
- package/cpp/dawn/include/dawn/native/dawn_native_export.h +49 -0
- package/cpp/dawn/include/dawn/platform/DawnPlatform.h +207 -0
- package/cpp/dawn/include/dawn/platform/dawn_platform_export.h +49 -0
- package/cpp/dawn/include/dawn/replay/Replay.h +99 -0
- package/cpp/dawn/include/dawn/replay/dawn_replay_export.h +49 -0
- package/cpp/dawn/include/dawn/webgpu_cpp_print.h +2856 -0
- package/cpp/dawn/include/tint/tint.h +91 -0
- package/cpp/dawn/include/webgpu/webgpu.h +5029 -0
- package/cpp/dawn/include/webgpu/webgpu_cpp.h +10353 -0
- package/cpp/dawn/include/webgpu/webgpu_cpp_chained_struct.h +57 -0
- package/cpp/dawn/include/webgpu/webgpu_enum_class_bitmasks.h +162 -0
- package/cpp/dawn/include/webgpu/webgpu_glfw.h +88 -0
- package/cpp/jsi/NativeObject.h +50 -32
- package/cpp/jsi/RuntimeAwareCache.cpp +1 -0
- package/cpp/jsi/RuntimeAwareCache.h +29 -0
- package/cpp/rnskia/RNSkManager.cpp +5 -0
- package/cpp/rnskia/RNSkPlatformContext.h +0 -3
- package/cpp/skia/src/gpu/graphite/ContextOptionsPriv.h +45 -0
- package/cpp/skia/src/gpu/graphite/ResourceTypes.h +360 -0
- package/cpp/skia/src/gpu/graphite/TextureProxyView.h +105 -0
- package/lib/commonjs/dom/nodes/datatypes/Rect.js +5 -1
- package/lib/commonjs/dom/nodes/datatypes/Rect.js.map +1 -1
- package/lib/commonjs/external/reanimated/useVideo.js +8 -2
- package/lib/commonjs/external/reanimated/useVideo.js.map +1 -1
- package/lib/commonjs/renderer/components/Mask.js +3 -9
- package/lib/commonjs/renderer/components/Mask.js.map +1 -1
- package/lib/commonjs/skia/types/JsiInstance.d.ts +1 -0
- package/lib/commonjs/skia/types/JsiInstance.js.map +1 -1
- package/lib/commonjs/skia/types/Matrix4.js +7 -2
- package/lib/commonjs/skia/types/Matrix4.js.map +1 -1
- package/lib/commonjs/skia/types/Skia.d.ts +1 -6
- package/lib/commonjs/skia/types/Skia.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkia.js +0 -3
- package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/DrawingContext.d.ts +1 -0
- package/lib/commonjs/sksg/Recorder/DrawingContext.js +15 -0
- package/lib/commonjs/sksg/Recorder/DrawingContext.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Player.js +1 -1
- package/lib/commonjs/sksg/Recorder/Player.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Visitor.js +6 -1
- package/lib/commonjs/sksg/Recorder/Visitor.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Drawing.js +10 -8
- package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js +15 -1
- package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Shaders.js +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Shaders.js.map +1 -1
- package/lib/commonjs/views/SkiaPictureView.web.js +19 -14
- package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
- package/lib/module/dom/nodes/datatypes/Rect.js +5 -1
- package/lib/module/dom/nodes/datatypes/Rect.js.map +1 -1
- package/lib/module/external/reanimated/useVideo.js +8 -2
- package/lib/module/external/reanimated/useVideo.js.map +1 -1
- package/lib/module/renderer/components/Mask.js +3 -9
- package/lib/module/renderer/components/Mask.js.map +1 -1
- package/lib/module/skia/types/JsiInstance.d.ts +1 -0
- package/lib/module/skia/types/JsiInstance.js.map +1 -1
- package/lib/module/skia/types/Matrix4.js +7 -2
- package/lib/module/skia/types/Matrix4.js.map +1 -1
- package/lib/module/skia/types/Skia.d.ts +1 -6
- package/lib/module/skia/types/Skia.js.map +1 -1
- package/lib/module/skia/web/JsiSkia.js +0 -3
- package/lib/module/skia/web/JsiSkia.js.map +1 -1
- package/lib/module/sksg/Recorder/DrawingContext.d.ts +1 -0
- package/lib/module/sksg/Recorder/DrawingContext.js +15 -0
- package/lib/module/sksg/Recorder/DrawingContext.js.map +1 -1
- package/lib/module/sksg/Recorder/Player.js +1 -1
- package/lib/module/sksg/Recorder/Player.js.map +1 -1
- package/lib/module/sksg/Recorder/Visitor.js +6 -1
- package/lib/module/sksg/Recorder/Visitor.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Drawing.js +10 -8
- package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/ImageFilters.js +15 -1
- package/lib/module/sksg/Recorder/commands/ImageFilters.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Shaders.js +1 -1
- package/lib/module/sksg/Recorder/commands/Shaders.js.map +1 -1
- package/lib/module/views/SkiaPictureView.web.js +19 -14
- package/lib/module/views/SkiaPictureView.web.js.map +1 -1
- package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +0 -1
- package/lib/typescript/lib/commonjs/sksg/Recorder/DrawingContext.d.ts +1 -0
- package/lib/typescript/lib/module/skia/Skia.web.d.ts +0 -1
- package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +0 -1
- package/lib/typescript/lib/module/sksg/Recorder/DrawingContext.d.ts +1 -0
- package/lib/typescript/src/skia/types/JsiInstance.d.ts +1 -0
- package/lib/typescript/src/skia/types/Skia.d.ts +1 -6
- package/lib/typescript/src/sksg/Recorder/DrawingContext.d.ts +1 -0
- package/libs/.graphite +1 -0
- package/package.json +6 -6
- package/src/dom/nodes/datatypes/Rect.ts +6 -1
- package/src/external/reanimated/useVideo.ts +7 -2
- package/src/renderer/components/Mask.tsx +10 -3
- package/src/skia/types/JsiInstance.ts +2 -0
- package/src/skia/types/Matrix4.ts +6 -2
- package/src/skia/types/Skia.ts +1 -7
- package/src/skia/web/JsiSkia.ts +0 -4
- package/src/sksg/Recorder/DrawingContext.ts +15 -0
- package/src/sksg/Recorder/Player.ts +1 -1
- package/src/sksg/Recorder/Visitor.ts +9 -6
- package/src/sksg/Recorder/commands/Drawing.ts +10 -8
- package/src/sksg/Recorder/commands/ImageFilters.ts +20 -1
- package/src/sksg/Recorder/commands/Shaders.ts +1 -1
- package/src/views/SkiaPictureView.web.tsx +17 -14
- package/cpp/api/JsiSkiaContext.h +0 -94
|
@@ -0,0 +1,57 @@
|
|
|
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_
|
|
@@ -0,0 +1,162 @@
|
|
|
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_
|
|
@@ -0,0 +1,88 @@
|
|
|
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_
|
package/cpp/jsi/NativeObject.h
CHANGED
|
@@ -51,26 +51,32 @@ struct PrototypeCacheEntry {
|
|
|
51
51
|
*
|
|
52
52
|
* When used with static storage (like prototype caches), the cache persists
|
|
53
53
|
* across hot reloads. But the JSI objects inside become invalid when the
|
|
54
|
-
* runtime is destroyed. This wrapper tracks which runtime the
|
|
55
|
-
* created for and allocates a new cache when the
|
|
54
|
+
* runtime is destroyed. This wrapper tracks which main-runtime generation the
|
|
55
|
+
* cache was created for and allocates a new cache when the native module is
|
|
56
|
+
* reinstalled (RNSkManager construction bumps the generation).
|
|
57
|
+
*
|
|
58
|
+
* The generation is used instead of the runtime pointer on purpose: on an
|
|
59
|
+
* in-process runtime recreate (expo-updates reloadAsync, DevSettings.reload)
|
|
60
|
+
* Hermes frequently allocates the new runtime at the address of the freed
|
|
61
|
+
* one. A pointer comparison then sees "same runtime", keeps the stale cache,
|
|
62
|
+
* and create()/installConstructor() end up passing a jsi::Object owned by the
|
|
63
|
+
* dead runtime to the new one (use-after-free).
|
|
56
64
|
*
|
|
57
65
|
* The old cache is intentionally leaked - we cannot safely destroy JSI
|
|
58
66
|
* objects after their runtime is gone.
|
|
59
67
|
*/
|
|
60
68
|
template <typename T> struct StaticRuntimeAwareCache {
|
|
61
69
|
RNJsi::RuntimeAwareCache<T> *cache = nullptr;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
RNJsi::RuntimeAwareCache<T> &get(jsi::Runtime &rt) {
|
|
65
|
-
auto
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
if (cache == nullptr) {
|
|
70
|
+
uint64_t cacheGeneration = 0;
|
|
71
|
+
|
|
72
|
+
RNJsi::RuntimeAwareCache<T> &get(jsi::Runtime & /*rt*/) {
|
|
73
|
+
auto generation =
|
|
74
|
+
RNJsi::BaseRuntimeAwareCache::getMainJsRuntimeGeneration();
|
|
75
|
+
if (cache == nullptr || cacheGeneration != generation) {
|
|
76
|
+
// First use, or the main runtime was reinstalled (hot reload / OTA):
|
|
77
|
+
// allocate a fresh cache and leak the old one.
|
|
72
78
|
cache = new RNJsi::RuntimeAwareCache<T>();
|
|
73
|
-
|
|
79
|
+
cacheGeneration = generation;
|
|
74
80
|
}
|
|
75
81
|
return *cache;
|
|
76
82
|
}
|
|
@@ -143,9 +149,29 @@ public:
|
|
|
143
149
|
*/
|
|
144
150
|
static void installPrototype(jsi::Runtime &runtime) {
|
|
145
151
|
std::lock_guard<std::mutex> lock(getPrototypeCacheMutex());
|
|
152
|
+
ensurePrototypeLocked(runtime);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Look up (and install on first use) the prototype entry for this runtime.
|
|
157
|
+
*
|
|
158
|
+
* Callers must hold getPrototypeCacheMutex() and must consume the returned
|
|
159
|
+
* entry while still holding it: the lookup and the use of the prototype
|
|
160
|
+
* have to share one lock scope, because a reinstall of the native module
|
|
161
|
+
* (generation bump, see StaticRuntimeAwareCache) can swap the cache from
|
|
162
|
+
* any thread. A caller that released the lock in between would re-resolve
|
|
163
|
+
* a fresh cache with an empty entry and hand out an object without a
|
|
164
|
+
* prototype.
|
|
165
|
+
*
|
|
166
|
+
* The returned reference stays valid for the runtime's lifetime: the
|
|
167
|
+
* RuntimeAwareCache is heap-allocated and never freed, and
|
|
168
|
+
* std::unordered_map keeps references to its elements stable across
|
|
169
|
+
* rehashes.
|
|
170
|
+
*/
|
|
171
|
+
static PrototypeCacheEntry &ensurePrototypeLocked(jsi::Runtime &runtime) {
|
|
146
172
|
auto &entry = getPrototypeCache(runtime).get(runtime);
|
|
147
173
|
if (entry.prototype.has_value()) {
|
|
148
|
-
return; // Already installed
|
|
174
|
+
return entry; // Already installed
|
|
149
175
|
}
|
|
150
176
|
|
|
151
177
|
// Create prototype object
|
|
@@ -264,6 +290,7 @@ public:
|
|
|
264
290
|
|
|
265
291
|
// Cache the prototype
|
|
266
292
|
entry.prototype = std::move(prototype);
|
|
293
|
+
return entry;
|
|
267
294
|
}
|
|
268
295
|
|
|
269
296
|
/**
|
|
@@ -274,13 +301,8 @@ public:
|
|
|
274
301
|
* created internally by the native code).
|
|
275
302
|
*/
|
|
276
303
|
static void installConstructor(jsi::Runtime &runtime) {
|
|
277
|
-
installPrototype(runtime);
|
|
278
|
-
|
|
279
304
|
std::lock_guard<std::mutex> lock(getPrototypeCacheMutex());
|
|
280
|
-
auto &entry =
|
|
281
|
-
if (!entry.prototype.has_value()) {
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
305
|
+
auto &entry = ensurePrototypeLocked(runtime);
|
|
284
306
|
|
|
285
307
|
// Create a constructor function that throws when called directly
|
|
286
308
|
auto ctor = jsi::Function::createFromHostFunction(
|
|
@@ -308,8 +330,6 @@ public:
|
|
|
308
330
|
*/
|
|
309
331
|
static jsi::Value create(jsi::Runtime &runtime,
|
|
310
332
|
std::shared_ptr<Derived> instance) {
|
|
311
|
-
installPrototype(runtime);
|
|
312
|
-
|
|
313
333
|
// Store creation runtime for logging etc.
|
|
314
334
|
instance->setCreationRuntime(&runtime);
|
|
315
335
|
|
|
@@ -319,18 +339,16 @@ public:
|
|
|
319
339
|
// Attach native state
|
|
320
340
|
obj.setNativeState(runtime, instance);
|
|
321
341
|
|
|
322
|
-
//
|
|
342
|
+
// Install (on first use) and apply the prototype in a single lock scope
|
|
343
|
+
// so a concurrent cache swap cannot slip in between the two steps.
|
|
323
344
|
{
|
|
324
345
|
std::lock_guard<std::mutex> lock(getPrototypeCacheMutex());
|
|
325
|
-
auto &entry =
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
objectCtor.getPropertyAsFunction(runtime, "setPrototypeOf");
|
|
332
|
-
setPrototypeOf.call(runtime, obj, *entry.prototype);
|
|
333
|
-
}
|
|
346
|
+
auto &entry = ensurePrototypeLocked(runtime);
|
|
347
|
+
// Use Object.setPrototypeOf to set the prototype
|
|
348
|
+
auto objectCtor = runtime.global().getPropertyAsObject(runtime, "Object");
|
|
349
|
+
auto setPrototypeOf =
|
|
350
|
+
objectCtor.getPropertyAsFunction(runtime, "setPrototypeOf");
|
|
351
|
+
setPrototypeOf.call(runtime, obj, *entry.prototype);
|
|
334
352
|
}
|
|
335
353
|
|
|
336
354
|
// Set memory pressure hint for GC
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
#include <jsi/jsi.h>
|
|
4
4
|
|
|
5
5
|
#include <atomic>
|
|
6
|
+
#include <cstdint>
|
|
6
7
|
#include <memory>
|
|
7
8
|
#include <mutex>
|
|
8
9
|
#include <unordered_map>
|
|
@@ -20,6 +21,33 @@ public:
|
|
|
20
21
|
// Atomic: hot reload rewrites this from the JS thread while worklet
|
|
21
22
|
// runtime threads read it concurrently.
|
|
22
23
|
_mainRuntime.store(rt, std::memory_order_release);
|
|
24
|
+
// Every (re)installation of the native module starts a new generation.
|
|
25
|
+
// Callers that hold process-wide state derived from the main runtime
|
|
26
|
+
// (see StaticRuntimeAwareCache) must key their invalidation on this
|
|
27
|
+
// counter and NOT on the runtime pointer: when the JS runtime is
|
|
28
|
+
// destroyed and recreated in-process (expo-updates OTA apply,
|
|
29
|
+
// DevSettings.reload) the new jsi::Runtime is frequently allocated at
|
|
30
|
+
// the exact address of the freed one, so a pointer comparison cannot
|
|
31
|
+
// tell a reload from the steady state.
|
|
32
|
+
_mainRuntimeGeneration.fetch_add(1, std::memory_order_acq_rel);
|
|
33
|
+
}
|
|
34
|
+
static uint64_t getMainJsRuntimeGeneration() {
|
|
35
|
+
return _mainRuntimeGeneration.load(std::memory_order_acquire);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Called when the main runtime is about to go away (RNSkManager destruction).
|
|
39
|
+
* Bumps the generation so process-wide caches keyed on it
|
|
40
|
+
* (StaticRuntimeAwareCache) stop trusting their contents before the next
|
|
41
|
+
* install(). This closes the window where a runtime allocated at the dead
|
|
42
|
+
* runtime's address would otherwise be taken for the main runtime and be
|
|
43
|
+
* handed the stale jsi::Objects of the previous one.
|
|
44
|
+
*
|
|
45
|
+
* The pointer itself is intentionally left in place: worklet runtime
|
|
46
|
+
* threads may still call getMainJsRuntime() while teardown overlaps, and
|
|
47
|
+
* that accessor asserts on nullptr.
|
|
48
|
+
*/
|
|
49
|
+
static void invalidateMainJsRuntime() {
|
|
50
|
+
_mainRuntimeGeneration.fetch_add(1, std::memory_order_acq_rel);
|
|
23
51
|
}
|
|
24
52
|
static jsi::Runtime *getMainJsRuntime() {
|
|
25
53
|
auto *rt = _mainRuntime.load(std::memory_order_acquire);
|
|
@@ -31,6 +59,7 @@ public:
|
|
|
31
59
|
|
|
32
60
|
private:
|
|
33
61
|
static std::atomic<jsi::Runtime *> _mainRuntime;
|
|
62
|
+
static std::atomic<uint64_t> _mainRuntimeGeneration;
|
|
34
63
|
};
|
|
35
64
|
|
|
36
65
|
/**
|
|
@@ -30,6 +30,11 @@ RNSkManager::RNSkManager(
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
RNSkManager::~RNSkManager() {
|
|
33
|
+
// The main runtime is going away: key out the process-wide prototype
|
|
34
|
+
// caches now rather than at the next install(), so nothing allocated at
|
|
35
|
+
// this runtime's address in between can be mistaken for it.
|
|
36
|
+
RNJsi::BaseRuntimeAwareCache::invalidateMainJsRuntime();
|
|
37
|
+
|
|
33
38
|
// Free up any references
|
|
34
39
|
_viewApi = nullptr;
|
|
35
40
|
_jsRuntime = nullptr;
|
|
@@ -96,9 +96,6 @@ public:
|
|
|
96
96
|
virtual sk_sp<SkSurface>
|
|
97
97
|
makeOffscreenSurface(int width, int height, bool useP3ColorSpace = false) = 0;
|
|
98
98
|
|
|
99
|
-
virtual std::shared_ptr<WindowContext>
|
|
100
|
-
makeContextFromNativeSurface(void *surface, int width, int height) = 0;
|
|
101
|
-
|
|
102
99
|
/**
|
|
103
100
|
* Creates an image from a native buffer.
|
|
104
101
|
* - On iOS, this is a `CVPixelBufferRef`
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|