@shopify/react-native-skia 0.1.155 → 0.1.156

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. package/android/cpp/jni/JniLoad.cpp +5 -5
  2. package/android/cpp/jni/JniPlatformContext.cpp +107 -119
  3. package/android/cpp/jni/JniSkiaManager.cpp +18 -20
  4. package/android/cpp/jni/include/JniPlatformContext.h +41 -45
  5. package/android/cpp/jni/include/JniSkiaBaseView.h +52 -55
  6. package/android/cpp/jni/include/JniSkiaDrawView.h +72 -77
  7. package/android/cpp/jni/include/JniSkiaManager.h +51 -53
  8. package/android/cpp/jni/include/JniSkiaPictureView.h +74 -78
  9. package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +36 -45
  10. package/android/cpp/rnskia-android/RNSkAndroidView.h +87 -92
  11. package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +62 -65
  12. package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.h +20 -17
  13. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.cpp +257 -313
  14. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +107 -110
  15. package/cpp/api/JsiSkApi.h +66 -62
  16. package/cpp/api/JsiSkCanvas.h +38 -30
  17. package/cpp/api/JsiSkColor.h +58 -56
  18. package/cpp/api/JsiSkColorFilter.h +5 -3
  19. package/cpp/api/JsiSkColorFilterFactory.h +23 -21
  20. package/cpp/api/JsiSkContourMeasure.h +74 -85
  21. package/cpp/api/JsiSkContourMeasureIter.h +68 -75
  22. package/cpp/api/JsiSkData.h +16 -22
  23. package/cpp/api/JsiSkDataFactory.h +86 -79
  24. package/cpp/api/JsiSkFont.h +286 -311
  25. package/cpp/api/JsiSkHostObjects.h +15 -16
  26. package/cpp/api/JsiSkImage.h +107 -103
  27. package/cpp/api/JsiSkImageFactory.h +34 -36
  28. package/cpp/api/JsiSkImageFilter.h +5 -3
  29. package/cpp/api/JsiSkImageFilterFactory.h +71 -68
  30. package/cpp/api/JsiSkImageInfo.h +41 -38
  31. package/cpp/api/JsiSkMaskFilter.h +5 -3
  32. package/cpp/api/JsiSkMaskFilterFactory.h +2 -3
  33. package/cpp/api/JsiSkMatrix.h +26 -36
  34. package/cpp/api/JsiSkPaint.h +20 -13
  35. package/cpp/api/JsiSkPath.h +70 -85
  36. package/cpp/api/JsiSkPathEffect.h +5 -3
  37. package/cpp/api/JsiSkPathEffectFactory.h +33 -28
  38. package/cpp/api/JsiSkPathFactory.h +68 -67
  39. package/cpp/api/JsiSkPicture.h +28 -22
  40. package/cpp/api/JsiSkPictureFactory.h +13 -12
  41. package/cpp/api/JsiSkPictureRecorder.h +21 -19
  42. package/cpp/api/JsiSkPoint.h +6 -8
  43. package/cpp/api/JsiSkRRect.h +11 -7
  44. package/cpp/api/JsiSkRSXform.h +82 -85
  45. package/cpp/api/JsiSkRect.h +9 -9
  46. package/cpp/api/JsiSkRuntimeEffect.h +182 -186
  47. package/cpp/api/JsiSkRuntimeEffectFactory.h +10 -11
  48. package/cpp/api/JsiSkRuntimeShaderBuilder.h +64 -61
  49. package/cpp/api/JsiSkSVG.h +4 -5
  50. package/cpp/api/JsiSkSVGFactory.h +28 -27
  51. package/cpp/api/JsiSkShader.h +3 -2
  52. package/cpp/api/JsiSkShaderFactory.h +37 -25
  53. package/cpp/api/JsiSkSurface.h +44 -40
  54. package/cpp/api/JsiSkSurfaceFactory.h +22 -22
  55. package/cpp/api/JsiSkTextBlob.h +28 -31
  56. package/cpp/api/JsiSkTextBlobFactory.h +88 -87
  57. package/cpp/api/JsiSkTypeface.h +6 -5
  58. package/cpp/api/JsiSkTypefaceFactory.h +22 -21
  59. package/cpp/api/JsiSkVertices.h +137 -124
  60. package/cpp/api/third_party/CSSColorParser.cpp +161 -174
  61. package/cpp/api/third_party/CSSColorParser.h +172 -96
  62. package/cpp/jsi/JsiHostObject.cpp +11 -9
  63. package/cpp/jsi/JsiHostObject.h +31 -24
  64. package/cpp/jsi/JsiSimpleValueWrapper.h +74 -83
  65. package/cpp/jsi/JsiValueWrapper.h +52 -54
  66. package/cpp/rnskia/RNSkAnimation.h +26 -29
  67. package/cpp/rnskia/RNSkDispatchQueue.cpp +50 -61
  68. package/cpp/rnskia/RNSkDispatchQueue.h +3 -1
  69. package/cpp/rnskia/RNSkInfoParameter.h +12 -12
  70. package/cpp/rnskia/RNSkJsView.cpp +82 -81
  71. package/cpp/rnskia/RNSkJsView.h +45 -41
  72. package/cpp/rnskia/RNSkJsiViewApi.h +99 -89
  73. package/cpp/rnskia/RNSkManager.cpp +8 -7
  74. package/cpp/rnskia/RNSkManager.h +8 -6
  75. package/cpp/rnskia/RNSkPictureView.h +44 -37
  76. package/cpp/rnskia/RNSkPlatformContext.h +39 -28
  77. package/cpp/rnskia/RNSkValueApi.h +33 -34
  78. package/cpp/rnskia/RNSkView.h +108 -93
  79. package/cpp/rnskia/values/RNSkClockValue.h +63 -64
  80. package/cpp/rnskia/values/RNSkComputedValue.h +32 -30
  81. package/cpp/rnskia/values/RNSkReadonlyValue.h +60 -59
  82. package/cpp/rnskia/values/RNSkValue.h +38 -40
  83. package/cpp/utils/RNSkLog.h +9 -7
  84. package/cpp/utils/RNSkMeasureTime.h +7 -7
  85. package/cpp/utils/RNSkTimingInfo.h +27 -24
  86. package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.h +8 -9
  87. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +24 -23
  88. package/ios/RNSkia-iOS/RNSkiOSView.h +16 -13
  89. package/ios/RNSkia-iOS/SkiaUIView.h +9 -8
  90. package/lib/commonjs/dom/nodes/JsiSkDOM.js +6 -0
  91. package/lib/commonjs/dom/nodes/JsiSkDOM.js.map +1 -1
  92. package/lib/commonjs/dom/nodes/LayerNode.js +43 -0
  93. package/lib/commonjs/dom/nodes/LayerNode.js.map +1 -0
  94. package/lib/commonjs/dom/types/NodeType.js +1 -0
  95. package/lib/commonjs/dom/types/NodeType.js.map +1 -1
  96. package/lib/commonjs/dom/types/SkDOM.js.map +1 -1
  97. package/lib/commonjs/renderer/HostComponents.js +3 -0
  98. package/lib/commonjs/renderer/HostComponents.js.map +1 -1
  99. package/lib/commonjs/renderer/components/Group.js +19 -4
  100. package/lib/commonjs/renderer/components/Group.js.map +1 -1
  101. package/lib/commonjs/renderer/components/Paint.js +6 -1
  102. package/lib/commonjs/renderer/components/Paint.js.map +1 -1
  103. package/lib/commonjs/views/SkiaPictureView.js +3 -2
  104. package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
  105. package/lib/commonjs/views/SkiaView.js +6 -3
  106. package/lib/commonjs/views/SkiaView.js.map +1 -1
  107. package/lib/module/dom/nodes/JsiSkDOM.js +5 -0
  108. package/lib/module/dom/nodes/JsiSkDOM.js.map +1 -1
  109. package/lib/module/dom/nodes/LayerNode.js +32 -0
  110. package/lib/module/dom/nodes/LayerNode.js.map +1 -0
  111. package/lib/module/dom/types/NodeType.js +1 -0
  112. package/lib/module/dom/types/NodeType.js.map +1 -1
  113. package/lib/module/dom/types/SkDOM.js.map +1 -1
  114. package/lib/module/renderer/HostComponents.js +3 -0
  115. package/lib/module/renderer/HostComponents.js.map +1 -1
  116. package/lib/module/renderer/components/Group.js +16 -3
  117. package/lib/module/renderer/components/Group.js.map +1 -1
  118. package/lib/module/renderer/components/Paint.js +7 -1
  119. package/lib/module/renderer/components/Paint.js.map +1 -1
  120. package/lib/module/views/SkiaPictureView.js +2 -2
  121. package/lib/module/views/SkiaPictureView.js.map +1 -1
  122. package/lib/module/views/SkiaView.js +4 -2
  123. package/lib/module/views/SkiaView.js.map +1 -1
  124. package/lib/typescript/src/dom/nodes/JsiSkDOM.d.ts +2 -0
  125. package/lib/typescript/src/dom/nodes/LayerNode.d.ts +8 -0
  126. package/lib/typescript/src/dom/types/NodeType.d.ts +1 -0
  127. package/lib/typescript/src/dom/types/SkDOM.d.ts +1 -0
  128. package/lib/typescript/src/renderer/HostComponents.d.ts +2 -1
  129. package/lib/typescript/src/renderer/components/Group.d.ts +5 -1
  130. package/lib/typescript/src/views/SkiaView.d.ts +3 -0
  131. package/libs/android/arm64-v8a/libskottie.a +0 -0
  132. package/libs/android/arm64-v8a/libsksg.a +0 -0
  133. package/libs/android/armeabi-v7a/libskottie.a +0 -0
  134. package/libs/android/armeabi-v7a/libsksg.a +0 -0
  135. package/libs/android/x86/libskottie.a +0 -0
  136. package/libs/android/x86/libsksg.a +0 -0
  137. package/libs/android/x86_64/libskottie.a +0 -0
  138. package/libs/android/x86_64/libsksg.a +0 -0
  139. package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  140. package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  141. package/libs/ios/libskottie.xcframework/Info.plist +42 -0
  142. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
  143. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  144. package/libs/ios/libsksg.xcframework/Info.plist +42 -0
  145. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
  146. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  147. package/libs/ios/libskshaper.xcframework/Info.plist +5 -5
  148. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  149. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  150. package/libs/ios/libsvg.xcframework/Info.plist +5 -5
  151. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  152. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  153. package/package.json +3 -1
  154. package/src/dom/nodes/JsiSkDOM.ts +5 -0
  155. package/src/dom/nodes/LayerNode.ts +35 -0
  156. package/src/dom/types/NodeType.ts +1 -0
  157. package/src/dom/types/SkDOM.ts +1 -0
  158. package/src/renderer/HostComponents.ts +3 -0
  159. package/src/renderer/components/Group.tsx +16 -3
  160. package/src/renderer/components/Paint.tsx +7 -1
  161. package/src/views/SkiaPictureView.tsx +2 -3
  162. package/src/views/SkiaView.tsx +2 -2
@@ -1,100 +1,95 @@
1
1
  #pragma once
2
2
 
3
+ #include <memory>
4
+ #include <string>
5
+ #include <vector>
6
+
3
7
  #include <RNSkJsView.h>
4
8
  #include <RNSkOpenGLCanvasProvider.h>
5
9
  #include <android/native_window.h>
6
10
 
7
11
  namespace RNSkia {
8
12
 
9
- class RNSkBaseAndroidView {
10
- public:
11
- virtual void surfaceAvailable(jobject surface, int width, int height) = 0;
12
-
13
- virtual void surfaceDestroyed() = 0;
14
-
15
- virtual void surfaceSizeChanged(int width, int height) = 0;
16
-
17
- virtual float getPixelDensity() = 0;
18
-
19
- virtual void updateTouchPoints(jni::JArrayDouble touches) = 0;
20
-
21
- virtual void setMode(std::string mode) = 0;
22
-
23
- virtual void setShowDebugInfo(bool show) = 0;
24
-
25
- virtual void viewDidUnmount() = 0;
26
-
27
- virtual std::shared_ptr<RNSkView> getSkiaView() = 0;
28
- };
29
-
30
- template<typename T>
31
- class RNSkAndroidView
32
- : public T, public RNSkBaseAndroidView {
33
- public:
34
- RNSkAndroidView(
35
- std::shared_ptr<RNSkia::RNSkPlatformContext> context) :
36
- T(context,
37
- std::make_shared<RNSkOpenGLCanvasProvider>(
38
- std::bind(&RNSkia::RNSkView::requestRedraw, this),
39
- context)
40
- ) {}
41
-
42
- void surfaceAvailable(jobject surface, int width, int height) override {
43
- std::static_pointer_cast<RNSkOpenGLCanvasProvider>(
44
- T::getCanvasProvider())->surfaceAvailable(surface, width, height);
45
- }
46
-
47
- void surfaceDestroyed() override {
48
- std::static_pointer_cast<RNSkOpenGLCanvasProvider>(
49
- T::getCanvasProvider())->surfaceDestroyed();
50
- }
51
-
52
- void surfaceSizeChanged(int width, int height) override {
53
- std::static_pointer_cast<RNSkOpenGLCanvasProvider>(
54
- T::getCanvasProvider())->surfaceSizeChanged(width, height);
55
- }
56
-
57
- float getPixelDensity() override {
58
- return T::getPlatformContext()->getPixelDensity();
59
- }
60
-
61
- void setMode(std::string mode) override {
62
- if (mode.compare("continuous") == 0) {
63
- T::setDrawingMode(RNSkDrawingMode::Continuous);
64
- } else {
65
- T::setDrawingMode(RNSkDrawingMode::Default);
66
- }
67
- }
68
-
69
- void setShowDebugInfo(bool show) override {
70
- T::setShowDebugOverlays(show);
71
- }
72
-
73
- void viewDidUnmount() override {
74
- T::endDrawingLoop();
75
- }
76
-
77
- void updateTouchPoints(jni::JArrayDouble touches) override {
78
- // Create touch points
79
- std::vector<RNSkia::RNSkTouchInfo> points;
80
- auto pin = touches.pin();
81
- auto scale = getPixelDensity();
82
- points.reserve(pin.size() / 5);
83
- for (size_t i = 0; i < pin.size(); i += 5) {
84
- RNSkTouchInfo point;
85
- point.x = pin[i] / scale;
86
- point.y = pin[i + 1] / scale;
87
- point.force = pin[i + 2];
88
- point.type = (RNSkia::RNSkTouchInfo::TouchType) pin[i + 3];
89
- point.id = pin[i + 4];
90
- points.push_back(point);
91
- }
92
- T::updateTouchState(points);
93
- }
94
-
95
- std::shared_ptr<RNSkView> getSkiaView() override {
96
- return T::shared_from_this();
97
- }
98
-
99
- };
100
- }
13
+ class RNSkBaseAndroidView {
14
+ public:
15
+ virtual void surfaceAvailable(jobject surface, int width, int height) = 0;
16
+
17
+ virtual void surfaceDestroyed() = 0;
18
+
19
+ virtual void surfaceSizeChanged(int width, int height) = 0;
20
+
21
+ virtual float getPixelDensity() = 0;
22
+
23
+ virtual void updateTouchPoints(jni::JArrayDouble touches) = 0;
24
+
25
+ virtual void setMode(std::string mode) = 0;
26
+
27
+ virtual void setShowDebugInfo(bool show) = 0;
28
+
29
+ virtual void viewDidUnmount() = 0;
30
+
31
+ virtual std::shared_ptr<RNSkView> getSkiaView() = 0;
32
+ };
33
+
34
+ template <typename T>
35
+ class RNSkAndroidView : public T, public RNSkBaseAndroidView {
36
+ public:
37
+ explicit RNSkAndroidView(std::shared_ptr<RNSkia::RNSkPlatformContext> context)
38
+ : T(context,
39
+ std::make_shared<RNSkOpenGLCanvasProvider>(
40
+ std::bind(&RNSkia::RNSkView::requestRedraw, this), context)) {}
41
+
42
+ void surfaceAvailable(jobject surface, int width, int height) override {
43
+ std::static_pointer_cast<RNSkOpenGLCanvasProvider>(T::getCanvasProvider())
44
+ ->surfaceAvailable(surface, width, height);
45
+ }
46
+
47
+ void surfaceDestroyed() override {
48
+ std::static_pointer_cast<RNSkOpenGLCanvasProvider>(T::getCanvasProvider())
49
+ ->surfaceDestroyed();
50
+ }
51
+
52
+ void surfaceSizeChanged(int width, int height) override {
53
+ std::static_pointer_cast<RNSkOpenGLCanvasProvider>(T::getCanvasProvider())
54
+ ->surfaceSizeChanged(width, height);
55
+ }
56
+
57
+ float getPixelDensity() override {
58
+ return T::getPlatformContext()->getPixelDensity();
59
+ }
60
+
61
+ void setMode(std::string mode) override {
62
+ if (mode.compare("continuous") == 0) {
63
+ T::setDrawingMode(RNSkDrawingMode::Continuous);
64
+ } else {
65
+ T::setDrawingMode(RNSkDrawingMode::Default);
66
+ }
67
+ }
68
+
69
+ void setShowDebugInfo(bool show) override { T::setShowDebugOverlays(show); }
70
+
71
+ void viewDidUnmount() override { T::endDrawingLoop(); }
72
+
73
+ void updateTouchPoints(jni::JArrayDouble touches) override {
74
+ // Create touch points
75
+ std::vector<RNSkia::RNSkTouchInfo> points;
76
+ auto pin = touches.pin();
77
+ auto scale = getPixelDensity();
78
+ points.reserve(pin.size() / 5);
79
+ for (size_t i = 0; i < pin.size(); i += 5) {
80
+ RNSkTouchInfo point;
81
+ point.x = pin[i] / scale;
82
+ point.y = pin[i + 1] / scale;
83
+ point.force = pin[i + 2];
84
+ point.type = (RNSkia::RNSkTouchInfo::TouchType)pin[i + 3];
85
+ point.id = pin[i + 4];
86
+ points.push_back(point);
87
+ }
88
+ T::updateTouchState(points);
89
+ }
90
+
91
+ std::shared_ptr<RNSkView> getSkiaView() override {
92
+ return T::shared_from_this();
93
+ }
94
+ };
95
+ } // namespace RNSkia
@@ -1,91 +1,88 @@
1
1
  #include <RNSkOpenGLCanvasProvider.h>
2
2
 
3
+ #include <memory>
4
+
3
5
  #pragma clang diagnostic push
4
6
  #pragma clang diagnostic ignored "-Wdocumentation"
5
7
 
6
- #include <SkSurface.h>
7
8
  #include <SkCanvas.h>
9
+ #include <SkSurface.h>
8
10
 
9
11
  #pragma clang diagnostic pop
10
12
 
11
13
  namespace RNSkia {
12
14
 
13
- RNSkOpenGLCanvasProvider::RNSkOpenGLCanvasProvider(
14
- std::function<void()> requestRedraw,
15
- std::shared_ptr<RNSkia::RNSkPlatformContext> context):
16
- RNSkCanvasProvider(requestRedraw),
17
- _context(context) {}
15
+ RNSkOpenGLCanvasProvider::RNSkOpenGLCanvasProvider(
16
+ std::function<void()> requestRedraw,
17
+ std::shared_ptr<RNSkia::RNSkPlatformContext> context)
18
+ : RNSkCanvasProvider(requestRedraw), _context(context) {}
18
19
 
19
- RNSkOpenGLCanvasProvider::~RNSkOpenGLCanvasProvider() {}
20
+ RNSkOpenGLCanvasProvider::~RNSkOpenGLCanvasProvider() {}
20
21
 
21
- float RNSkOpenGLCanvasProvider::getScaledWidth() {
22
- return _width;
23
- }
22
+ float RNSkOpenGLCanvasProvider::getScaledWidth() { return _width; }
24
23
 
25
- float RNSkOpenGLCanvasProvider::getScaledHeight() {
26
- return _height;
27
- }
24
+ float RNSkOpenGLCanvasProvider::getScaledHeight() { return _height; }
28
25
 
29
- void RNSkOpenGLCanvasProvider::renderToCanvas(const std::function<void(SkCanvas *)> &cb) {
30
- if(_renderer != nullptr) {
31
- _renderer->run(cb, _width, _height);
32
- }
26
+ void RNSkOpenGLCanvasProvider::renderToCanvas(
27
+ const std::function<void(SkCanvas *)> &cb) {
28
+ if (_renderer != nullptr) {
29
+ _renderer->run(cb, _width, _height);
33
30
  }
31
+ }
34
32
 
35
- void RNSkOpenGLCanvasProvider::surfaceAvailable(jobject surface, int width, int height) {
36
- _width = width;
37
- _height = height;
33
+ void RNSkOpenGLCanvasProvider::surfaceAvailable(jobject surface, int width,
34
+ int height) {
35
+ _width = width;
36
+ _height = height;
38
37
 
39
- if (_renderer == nullptr)
40
- {
41
- // Create renderer!
42
- _renderer = std::make_unique<SkiaOpenGLRenderer>(surface);
38
+ if (_renderer == nullptr) {
39
+ // Create renderer!
40
+ _renderer = std::make_unique<SkiaOpenGLRenderer>(surface);
43
41
 
44
- // Redraw
45
- _requestRedraw();
46
- }
42
+ // Redraw
43
+ _requestRedraw();
47
44
  }
48
- void RNSkOpenGLCanvasProvider::surfaceDestroyed() {
49
- if (_renderer != nullptr)
50
- {
51
- // teardown
52
- _renderer->teardown();
53
-
54
- // Teardown renderer on the render thread since OpenGL demands
55
- // same thread access for OpenGL contexts.
56
- std::condition_variable cv;
57
- std::mutex m;
45
+ }
46
+ void RNSkOpenGLCanvasProvider::surfaceDestroyed() {
47
+ if (_renderer != nullptr) {
48
+ // teardown
49
+ _renderer->teardown();
50
+
51
+ // Teardown renderer on the render thread since OpenGL demands
52
+ // same thread access for OpenGL contexts.
53
+ std::condition_variable cv;
54
+ std::mutex m;
55
+ std::unique_lock<std::mutex> lock(m);
56
+
57
+ _context->runOnRenderThread([&cv, &m, weakSelf = weak_from_this()]() {
58
+ // Lock
58
59
  std::unique_lock<std::mutex> lock(m);
59
60
 
60
- _context->runOnRenderThread([&cv, &m, weakSelf = weak_from_this()]() {
61
- // Lock
62
- std::unique_lock<std::mutex> lock(m);
63
-
64
- auto self = weakSelf.lock();
65
- if(self) {
66
- if(self->_renderer != nullptr) {
67
- self->_renderer->run(nullptr, 0, 0);
68
- }
69
- // Remove renderer
70
- self->_renderer = nullptr;
71
- }
72
- cv.notify_one();
73
- });
74
-
75
- cv.wait(lock);
76
- }
61
+ auto self = weakSelf.lock();
62
+ if (self) {
63
+ if (self->_renderer != nullptr) {
64
+ self->_renderer->run(nullptr, 0, 0);
65
+ }
66
+ // Remove renderer
67
+ self->_renderer = nullptr;
68
+ }
69
+ cv.notify_one();
70
+ });
71
+
72
+ cv.wait(lock);
77
73
  }
74
+ }
78
75
 
79
- void RNSkOpenGLCanvasProvider::surfaceSizeChanged(int width, int height) {
80
- if(width == 0 && height == 0) {
81
- // Setting width/height to zero is nothing we need to care about when
82
- // it comes to invalidating the surface.
83
- return;
84
- }
85
- _width = width;
86
- _height = height;
87
-
88
- // Redraw after size change
89
- _requestRedraw();
76
+ void RNSkOpenGLCanvasProvider::surfaceSizeChanged(int width, int height) {
77
+ if (width == 0 && height == 0) {
78
+ // Setting width/height to zero is nothing we need to care about when
79
+ // it comes to invalidating the surface.
80
+ return;
90
81
  }
82
+ _width = width;
83
+ _height = height;
84
+
85
+ // Redraw after size change
86
+ _requestRedraw();
91
87
  }
88
+ } // namespace RNSkia
@@ -2,6 +2,8 @@
2
2
 
3
3
  #include <fbjni/fbjni.h>
4
4
 
5
+ #include <memory>
6
+
5
7
  #include <RNSkJsView.h>
6
8
 
7
9
  #include <SkiaOpenGLRenderer.h>
@@ -9,31 +11,32 @@
9
11
 
10
12
  namespace RNSkia {
11
13
 
12
- class RNSkOpenGLCanvasProvider :
13
- public RNSkia::RNSkCanvasProvider,
14
- public std::enable_shared_from_this<RNSkOpenGLCanvasProvider> {
14
+ class RNSkOpenGLCanvasProvider
15
+ : public RNSkia::RNSkCanvasProvider,
16
+ public std::enable_shared_from_this<RNSkOpenGLCanvasProvider> {
15
17
  public:
16
- RNSkOpenGLCanvasProvider(std::function<void()> requestRedraw,
17
- std::shared_ptr <RNSkia::RNSkPlatformContext> context);
18
+ RNSkOpenGLCanvasProvider(
19
+ std::function<void()> requestRedraw,
20
+ std::shared_ptr<RNSkia::RNSkPlatformContext> context);
18
21
 
19
- ~RNSkOpenGLCanvasProvider();
22
+ ~RNSkOpenGLCanvasProvider();
20
23
 
21
- float getScaledWidth() override;
24
+ float getScaledWidth() override;
22
25
 
23
- float getScaledHeight() override;
26
+ float getScaledHeight() override;
24
27
 
25
- void renderToCanvas(const std::function<void(SkCanvas * )> &cb) override;
28
+ void renderToCanvas(const std::function<void(SkCanvas *)> &cb) override;
26
29
 
27
- void surfaceAvailable(jobject surface, int width, int height);
30
+ void surfaceAvailable(jobject surface, int width, int height);
28
31
 
29
- void surfaceDestroyed();
32
+ void surfaceDestroyed();
30
33
 
31
- void surfaceSizeChanged(int width, int height);
34
+ void surfaceSizeChanged(int width, int height);
32
35
 
33
36
  private:
34
- std::unique_ptr <SkiaOpenGLRenderer> _renderer = nullptr;
35
- std::shared_ptr <RNSkPlatformContext> _context;
36
- float _width = -1;
37
- float _height = -1;
37
+ std::unique_ptr<SkiaOpenGLRenderer> _renderer = nullptr;
38
+ std::shared_ptr<RNSkPlatformContext> _context;
39
+ float _width = -1;
40
+ float _height = -1;
38
41
  };
39
- }
42
+ } // namespace RNSkia