@shopify/react-native-skia 1.5.8 → 1.5.9
Sign up to get free protection for your applications and to get access to all the features.
- package/android/CMakeLists.txt +0 -1
- package/android/cpp/jni/JniPlatformContext.cpp +0 -49
- package/android/cpp/jni/include/JniPlatformContext.h +1 -17
- package/android/cpp/jni/include/JniSkiaBaseView.h +0 -2
- package/android/cpp/jni/include/JniSkiaDomView.h +0 -3
- package/android/cpp/jni/include/JniSkiaManager.h +0 -2
- package/android/cpp/jni/include/JniSkiaPictureView.h +0 -3
- package/android/cpp/rnskia-android/MainThreadDispatcher.h +69 -0
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +4 -11
- package/android/cpp/rnskia-android/RNSkAndroidView.h +3 -13
- package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +0 -1
- package/android/src/main/java/com/shopify/reactnative/skia/PlatformContext.java +0 -85
- package/android/src/main/java/com/shopify/reactnative/skia/RNSkiaModule.java +1 -21
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaManager.java +0 -4
- package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaDomViewManagerDelegate.java +1 -4
- package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaDomViewManagerInterface.java +0 -1
- package/cpp/rnskia/RNSkManager.cpp +2 -3
- package/cpp/rnskia/RNSkPlatformContext.h +2 -114
- package/cpp/rnskia/RNSkView.h +16 -75
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +1 -10
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +0 -16
- package/ios/RNSkia-iOS/SkiaDomView.mm +0 -1
- package/ios/RNSkia-iOS/SkiaDomViewManager.mm +0 -6
- package/ios/RNSkia-iOS/SkiaPictureView.mm +0 -1
- package/ios/RNSkia-iOS/SkiaPictureViewManager.mm +0 -6
- package/ios/RNSkia-iOS/SkiaUIView.h +0 -1
- package/ios/RNSkia-iOS/SkiaUIView.mm +1 -14
- package/lib/commonjs/renderer/Canvas.d.ts +1 -0
- package/lib/commonjs/renderer/Canvas.js +5 -5
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +0 -1
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +1 -1
- package/lib/commonjs/views/SkiaBaseWebView.d.ts +1 -12
- package/lib/commonjs/views/SkiaBaseWebView.js +1 -19
- package/lib/commonjs/views/SkiaBaseWebView.js.map +1 -1
- package/lib/commonjs/views/SkiaDomView.d.ts +8 -1
- package/lib/commonjs/views/SkiaDomView.js +14 -2
- package/lib/commonjs/views/SkiaDomView.js.map +1 -1
- package/lib/commonjs/views/SkiaDomView.web.d.ts +3 -3
- package/lib/commonjs/views/SkiaDomView.web.js.map +1 -1
- package/lib/commonjs/views/SkiaJSDomView.d.ts +12 -6
- package/lib/commonjs/views/SkiaJSDomView.js +12 -3
- package/lib/commonjs/views/SkiaJSDomView.js.map +1 -1
- package/lib/commonjs/views/SkiaPictureView.d.ts +8 -1
- package/lib/commonjs/views/SkiaPictureView.js +14 -1
- package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
- package/lib/commonjs/views/SkiaPictureView.web.d.ts +3 -3
- package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
- package/lib/commonjs/views/types.d.ts +2 -12
- package/lib/commonjs/views/types.js.map +1 -1
- package/lib/module/renderer/Canvas.d.ts +1 -0
- package/lib/module/renderer/Canvas.js +5 -5
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +0 -1
- package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +1 -1
- package/lib/module/views/SkiaBaseWebView.d.ts +1 -12
- package/lib/module/views/SkiaBaseWebView.js +1 -19
- package/lib/module/views/SkiaBaseWebView.js.map +1 -1
- package/lib/module/views/SkiaDomView.d.ts +8 -1
- package/lib/module/views/SkiaDomView.js +14 -2
- package/lib/module/views/SkiaDomView.js.map +1 -1
- package/lib/module/views/SkiaDomView.web.d.ts +3 -3
- package/lib/module/views/SkiaDomView.web.js.map +1 -1
- package/lib/module/views/SkiaJSDomView.d.ts +12 -6
- package/lib/module/views/SkiaJSDomView.js +12 -3
- package/lib/module/views/SkiaJSDomView.js.map +1 -1
- package/lib/module/views/SkiaPictureView.d.ts +8 -1
- package/lib/module/views/SkiaPictureView.js +14 -1
- package/lib/module/views/SkiaPictureView.js.map +1 -1
- package/lib/module/views/SkiaPictureView.web.d.ts +3 -3
- package/lib/module/views/SkiaPictureView.web.js.map +1 -1
- package/lib/module/views/types.d.ts +2 -12
- package/lib/module/views/types.js.map +1 -1
- package/lib/typescript/lib/commonjs/views/SkiaBaseWebView.d.ts +0 -11
- package/lib/typescript/lib/commonjs/views/SkiaDomView.d.ts +3 -0
- package/lib/typescript/lib/commonjs/views/SkiaJSDomView.d.ts +2 -0
- package/lib/typescript/lib/commonjs/views/SkiaPictureView.d.ts +3 -0
- package/lib/typescript/lib/module/views/SkiaBaseWebView.d.ts +0 -11
- package/lib/typescript/lib/module/views/SkiaDomView.d.ts +3 -0
- package/lib/typescript/lib/module/views/SkiaJSDomView.d.ts +2 -0
- package/lib/typescript/lib/module/views/SkiaPictureView.d.ts +3 -0
- package/lib/typescript/src/renderer/Canvas.d.ts +1 -0
- package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.d.ts +0 -1
- package/lib/typescript/src/views/SkiaBaseWebView.d.ts +1 -12
- package/lib/typescript/src/views/SkiaDomView.d.ts +8 -1
- package/lib/typescript/src/views/SkiaDomView.web.d.ts +3 -3
- package/lib/typescript/src/views/SkiaJSDomView.d.ts +12 -6
- package/lib/typescript/src/views/SkiaPictureView.d.ts +8 -1
- package/lib/typescript/src/views/SkiaPictureView.web.d.ts +3 -3
- package/lib/typescript/src/views/types.d.ts +2 -12
- package/package.json +1 -1
- package/src/renderer/Canvas.tsx +4 -3
- package/src/specs/SkiaPictureViewNativeComponent.ts +0 -1
- package/src/views/SkiaBaseWebView.tsx +3 -19
- package/src/views/SkiaDomView.tsx +23 -4
- package/src/views/SkiaDomView.web.tsx +3 -3
- package/src/views/SkiaJSDomView.tsx +30 -9
- package/src/views/SkiaPictureView.tsx +22 -2
- package/src/views/SkiaPictureView.web.tsx +3 -3
- package/src/views/types.ts +2 -13
- package/cpp/rnskia/RNSkDispatchQueue.cpp +0 -73
- package/cpp/rnskia/RNSkDispatchQueue.h +0 -49
- package/ios/RNSkia-iOS/DisplayLink.h +0 -17
- package/ios/RNSkia-iOS/DisplayLink.mm +0 -41
@@ -9,7 +9,6 @@
|
|
9
9
|
#include <unordered_map>
|
10
10
|
#include <utility>
|
11
11
|
|
12
|
-
#include "RNSkDispatchQueue.h"
|
13
12
|
#include "RNSkVideo.h"
|
14
13
|
#include "WindowContext.h"
|
15
14
|
|
@@ -42,57 +41,19 @@ public:
|
|
42
41
|
std::shared_ptr<react::CallInvoker> callInvoker,
|
43
42
|
float pixelDensity)
|
44
43
|
: _pixelDensity(pixelDensity), _jsRuntime(runtime),
|
45
|
-
_callInvoker(callInvoker)
|
46
|
-
_dispatchQueue(
|
47
|
-
std::make_unique<RNSkDispatchQueue>("skia-render-thread")) {
|
48
|
-
_jsThreadId = std::this_thread::get_id();
|
44
|
+
_callInvoker(callInvoker) {
|
49
45
|
}
|
50
46
|
|
51
|
-
|
52
|
-
* Destructor
|
53
|
-
*/
|
54
|
-
virtual ~RNSkPlatformContext() { invalidate(); }
|
55
|
-
|
56
|
-
void invalidate() {
|
57
|
-
if (!_isValid) {
|
58
|
-
return;
|
59
|
-
}
|
60
|
-
// Stop the refresh loop
|
61
|
-
stopDrawLoop();
|
62
|
-
// Notify draw loop listeners once with the invalidated parameter
|
63
|
-
// set to true signalling that we are done and can clean up.
|
64
|
-
notifyDrawLoop(true);
|
65
|
-
_isValid = false;
|
66
|
-
}
|
67
|
-
|
68
|
-
/*
|
69
|
-
Returns true if the current execution context is the javascript thread.
|
70
|
-
*/
|
71
|
-
bool isOnJavascriptThread() {
|
72
|
-
return _jsThreadId == std::this_thread::get_id();
|
73
|
-
}
|
47
|
+
virtual ~RNSkPlatformContext() = default;
|
74
48
|
|
75
49
|
/**
|
76
50
|
* Schedules the function to be run on the javascript thread async
|
77
51
|
* @param func Function to run
|
78
52
|
*/
|
79
53
|
void runOnJavascriptThread(std::function<void()> func) {
|
80
|
-
if (!_isValid) {
|
81
|
-
return;
|
82
|
-
}
|
83
54
|
_callInvoker->invokeAsync(std::move(func));
|
84
55
|
}
|
85
56
|
|
86
|
-
/**
|
87
|
-
Runs the function on the render thread
|
88
|
-
*/
|
89
|
-
void runOnRenderThread(std::function<void()> func) {
|
90
|
-
if (!_isValid) {
|
91
|
-
return;
|
92
|
-
}
|
93
|
-
_dispatchQueue->dispatch(std::move(func));
|
94
|
-
}
|
95
|
-
|
96
57
|
/**
|
97
58
|
* Runs the passed function on the main thread
|
98
59
|
* @param func Function to run.
|
@@ -192,82 +153,9 @@ public:
|
|
192
153
|
*/
|
193
154
|
float getPixelDensity() { return _pixelDensity; }
|
194
155
|
|
195
|
-
/**
|
196
|
-
* Starts (if not started) a loop that will call back on display sync
|
197
|
-
* @param callback Callback to call on sync
|
198
|
-
* @returns Identifier of the draw loop entry
|
199
|
-
*/
|
200
|
-
size_t beginDrawLoop(size_t nativeId, std::function<void(bool)> callback) {
|
201
|
-
if (!_isValid) {
|
202
|
-
return 0;
|
203
|
-
}
|
204
|
-
auto shouldStart = false;
|
205
|
-
{
|
206
|
-
std::lock_guard<std::mutex> lock(_drawCallbacksLock);
|
207
|
-
_drawCallbacks.emplace(nativeId, std::move(callback));
|
208
|
-
shouldStart = _drawCallbacks.size() == 1;
|
209
|
-
}
|
210
|
-
if (shouldStart) {
|
211
|
-
// Start
|
212
|
-
startDrawLoop();
|
213
|
-
}
|
214
|
-
return nativeId;
|
215
|
-
}
|
216
|
-
|
217
|
-
/**
|
218
|
-
* Ends (if running) the drawing loop that was started with beginDrawLoop.
|
219
|
-
* This method must be called symmetrically with the beginDrawLoop method.
|
220
|
-
* @param nativeId Identifier of view to end
|
221
|
-
*/
|
222
|
-
void endDrawLoop(size_t nativeId) {
|
223
|
-
if (!_isValid) {
|
224
|
-
return;
|
225
|
-
}
|
226
|
-
auto shouldStop = false;
|
227
|
-
{
|
228
|
-
std::lock_guard<std::mutex> lock(_drawCallbacksLock);
|
229
|
-
if (_drawCallbacks.count(nativeId) > 0) {
|
230
|
-
_drawCallbacks.erase(nativeId);
|
231
|
-
}
|
232
|
-
shouldStop = _drawCallbacks.size() == 0;
|
233
|
-
}
|
234
|
-
if (shouldStop) {
|
235
|
-
stopDrawLoop();
|
236
|
-
}
|
237
|
-
}
|
238
|
-
|
239
|
-
/**
|
240
|
-
* Notifies all drawing callbacks
|
241
|
-
* @param invalidated True if the context was invalidated, otherwise false.
|
242
|
-
* This can be used to receive a notification that we have stopped the main
|
243
|
-
* drawloop
|
244
|
-
*/
|
245
|
-
void notifyDrawLoop(bool invalidated) {
|
246
|
-
if (!_isValid) {
|
247
|
-
return;
|
248
|
-
}
|
249
|
-
std::lock_guard<std::mutex> lock(_drawCallbacksLock);
|
250
|
-
for (auto it = _drawCallbacks.begin(); it != _drawCallbacks.end(); it++) {
|
251
|
-
it->second(invalidated);
|
252
|
-
}
|
253
|
-
}
|
254
|
-
|
255
|
-
// default implementation does nothing, so it can be called from virtual
|
256
|
-
// destructor.
|
257
|
-
virtual void startDrawLoop() {}
|
258
|
-
virtual void stopDrawLoop() {}
|
259
|
-
|
260
156
|
private:
|
261
157
|
float _pixelDensity;
|
262
|
-
|
263
|
-
std::thread::id _jsThreadId;
|
264
|
-
|
265
158
|
jsi::Runtime *_jsRuntime;
|
266
159
|
std::shared_ptr<react::CallInvoker> _callInvoker;
|
267
|
-
std::unique_ptr<RNSkDispatchQueue> _dispatchQueue;
|
268
|
-
|
269
|
-
std::unordered_map<size_t, std::function<void(bool)>> _drawCallbacks;
|
270
|
-
std::mutex _drawCallbacksLock;
|
271
|
-
std::atomic<bool> _isValid = {true};
|
272
160
|
};
|
273
161
|
} // namespace RNSkia
|
package/cpp/rnskia/RNSkView.h
CHANGED
@@ -145,8 +145,6 @@ private:
|
|
145
145
|
std::shared_ptr<RNSkPlatformContext> _context;
|
146
146
|
};
|
147
147
|
|
148
|
-
enum RNSkDrawingMode { Default, Continuous };
|
149
|
-
|
150
148
|
class RNSkView : public std::enable_shared_from_this<RNSkView> {
|
151
149
|
public:
|
152
150
|
/**
|
@@ -161,7 +159,7 @@ public:
|
|
161
159
|
/**
|
162
160
|
Destructor
|
163
161
|
*/
|
164
|
-
virtual ~RNSkView() {
|
162
|
+
virtual ~RNSkView() {}
|
165
163
|
|
166
164
|
/**
|
167
165
|
Sets custom properties. Custom properties are properties that are set
|
@@ -172,43 +170,33 @@ public:
|
|
172
170
|
// Nothing here...
|
173
171
|
}
|
174
172
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
173
|
+
void requestRedraw() {
|
174
|
+
if (!_redrawRequested) {
|
175
|
+
_redrawRequested = true;
|
176
|
+
_platformContext->runOnMainThread([this]() {
|
177
|
+
if (_renderer) {
|
178
|
+
_renderer->renderImmediate(_canvasProvider);
|
179
|
+
_redrawRequested = false;
|
180
|
+
}
|
181
|
+
});
|
182
|
+
}
|
183
|
+
}
|
181
184
|
|
182
|
-
|
183
|
-
Renders immediate. Be carefull to not call this method from another thread
|
184
|
-
than the UI thread
|
185
|
-
*/
|
186
|
-
void renderImmediate() {
|
185
|
+
void redraw() {
|
187
186
|
_renderer->renderImmediate(_canvasProvider);
|
188
|
-
|
187
|
+
_redrawRequested = false;
|
189
188
|
}
|
190
189
|
|
191
190
|
/**
|
192
191
|
Sets the native id of the view
|
193
192
|
*/
|
194
|
-
virtual void setNativeId(size_t nativeId) {
|
195
|
-
_nativeId = nativeId;
|
196
|
-
beginDrawingLoop();
|
197
|
-
}
|
193
|
+
virtual void setNativeId(size_t nativeId) { _nativeId = nativeId; }
|
198
194
|
|
199
195
|
/**
|
200
196
|
Returns the native id
|
201
197
|
*/
|
202
198
|
size_t getNativeId() { return _nativeId; }
|
203
199
|
|
204
|
-
/**
|
205
|
-
Sets the drawing mode for the view
|
206
|
-
*/
|
207
|
-
void setDrawingMode(RNSkDrawingMode mode) {
|
208
|
-
_drawingMode = mode;
|
209
|
-
requestRedraw();
|
210
|
-
}
|
211
|
-
|
212
200
|
/**
|
213
201
|
* Set to true to show the debug overlays on render
|
214
202
|
*/
|
@@ -240,61 +228,14 @@ protected:
|
|
240
228
|
return _canvasProvider;
|
241
229
|
}
|
242
230
|
|
243
|
-
/**
|
244
|
-
Ends an ongoing beginDrawCallback loop for this view. This method is made
|
245
|
-
protected if the drawing loop should be stopped before reaching the
|
246
|
-
destructor (like we do for Android views)
|
247
|
-
*/
|
248
|
-
void endDrawingLoop() {
|
249
|
-
if (_drawingLoopId != 0) {
|
250
|
-
_drawingLoopId = 0;
|
251
|
-
_platformContext->endDrawLoop(_nativeId);
|
252
|
-
}
|
253
|
-
}
|
254
|
-
|
255
231
|
private:
|
256
|
-
/**
|
257
|
-
Starts beginDrawCallback loop if the drawing mode is continuous
|
258
|
-
*/
|
259
|
-
void beginDrawingLoop() {
|
260
|
-
if (_drawingLoopId != 0 || _nativeId == 0) {
|
261
|
-
return;
|
262
|
-
}
|
263
|
-
// Set to zero to avoid calling beginDrawLoop before we return
|
264
|
-
_drawingLoopId = _platformContext->beginDrawLoop(
|
265
|
-
_nativeId, [weakSelf = weak_from_this()](bool invalidated) {
|
266
|
-
auto self = weakSelf.lock();
|
267
|
-
if (self) {
|
268
|
-
self->drawLoopCallback(invalidated);
|
269
|
-
}
|
270
|
-
});
|
271
|
-
}
|
272
|
-
|
273
|
-
/**
|
274
|
-
Draw loop callback
|
275
|
-
*/
|
276
|
-
void drawLoopCallback(bool invalidated) {
|
277
|
-
if (_redrawRequestCounter > 0 ||
|
278
|
-
_drawingMode == RNSkDrawingMode::Continuous) {
|
279
|
-
_redrawRequestCounter = 0;
|
280
|
-
|
281
|
-
if (!_renderer->tryRender(_canvasProvider)) {
|
282
|
-
// The renderer could not render cause it was busy, just schedule
|
283
|
-
// redrawing on the next frame.
|
284
|
-
requestRedraw();
|
285
|
-
}
|
286
|
-
}
|
287
|
-
}
|
288
|
-
|
289
232
|
std::shared_ptr<RNSkPlatformContext> _platformContext;
|
290
233
|
std::shared_ptr<RNSkCanvasProvider> _canvasProvider;
|
291
234
|
std::shared_ptr<RNSkRenderer> _renderer;
|
292
235
|
|
293
|
-
RNSkDrawingMode _drawingMode = RNSkDrawingMode::Default;
|
294
236
|
size_t _nativeId;
|
295
237
|
|
296
|
-
|
297
|
-
std::atomic<int> _redrawRequestCounter = {1};
|
238
|
+
std::atomic<bool> _redrawRequested = {false};
|
298
239
|
};
|
299
240
|
|
300
241
|
} // namespace RNSkia
|
@@ -7,7 +7,6 @@
|
|
7
7
|
#include <memory>
|
8
8
|
#include <string>
|
9
9
|
|
10
|
-
#include "DisplayLink.h"
|
11
10
|
#include "RNSkPlatformContext.h"
|
12
11
|
#include "ViewScreenshotService.h"
|
13
12
|
|
@@ -49,12 +48,8 @@ public:
|
|
49
48
|
~RNSkiOSPlatformContext() {
|
50
49
|
CFNotificationCenterRemoveEveryObserver(
|
51
50
|
CFNotificationCenterGetLocalCenter(), this);
|
52
|
-
stopDrawLoop();
|
53
51
|
}
|
54
52
|
|
55
|
-
void startDrawLoop() override;
|
56
|
-
void stopDrawLoop() override;
|
57
|
-
|
58
53
|
void runOnMainThread(std::function<void()>) override;
|
59
54
|
|
60
55
|
sk_sp<SkImage> takeScreenshotFromViewTag(size_t tag) override;
|
@@ -81,13 +76,9 @@ public:
|
|
81
76
|
#endif
|
82
77
|
sk_sp<SkFontMgr> createFontMgr() override;
|
83
78
|
|
84
|
-
void willInvalidateModules() {
|
85
|
-
// We need to do some house-cleaning here!
|
86
|
-
invalidate();
|
87
|
-
}
|
79
|
+
void willInvalidateModules() {}
|
88
80
|
|
89
81
|
private:
|
90
|
-
DisplayLink *_displayLink;
|
91
82
|
ViewScreenshotService *_screenshotService;
|
92
83
|
};
|
93
84
|
|
@@ -214,20 +214,4 @@ RNSkiOSPlatformContext::takeScreenshotFromViewTag(size_t viewTag) {
|
|
214
214
|
screenshotOfViewWithTag:[NSNumber numberWithLong:viewTag]];
|
215
215
|
}
|
216
216
|
|
217
|
-
void RNSkiOSPlatformContext::startDrawLoop() {
|
218
|
-
if (_displayLink == nullptr) {
|
219
|
-
_displayLink = [[DisplayLink alloc] init];
|
220
|
-
[_displayLink start:^(double time) {
|
221
|
-
notifyDrawLoop(false);
|
222
|
-
}];
|
223
|
-
}
|
224
|
-
}
|
225
|
-
|
226
|
-
void RNSkiOSPlatformContext::stopDrawLoop() {
|
227
|
-
if (_displayLink != nullptr) {
|
228
|
-
[_displayLink stop];
|
229
|
-
_displayLink = nullptr;
|
230
|
-
}
|
231
|
-
}
|
232
|
-
|
233
217
|
} // namespace RNSkia
|
@@ -26,12 +26,6 @@ RCT_CUSTOM_VIEW_PROPERTY(nativeID, NSNumber, SkiaUIView) {
|
|
26
26
|
[(SkiaUIView *)view setNativeId:nativeId];
|
27
27
|
}
|
28
28
|
|
29
|
-
RCT_CUSTOM_VIEW_PROPERTY(mode, NSString, SkiaUIView) {
|
30
|
-
std::string mode =
|
31
|
-
json != NULL ? [[RCTConvert NSString:json] UTF8String] : "default";
|
32
|
-
[(SkiaUIView *)view setDrawingMode:mode];
|
33
|
-
}
|
34
|
-
|
35
29
|
RCT_CUSTOM_VIEW_PROPERTY(debug, BOOL, SkiaUIView) {
|
36
30
|
bool debug = json != NULL ? [RCTConvert BOOL:json] : false;
|
37
31
|
[(SkiaUIView *)view setDebugMode:debug];
|
@@ -26,12 +26,6 @@ RCT_CUSTOM_VIEW_PROPERTY(nativeID, NSNumber, SkiaUIView) {
|
|
26
26
|
[(SkiaUIView *)view setNativeId:nativeId];
|
27
27
|
}
|
28
28
|
|
29
|
-
RCT_CUSTOM_VIEW_PROPERTY(mode, NSString, SkiaUIView) {
|
30
|
-
std::string mode =
|
31
|
-
json != NULL ? [[RCTConvert NSString:json] UTF8String] : "default";
|
32
|
-
[(SkiaUIView *)view setDrawingMode:mode];
|
33
|
-
}
|
34
|
-
|
35
29
|
RCT_CUSTOM_VIEW_PROPERTY(debug, BOOL, SkiaUIView) {
|
36
30
|
bool debug = json != NULL ? [RCTConvert BOOL:json] : false;
|
37
31
|
[(SkiaUIView *)view setDebugMode:debug];
|
@@ -11,7 +11,6 @@
|
|
11
11
|
@implementation SkiaUIView {
|
12
12
|
std::shared_ptr<RNSkBaseiOSView> _impl;
|
13
13
|
RNSkia::RNSkManager *_manager;
|
14
|
-
RNSkia::RNSkDrawingMode _drawingMode;
|
15
14
|
std::function<std::shared_ptr<RNSkBaseiOSView>(
|
16
15
|
std::shared_ptr<RNSkia::RNSkPlatformContext>)>
|
17
16
|
_factory;
|
@@ -45,7 +44,6 @@
|
|
45
44
|
_manager = manager;
|
46
45
|
_nativeId = 0;
|
47
46
|
_debugMode = false;
|
48
|
-
_drawingMode = RNSkia::RNSkDrawingMode::Default;
|
49
47
|
_factory = factory;
|
50
48
|
}
|
51
49
|
|
@@ -86,7 +84,6 @@
|
|
86
84
|
if (_nativeId != 0) {
|
87
85
|
_manager->setSkiaView(_nativeId, _impl->getDrawView());
|
88
86
|
}
|
89
|
-
_impl->getDrawView()->setDrawingMode(_drawingMode);
|
90
87
|
_impl->getDrawView()->setShowDebugOverlays(_debugMode);
|
91
88
|
}
|
92
89
|
}
|
@@ -131,7 +128,7 @@
|
|
131
128
|
// We override drawRect to ensure we to direct rendering when the
|
132
129
|
// underlying OS view needs to render:
|
133
130
|
if (_impl != nullptr) {
|
134
|
-
_impl->getDrawView()->
|
131
|
+
_impl->getDrawView()->redraw();
|
135
132
|
}
|
136
133
|
}
|
137
134
|
|
@@ -146,16 +143,6 @@
|
|
146
143
|
|
147
144
|
#pragma mark Properties
|
148
145
|
|
149
|
-
- (void)setDrawingMode:(std::string)mode {
|
150
|
-
_drawingMode = mode.compare("continuous") == 0
|
151
|
-
? RNSkia::RNSkDrawingMode::Continuous
|
152
|
-
: RNSkia::RNSkDrawingMode::Default;
|
153
|
-
|
154
|
-
if (_impl != nullptr) {
|
155
|
-
_impl->getDrawView()->setDrawingMode(_drawingMode);
|
156
|
-
}
|
157
|
-
}
|
158
|
-
|
159
146
|
- (void)setDebugMode:(bool)debugMode {
|
160
147
|
_debugMode = debugMode;
|
161
148
|
if (_impl != nullptr) {
|
@@ -6,5 +6,6 @@ export declare const useCanvasRef: () => React.RefObject<SkiaDomView>;
|
|
6
6
|
export interface CanvasProps extends SkiaBaseViewProps {
|
7
7
|
ref?: RefObject<SkiaDomView>;
|
8
8
|
children: ReactNode;
|
9
|
+
mode?: "default" | "continuous";
|
9
10
|
}
|
10
11
|
export declare const Canvas: FunctionComponent<CanvasProps & React.RefAttributes<SkiaDomView>>;
|
@@ -36,7 +36,7 @@ const Canvas = exports.Canvas = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
36
36
|
children,
|
37
37
|
style,
|
38
38
|
debug,
|
39
|
-
mode,
|
39
|
+
mode = "default",
|
40
40
|
onSize: _onSize,
|
41
41
|
onLayout: _onLayout,
|
42
42
|
...props
|
@@ -70,19 +70,19 @@ const Canvas = exports.Canvas = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
70
70
|
style: style,
|
71
71
|
root: root.dom,
|
72
72
|
onLayout: onLayout,
|
73
|
-
|
74
|
-
|
73
|
+
debug: debug,
|
74
|
+
mode: mode
|
75
75
|
}, props));
|
76
76
|
} else {
|
77
77
|
return /*#__PURE__*/_react.default.createElement(_SkiaJSDomView.SkiaJSDomView, _extends({
|
78
|
-
Skia: _Skia.Skia
|
78
|
+
Skia: _Skia.Skia,
|
79
|
+
mode: mode
|
79
80
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
80
81
|
,
|
81
82
|
ref: ref,
|
82
83
|
style: style,
|
83
84
|
root: root.dom,
|
84
85
|
onLayout: onLayout,
|
85
|
-
mode: mode,
|
86
86
|
debug: debug
|
87
87
|
}, props));
|
88
88
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_views","_Skia","_SkiaJSDomView","_Reconciler","_HostComponents","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_extends","assign","bind","arguments","length","apply","useCanvasRef","useRef","exports","useOnSizeEvent","resultValue","onLayout","useCallback","event","width","height","nativeEvent","layout","value","Canvas","forwardRef","children","style","debug","mode","onSize","_onSize","_onLayout","props","forwardedRef","innerRef","ref","useCombinedRefs","redraw","_innerRef$current","current","getNativeId","_innerRef$current$nat","_innerRef$current2","id","nativeId","root","useMemo","SkiaRoot","Skia","NATIVE_DOM","useEffect","render","unmount","createElement","SkiaDomView","dom","SkiaJSDomView","refs","targetRef","React","forEach"],"sources":["Canvas.tsx"],"sourcesContent":["import React, {\n useEffect,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n MutableRefObject,\n ForwardedRef,\n FunctionComponent,\n} from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\n\nimport { SkiaDomView } from \"../views\";\nimport { Skia } from \"../skia/Skia\";\nimport type { SkiaBaseViewProps } from \"../views\";\nimport { SkiaJSDomView } from \"../views/SkiaJSDomView\";\n\nimport { SkiaRoot } from \"./Reconciler\";\nimport { NATIVE_DOM } from \"./HostComponents\";\n\nexport const useCanvasRef = () => useRef<SkiaDomView>(null);\n\nexport interface CanvasProps extends SkiaBaseViewProps {\n ref?: RefObject<SkiaDomView>;\n children: ReactNode;\n}\n\nconst useOnSizeEvent = (\n resultValue: SkiaBaseViewProps[\"onSize\"],\n onLayout?: (event: LayoutChangeEvent) => void\n) => {\n return useCallback(\n (event: LayoutChangeEvent) => {\n if (onLayout) {\n onLayout(event);\n }\n const { width, height } = event.nativeEvent.layout;\n\n if (resultValue) {\n resultValue.value = { width, height };\n }\n },\n [onLayout, resultValue]\n );\n};\n\nexport const Canvas = forwardRef<SkiaDomView, CanvasProps>(\n (\n {\n children,\n style,\n debug,\n mode,\n onSize: _onSize,\n onLayout: _onLayout,\n ...props\n },\n forwardedRef\n ) => {\n const onLayout = useOnSizeEvent(_onSize, _onLayout);\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const redraw = useCallback(() => {\n innerRef.current?.redraw();\n }, [innerRef]);\n const getNativeId = useCallback(() => {\n const id = innerRef.current?.nativeId ?? -1;\n return id;\n }, [innerRef]);\n\n const root = useMemo(\n () => new SkiaRoot(Skia, NATIVE_DOM, redraw, getNativeId),\n [redraw, getNativeId]\n );\n\n // Render effect\n useEffect(() => {\n root.render(children);\n }, [children, root, redraw]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n if (NATIVE_DOM) {\n return (\n <SkiaDomView\n ref={ref}\n style={style}\n root={root.dom}\n onLayout={onLayout}\n
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_views","_Skia","_SkiaJSDomView","_Reconciler","_HostComponents","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_extends","assign","bind","arguments","length","apply","useCanvasRef","useRef","exports","useOnSizeEvent","resultValue","onLayout","useCallback","event","width","height","nativeEvent","layout","value","Canvas","forwardRef","children","style","debug","mode","onSize","_onSize","_onLayout","props","forwardedRef","innerRef","ref","useCombinedRefs","redraw","_innerRef$current","current","getNativeId","_innerRef$current$nat","_innerRef$current2","id","nativeId","root","useMemo","SkiaRoot","Skia","NATIVE_DOM","useEffect","render","unmount","createElement","SkiaDomView","dom","SkiaJSDomView","refs","targetRef","React","forEach"],"sources":["Canvas.tsx"],"sourcesContent":["import React, {\n useEffect,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n MutableRefObject,\n ForwardedRef,\n FunctionComponent,\n} from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\n\nimport { SkiaDomView } from \"../views\";\nimport { Skia } from \"../skia/Skia\";\nimport type { SkiaBaseViewProps } from \"../views\";\nimport { SkiaJSDomView } from \"../views/SkiaJSDomView\";\n\nimport { SkiaRoot } from \"./Reconciler\";\nimport { NATIVE_DOM } from \"./HostComponents\";\n\nexport const useCanvasRef = () => useRef<SkiaDomView>(null);\n\nexport interface CanvasProps extends SkiaBaseViewProps {\n ref?: RefObject<SkiaDomView>;\n children: ReactNode;\n mode?: \"default\" | \"continuous\";\n}\n\nconst useOnSizeEvent = (\n resultValue: SkiaBaseViewProps[\"onSize\"],\n onLayout?: (event: LayoutChangeEvent) => void\n) => {\n return useCallback(\n (event: LayoutChangeEvent) => {\n if (onLayout) {\n onLayout(event);\n }\n const { width, height } = event.nativeEvent.layout;\n\n if (resultValue) {\n resultValue.value = { width, height };\n }\n },\n [onLayout, resultValue]\n );\n};\n\nexport const Canvas = forwardRef<SkiaDomView, CanvasProps>(\n (\n {\n children,\n style,\n debug,\n mode = \"default\",\n onSize: _onSize,\n onLayout: _onLayout,\n ...props\n },\n forwardedRef\n ) => {\n const onLayout = useOnSizeEvent(_onSize, _onLayout);\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const redraw = useCallback(() => {\n innerRef.current?.redraw();\n }, [innerRef]);\n const getNativeId = useCallback(() => {\n const id = innerRef.current?.nativeId ?? -1;\n return id;\n }, [innerRef]);\n\n const root = useMemo(\n () => new SkiaRoot(Skia, NATIVE_DOM, redraw, getNativeId),\n [redraw, getNativeId]\n );\n\n // Render effect\n useEffect(() => {\n root.render(children);\n }, [children, root, redraw]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n if (NATIVE_DOM) {\n return (\n <SkiaDomView\n ref={ref}\n style={style}\n root={root.dom}\n onLayout={onLayout}\n debug={debug}\n mode={mode}\n {...props}\n />\n );\n } else {\n return (\n <SkiaJSDomView\n Skia={Skia}\n mode={mode}\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref={ref as any}\n style={style}\n root={root.dom}\n onLayout={onLayout}\n debug={debug}\n {...props}\n />\n );\n }\n }\n) as FunctionComponent<CanvasProps & React.RefAttributes<SkiaDomView>>;\n\n/**\n * Combines a list of refs into a single ref. This can be used to provide\n * both a forwarded ref and an internal ref keeping the same functionality\n * on both of the refs.\n * @param refs Array of refs to combine\n * @returns A single ref that can be used in a ref prop.\n */\nconst useCombinedRefs = <T,>(\n ...refs: Array<MutableRefObject<T> | ForwardedRef<T>>\n) => {\n const targetRef = React.useRef<T>(null);\n React.useEffect(() => {\n refs.forEach((ref) => {\n if (ref) {\n if (typeof ref === \"function\") {\n ref(targetRef.current);\n } else {\n ref.current = targetRef.current;\n }\n }\n });\n }, [refs]);\n return targetRef;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAgBA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAEA,IAAAG,cAAA,GAAAH,OAAA;AAEA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,eAAA,GAAAL,OAAA;AAA8C,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAR,wBAAAQ,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA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D;EACH,MAAMC,SAAS,GAAGC,cAAK,CAAChD,MAAM,CAAI,IAAI,CAAC;EACvCgD,cAAK,CAACT,SAAS,CAAC,MAAM;IACpBO,IAAI,CAACG,OAAO,CAAEzB,GAAG,IAAK;MACpB,IAAIA,GAAG,EAAE;QACP,IAAI,OAAOA,GAAG,KAAK,UAAU,EAAE;UAC7BA,GAAG,CAACuB,SAAS,CAACnB,OAAO,CAAC;QACxB,CAAC,MAAM;UACLJ,GAAG,CAACI,OAAO,GAAGmB,SAAS,CAACnB,OAAO;QACjC;MACF;IACF,CAAC,CAAC;EACJ,CAAC,EAAE,CAACkB,IAAI,CAAC,CAAC;EACV,OAAOC,SAAS;AAClB,CAAC","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_codegenNativeComponent","_interopRequireDefault","require","e","__esModule","default","_default","exports","codegenNativeComponent"],"sources":["SkiaPictureViewNativeComponent.ts"],"sourcesContent":["import codegenNativeComponent from \"react-native/Libraries/Utilities/codegenNativeComponent\";\nimport type { ViewProps } from \"react-native\";\n\nexport interface NativeProps extends ViewProps {\n
|
1
|
+
{"version":3,"names":["_codegenNativeComponent","_interopRequireDefault","require","e","__esModule","default","_default","exports","codegenNativeComponent"],"sources":["SkiaPictureViewNativeComponent.ts"],"sourcesContent":["import codegenNativeComponent from \"react-native/Libraries/Utilities/codegenNativeComponent\";\nimport type { ViewProps } from \"react-native\";\n\nexport interface NativeProps extends ViewProps {\n debug?: boolean;\n}\n\n// eslint-disable-next-line import/no-default-export\nexport default codegenNativeComponent<NativeProps>(\"SkiaPictureView\");\n"],"mappings":";;;;;;AAAA,IAAAA,uBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA6F,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAO7F;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GACe,IAAAG,+BAAsB,EAAc,iBAAiB,CAAC","ignoreList":[]}
|
@@ -1,13 +1,12 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import type { SkRect, SkCanvas } from "../skia/types";
|
3
|
-
import type {
|
3
|
+
import type { SkiaBaseViewProps } from "./types";
|
4
4
|
export declare abstract class SkiaBaseWebView<TProps extends SkiaBaseViewProps> extends React.Component<TProps> {
|
5
5
|
constructor(props: TProps);
|
6
6
|
private _surface;
|
7
7
|
private _unsubscriptions;
|
8
8
|
private _canvas;
|
9
9
|
private _canvasRef;
|
10
|
-
private _mode;
|
11
10
|
private _redrawRequests;
|
12
11
|
private requestId;
|
13
12
|
protected width: number;
|
@@ -36,16 +35,6 @@ export declare abstract class SkiaBaseWebView<TProps extends SkiaBaseViewProps>
|
|
36
35
|
*/
|
37
36
|
private tick;
|
38
37
|
redraw(): void;
|
39
|
-
/**
|
40
|
-
* Updates the drawing mode for the skia view. This is the same
|
41
|
-
* as declaratively setting the mode property on the SkiaView.
|
42
|
-
* There are two drawing modes, "continuous" and "default",
|
43
|
-
* where the continuous mode will continuously redraw the view and
|
44
|
-
* the default mode will only redraw when any of the regular react
|
45
|
-
* properties are changed like size and margins.
|
46
|
-
* @param mode Drawing mode to use.
|
47
|
-
*/
|
48
|
-
setDrawMode(mode: DrawMode): void;
|
49
38
|
private onLayout;
|
50
39
|
render(): React.JSX.Element;
|
51
40
|
}
|
@@ -15,19 +15,16 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
15
15
|
const pd = _Platform.Platform.PixelRatio;
|
16
16
|
class SkiaBaseWebView extends _react.default.Component {
|
17
17
|
constructor(props) {
|
18
|
-
var _props$mode;
|
19
18
|
super(props);
|
20
19
|
_defineProperty(this, "_surface", null);
|
21
20
|
_defineProperty(this, "_unsubscriptions", []);
|
22
21
|
_defineProperty(this, "_canvas", null);
|
23
22
|
_defineProperty(this, "_canvasRef", /*#__PURE__*/_react.default.createRef());
|
24
|
-
_defineProperty(this, "_mode", void 0);
|
25
23
|
_defineProperty(this, "_redrawRequests", 0);
|
26
24
|
_defineProperty(this, "requestId", 0);
|
27
25
|
_defineProperty(this, "width", 0);
|
28
26
|
_defineProperty(this, "height", 0);
|
29
27
|
_defineProperty(this, "onLayout", this.onLayoutEvent.bind(this));
|
30
|
-
this._mode = (_props$mode = props.mode) !== null && _props$mode !== void 0 ? _props$mode : "default";
|
31
28
|
}
|
32
29
|
unsubscribeAll() {
|
33
30
|
this._unsubscriptions.forEach(u => u());
|
@@ -104,7 +101,7 @@ class SkiaBaseWebView extends _react.default.Component {
|
|
104
101
|
* Sends a redraw request to the native SkiaView.
|
105
102
|
*/
|
106
103
|
tick() {
|
107
|
-
if (this.
|
104
|
+
if (this._redrawRequests > 0) {
|
108
105
|
this._redrawRequests = 0;
|
109
106
|
if (this._canvas) {
|
110
107
|
var _this$_surface3;
|
@@ -122,23 +119,8 @@ class SkiaBaseWebView extends _react.default.Component {
|
|
122
119
|
redraw() {
|
123
120
|
this._redrawRequests++;
|
124
121
|
}
|
125
|
-
|
126
|
-
/**
|
127
|
-
* Updates the drawing mode for the skia view. This is the same
|
128
|
-
* as declaratively setting the mode property on the SkiaView.
|
129
|
-
* There are two drawing modes, "continuous" and "default",
|
130
|
-
* where the continuous mode will continuously redraw the view and
|
131
|
-
* the default mode will only redraw when any of the regular react
|
132
|
-
* properties are changed like size and margins.
|
133
|
-
* @param mode Drawing mode to use.
|
134
|
-
*/
|
135
|
-
setDrawMode(mode) {
|
136
|
-
this._mode = mode;
|
137
|
-
this.tick();
|
138
|
-
}
|
139
122
|
render() {
|
140
123
|
const {
|
141
|
-
mode,
|
142
124
|
debug = false,
|
143
125
|
...viewProps
|
144
126
|
} = this.props;
|