@shopify/react-native-skia 0.1.154 → 0.1.156
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/cpp/jni/JniLoad.cpp +5 -5
- package/android/cpp/jni/JniPlatformContext.cpp +107 -119
- package/android/cpp/jni/JniSkiaManager.cpp +18 -20
- package/android/cpp/jni/include/JniPlatformContext.h +41 -45
- package/android/cpp/jni/include/JniSkiaBaseView.h +52 -55
- package/android/cpp/jni/include/JniSkiaDrawView.h +72 -77
- package/android/cpp/jni/include/JniSkiaManager.h +51 -53
- package/android/cpp/jni/include/JniSkiaPictureView.h +74 -78
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +36 -45
- package/android/cpp/rnskia-android/RNSkAndroidView.h +87 -92
- package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +62 -65
- package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.h +20 -17
- package/android/cpp/rnskia-android/SkiaOpenGLRenderer.cpp +257 -313
- package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +107 -110
- package/cpp/api/JsiSkApi.h +66 -62
- package/cpp/api/JsiSkCanvas.h +38 -30
- package/cpp/api/JsiSkColor.h +58 -56
- package/cpp/api/JsiSkColorFilter.h +5 -3
- package/cpp/api/JsiSkColorFilterFactory.h +23 -21
- package/cpp/api/JsiSkContourMeasure.h +74 -85
- package/cpp/api/JsiSkContourMeasureIter.h +68 -75
- package/cpp/api/JsiSkData.h +16 -22
- package/cpp/api/JsiSkDataFactory.h +86 -79
- package/cpp/api/JsiSkFont.h +286 -311
- package/cpp/api/JsiSkHostObjects.h +15 -16
- package/cpp/api/JsiSkImage.h +107 -103
- package/cpp/api/JsiSkImageFactory.h +34 -36
- package/cpp/api/JsiSkImageFilter.h +5 -3
- package/cpp/api/JsiSkImageFilterFactory.h +71 -68
- package/cpp/api/JsiSkImageInfo.h +41 -38
- package/cpp/api/JsiSkMaskFilter.h +5 -3
- package/cpp/api/JsiSkMaskFilterFactory.h +2 -3
- package/cpp/api/JsiSkMatrix.h +26 -36
- package/cpp/api/JsiSkPaint.h +20 -13
- package/cpp/api/JsiSkPath.h +70 -85
- package/cpp/api/JsiSkPathEffect.h +5 -3
- package/cpp/api/JsiSkPathEffectFactory.h +33 -28
- package/cpp/api/JsiSkPathFactory.h +68 -67
- package/cpp/api/JsiSkPicture.h +28 -22
- package/cpp/api/JsiSkPictureFactory.h +13 -12
- package/cpp/api/JsiSkPictureRecorder.h +21 -19
- package/cpp/api/JsiSkPoint.h +6 -8
- package/cpp/api/JsiSkRRect.h +11 -7
- package/cpp/api/JsiSkRSXform.h +82 -85
- package/cpp/api/JsiSkRect.h +9 -9
- package/cpp/api/JsiSkRuntimeEffect.h +182 -186
- package/cpp/api/JsiSkRuntimeEffectFactory.h +10 -11
- package/cpp/api/JsiSkRuntimeShaderBuilder.h +64 -61
- package/cpp/api/JsiSkSVG.h +4 -5
- package/cpp/api/JsiSkSVGFactory.h +28 -27
- package/cpp/api/JsiSkShader.h +3 -2
- package/cpp/api/JsiSkShaderFactory.h +37 -25
- package/cpp/api/JsiSkSurface.h +44 -40
- package/cpp/api/JsiSkSurfaceFactory.h +22 -22
- package/cpp/api/JsiSkTextBlob.h +28 -31
- package/cpp/api/JsiSkTextBlobFactory.h +88 -87
- package/cpp/api/JsiSkTypeface.h +6 -5
- package/cpp/api/JsiSkTypefaceFactory.h +22 -21
- package/cpp/api/JsiSkVertices.h +137 -124
- package/cpp/api/third_party/CSSColorParser.cpp +161 -174
- package/cpp/api/third_party/CSSColorParser.h +172 -96
- package/cpp/jsi/JsiHostObject.cpp +11 -9
- package/cpp/jsi/JsiHostObject.h +31 -24
- package/cpp/jsi/JsiSimpleValueWrapper.h +74 -83
- package/cpp/jsi/JsiValueWrapper.h +52 -54
- package/cpp/rnskia/RNSkAnimation.h +26 -29
- package/cpp/rnskia/RNSkDispatchQueue.cpp +50 -61
- package/cpp/rnskia/RNSkDispatchQueue.h +3 -1
- package/cpp/rnskia/RNSkInfoParameter.h +12 -12
- package/cpp/rnskia/RNSkJsView.cpp +82 -81
- package/cpp/rnskia/RNSkJsView.h +45 -41
- package/cpp/rnskia/RNSkJsiViewApi.h +99 -89
- package/cpp/rnskia/RNSkManager.cpp +8 -7
- package/cpp/rnskia/RNSkManager.h +8 -6
- package/cpp/rnskia/RNSkPictureView.h +44 -37
- package/cpp/rnskia/RNSkPlatformContext.h +39 -28
- package/cpp/rnskia/RNSkValueApi.h +33 -34
- package/cpp/rnskia/RNSkView.h +108 -93
- package/cpp/rnskia/values/RNSkClockValue.h +63 -64
- package/cpp/rnskia/values/RNSkComputedValue.h +32 -30
- package/cpp/rnskia/values/RNSkReadonlyValue.h +60 -59
- package/cpp/rnskia/values/RNSkValue.h +38 -40
- package/cpp/utils/RNSkLog.h +9 -7
- package/cpp/utils/RNSkMeasureTime.h +7 -7
- package/cpp/utils/RNSkTimingInfo.h +27 -24
- package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.h +8 -9
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +24 -23
- package/ios/RNSkia-iOS/RNSkiOSView.h +16 -13
- package/ios/RNSkia-iOS/SkiaUIView.h +9 -8
- package/lib/commonjs/dom/nodes/JsiSkDOM.js +6 -0
- package/lib/commonjs/dom/nodes/JsiSkDOM.js.map +1 -1
- package/lib/commonjs/dom/nodes/LayerNode.js +43 -0
- package/lib/commonjs/dom/nodes/LayerNode.js.map +1 -0
- package/lib/commonjs/dom/nodes/RenderNode.js +1 -1
- package/lib/commonjs/dom/nodes/RenderNode.js.map +1 -1
- package/lib/commonjs/dom/types/NodeType.js +1 -0
- package/lib/commonjs/dom/types/NodeType.js.map +1 -1
- package/lib/commonjs/dom/types/SkDOM.js.map +1 -1
- package/lib/commonjs/renderer/HostComponents.js +3 -0
- package/lib/commonjs/renderer/HostComponents.js.map +1 -1
- package/lib/commonjs/renderer/components/Group.js +19 -4
- package/lib/commonjs/renderer/components/Group.js.map +1 -1
- package/lib/commonjs/renderer/components/Paint.js +6 -1
- package/lib/commonjs/renderer/components/Paint.js.map +1 -1
- package/lib/commonjs/views/SkiaPictureView.js +3 -2
- package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
- package/lib/commonjs/views/SkiaView.js +6 -3
- package/lib/commonjs/views/SkiaView.js.map +1 -1
- package/lib/module/dom/nodes/JsiSkDOM.js +5 -0
- package/lib/module/dom/nodes/JsiSkDOM.js.map +1 -1
- package/lib/module/dom/nodes/LayerNode.js +32 -0
- package/lib/module/dom/nodes/LayerNode.js.map +1 -0
- package/lib/module/dom/nodes/RenderNode.js +1 -1
- package/lib/module/dom/nodes/RenderNode.js.map +1 -1
- package/lib/module/dom/types/NodeType.js +1 -0
- package/lib/module/dom/types/NodeType.js.map +1 -1
- package/lib/module/dom/types/SkDOM.js.map +1 -1
- package/lib/module/renderer/HostComponents.js +3 -0
- package/lib/module/renderer/HostComponents.js.map +1 -1
- package/lib/module/renderer/components/Group.js +16 -3
- package/lib/module/renderer/components/Group.js.map +1 -1
- package/lib/module/renderer/components/Paint.js +7 -1
- package/lib/module/renderer/components/Paint.js.map +1 -1
- package/lib/module/views/SkiaPictureView.js +2 -2
- package/lib/module/views/SkiaPictureView.js.map +1 -1
- package/lib/module/views/SkiaView.js +4 -2
- package/lib/module/views/SkiaView.js.map +1 -1
- package/lib/typescript/src/dom/nodes/JsiSkDOM.d.ts +2 -0
- package/lib/typescript/src/dom/nodes/LayerNode.d.ts +8 -0
- package/lib/typescript/src/dom/types/NodeType.d.ts +1 -0
- package/lib/typescript/src/dom/types/SkDOM.d.ts +1 -0
- package/lib/typescript/src/renderer/HostComponents.d.ts +2 -1
- package/lib/typescript/src/renderer/components/Group.d.ts +5 -1
- package/lib/typescript/src/views/SkiaView.d.ts +3 -0
- package/libs/android/arm64-v8a/libskottie.a +0 -0
- package/libs/android/arm64-v8a/libsksg.a +0 -0
- package/libs/android/armeabi-v7a/libskottie.a +0 -0
- package/libs/android/armeabi-v7a/libsksg.a +0 -0
- package/libs/android/x86/libskottie.a +0 -0
- package/libs/android/x86/libsksg.a +0 -0
- package/libs/android/x86_64/libskottie.a +0 -0
- package/libs/android/x86_64/libsksg.a +0 -0
- package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
- package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
- package/libs/ios/libskottie.xcframework/Info.plist +42 -0
- package/libs/ios/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
- package/libs/ios/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
- package/libs/ios/libsksg.xcframework/Info.plist +42 -0
- package/libs/ios/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
- package/libs/ios/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
- package/libs/ios/libskshaper.xcframework/Info.plist +5 -5
- package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
- package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
- package/libs/ios/libsvg.xcframework/Info.plist +5 -5
- package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
- package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
- package/package.json +3 -1
- package/src/dom/nodes/JsiSkDOM.ts +5 -0
- package/src/dom/nodes/LayerNode.ts +35 -0
- package/src/dom/nodes/RenderNode.ts +4 -3
- package/src/dom/types/NodeType.ts +1 -0
- package/src/dom/types/SkDOM.ts +1 -0
- package/src/renderer/HostComponents.ts +3 -0
- package/src/renderer/components/Group.tsx +16 -3
- package/src/renderer/components/Paint.tsx +7 -1
- package/src/views/SkiaPictureView.tsx +2 -3
- 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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
20
|
+
RNSkOpenGLCanvasProvider::~RNSkOpenGLCanvasProvider() {}
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
return _width;
|
|
23
|
-
}
|
|
22
|
+
float RNSkOpenGLCanvasProvider::getScaledWidth() { return _width; }
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
return _height;
|
|
27
|
-
}
|
|
24
|
+
float RNSkOpenGLCanvasProvider::getScaledHeight() { return _height; }
|
|
28
25
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
void RNSkOpenGLCanvasProvider::surfaceAvailable(jobject surface, int width,
|
|
34
|
+
int height) {
|
|
35
|
+
_width = width;
|
|
36
|
+
_height = height;
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
_renderer = std::make_unique<SkiaOpenGLRenderer>(surface);
|
|
38
|
+
if (_renderer == nullptr) {
|
|
39
|
+
// Create renderer!
|
|
40
|
+
_renderer = std::make_unique<SkiaOpenGLRenderer>(surface);
|
|
43
41
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
42
|
+
// Redraw
|
|
43
|
+
_requestRedraw();
|
|
47
44
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
14
|
-
|
|
14
|
+
class RNSkOpenGLCanvasProvider
|
|
15
|
+
: public RNSkia::RNSkCanvasProvider,
|
|
16
|
+
public std::enable_shared_from_this<RNSkOpenGLCanvasProvider> {
|
|
15
17
|
public:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
RNSkOpenGLCanvasProvider(
|
|
19
|
+
std::function<void()> requestRedraw,
|
|
20
|
+
std::shared_ptr<RNSkia::RNSkPlatformContext> context);
|
|
18
21
|
|
|
19
|
-
|
|
22
|
+
~RNSkOpenGLCanvasProvider();
|
|
20
23
|
|
|
21
|
-
|
|
24
|
+
float getScaledWidth() override;
|
|
22
25
|
|
|
23
|
-
|
|
26
|
+
float getScaledHeight() override;
|
|
24
27
|
|
|
25
|
-
|
|
28
|
+
void renderToCanvas(const std::function<void(SkCanvas *)> &cb) override;
|
|
26
29
|
|
|
27
|
-
|
|
30
|
+
void surfaceAvailable(jobject surface, int width, int height);
|
|
28
31
|
|
|
29
|
-
|
|
32
|
+
void surfaceDestroyed();
|
|
30
33
|
|
|
31
|
-
|
|
34
|
+
void surfaceSizeChanged(int width, int height);
|
|
32
35
|
|
|
33
36
|
private:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|