@shopify/react-native-skia 1.0.5 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/android/CMakeLists.txt +4 -8
- package/android/build.gradle +9 -2
- package/android/cpp/jni/JniPlatformContext.cpp +7 -7
- package/android/cpp/jni/JniSkiaManager.cpp +1 -1
- package/android/cpp/jni/include/JniSkiaBaseView.h +2 -2
- package/android/cpp/jni/include/JniSkiaDomView.h +4 -4
- package/android/cpp/jni/include/JniSkiaManager.h +4 -4
- package/android/cpp/jni/include/JniSkiaPictureView.h +4 -4
- package/android/cpp/rnskia-android/GrAHardwareBufferUtils.cpp +245 -0
- package/android/cpp/rnskia-android/GrAHardwareBufferUtils.h +33 -0
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +3 -3
- package/android/cpp/rnskia-android/RNSkAndroidView.h +1 -1
- package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +2 -2
- package/android/cpp/rnskia-android/SkiaOpenGLHelper.h +4 -4
- package/android/cpp/rnskia-android/SkiaOpenGLSurfaceFactory.cpp +32 -2
- package/android/cpp/rnskia-android/SkiaOpenGLSurfaceFactory.h +7 -4
- package/cpp/api/JsiSkAnimatedImage.h +1 -1
- package/cpp/api/JsiSkCanvas.h +8 -8
- package/cpp/api/JsiSkColor.h +1 -1
- package/cpp/api/JsiSkColorFilter.h +1 -1
- package/cpp/api/JsiSkColorFilterFactory.h +2 -2
- package/cpp/api/JsiSkContourMeasure.h +1 -1
- package/cpp/api/JsiSkContourMeasureIter.h +1 -1
- package/cpp/api/JsiSkData.h +2 -2
- package/cpp/api/JsiSkFont.h +2 -2
- package/cpp/api/JsiSkFontMgr.h +1 -1
- package/cpp/api/JsiSkFontMgrFactory.h +1 -1
- package/cpp/api/JsiSkFontStyle.h +2 -2
- package/cpp/api/JsiSkImage.h +2 -2
- package/cpp/api/JsiSkImageFactory.h +0 -1
- package/cpp/api/JsiSkImageFilter.h +1 -1
- package/cpp/api/JsiSkImageFilterFactory.h +1 -1
- package/cpp/api/JsiSkImageInfo.h +1 -1
- package/cpp/api/JsiSkMaskFilter.h +1 -1
- package/cpp/api/JsiSkMaskFilterFactory.h +1 -1
- package/cpp/api/JsiSkMatrix.h +1 -1
- package/cpp/api/JsiSkPaint.h +1 -1
- package/cpp/api/JsiSkParagraph.h +7 -7
- package/cpp/api/JsiSkParagraphBuilder.h +9 -9
- package/cpp/api/JsiSkParagraphBuilderFactory.h +4 -4
- package/cpp/api/JsiSkParagraphStyle.h +3 -3
- package/cpp/api/JsiSkPath.h +11 -11
- package/cpp/api/JsiSkPathEffect.h +1 -1
- package/cpp/api/JsiSkPathEffectFactory.h +4 -4
- package/cpp/api/JsiSkPathFactory.h +2 -2
- package/cpp/api/JsiSkPicture.h +1 -1
- package/cpp/api/JsiSkPictureFactory.h +2 -2
- package/cpp/api/JsiSkPictureRecorder.h +2 -2
- package/cpp/api/JsiSkPoint.h +1 -1
- package/cpp/api/JsiSkRRect.h +1 -1
- package/cpp/api/JsiSkRSXform.h +1 -1
- package/cpp/api/JsiSkRect.h +1 -1
- package/cpp/api/JsiSkRuntimeEffect.h +1 -1
- package/cpp/api/JsiSkRuntimeShaderBuilder.h +1 -1
- package/cpp/api/JsiSkSVGFactory.h +1 -1
- package/cpp/api/JsiSkShader.h +2 -2
- package/cpp/api/JsiSkShaderFactory.h +3 -3
- package/cpp/api/JsiSkStrutStyle.h +1 -1
- package/cpp/api/JsiSkSurface.h +1 -1
- package/cpp/api/JsiSkSurfaceFactory.h +1 -1
- package/cpp/api/JsiSkTextBlob.h +1 -1
- package/cpp/api/JsiSkTextBlobFactory.h +1 -1
- package/cpp/api/JsiSkTextStyle.h +2 -2
- package/cpp/api/JsiSkTypeface.h +3 -3
- package/cpp/api/JsiSkTypefaceFontProvider.h +2 -2
- package/cpp/api/JsiSkVertices.h +1 -1
- package/cpp/jsi/JsiHostObject.cpp +1 -1
- package/cpp/rnskia/RNSkDomView.cpp +1 -1
- package/cpp/rnskia/RNSkDomView.h +3 -3
- package/cpp/rnskia/RNSkJsiViewApi.h +48 -0
- package/cpp/rnskia/RNSkManager.cpp +5 -5
- package/cpp/rnskia/RNSkPictureView.h +3 -3
- package/cpp/rnskia/RNSkPlatformContext.h +5 -5
- package/cpp/rnskia/RNSkView.h +2 -2
- package/cpp/rnskia/dom/base/ConcatablePaint.h +6 -6
- package/cpp/rnskia/dom/base/Declaration.h +1 -1
- package/cpp/rnskia/dom/base/DeclarationContext.h +7 -7
- package/cpp/rnskia/dom/base/DrawingContext.h +3 -3
- package/cpp/rnskia/dom/nodes/JsiBlurMaskNode.h +2 -2
- package/cpp/rnskia/dom/nodes/JsiColorFilterNodes.h +1 -1
- package/cpp/rnskia/dom/nodes/JsiImageFilterNodes.h +1 -1
- package/cpp/rnskia/dom/nodes/JsiPathEffectNodes.h +1 -1
- package/cpp/rnskia/dom/nodes/JsiPathNode.h +1 -1
- package/cpp/rnskia/dom/nodes/JsiPointsNode.h +1 -1
- package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +1 -1
- package/cpp/rnskia/dom/props/BlendModeProp.h +1 -1
- package/cpp/rnskia/dom/props/BoxShadowProps.h +1 -1
- package/cpp/rnskia/dom/props/CircleProp.h +1 -1
- package/cpp/rnskia/dom/props/ClipProp.h +2 -2
- package/cpp/rnskia/dom/props/PaintProps.h +1 -1
- package/cpp/rnskia/dom/props/PathProp.h +1 -1
- package/cpp/rnskia/dom/props/PointProp.h +1 -1
- package/cpp/rnskia/dom/props/PointsProp.h +1 -1
- package/cpp/rnskia/dom/props/RRectProp.h +2 -2
- package/cpp/rnskia/dom/props/RSXformProp.h +1 -1
- package/cpp/rnskia/dom/props/RadiusProp.h +1 -1
- package/cpp/rnskia/dom/props/RectProp.h +1 -1
- package/cpp/rnskia/dom/props/StrokeProps.h +1 -1
- package/cpp/rnskia/dom/props/TileModeProp.h +1 -1
- package/cpp/rnskia/dom/props/UniformsProp.h +1 -1
- package/cpp/rnskia/dom/props/VertexModeProp.h +1 -1
- package/cpp/rnskia/dom/props/VerticesProps.h +1 -1
- package/cpp/skia/src/gpu/ganesh/gl/GrGLDefines.h +1158 -0
- package/cpp/utils/RNSkTypedArray.h +1 -1
- package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +6 -6
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +3 -3
- package/ios/RNSkia-iOS/SkiaDomView.mm +7 -7
- package/ios/RNSkia-iOS/SkiaDomViewManager.mm +7 -7
- package/ios/RNSkia-iOS/SkiaManager.h +1 -1
- package/ios/RNSkia-iOS/SkiaMetalSurfaceFactory.h +1 -1
- package/ios/RNSkia-iOS/SkiaMetalSurfaceFactory.mm +5 -5
- package/ios/RNSkia-iOS/SkiaPictureView.mm +7 -7
- package/ios/RNSkia-iOS/SkiaPictureViewManager.mm +4 -4
- package/ios/RNSkia-iOS/SkiaUIView.h +3 -3
- package/ios/RNSkia-iOS/SkiaUIView.mm +2 -2
- package/ios/RNSkia-iOS/ViewScreenshotService.h +1 -1
- package/ios/RNSkia-iOS/ViewScreenshotService.mm +1 -1
- package/lib/commonjs/headless/index.d.ts +1 -0
- package/lib/commonjs/headless/index.js +17 -0
- package/lib/commonjs/headless/index.js.map +1 -1
- package/lib/commonjs/mock/index.js +1 -0
- package/lib/commonjs/mock/index.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js +1 -1
- package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js.map +1 -1
- package/lib/commonjs/views/SkiaDomView.d.ts +6 -0
- package/lib/commonjs/views/SkiaDomView.js +10 -0
- package/lib/commonjs/views/SkiaDomView.js.map +1 -1
- package/lib/commonjs/views/types.d.ts +1 -0
- package/lib/commonjs/views/types.js.map +1 -1
- package/lib/module/headless/index.d.ts +1 -0
- package/lib/module/headless/index.js +1 -0
- package/lib/module/headless/index.js.map +1 -1
- package/lib/module/mock/index.js +1 -0
- package/lib/module/mock/index.js.map +1 -1
- package/lib/module/skia/web/JsiSkSurfaceFactory.js +1 -1
- package/lib/module/skia/web/JsiSkSurfaceFactory.js.map +1 -1
- package/lib/module/views/SkiaDomView.d.ts +6 -0
- package/lib/module/views/SkiaDomView.js +10 -0
- package/lib/module/views/SkiaDomView.js.map +1 -1
- package/lib/module/views/types.d.ts +1 -0
- package/lib/module/views/types.js.map +1 -1
- package/lib/typescript/src/headless/index.d.ts +1 -0
- package/lib/typescript/src/views/SkiaDomView.d.ts +6 -0
- package/lib/typescript/src/views/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/headless/index.ts +2 -0
- package/src/mock/index.ts +1 -0
- package/src/skia/web/JsiSkSurfaceFactory.ts +1 -1
- package/src/views/SkiaDomView.tsx +10 -0
- package/src/views/types.ts +1 -0
package/cpp/api/JsiSkData.h
CHANGED
package/cpp/api/JsiSkFont.h
CHANGED
@@ -17,8 +17,8 @@
|
|
17
17
|
#pragma clang diagnostic push
|
18
18
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
19
19
|
|
20
|
-
#include "SkFont.h"
|
21
|
-
#include "SkFontMetrics.h"
|
20
|
+
#include "include/core/SkFont.h"
|
21
|
+
#include "include/core/SkFontMetrics.h"
|
22
22
|
|
23
23
|
#pragma clang diagnostic pop
|
24
24
|
|
package/cpp/api/JsiSkFontMgr.h
CHANGED
package/cpp/api/JsiSkFontStyle.h
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
#pragma clang diagnostic push
|
11
11
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
12
12
|
|
13
|
-
#include "SkFontStyle.h"
|
13
|
+
#include "include/core/SkFontStyle.h"
|
14
14
|
|
15
15
|
#pragma clang diagnostic pop
|
16
16
|
|
@@ -64,4 +64,4 @@ public:
|
|
64
64
|
std::make_shared<JsiSkFontStyle>(std::move(context), fontStyle));
|
65
65
|
}
|
66
66
|
};
|
67
|
-
} // namespace RNSkia
|
67
|
+
} // namespace RNSkia
|
package/cpp/api/JsiSkImage.h
CHANGED
@@ -15,9 +15,9 @@
|
|
15
15
|
#pragma clang diagnostic push
|
16
16
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
17
17
|
|
18
|
-
#include "SkImage.h"
|
19
|
-
#include "SkStream.h"
|
20
18
|
#include "include/codec/SkEncodedImageFormat.h"
|
19
|
+
#include "include/core/SkImage.h"
|
20
|
+
#include "include/core/SkStream.h"
|
21
21
|
#include "include/encode/SkJpegEncoder.h"
|
22
22
|
#include "include/encode/SkPngEncoder.h"
|
23
23
|
#include "include/encode/SkWebpEncoder.h"
|
@@ -47,7 +47,6 @@ public:
|
|
47
47
|
[context = std::move(context), viewTag](
|
48
48
|
jsi::Runtime &runtime,
|
49
49
|
std::shared_ptr<RNJsi::JsiPromises::Promise> promise) -> void {
|
50
|
-
// Create a stream operation - this will be run on the main thread
|
51
50
|
context->makeViewScreenshot(
|
52
51
|
viewTag, [&runtime, context = std::move(context),
|
53
52
|
promise = std::move(promise)](sk_sp<SkImage> image) {
|
package/cpp/api/JsiSkImageInfo.h
CHANGED
package/cpp/api/JsiSkMatrix.h
CHANGED
package/cpp/api/JsiSkPaint.h
CHANGED
package/cpp/api/JsiSkParagraph.h
CHANGED
@@ -7,17 +7,17 @@
|
|
7
7
|
|
8
8
|
#include <jsi/jsi.h>
|
9
9
|
|
10
|
-
#include
|
11
|
-
#include
|
12
|
-
#include
|
13
|
-
#include
|
10
|
+
#include "JsiSkCanvas.h"
|
11
|
+
#include "JsiSkHostObjects.h"
|
12
|
+
#include "JsiSkPath.h"
|
13
|
+
#include "JsiSkRect.h"
|
14
14
|
|
15
15
|
#pragma clang diagnostic push
|
16
16
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
17
17
|
|
18
|
-
#include "Paragraph.h"
|
19
|
-
#include "ParagraphBuilder.h"
|
20
|
-
#include "ParagraphStyle.h"
|
18
|
+
#include "modules/skparagraph/include/Paragraph.h"
|
19
|
+
#include "modules/skparagraph/include/ParagraphBuilder.h"
|
20
|
+
#include "modules/skparagraph/include/ParagraphStyle.h"
|
21
21
|
|
22
22
|
#pragma clang diagnostic pop
|
23
23
|
|
@@ -5,19 +5,19 @@
|
|
5
5
|
|
6
6
|
#include <jsi/jsi.h>
|
7
7
|
|
8
|
-
#include
|
9
|
-
#include
|
10
|
-
#include
|
11
|
-
#include
|
12
|
-
#include
|
13
|
-
#include
|
14
|
-
#include
|
15
|
-
#include
|
8
|
+
#include "JsiSkFont.h"
|
9
|
+
#include "JsiSkFontMgr.h"
|
10
|
+
#include "JsiSkFontMgrFactory.h"
|
11
|
+
#include "JsiSkHostObjects.h"
|
12
|
+
#include "JsiSkParagraph.h"
|
13
|
+
#include "JsiSkParagraphStyle.h"
|
14
|
+
#include "JsiSkTextStyle.h"
|
15
|
+
#include "JsiSkTypefaceFontProvider.h"
|
16
16
|
|
17
17
|
#pragma clang diagnostic push
|
18
18
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
19
19
|
|
20
|
-
#include "ParagraphBuilder.h"
|
20
|
+
#include "modules/skparagraph/include/ParagraphBuilder.h"
|
21
21
|
|
22
22
|
#pragma clang diagnostic pop
|
23
23
|
|
@@ -5,13 +5,13 @@
|
|
5
5
|
|
6
6
|
#include <jsi/jsi.h>
|
7
7
|
|
8
|
-
#include
|
9
|
-
#include
|
8
|
+
#include "JsiSkParagraphBuilder.h"
|
9
|
+
#include "JsiSkParagraphStyle.h"
|
10
10
|
|
11
11
|
#pragma clang diagnostic push
|
12
12
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
13
13
|
|
14
|
-
#include "ParagraphBuilder.h"
|
14
|
+
#include "modules/skparagraph/include/ParagraphBuilder.h"
|
15
15
|
|
16
16
|
#pragma clang diagnostic pop
|
17
17
|
|
@@ -51,4 +51,4 @@ public:
|
|
51
51
|
: JsiSkHostObject(std::move(context)) {}
|
52
52
|
};
|
53
53
|
|
54
|
-
} // namespace RNSkia
|
54
|
+
} // namespace RNSkia
|
@@ -9,13 +9,13 @@
|
|
9
9
|
|
10
10
|
#include <jsi/jsi.h>
|
11
11
|
|
12
|
-
#include
|
13
|
-
#include
|
12
|
+
#include "JsiSkStrutStyle.h"
|
13
|
+
#include "JsiSkTextStyle.h"
|
14
14
|
|
15
15
|
#pragma clang diagnostic push
|
16
16
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
17
17
|
|
18
|
-
#include "Paragraph.h"
|
18
|
+
#include "modules/skparagraph/include/Paragraph.h"
|
19
19
|
|
20
20
|
#pragma clang diagnostic pop
|
21
21
|
|
package/cpp/api/JsiSkPath.h
CHANGED
@@ -16,17 +16,17 @@
|
|
16
16
|
#pragma clang diagnostic push
|
17
17
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
18
18
|
|
19
|
-
#include "
|
20
|
-
#include "
|
21
|
-
#include "
|
22
|
-
#include "
|
23
|
-
#include "
|
24
|
-
#include "
|
25
|
-
#include "
|
26
|
-
#include "
|
27
|
-
#include "
|
28
|
-
#include "
|
29
|
-
#include "
|
19
|
+
#include "include/core/SkPath.h"
|
20
|
+
#include "include/core/SkPathEffect.h"
|
21
|
+
#include "include/core/SkPathTypes.h"
|
22
|
+
#include "include/core/SkPathUtils.h"
|
23
|
+
#include "include/core/SkString.h"
|
24
|
+
#include "include/core/SkStrokeRec.h"
|
25
|
+
#include "include/effects/SkDashPathEffect.h"
|
26
|
+
#include "include/effects/SkTrimPathEffect.h"
|
27
|
+
#include "include/pathops/SkPathOps.h"
|
28
|
+
#include "include/utils/SkParsePath.h"
|
29
|
+
#include "include/utils/SkTextUtils.h"
|
30
30
|
#include "src/core/SkPathPriv.h"
|
31
31
|
|
32
32
|
#pragma clang diagnostic pop
|
@@ -12,12 +12,12 @@
|
|
12
12
|
#pragma clang diagnostic push
|
13
13
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
14
14
|
|
15
|
-
#include "
|
16
|
-
#include "SkDashPathEffect.h"
|
17
|
-
#include "SkDiscretePathEffect.h"
|
18
|
-
#include "SkPathEffect.h"
|
15
|
+
#include "include/core/SkPathEffect.h"
|
19
16
|
#include "include/effects/Sk1DPathEffect.h"
|
20
17
|
#include "include/effects/Sk2DPathEffect.h"
|
18
|
+
#include "include/effects/SkCornerPathEffect.h"
|
19
|
+
#include "include/effects/SkDashPathEffect.h"
|
20
|
+
#include "include/effects/SkDiscretePathEffect.h"
|
21
21
|
|
22
22
|
#pragma clang diagnostic pop
|
23
23
|
|
package/cpp/api/JsiSkPicture.h
CHANGED
@@ -10,8 +10,8 @@
|
|
10
10
|
#pragma clang diagnostic push
|
11
11
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
12
12
|
|
13
|
-
#include "SkBBHFactory.h"
|
14
|
-
#include "SkPictureRecorder.h"
|
13
|
+
#include "include/core/SkBBHFactory.h"
|
14
|
+
#include "include/core/SkPictureRecorder.h"
|
15
15
|
|
16
16
|
#pragma clang diagnostic pop
|
17
17
|
|
package/cpp/api/JsiSkPoint.h
CHANGED
package/cpp/api/JsiSkRRect.h
CHANGED
package/cpp/api/JsiSkRSXform.h
CHANGED
package/cpp/api/JsiSkRect.h
CHANGED
package/cpp/api/JsiSkShader.h
CHANGED
@@ -10,8 +10,8 @@
|
|
10
10
|
#pragma clang diagnostic push
|
11
11
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
12
12
|
|
13
|
-
#include "
|
14
|
-
#include "
|
13
|
+
#include "include/core/SkShader.h"
|
14
|
+
#include "include/effects/SkGradientShader.h"
|
15
15
|
|
16
16
|
#pragma clang diagnostic pop
|
17
17
|
|
@@ -12,9 +12,9 @@
|
|
12
12
|
#pragma clang diagnostic push
|
13
13
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
14
14
|
|
15
|
-
#include "SkColorFilter.h"
|
16
|
-
#include "SkImageFilters.h"
|
17
|
-
#include "SkPerlinNoiseShader.h"
|
15
|
+
#include "include/core/SkColorFilter.h"
|
16
|
+
#include "include/effects/SkImageFilters.h"
|
17
|
+
#include "include/effects/SkPerlinNoiseShader.h"
|
18
18
|
|
19
19
|
#pragma clang diagnostic pop
|
20
20
|
|
package/cpp/api/JsiSkSurface.h
CHANGED
package/cpp/api/JsiSkTextBlob.h
CHANGED
package/cpp/api/JsiSkTextStyle.h
CHANGED
@@ -10,8 +10,8 @@
|
|
10
10
|
#pragma clang diagnostic push
|
11
11
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
12
12
|
|
13
|
-
#include "Paragraph.h"
|
14
|
-
#include "ParagraphStyle.h"
|
13
|
+
#include "modules/skparagraph/include/Paragraph.h"
|
14
|
+
#include "modules/skparagraph/include/ParagraphStyle.h"
|
15
15
|
|
16
16
|
#pragma clang diagnostic pop
|
17
17
|
|
package/cpp/api/JsiSkTypeface.h
CHANGED
@@ -12,9 +12,9 @@
|
|
12
12
|
#pragma clang diagnostic push
|
13
13
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
14
14
|
|
15
|
-
#include "SkFont.h"
|
16
|
-
#include "SkFontTypes.h"
|
17
|
-
#include "SkTypeface.h"
|
15
|
+
#include "include/core/SkFont.h"
|
16
|
+
#include "include/core/SkFontTypes.h"
|
17
|
+
#include "include/core/SkTypeface.h"
|
18
18
|
|
19
19
|
#pragma clang diagnostic pop
|
20
20
|
|
@@ -14,8 +14,8 @@
|
|
14
14
|
#pragma clang diagnostic push
|
15
15
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
16
16
|
|
17
|
-
#include "SkFont.h"
|
18
|
-
#include "skparagraph/include/TypefaceFontProvider.h"
|
17
|
+
#include "include/core/SkFont.h"
|
18
|
+
#include "modules/skparagraph/include/TypefaceFontProvider.h"
|
19
19
|
|
20
20
|
#pragma clang diagnostic pop
|
21
21
|
|
package/cpp/api/JsiSkVertices.h
CHANGED
package/cpp/rnskia/RNSkDomView.h
CHANGED
@@ -21,9 +21,9 @@
|
|
21
21
|
#pragma clang diagnostic push
|
22
22
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
23
23
|
|
24
|
-
#include "SkBBHFactory.h"
|
25
|
-
#include "SkCanvas.h"
|
26
|
-
#include "SkPictureRecorder.h"
|
24
|
+
#include "include/core/SkBBHFactory.h"
|
25
|
+
#include "include/core/SkCanvas.h"
|
26
|
+
#include "include/core/SkPictureRecorder.h"
|
27
27
|
|
28
28
|
#pragma clang diagnostic pop
|
29
29
|
|
@@ -5,6 +5,7 @@
|
|
5
5
|
#include <mutex>
|
6
6
|
#include <string>
|
7
7
|
#include <unordered_map>
|
8
|
+
#include <utility>
|
8
9
|
#include <vector>
|
9
10
|
|
10
11
|
#include "JsiHostObject.h"
|
@@ -177,9 +178,56 @@ public:
|
|
177
178
|
return jsi::Value::undefined();
|
178
179
|
}
|
179
180
|
|
181
|
+
JSI_HOST_FUNCTION(makeImageSnapshotAsync) {
|
182
|
+
if (count < 1) {
|
183
|
+
_platformContext->raiseError(std::string(
|
184
|
+
"makeImageSnapshotAsync: Expected at least 1 argument, got " +
|
185
|
+
std::to_string(count) + "."));
|
186
|
+
return jsi::Value::undefined();
|
187
|
+
}
|
188
|
+
|
189
|
+
if (!arguments[0].isNumber()) {
|
190
|
+
_platformContext->raiseError(
|
191
|
+
"makeImageSnapshot: First argument must be a number");
|
192
|
+
return jsi::Value::undefined();
|
193
|
+
}
|
194
|
+
|
195
|
+
// find Skia view
|
196
|
+
int nativeId = arguments[0].asNumber();
|
197
|
+
auto info = getEnsuredViewInfo(nativeId);
|
198
|
+
auto context = _platformContext;
|
199
|
+
auto bounds =
|
200
|
+
count > 1 && !arguments[1].isUndefined() && !arguments[1].isNull()
|
201
|
+
? JsiSkRect::fromValue(runtime, arguments[1])
|
202
|
+
: nullptr;
|
203
|
+
return RNJsi::JsiPromises::createPromiseAsJSIValue(
|
204
|
+
runtime, [context = std::move(context), info, bounds](
|
205
|
+
jsi::Runtime &runtime,
|
206
|
+
std::shared_ptr<RNJsi::JsiPromises::Promise> promise) {
|
207
|
+
context->runOnMainThread([&runtime, info = std::move(info),
|
208
|
+
promise = std::move(promise),
|
209
|
+
context = std::move(context), bounds]() {
|
210
|
+
auto image = info->view->makeImageSnapshot(
|
211
|
+
bounds == nullptr ? nullptr : bounds.get());
|
212
|
+
context->runOnJavascriptThread(
|
213
|
+
[&runtime, context = std::move(context),
|
214
|
+
promise = std::move(promise), image = std::move(image)]() {
|
215
|
+
if (image == nullptr) {
|
216
|
+
promise->reject("Failed to make snapshot from view.");
|
217
|
+
return;
|
218
|
+
}
|
219
|
+
promise->resolve(jsi::Object::createFromHostObject(
|
220
|
+
runtime, std::make_shared<JsiSkImage>(std::move(context),
|
221
|
+
std::move(image))));
|
222
|
+
});
|
223
|
+
});
|
224
|
+
});
|
225
|
+
}
|
226
|
+
|
180
227
|
JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(RNSkJsiViewApi, setJsiProperty),
|
181
228
|
JSI_EXPORT_FUNC(RNSkJsiViewApi, callJsiMethod),
|
182
229
|
JSI_EXPORT_FUNC(RNSkJsiViewApi, requestRedraw),
|
230
|
+
JSI_EXPORT_FUNC(RNSkJsiViewApi, makeImageSnapshotAsync),
|
183
231
|
JSI_EXPORT_FUNC(RNSkJsiViewApi, makeImageSnapshot))
|
184
232
|
|
185
233
|
/**
|