@shopify/react-native-skia 1.5.7 → 1.5.9
Sign up to get free protection for your applications and to get access to all the features.
- package/android/CMakeLists.txt +1 -2
- 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/OpenGLContext.h +3 -1
- package/android/cpp/rnskia-android/OpenGLWindowContext.cpp +1 -1
- package/android/cpp/rnskia-android/OpenGLWindowContext.h +4 -5
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +10 -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/api/JsiSkImage.h +20 -4
- package/cpp/rnskia/RNSkManager.cpp +2 -3
- package/cpp/rnskia/RNSkPlatformContext.h +6 -114
- package/cpp/rnskia/RNSkView.h +21 -77
- package/ios/RNSkia-iOS/MetalContext.h +2 -0
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +4 -10
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +6 -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/react-native-skia.podspec +2 -2
- package/src/renderer/Canvas.tsx +4 -3
- package/src/renderer/__tests__/e2e/Image.spec.tsx +2 -64
- package/src/skia/__tests__/assets/oslo-mini.jpg +0 -0
- 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
@@ -47,13 +47,12 @@ void RNSkManager::invalidate() {
|
|
47
47
|
|
48
48
|
// Invalidate members
|
49
49
|
_viewApi->unregisterAll();
|
50
|
-
_platformContext->invalidate();
|
51
50
|
}
|
52
51
|
|
53
52
|
void RNSkManager::registerSkiaView(size_t nativeId,
|
54
53
|
std::shared_ptr<RNSkView> view) {
|
55
54
|
if (!_isInvalidated && _viewApi != nullptr)
|
56
|
-
_viewApi->registerSkiaView(nativeId, view);
|
55
|
+
_viewApi->registerSkiaView(nativeId, std::move(view));
|
57
56
|
}
|
58
57
|
|
59
58
|
void RNSkManager::unregisterSkiaView(size_t nativeId) {
|
@@ -63,7 +62,7 @@ void RNSkManager::unregisterSkiaView(size_t nativeId) {
|
|
63
62
|
|
64
63
|
void RNSkManager::setSkiaView(size_t nativeId, std::shared_ptr<RNSkView> view) {
|
65
64
|
if (!_isInvalidated && _viewApi != nullptr)
|
66
|
-
_viewApi->setSkiaView(nativeId, view);
|
65
|
+
_viewApi->setSkiaView(nativeId, std::move(view));
|
67
66
|
}
|
68
67
|
|
69
68
|
void RNSkManager::installBindings() {
|
@@ -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.
|
@@ -147,6 +108,10 @@ public:
|
|
147
108
|
*/
|
148
109
|
virtual sk_sp<SkImage> makeImageFromNativeBuffer(void *buffer) = 0;
|
149
110
|
|
111
|
+
#if !defined(SK_GRAPHITE)
|
112
|
+
virtual GrDirectContext *getDirectContext() = 0;
|
113
|
+
#endif
|
114
|
+
|
150
115
|
virtual void releaseNativeBuffer(uint64_t pointer) = 0;
|
151
116
|
|
152
117
|
virtual uint64_t makeNativeBuffer(sk_sp<SkImage> image) = 0;
|
@@ -188,82 +153,9 @@ public:
|
|
188
153
|
*/
|
189
154
|
float getPixelDensity() { return _pixelDensity; }
|
190
155
|
|
191
|
-
/**
|
192
|
-
* Starts (if not started) a loop that will call back on display sync
|
193
|
-
* @param callback Callback to call on sync
|
194
|
-
* @returns Identifier of the draw loop entry
|
195
|
-
*/
|
196
|
-
size_t beginDrawLoop(size_t nativeId, std::function<void(bool)> callback) {
|
197
|
-
if (!_isValid) {
|
198
|
-
return 0;
|
199
|
-
}
|
200
|
-
auto shouldStart = false;
|
201
|
-
{
|
202
|
-
std::lock_guard<std::mutex> lock(_drawCallbacksLock);
|
203
|
-
_drawCallbacks.emplace(nativeId, std::move(callback));
|
204
|
-
shouldStart = _drawCallbacks.size() == 1;
|
205
|
-
}
|
206
|
-
if (shouldStart) {
|
207
|
-
// Start
|
208
|
-
startDrawLoop();
|
209
|
-
}
|
210
|
-
return nativeId;
|
211
|
-
}
|
212
|
-
|
213
|
-
/**
|
214
|
-
* Ends (if running) the drawing loop that was started with beginDrawLoop.
|
215
|
-
* This method must be called symmetrically with the beginDrawLoop method.
|
216
|
-
* @param nativeId Identifier of view to end
|
217
|
-
*/
|
218
|
-
void endDrawLoop(size_t nativeId) {
|
219
|
-
if (!_isValid) {
|
220
|
-
return;
|
221
|
-
}
|
222
|
-
auto shouldStop = false;
|
223
|
-
{
|
224
|
-
std::lock_guard<std::mutex> lock(_drawCallbacksLock);
|
225
|
-
if (_drawCallbacks.count(nativeId) > 0) {
|
226
|
-
_drawCallbacks.erase(nativeId);
|
227
|
-
}
|
228
|
-
shouldStop = _drawCallbacks.size() == 0;
|
229
|
-
}
|
230
|
-
if (shouldStop) {
|
231
|
-
stopDrawLoop();
|
232
|
-
}
|
233
|
-
}
|
234
|
-
|
235
|
-
/**
|
236
|
-
* Notifies all drawing callbacks
|
237
|
-
* @param invalidated True if the context was invalidated, otherwise false.
|
238
|
-
* This can be used to receive a notification that we have stopped the main
|
239
|
-
* drawloop
|
240
|
-
*/
|
241
|
-
void notifyDrawLoop(bool invalidated) {
|
242
|
-
if (!_isValid) {
|
243
|
-
return;
|
244
|
-
}
|
245
|
-
std::lock_guard<std::mutex> lock(_drawCallbacksLock);
|
246
|
-
for (auto it = _drawCallbacks.begin(); it != _drawCallbacks.end(); it++) {
|
247
|
-
it->second(invalidated);
|
248
|
-
}
|
249
|
-
}
|
250
|
-
|
251
|
-
// default implementation does nothing, so it can be called from virtual
|
252
|
-
// destructor.
|
253
|
-
virtual void startDrawLoop() {}
|
254
|
-
virtual void stopDrawLoop() {}
|
255
|
-
|
256
156
|
private:
|
257
157
|
float _pixelDensity;
|
258
|
-
|
259
|
-
std::thread::id _jsThreadId;
|
260
|
-
|
261
158
|
jsi::Runtime *_jsRuntime;
|
262
159
|
std::shared_ptr<react::CallInvoker> _callInvoker;
|
263
|
-
std::unique_ptr<RNSkDispatchQueue> _dispatchQueue;
|
264
|
-
|
265
|
-
std::unordered_map<size_t, std::function<void(bool)>> _drawCallbacks;
|
266
|
-
std::mutex _drawCallbacksLock;
|
267
|
-
std::atomic<bool> _isValid = {true};
|
268
160
|
};
|
269
161
|
} // namespace RNSkia
|
package/cpp/rnskia/RNSkView.h
CHANGED
@@ -90,7 +90,8 @@ public:
|
|
90
90
|
RNSkOffscreenCanvasProvider(std::shared_ptr<RNSkPlatformContext> context,
|
91
91
|
std::function<void()> requestRedraw, float width,
|
92
92
|
float height)
|
93
|
-
: RNSkCanvasProvider(requestRedraw),
|
93
|
+
: RNSkCanvasProvider(requestRedraw), _context(context), _width(width),
|
94
|
+
_height(height) {
|
94
95
|
_surface = context->makeOffscreenSurface(_width, _height);
|
95
96
|
_pd = context->getPixelDensity();
|
96
97
|
}
|
@@ -113,7 +114,8 @@ public:
|
|
113
114
|
_surface->recorder()->snap().get());
|
114
115
|
return DawnContext::getInstance().MakeRasterImage(image);
|
115
116
|
#else
|
116
|
-
|
117
|
+
auto grContext = _context->getDirectContext();
|
118
|
+
return image->makeRasterImage(grContext);
|
117
119
|
#endif
|
118
120
|
}
|
119
121
|
|
@@ -140,10 +142,9 @@ private:
|
|
140
142
|
float _height;
|
141
143
|
float _pd = 1.0f;
|
142
144
|
sk_sp<SkSurface> _surface;
|
145
|
+
std::shared_ptr<RNSkPlatformContext> _context;
|
143
146
|
};
|
144
147
|
|
145
|
-
enum RNSkDrawingMode { Default, Continuous };
|
146
|
-
|
147
148
|
class RNSkView : public std::enable_shared_from_this<RNSkView> {
|
148
149
|
public:
|
149
150
|
/**
|
@@ -158,7 +159,7 @@ public:
|
|
158
159
|
/**
|
159
160
|
Destructor
|
160
161
|
*/
|
161
|
-
virtual ~RNSkView() {
|
162
|
+
virtual ~RNSkView() {}
|
162
163
|
|
163
164
|
/**
|
164
165
|
Sets custom properties. Custom properties are properties that are set
|
@@ -169,43 +170,33 @@ public:
|
|
169
170
|
// Nothing here...
|
170
171
|
}
|
171
172
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
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
|
+
}
|
178
184
|
|
179
|
-
|
180
|
-
Renders immediate. Be carefull to not call this method from another thread
|
181
|
-
than the UI thread
|
182
|
-
*/
|
183
|
-
void renderImmediate() {
|
185
|
+
void redraw() {
|
184
186
|
_renderer->renderImmediate(_canvasProvider);
|
185
|
-
|
187
|
+
_redrawRequested = false;
|
186
188
|
}
|
187
189
|
|
188
190
|
/**
|
189
191
|
Sets the native id of the view
|
190
192
|
*/
|
191
|
-
virtual void setNativeId(size_t nativeId) {
|
192
|
-
_nativeId = nativeId;
|
193
|
-
beginDrawingLoop();
|
194
|
-
}
|
193
|
+
virtual void setNativeId(size_t nativeId) { _nativeId = nativeId; }
|
195
194
|
|
196
195
|
/**
|
197
196
|
Returns the native id
|
198
197
|
*/
|
199
198
|
size_t getNativeId() { return _nativeId; }
|
200
199
|
|
201
|
-
/**
|
202
|
-
Sets the drawing mode for the view
|
203
|
-
*/
|
204
|
-
void setDrawingMode(RNSkDrawingMode mode) {
|
205
|
-
_drawingMode = mode;
|
206
|
-
requestRedraw();
|
207
|
-
}
|
208
|
-
|
209
200
|
/**
|
210
201
|
* Set to true to show the debug overlays on render
|
211
202
|
*/
|
@@ -237,61 +228,14 @@ protected:
|
|
237
228
|
return _canvasProvider;
|
238
229
|
}
|
239
230
|
|
240
|
-
/**
|
241
|
-
Ends an ongoing beginDrawCallback loop for this view. This method is made
|
242
|
-
protected if the drawing loop should be stopped before reaching the
|
243
|
-
destructor (like we do for Android views)
|
244
|
-
*/
|
245
|
-
void endDrawingLoop() {
|
246
|
-
if (_drawingLoopId != 0) {
|
247
|
-
_drawingLoopId = 0;
|
248
|
-
_platformContext->endDrawLoop(_nativeId);
|
249
|
-
}
|
250
|
-
}
|
251
|
-
|
252
231
|
private:
|
253
|
-
/**
|
254
|
-
Starts beginDrawCallback loop if the drawing mode is continuous
|
255
|
-
*/
|
256
|
-
void beginDrawingLoop() {
|
257
|
-
if (_drawingLoopId != 0 || _nativeId == 0) {
|
258
|
-
return;
|
259
|
-
}
|
260
|
-
// Set to zero to avoid calling beginDrawLoop before we return
|
261
|
-
_drawingLoopId = _platformContext->beginDrawLoop(
|
262
|
-
_nativeId, [weakSelf = weak_from_this()](bool invalidated) {
|
263
|
-
auto self = weakSelf.lock();
|
264
|
-
if (self) {
|
265
|
-
self->drawLoopCallback(invalidated);
|
266
|
-
}
|
267
|
-
});
|
268
|
-
}
|
269
|
-
|
270
|
-
/**
|
271
|
-
Draw loop callback
|
272
|
-
*/
|
273
|
-
void drawLoopCallback(bool invalidated) {
|
274
|
-
if (_redrawRequestCounter > 0 ||
|
275
|
-
_drawingMode == RNSkDrawingMode::Continuous) {
|
276
|
-
_redrawRequestCounter = 0;
|
277
|
-
|
278
|
-
if (!_renderer->tryRender(_canvasProvider)) {
|
279
|
-
// The renderer could not render cause it was busy, just schedule
|
280
|
-
// redrawing on the next frame.
|
281
|
-
requestRedraw();
|
282
|
-
}
|
283
|
-
}
|
284
|
-
}
|
285
|
-
|
286
232
|
std::shared_ptr<RNSkPlatformContext> _platformContext;
|
287
233
|
std::shared_ptr<RNSkCanvasProvider> _canvasProvider;
|
288
234
|
std::shared_ptr<RNSkRenderer> _renderer;
|
289
235
|
|
290
|
-
RNSkDrawingMode _drawingMode = RNSkDrawingMode::Default;
|
291
236
|
size_t _nativeId;
|
292
237
|
|
293
|
-
|
294
|
-
std::atomic<int> _redrawRequestCounter = {1};
|
238
|
+
std::atomic<bool> _redrawRequested = {false};
|
295
239
|
};
|
296
240
|
|
297
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;
|
@@ -76,15 +71,14 @@ public:
|
|
76
71
|
|
77
72
|
void raiseError(const std::exception &err) override;
|
78
73
|
sk_sp<SkSurface> makeOffscreenSurface(int width, int height) override;
|
74
|
+
#if !defined(SK_GRAPHITE)
|
75
|
+
GrDirectContext *getDirectContext() override;
|
76
|
+
#endif
|
79
77
|
sk_sp<SkFontMgr> createFontMgr() override;
|
80
78
|
|
81
|
-
void willInvalidateModules() {
|
82
|
-
// We need to do some house-cleaning here!
|
83
|
-
invalidate();
|
84
|
-
}
|
79
|
+
void willInvalidateModules() {}
|
85
80
|
|
86
81
|
private:
|
87
|
-
DisplayLink *_displayLink;
|
88
82
|
ViewScreenshotService *_screenshotService;
|
89
83
|
};
|
90
84
|
|
@@ -192,6 +192,12 @@ sk_sp<SkImage> RNSkiOSPlatformContext::makeImageFromNativeBuffer(void *buffer) {
|
|
192
192
|
#endif
|
193
193
|
}
|
194
194
|
|
195
|
+
#if !defined(SK_GRAPHITE)
|
196
|
+
GrDirectContext *RNSkiOSPlatformContext::getDirectContext() {
|
197
|
+
return MetalContext::getInstance().getDirectContext();
|
198
|
+
}
|
199
|
+
#endif
|
200
|
+
|
195
201
|
sk_sp<SkFontMgr> RNSkiOSPlatformContext::createFontMgr() {
|
196
202
|
return SkFontMgr_New_CoreText(nullptr);
|
197
203
|
}
|
@@ -208,20 +214,4 @@ RNSkiOSPlatformContext::takeScreenshotFromViewTag(size_t viewTag) {
|
|
208
214
|
screenshotOfViewWithTag:[NSNumber numberWithLong:viewTag]];
|
209
215
|
}
|
210
216
|
|
211
|
-
void RNSkiOSPlatformContext::startDrawLoop() {
|
212
|
-
if (_displayLink == nullptr) {
|
213
|
-
_displayLink = [[DisplayLink alloc] init];
|
214
|
-
[_displayLink start:^(double time) {
|
215
|
-
notifyDrawLoop(false);
|
216
|
-
}];
|
217
|
-
}
|
218
|
-
}
|
219
|
-
|
220
|
-
void RNSkiOSPlatformContext::stopDrawLoop() {
|
221
|
-
if (_displayLink != nullptr) {
|
222
|
-
[_displayLink stop];
|
223
|
-
_displayLink = nullptr;
|
224
|
-
}
|
225
|
-
}
|
226
|
-
|
227
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,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAA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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
|
}
|