@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.
Files changed (104) hide show
  1. package/android/CMakeLists.txt +0 -1
  2. package/android/cpp/jni/JniPlatformContext.cpp +0 -49
  3. package/android/cpp/jni/include/JniPlatformContext.h +1 -17
  4. package/android/cpp/jni/include/JniSkiaBaseView.h +0 -2
  5. package/android/cpp/jni/include/JniSkiaDomView.h +0 -3
  6. package/android/cpp/jni/include/JniSkiaManager.h +0 -2
  7. package/android/cpp/jni/include/JniSkiaPictureView.h +0 -3
  8. package/android/cpp/rnskia-android/MainThreadDispatcher.h +69 -0
  9. package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +4 -11
  10. package/android/cpp/rnskia-android/RNSkAndroidView.h +3 -13
  11. package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +0 -1
  12. package/android/src/main/java/com/shopify/reactnative/skia/PlatformContext.java +0 -85
  13. package/android/src/main/java/com/shopify/reactnative/skia/RNSkiaModule.java +1 -21
  14. package/android/src/main/java/com/shopify/reactnative/skia/SkiaManager.java +0 -4
  15. package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaDomViewManagerDelegate.java +1 -4
  16. package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaDomViewManagerInterface.java +0 -1
  17. package/cpp/rnskia/RNSkManager.cpp +2 -3
  18. package/cpp/rnskia/RNSkPlatformContext.h +2 -114
  19. package/cpp/rnskia/RNSkView.h +16 -75
  20. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +1 -10
  21. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +0 -16
  22. package/ios/RNSkia-iOS/SkiaDomView.mm +0 -1
  23. package/ios/RNSkia-iOS/SkiaDomViewManager.mm +0 -6
  24. package/ios/RNSkia-iOS/SkiaPictureView.mm +0 -1
  25. package/ios/RNSkia-iOS/SkiaPictureViewManager.mm +0 -6
  26. package/ios/RNSkia-iOS/SkiaUIView.h +0 -1
  27. package/ios/RNSkia-iOS/SkiaUIView.mm +1 -14
  28. package/lib/commonjs/renderer/Canvas.d.ts +1 -0
  29. package/lib/commonjs/renderer/Canvas.js +5 -5
  30. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  31. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +0 -1
  32. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +1 -1
  33. package/lib/commonjs/views/SkiaBaseWebView.d.ts +1 -12
  34. package/lib/commonjs/views/SkiaBaseWebView.js +1 -19
  35. package/lib/commonjs/views/SkiaBaseWebView.js.map +1 -1
  36. package/lib/commonjs/views/SkiaDomView.d.ts +8 -1
  37. package/lib/commonjs/views/SkiaDomView.js +14 -2
  38. package/lib/commonjs/views/SkiaDomView.js.map +1 -1
  39. package/lib/commonjs/views/SkiaDomView.web.d.ts +3 -3
  40. package/lib/commonjs/views/SkiaDomView.web.js.map +1 -1
  41. package/lib/commonjs/views/SkiaJSDomView.d.ts +12 -6
  42. package/lib/commonjs/views/SkiaJSDomView.js +12 -3
  43. package/lib/commonjs/views/SkiaJSDomView.js.map +1 -1
  44. package/lib/commonjs/views/SkiaPictureView.d.ts +8 -1
  45. package/lib/commonjs/views/SkiaPictureView.js +14 -1
  46. package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
  47. package/lib/commonjs/views/SkiaPictureView.web.d.ts +3 -3
  48. package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
  49. package/lib/commonjs/views/types.d.ts +2 -12
  50. package/lib/commonjs/views/types.js.map +1 -1
  51. package/lib/module/renderer/Canvas.d.ts +1 -0
  52. package/lib/module/renderer/Canvas.js +5 -5
  53. package/lib/module/renderer/Canvas.js.map +1 -1
  54. package/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +0 -1
  55. package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +1 -1
  56. package/lib/module/views/SkiaBaseWebView.d.ts +1 -12
  57. package/lib/module/views/SkiaBaseWebView.js +1 -19
  58. package/lib/module/views/SkiaBaseWebView.js.map +1 -1
  59. package/lib/module/views/SkiaDomView.d.ts +8 -1
  60. package/lib/module/views/SkiaDomView.js +14 -2
  61. package/lib/module/views/SkiaDomView.js.map +1 -1
  62. package/lib/module/views/SkiaDomView.web.d.ts +3 -3
  63. package/lib/module/views/SkiaDomView.web.js.map +1 -1
  64. package/lib/module/views/SkiaJSDomView.d.ts +12 -6
  65. package/lib/module/views/SkiaJSDomView.js +12 -3
  66. package/lib/module/views/SkiaJSDomView.js.map +1 -1
  67. package/lib/module/views/SkiaPictureView.d.ts +8 -1
  68. package/lib/module/views/SkiaPictureView.js +14 -1
  69. package/lib/module/views/SkiaPictureView.js.map +1 -1
  70. package/lib/module/views/SkiaPictureView.web.d.ts +3 -3
  71. package/lib/module/views/SkiaPictureView.web.js.map +1 -1
  72. package/lib/module/views/types.d.ts +2 -12
  73. package/lib/module/views/types.js.map +1 -1
  74. package/lib/typescript/lib/commonjs/views/SkiaBaseWebView.d.ts +0 -11
  75. package/lib/typescript/lib/commonjs/views/SkiaDomView.d.ts +3 -0
  76. package/lib/typescript/lib/commonjs/views/SkiaJSDomView.d.ts +2 -0
  77. package/lib/typescript/lib/commonjs/views/SkiaPictureView.d.ts +3 -0
  78. package/lib/typescript/lib/module/views/SkiaBaseWebView.d.ts +0 -11
  79. package/lib/typescript/lib/module/views/SkiaDomView.d.ts +3 -0
  80. package/lib/typescript/lib/module/views/SkiaJSDomView.d.ts +2 -0
  81. package/lib/typescript/lib/module/views/SkiaPictureView.d.ts +3 -0
  82. package/lib/typescript/src/renderer/Canvas.d.ts +1 -0
  83. package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.d.ts +0 -1
  84. package/lib/typescript/src/views/SkiaBaseWebView.d.ts +1 -12
  85. package/lib/typescript/src/views/SkiaDomView.d.ts +8 -1
  86. package/lib/typescript/src/views/SkiaDomView.web.d.ts +3 -3
  87. package/lib/typescript/src/views/SkiaJSDomView.d.ts +12 -6
  88. package/lib/typescript/src/views/SkiaPictureView.d.ts +8 -1
  89. package/lib/typescript/src/views/SkiaPictureView.web.d.ts +3 -3
  90. package/lib/typescript/src/views/types.d.ts +2 -12
  91. package/package.json +1 -1
  92. package/src/renderer/Canvas.tsx +4 -3
  93. package/src/specs/SkiaPictureViewNativeComponent.ts +0 -1
  94. package/src/views/SkiaBaseWebView.tsx +3 -19
  95. package/src/views/SkiaDomView.tsx +23 -4
  96. package/src/views/SkiaDomView.web.tsx +3 -3
  97. package/src/views/SkiaJSDomView.tsx +30 -9
  98. package/src/views/SkiaPictureView.tsx +22 -2
  99. package/src/views/SkiaPictureView.web.tsx +3 -3
  100. package/src/views/types.ts +2 -13
  101. package/cpp/rnskia/RNSkDispatchQueue.cpp +0 -73
  102. package/cpp/rnskia/RNSkDispatchQueue.h +0 -49
  103. package/ios/RNSkia-iOS/DisplayLink.h +0 -17
  104. 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