@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
@@ -1,73 +0,0 @@
|
|
1
|
-
#include "RNSkDispatchQueue.h"
|
2
|
-
|
3
|
-
#include <memory>
|
4
|
-
#include <mutex>
|
5
|
-
#include <utility>
|
6
|
-
|
7
|
-
namespace RNSkia {
|
8
|
-
|
9
|
-
RNSkDispatchQueue::~RNSkDispatchQueue() {
|
10
|
-
// Signal to dispatch threads that it's time to wrap up
|
11
|
-
std::unique_lock<std::mutex> lock(lock_);
|
12
|
-
quit_ = true;
|
13
|
-
lock.unlock();
|
14
|
-
cv_.notify_all();
|
15
|
-
|
16
|
-
// Wait for threads to finish before we exit
|
17
|
-
for (size_t i = 0; i < threads_.size(); i++) {
|
18
|
-
if (threads_[i].joinable()) {
|
19
|
-
threads_[i].join();
|
20
|
-
}
|
21
|
-
}
|
22
|
-
}
|
23
|
-
|
24
|
-
RNSkDispatchQueue::RNSkDispatchQueue(std::string name, size_t thread_cnt)
|
25
|
-
: name_{std::move(name)}, threads_(thread_cnt) {
|
26
|
-
for (size_t i = 0; i < threads_.size(); i++) {
|
27
|
-
threads_[i] =
|
28
|
-
std::thread(&RNSkDispatchQueue::dispatch_thread_handler, this);
|
29
|
-
}
|
30
|
-
}
|
31
|
-
|
32
|
-
void RNSkDispatchQueue::dispatch(const fp_t &op) {
|
33
|
-
std::unique_lock<std::mutex> lock(lock_);
|
34
|
-
q_.push(op);
|
35
|
-
|
36
|
-
// Manual unlocking is done before notifying, to avoid waking up
|
37
|
-
// the waiting thread only to block again (see notify_one for details)
|
38
|
-
lock.unlock();
|
39
|
-
cv_.notify_one();
|
40
|
-
}
|
41
|
-
|
42
|
-
void RNSkDispatchQueue::dispatch(fp_t &&op) {
|
43
|
-
std::unique_lock<std::mutex> lock(lock_);
|
44
|
-
q_.push(std::move(op));
|
45
|
-
|
46
|
-
// Manual unlocking is done before notifying, to avoid waking up
|
47
|
-
// the waiting thread only to block again (see notify_one for details)
|
48
|
-
lock.unlock();
|
49
|
-
cv_.notify_one();
|
50
|
-
}
|
51
|
-
|
52
|
-
void RNSkDispatchQueue::dispatch_thread_handler(void) {
|
53
|
-
std::unique_lock<std::mutex> lock(lock_);
|
54
|
-
|
55
|
-
do {
|
56
|
-
// Wait until we have data or a quit signal
|
57
|
-
cv_.wait(lock, [this] { return (q_.size() || quit_); });
|
58
|
-
|
59
|
-
// after wait, we own the lock
|
60
|
-
if (!quit_ && q_.size()) {
|
61
|
-
auto op = std::move(q_.front());
|
62
|
-
q_.pop();
|
63
|
-
|
64
|
-
// unlock now that we're done messing with the queue
|
65
|
-
lock.unlock();
|
66
|
-
|
67
|
-
op();
|
68
|
-
|
69
|
-
lock.lock();
|
70
|
-
}
|
71
|
-
} while (!quit_);
|
72
|
-
}
|
73
|
-
} // namespace RNSkia
|
@@ -1,49 +0,0 @@
|
|
1
|
-
#pragma once
|
2
|
-
|
3
|
-
#include <condition_variable>
|
4
|
-
#include <cstdint>
|
5
|
-
#include <cstdio>
|
6
|
-
#include <functional>
|
7
|
-
#include <mutex>
|
8
|
-
#include <queue>
|
9
|
-
#include <string>
|
10
|
-
#include <thread>
|
11
|
-
#include <vector>
|
12
|
-
|
13
|
-
// https://github.com/embeddedartistry/embedded-resources/blob/master/examples/cpp/dispatch.cpp
|
14
|
-
namespace RNSkia {
|
15
|
-
|
16
|
-
class RNSkDispatchQueue {
|
17
|
-
typedef std::function<void(void)> fp_t;
|
18
|
-
|
19
|
-
public:
|
20
|
-
explicit RNSkDispatchQueue(std::string name, size_t thread_cnt = 1);
|
21
|
-
|
22
|
-
~RNSkDispatchQueue();
|
23
|
-
|
24
|
-
// dispatch and copy
|
25
|
-
void dispatch(const fp_t &op);
|
26
|
-
|
27
|
-
// dispatch and move
|
28
|
-
void dispatch(fp_t &&op);
|
29
|
-
|
30
|
-
// Deleted operations
|
31
|
-
RNSkDispatchQueue(const RNSkDispatchQueue &rhs) = delete;
|
32
|
-
|
33
|
-
RNSkDispatchQueue &operator=(const RNSkDispatchQueue &rhs) = delete;
|
34
|
-
|
35
|
-
RNSkDispatchQueue(RNSkDispatchQueue &&rhs) = delete;
|
36
|
-
|
37
|
-
RNSkDispatchQueue &operator=(RNSkDispatchQueue &&rhs) = delete;
|
38
|
-
|
39
|
-
private:
|
40
|
-
std::string name_;
|
41
|
-
std::mutex lock_;
|
42
|
-
std::vector<std::thread> threads_;
|
43
|
-
std::queue<fp_t> q_;
|
44
|
-
std::condition_variable cv_;
|
45
|
-
bool quit_ = false;
|
46
|
-
|
47
|
-
void dispatch_thread_handler(void);
|
48
|
-
};
|
49
|
-
} // namespace RNSkia
|
@@ -1,17 +0,0 @@
|
|
1
|
-
#pragma once
|
2
|
-
|
3
|
-
#import <CoreFoundation/CoreFoundation.h>
|
4
|
-
#import <UIKit/UIKit.h>
|
5
|
-
|
6
|
-
typedef void (^block_t)(double);
|
7
|
-
@interface DisplayLink : NSObject {
|
8
|
-
CADisplayLink *_displayLink;
|
9
|
-
}
|
10
|
-
|
11
|
-
@property(nonatomic, copy) block_t updateBlock;
|
12
|
-
|
13
|
-
- (void)start:(block_t)block;
|
14
|
-
|
15
|
-
- (void)stop;
|
16
|
-
|
17
|
-
@end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
#import "DisplayLink.h"
|
2
|
-
|
3
|
-
@implementation DisplayLink
|
4
|
-
|
5
|
-
- (void)start:(block_t)block {
|
6
|
-
self.updateBlock = block;
|
7
|
-
// check whether the loop is already running
|
8
|
-
if (_displayLink == nil) {
|
9
|
-
// specify update method
|
10
|
-
_displayLink = [CADisplayLink displayLinkWithTarget:self
|
11
|
-
selector:@selector(update:)];
|
12
|
-
|
13
|
-
if (@available(iOS 15.0, *)) {
|
14
|
-
CAFrameRateRange rate = CAFrameRateRangeMake(60, 120, 120);
|
15
|
-
_displayLink.preferredFrameRateRange = rate;
|
16
|
-
} else {
|
17
|
-
_displayLink.preferredFramesPerSecond = 60;
|
18
|
-
}
|
19
|
-
|
20
|
-
// add the display link to the main run loop
|
21
|
-
[_displayLink addToRunLoop:[NSRunLoop mainRunLoop]
|
22
|
-
forMode:NSRunLoopCommonModes];
|
23
|
-
}
|
24
|
-
}
|
25
|
-
|
26
|
-
- (void)stop {
|
27
|
-
// check whether the loop is already stopped
|
28
|
-
if (_displayLink != nil) {
|
29
|
-
// if the display link is present, it gets invalidated (loop stops)
|
30
|
-
|
31
|
-
[_displayLink invalidate];
|
32
|
-
_displayLink = nil;
|
33
|
-
}
|
34
|
-
}
|
35
|
-
|
36
|
-
- (void)update:(CADisplayLink *)sender {
|
37
|
-
double time = [sender timestamp];
|
38
|
-
_updateBlock(time);
|
39
|
-
}
|
40
|
-
|
41
|
-
@end
|