react-native-skia 2.15.0 → 3.0.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.
- package/android/CMakeLists.txt +1 -0
- package/android/cpp/jni/include/JniSkiaBaseView.h +9 -4
- package/android/cpp/jni/include/JniSkiaGraphiteView.h +2 -2
- package/android/cpp/jni/include/JniSkiaPictureView.h +1 -12
- package/cpp/api/recorder/ColorFilters.h +1 -0
- package/cpp/api/recorder/Convertor.h +39 -11
- package/cpp/api/recorder/DataTypes.h +12 -0
- package/cpp/api/recorder/DrawingCtx.h +14 -0
- package/cpp/api/recorder/Drawings.h +5 -0
- package/cpp/api/recorder/PathEffects.h +8 -0
- package/cpp/api/recorder/RNRecorder.h +68 -11
- package/cpp/api/recorder/Shaders.h +3 -0
- package/cpp/dawn/include/dawn/dawn_proc.h +53 -0
- package/cpp/dawn/include/dawn/dawn_proc_table.h +329 -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 +104 -0
- package/cpp/dawn/include/dawn/native/D3DBackend.h +56 -0
- package/cpp/dawn/include/dawn/native/DawnNative.h +367 -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 +211 -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 +2868 -0
- package/cpp/dawn/include/tint/tint.h +91 -0
- package/cpp/dawn/include/webgpu/webgpu.h +5063 -0
- package/cpp/dawn/include/webgpu/webgpu_cpp.h +10401 -0
- package/cpp/dawn/include/webgpu/webgpu_cpp_chained_struct.h +57 -0
- package/cpp/dawn/include/webgpu/webgpu_enum_class_bitmasks.h +163 -0
- package/cpp/dawn/include/webgpu/webgpu_glfw.h +88 -0
- package/cpp/rnskia/RNSkGraphiteProducer.cpp +189 -0
- package/cpp/rnskia/RNSkGraphiteProducer.h +116 -0
- package/cpp/rnskia/RNSkGraphiteView.h +129 -24
- package/cpp/rnskia/RNSkJsiViewApi.h +2 -6
- package/cpp/rnskia/RNSkPictureView.cpp +22 -11
- package/cpp/rnskia/RNSkPictureView.h +24 -11
- package/cpp/rnskia/RNSkThreadPool.h +91 -0
- package/cpp/rnskia/RNSkView.h +18 -0
- package/cpp/skia/src/gpu/graphite/ContextOptionsPriv.h +45 -0
- package/cpp/skia/src/gpu/graphite/ResourceTypes.h +362 -0
- package/cpp/skia/src/gpu/graphite/TextureProxyView.h +105 -0
- package/lib/commonjs/index.d.ts +4 -1
- package/lib/commonjs/index.js +31 -12
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mock/index.js +1 -0
- package/lib/commonjs/mock/index.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.d.ts +10 -1
- package/lib/commonjs/renderer/Canvas.js +37 -10
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/renderer/DefaultCanvas.d.ts +8 -0
- package/lib/commonjs/renderer/DefaultCanvas.js +42 -0
- package/lib/commonjs/renderer/DefaultCanvas.js.map +1 -0
- package/lib/commonjs/renderer/GraphiteCanvas.d.ts +22 -0
- package/lib/commonjs/renderer/GraphiteCanvas.js +64 -0
- package/lib/commonjs/renderer/GraphiteCanvas.js.map +1 -0
- package/lib/commonjs/renderer/GraphiteCanvas.web.d.ts +1 -0
- package/lib/commonjs/renderer/GraphiteCanvas.web.js +13 -0
- package/lib/commonjs/renderer/GraphiteCanvas.web.js.map +1 -0
- package/lib/module/index.d.ts +4 -1
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/mock/index.js +1 -0
- package/lib/module/mock/index.js.map +1 -1
- package/lib/module/renderer/Canvas.d.ts +10 -1
- package/lib/module/renderer/Canvas.js +35 -9
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/renderer/DefaultCanvas.d.ts +8 -0
- package/lib/module/renderer/DefaultCanvas.js +34 -0
- package/lib/module/renderer/DefaultCanvas.js.map +1 -0
- package/lib/module/renderer/GraphiteCanvas.d.ts +22 -0
- package/lib/module/renderer/GraphiteCanvas.js +57 -0
- package/lib/module/renderer/GraphiteCanvas.js.map +1 -0
- package/lib/module/renderer/GraphiteCanvas.web.d.ts +1 -0
- package/lib/module/renderer/GraphiteCanvas.web.js +4 -0
- package/lib/module/renderer/GraphiteCanvas.web.js.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -1
- package/lib/typescript/src/renderer/Canvas.d.ts +10 -1
- package/lib/typescript/src/renderer/DefaultCanvas.d.ts +8 -0
- package/lib/typescript/src/renderer/GraphiteCanvas.d.ts +22 -0
- package/lib/typescript/src/renderer/GraphiteCanvas.web.d.ts +1 -0
- package/libs/.graphite +1 -0
- package/package.json +4 -5
- package/src/index.ts +4 -1
- package/src/mock/index.ts +1 -0
- package/src/renderer/Canvas.tsx +29 -9
- package/src/renderer/DefaultCanvas.tsx +41 -0
- package/src/renderer/GraphiteCanvas.tsx +61 -0
- package/src/renderer/GraphiteCanvas.web.tsx +3 -0
package/android/CMakeLists.txt
CHANGED
|
@@ -85,6 +85,7 @@ add_library(
|
|
|
85
85
|
|
|
86
86
|
"${PROJECT_SOURCE_DIR}/../cpp/rnskia/RNSkManager.cpp"
|
|
87
87
|
"${PROJECT_SOURCE_DIR}/../cpp/rnskia/RNSkPictureView.cpp"
|
|
88
|
+
"${PROJECT_SOURCE_DIR}/../cpp/rnskia/RNSkGraphiteProducer.cpp"
|
|
88
89
|
|
|
89
90
|
"${PROJECT_SOURCE_DIR}/../cpp/api/third_party/CSSColorParser.cpp"
|
|
90
91
|
"${PROJECT_SOURCE_DIR}/../cpp/api/third_party/base64.cpp"
|
|
@@ -61,16 +61,21 @@ protected:
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
virtual void unregisterView() {
|
|
64
|
-
|
|
65
|
-
if (manager == nullptr || _skiaAndroidView == nullptr) {
|
|
64
|
+
if (_skiaAndroidView == nullptr) {
|
|
66
65
|
return;
|
|
67
66
|
}
|
|
68
67
|
auto skiaView = _skiaAndroidView->getSkiaView();
|
|
69
68
|
if (skiaView == nullptr) {
|
|
70
69
|
return;
|
|
71
70
|
}
|
|
72
|
-
manager
|
|
73
|
-
|
|
71
|
+
if (auto manager = getSkiaManager()) {
|
|
72
|
+
manager->setSkiaView(skiaView->getNativeId(), nullptr);
|
|
73
|
+
manager->unregisterSkiaView(skiaView->getNativeId());
|
|
74
|
+
}
|
|
75
|
+
// React drops the Java view here, but the native view behind it (and the
|
|
76
|
+
// content it owns) is only destroyed when the Java object is finalized.
|
|
77
|
+
// Release the content now so it does not wait for the garbage collector.
|
|
78
|
+
skiaView->releaseContent();
|
|
74
79
|
}
|
|
75
80
|
|
|
76
81
|
virtual jni::local_ref<jni::JArrayInt> getBitmap(int width, int height) {
|
|
@@ -59,8 +59,8 @@ protected:
|
|
|
59
59
|
highBitDepth);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
void surfaceSizeChanged(jobject surface, int width, int height,
|
|
63
|
-
bool highBitDepth) override {
|
|
62
|
+
void surfaceSizeChanged(jobject surface, int width, int height,
|
|
63
|
+
bool isSurface, bool highBitDepth) override {
|
|
64
64
|
JniSkiaBaseView::surfaceSizeChanged(surface, width, height, isSurface,
|
|
65
65
|
highBitDepth);
|
|
66
66
|
}
|
|
@@ -83,18 +83,7 @@ protected:
|
|
|
83
83
|
JniSkiaBaseView::registerView(nativeId);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
void unregisterView() override {
|
|
87
|
-
JniSkiaBaseView::unregisterView();
|
|
88
|
-
// React drops the Java view here, but the native view behind it (and the
|
|
89
|
-
// recording it owns) is only destroyed when the Java object is finalized.
|
|
90
|
-
// Release the content now so it does not wait for the Java garbage
|
|
91
|
-
// collector.
|
|
92
|
-
if (_skiaAndroidView != nullptr) {
|
|
93
|
-
auto renderer = std::static_pointer_cast<RNSkia::RNSkPictureRenderer>(
|
|
94
|
-
_skiaAndroidView->getSkiaView()->getRenderer());
|
|
95
|
-
renderer->clear();
|
|
96
|
-
}
|
|
97
|
-
}
|
|
86
|
+
void unregisterView() override { JniSkiaBaseView::unregisterView(); }
|
|
98
87
|
|
|
99
88
|
jni::local_ref<jni::JArrayInt> getBitmap(int width, int height) override {
|
|
100
89
|
// Get the RNSkPictureView from the android view
|
|
@@ -10,12 +10,25 @@
|
|
|
10
10
|
#include <include/core/SkPaint.h>
|
|
11
11
|
#include <include/core/SkPathEffect.h>
|
|
12
12
|
#include <include/core/SkPoint.h>
|
|
13
|
+
#include <include/effects/Sk1DPathEffect.h>
|
|
13
14
|
#include <include/effects/SkRuntimeEffect.h>
|
|
14
15
|
#include <modules/skparagraph/include/Paragraph.h>
|
|
15
16
|
#include <modules/skparagraph/include/ParagraphBuilder.h>
|
|
16
17
|
#include <modules/skparagraph/include/ParagraphStyle.h>
|
|
17
18
|
|
|
18
19
|
#include "../CustomBlendModes.h"
|
|
20
|
+
#include "api/JsiSkFont.h"
|
|
21
|
+
#include "api/JsiSkImage.h"
|
|
22
|
+
#include "api/JsiSkImageFilter.h"
|
|
23
|
+
#include "api/JsiSkMatrix.h"
|
|
24
|
+
#include "api/JsiSkPaint.h"
|
|
25
|
+
#include "api/JsiSkParagraph.h"
|
|
26
|
+
#include "api/JsiSkPicture.h"
|
|
27
|
+
#include "api/JsiSkRSXform.h"
|
|
28
|
+
#include "api/JsiSkRuntimeEffect.h"
|
|
29
|
+
#include "api/JsiSkSVG.h"
|
|
30
|
+
#include "api/JsiSkSkottie.h"
|
|
31
|
+
#include "api/JsiSkTextBlob.h"
|
|
19
32
|
#include "api/third_party/CSSColorParser.h"
|
|
20
33
|
|
|
21
34
|
#include "DataTypes.h"
|
|
@@ -29,8 +42,13 @@ struct Radius {
|
|
|
29
42
|
float rY;
|
|
30
43
|
};
|
|
31
44
|
|
|
32
|
-
|
|
33
|
-
|
|
45
|
+
// A value read from a shared value, waiting to be written into a command
|
|
46
|
+
// property. Reading needs the runtime the shared value lives on; writing does
|
|
47
|
+
// not, so the thread that replays the commands writes it right before.
|
|
48
|
+
// Empty when there is nothing to write.
|
|
49
|
+
using PendingWrite = std::function<void()>;
|
|
50
|
+
using ConversionFunction = std::function<PendingWrite(
|
|
51
|
+
jsi::Runtime &runtime, const jsi::Object &object)>;
|
|
34
52
|
using Variables = std::map<std::string, std::vector<ConversionFunction>>;
|
|
35
53
|
|
|
36
54
|
using Patch = std::array<SkPoint, 12>;
|
|
@@ -91,27 +109,32 @@ bool convertSelectorProperty(jsi::Runtime &runtime, const jsi::Value &prop,
|
|
|
91
109
|
sharedValue.getProperty(runtime, "name").asString(runtime).utf8(runtime);
|
|
92
110
|
|
|
93
111
|
auto conv = [target = &target, key](jsi::Runtime &runtime,
|
|
94
|
-
const jsi::Object &val) {
|
|
112
|
+
const jsi::Object &val) -> PendingWrite {
|
|
95
113
|
auto value = val.getProperty(runtime, "value");
|
|
96
114
|
if (!value.isObject()) {
|
|
97
|
-
return;
|
|
115
|
+
return nullptr;
|
|
98
116
|
}
|
|
99
117
|
auto values = value.asObject(runtime);
|
|
100
118
|
if (!values.hasProperty(runtime, key.c_str())) {
|
|
101
|
-
return;
|
|
119
|
+
return nullptr;
|
|
102
120
|
}
|
|
103
121
|
|
|
104
122
|
auto selected = values.getProperty(runtime, key.c_str());
|
|
105
123
|
if (selected.isUndefined() || selected.isNull() ||
|
|
106
124
|
(selected.isObject() &&
|
|
107
125
|
selected.asObject(runtime).isFunction(runtime))) {
|
|
108
|
-
return;
|
|
126
|
+
return nullptr;
|
|
109
127
|
}
|
|
110
|
-
|
|
128
|
+
return
|
|
129
|
+
[target, converted = getPropertyValue<T>(runtime, selected)]() mutable {
|
|
130
|
+
*target = std::move(converted);
|
|
131
|
+
};
|
|
111
132
|
};
|
|
112
133
|
|
|
113
134
|
variables[name].push_back(conv);
|
|
114
|
-
conv(runtime, sharedValue)
|
|
135
|
+
if (auto write = conv(runtime, sharedValue)) {
|
|
136
|
+
write();
|
|
137
|
+
}
|
|
115
138
|
return true;
|
|
116
139
|
}
|
|
117
140
|
|
|
@@ -135,12 +158,17 @@ void convertPropertyImpl(jsi::Runtime &runtime, const jsi::Object &object,
|
|
|
135
158
|
.asString(runtime)
|
|
136
159
|
.utf8(runtime);
|
|
137
160
|
auto conv = [target = &target](jsi::Runtime &runtime,
|
|
138
|
-
const jsi::Object &val) {
|
|
161
|
+
const jsi::Object &val) -> PendingWrite {
|
|
139
162
|
auto value = val.getProperty(runtime, "value");
|
|
140
|
-
|
|
163
|
+
return
|
|
164
|
+
[target, converted = getPropertyValue<T>(runtime, value)]() mutable {
|
|
165
|
+
*target = std::move(converted);
|
|
166
|
+
};
|
|
141
167
|
};
|
|
142
168
|
variables[name].push_back(conv);
|
|
143
|
-
conv(runtime, sharedValue)
|
|
169
|
+
if (auto write = conv(runtime, sharedValue)) {
|
|
170
|
+
write();
|
|
171
|
+
}
|
|
144
172
|
return;
|
|
145
173
|
}
|
|
146
174
|
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <string>
|
|
5
|
+
#include <vector>
|
|
6
|
+
|
|
3
7
|
#include <jsi/jsi.h>
|
|
4
8
|
|
|
9
|
+
#include "include/core/SkData.h"
|
|
10
|
+
#include "include/utils/SkParsePath.h"
|
|
11
|
+
|
|
12
|
+
#include "api/JsiSkPath.h"
|
|
13
|
+
#include "api/JsiSkRRect.h"
|
|
14
|
+
#include "api/JsiSkRect.h"
|
|
15
|
+
#include "api/JsiSkRuntimeEffect.h"
|
|
16
|
+
|
|
5
17
|
namespace RNSkia {
|
|
6
18
|
|
|
7
19
|
using Uniforms = std::map<std::string, std::vector<float>>;
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
+
#include <algorithm>
|
|
4
|
+
#include <functional>
|
|
3
5
|
#include <memory>
|
|
6
|
+
#include <numeric>
|
|
7
|
+
#include <stdexcept>
|
|
8
|
+
#include <utility>
|
|
4
9
|
#include <vector>
|
|
5
10
|
|
|
11
|
+
#include "include/core/SkCanvas.h"
|
|
12
|
+
#include "include/core/SkColorFilter.h"
|
|
13
|
+
#include "include/core/SkImageFilter.h"
|
|
14
|
+
#include "include/core/SkMaskFilter.h"
|
|
15
|
+
#include "include/core/SkPaint.h"
|
|
16
|
+
#include "include/core/SkPathEffect.h"
|
|
17
|
+
#include "include/core/SkShader.h"
|
|
18
|
+
#include "include/effects/SkImageFilters.h"
|
|
19
|
+
|
|
6
20
|
namespace RNSkia {
|
|
7
21
|
|
|
8
22
|
// Generic composer type using std::function
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
+
#include <algorithm>
|
|
4
|
+
#include <memory>
|
|
3
5
|
#include <optional>
|
|
6
|
+
#include <string>
|
|
7
|
+
#include <vector>
|
|
4
8
|
|
|
5
9
|
#include "Command.h"
|
|
6
10
|
#include "Convertor.h"
|
|
@@ -8,6 +12,7 @@
|
|
|
8
12
|
#include "ImageFit.h"
|
|
9
13
|
#include "rnskia/RNSkPlatformContext.h"
|
|
10
14
|
|
|
15
|
+
#include "include/core/SkContourMeasure.h"
|
|
11
16
|
#include "include/core/SkPathBuilder.h"
|
|
12
17
|
#include "include/core/SkStrokeRec.h"
|
|
13
18
|
|
|
@@ -2,7 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
#include <optional>
|
|
4
4
|
#include <string>
|
|
5
|
+
#include <utility>
|
|
5
6
|
#include <variant>
|
|
7
|
+
#include <vector>
|
|
8
|
+
|
|
9
|
+
#include <include/effects/Sk1DPathEffect.h>
|
|
10
|
+
#include <include/effects/Sk2DPathEffect.h>
|
|
11
|
+
#include <include/effects/SkCornerPathEffect.h>
|
|
12
|
+
#include <include/effects/SkDashPathEffect.h>
|
|
13
|
+
#include <include/effects/SkDiscretePathEffect.h>
|
|
6
14
|
|
|
7
15
|
#include "Command.h"
|
|
8
16
|
#include "Convertor.h"
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
#include <atomic>
|
|
5
5
|
#include <cmath>
|
|
6
6
|
#include <cstdint>
|
|
7
|
+
#include <map>
|
|
7
8
|
#include <memory>
|
|
8
9
|
#include <mutex>
|
|
9
10
|
#include <optional>
|
|
@@ -45,12 +46,51 @@ private:
|
|
|
45
46
|
CommandList commands;
|
|
46
47
|
std::vector<CommandList *> commandStack;
|
|
47
48
|
|
|
48
|
-
// Once a view owns the recording, the Reanimated mapper
|
|
49
|
-
// values into
|
|
50
|
-
//
|
|
51
|
-
// never nests with
|
|
49
|
+
// Once a view owns the recording, the Reanimated mapper reads the shared
|
|
50
|
+
// values into pending writes (readUpdates, UI thread) and whoever replays
|
|
51
|
+
// the commands writes them into the commands first (play, under this
|
|
52
|
+
// lock). Nothing else holds this lock, so it never nests with a view's
|
|
53
|
+
// lock.
|
|
52
54
|
std::mutex _commandsMutex;
|
|
53
55
|
|
|
56
|
+
// The pending writes, one slot per conversion function: a value read
|
|
57
|
+
// several times between two replays is written once (the last read wins),
|
|
58
|
+
// and the memory stays bounded whatever the ratio of updates to replays.
|
|
59
|
+
// The slots are assigned on the first read, once the recording, and thus
|
|
60
|
+
// `variables`, is complete.
|
|
61
|
+
std::mutex _pendingMutex;
|
|
62
|
+
std::vector<PendingWrite> _pendingWrites;
|
|
63
|
+
std::map<std::string, size_t> _slotBase;
|
|
64
|
+
bool _hasPendingWrites = false;
|
|
65
|
+
|
|
66
|
+
size_t slotBase(const std::string &name) {
|
|
67
|
+
std::lock_guard<std::mutex> lock(_pendingMutex);
|
|
68
|
+
if (_slotBase.empty()) {
|
|
69
|
+
size_t count = 0;
|
|
70
|
+
for (const auto &entry : variables) {
|
|
71
|
+
_slotBase[entry.first] = count;
|
|
72
|
+
count += entry.second.size();
|
|
73
|
+
}
|
|
74
|
+
_pendingWrites.resize(count);
|
|
75
|
+
}
|
|
76
|
+
return _slotBase.at(name);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Writes the pending values into the commands. Under _commandsMutex. */
|
|
80
|
+
void flushPendingWritesLocked() {
|
|
81
|
+
std::lock_guard<std::mutex> lock(_pendingMutex);
|
|
82
|
+
if (!_hasPendingWrites) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
for (auto &write : _pendingWrites) {
|
|
86
|
+
if (write) {
|
|
87
|
+
write();
|
|
88
|
+
write = nullptr;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
_hasPendingWrites = false;
|
|
92
|
+
}
|
|
93
|
+
|
|
54
94
|
CommandList ¤tCommands() { return *commandStack.back(); }
|
|
55
95
|
|
|
56
96
|
void pushCommand(std::unique_ptr<Command> command) {
|
|
@@ -404,6 +444,7 @@ public:
|
|
|
404
444
|
|
|
405
445
|
void play(DrawingCtx *ctx) {
|
|
406
446
|
std::lock_guard<std::mutex> lock(_commandsMutex);
|
|
447
|
+
flushPendingWritesLocked();
|
|
407
448
|
for (const auto &cmd : commands) {
|
|
408
449
|
playCommand(ctx, cmd.get());
|
|
409
450
|
}
|
|
@@ -425,23 +466,39 @@ public:
|
|
|
425
466
|
|
|
426
467
|
/**
|
|
427
468
|
* Reads the current value of each shared value (in the order they were
|
|
428
|
-
* registered as variable0, variable1, ...) on the calling runtime
|
|
429
|
-
* writes
|
|
469
|
+
* registered as variable0, variable1, ...) on the calling runtime into the
|
|
470
|
+
* pending writes. The writes do not need the runtime: the next replay
|
|
471
|
+
* (play, on whichever thread owns the commands) writes them into the
|
|
472
|
+
* commands first, so the caller never waits for a replay.
|
|
430
473
|
*/
|
|
431
|
-
void
|
|
432
|
-
std::lock_guard<std::mutex> lock(_commandsMutex);
|
|
474
|
+
void readUpdates(jsi::Runtime &runtime, const jsi::Array &values) {
|
|
433
475
|
auto size = values.size(runtime);
|
|
434
476
|
for (size_t i = 0; i < size; i++) {
|
|
435
477
|
auto sharedValue = values.getValueAtIndex(runtime, i).asObject(runtime);
|
|
436
478
|
auto name = "variable" + std::to_string(i);
|
|
437
479
|
auto it = variables.find(name);
|
|
438
|
-
if (it
|
|
439
|
-
|
|
440
|
-
|
|
480
|
+
if (it == variables.end()) {
|
|
481
|
+
continue;
|
|
482
|
+
}
|
|
483
|
+
auto base = slotBase(name);
|
|
484
|
+
for (size_t j = 0; j < it->second.size(); j++) {
|
|
485
|
+
if (auto write = it->second[j](runtime, sharedValue)) {
|
|
486
|
+
std::lock_guard<std::mutex> lock(_pendingMutex);
|
|
487
|
+
_pendingWrites[base + j] = std::move(write);
|
|
488
|
+
_hasPendingWrites = true;
|
|
441
489
|
}
|
|
442
490
|
}
|
|
443
491
|
}
|
|
444
492
|
}
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Reads the shared values and writes them into the commands right away.
|
|
496
|
+
*/
|
|
497
|
+
void applyUpdates(jsi::Runtime &runtime, const jsi::Array &values) {
|
|
498
|
+
readUpdates(runtime, values);
|
|
499
|
+
std::lock_guard<std::mutex> lock(_commandsMutex);
|
|
500
|
+
flushPendingWritesLocked();
|
|
501
|
+
}
|
|
445
502
|
};
|
|
446
503
|
|
|
447
504
|
inline void Recorder::playCommand(DrawingCtx *ctx, Command *cmd) {
|
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
#include <optional>
|
|
4
4
|
#include <string>
|
|
5
|
+
#include <utility>
|
|
5
6
|
#include <variant>
|
|
7
|
+
#include <vector>
|
|
6
8
|
|
|
7
9
|
#include <include/core/SkSamplingOptions.h>
|
|
8
10
|
#include <include/effects/SkGradient.h>
|
|
11
|
+
#include <include/effects/SkPerlinNoiseShader.h>
|
|
9
12
|
|
|
10
13
|
#include "Command.h"
|
|
11
14
|
#include "Convertor.h"
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Copyright 2019 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_DAWN_DAWN_PROC_H_
|
|
29
|
+
#define INCLUDE_DAWN_DAWN_PROC_H_
|
|
30
|
+
|
|
31
|
+
#include <webgpu/webgpu.h>
|
|
32
|
+
|
|
33
|
+
#include "dawn/dawn_proc_table.h"
|
|
34
|
+
|
|
35
|
+
#ifdef __cplusplus
|
|
36
|
+
extern "C" {
|
|
37
|
+
#endif
|
|
38
|
+
|
|
39
|
+
// Sets the static proctable used by libdawn_proc to implement the Dawn entrypoints. Passing NULL
|
|
40
|
+
// for `procs` sets up the null proctable that contains only null function pointers. It is the
|
|
41
|
+
// default value of the proctable. Setting the proctable back to null is good practice when you
|
|
42
|
+
// are done using libdawn_proc since further usage will cause a segfault instead of calling an
|
|
43
|
+
// unexpected function.
|
|
44
|
+
WGPU_EXPORT void dawnProcSetProcs(const DawnProcTable* procs);
|
|
45
|
+
|
|
46
|
+
// Returns the static array of uint8_t of size 20 representing the Dawn version.
|
|
47
|
+
WGPU_EXPORT const uint8_t* dawnProcGetVersion();
|
|
48
|
+
|
|
49
|
+
#ifdef __cplusplus
|
|
50
|
+
} // extern "C"
|
|
51
|
+
#endif
|
|
52
|
+
|
|
53
|
+
#endif // INCLUDE_DAWN_DAWN_PROC_H_
|