@shopify/react-native-skia 0.1.233 → 0.1.236
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/JniSkiaManager.cpp +0 -1
- package/android/cpp/rnskia-android/RNSkAndroidView.h +0 -1
- package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +1 -1
- package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.h +1 -2
- package/cpp/api/JsiSkTypefaceFactory.h +2 -1
- package/cpp/skia/include/android/AHardwareBufferUtils.h +23 -0
- package/cpp/skia/include/android/GrAHardwareBufferUtils.h +2 -0
- package/cpp/skia/include/android/graphite/SurfaceAndroid.h +59 -0
- package/cpp/skia/include/codec/SkAvifDecoder.h +1 -1
- package/cpp/skia/include/codec/SkBmpDecoder.h +1 -1
- package/cpp/skia/include/codec/SkCodec.h +21 -3
- package/cpp/skia/include/codec/SkGifDecoder.h +1 -1
- package/cpp/skia/include/codec/SkIcoDecoder.h +1 -1
- package/cpp/skia/include/codec/SkJpegDecoder.h +1 -1
- package/cpp/skia/include/codec/SkJpegxlDecoder.h +1 -1
- package/cpp/skia/include/codec/SkPngDecoder.h +1 -1
- package/cpp/skia/include/codec/SkRawDecoder.h +1 -1
- package/cpp/skia/include/codec/SkWbmpDecoder.h +1 -1
- package/cpp/skia/include/codec/SkWebpDecoder.h +1 -1
- package/cpp/skia/include/config/SkUserConfig.h +3 -1
- package/cpp/skia/include/core/SkCanvas.h +66 -37
- package/cpp/skia/include/core/SkColorFilter.h +5 -2
- package/cpp/skia/include/core/SkContourMeasure.h +1 -0
- package/cpp/skia/include/core/SkDocument.h +1 -0
- package/cpp/skia/include/core/SkFont.h +14 -24
- package/cpp/skia/include/core/SkFontArguments.h +1 -1
- package/cpp/skia/include/core/SkFontMetrics.h +1 -1
- package/cpp/skia/include/core/SkFontMgr.h +0 -7
- package/cpp/skia/include/core/SkGraphics.h +13 -0
- package/cpp/skia/include/core/SkMesh.h +9 -13
- package/cpp/skia/include/core/SkMilestone.h +1 -1
- package/cpp/skia/include/core/SkPathMeasure.h +2 -0
- package/cpp/skia/include/core/SkSerialProcs.h +29 -11
- package/cpp/skia/include/core/SkSize.h +3 -3
- package/cpp/skia/include/core/SkStream.h +3 -13
- package/cpp/skia/include/core/SkSurface.h +6 -3
- package/cpp/skia/include/core/SkSurfaceProps.h +2 -4
- package/cpp/skia/include/core/SkTraceMemoryDump.h +15 -0
- package/cpp/skia/include/core/SkTypeface.h +8 -56
- package/cpp/skia/include/core/SkTypes.h +8 -0
- package/cpp/skia/include/core/SkVertices.h +1 -1
- package/cpp/skia/include/docs/SkMultiPictureDocument.h +53 -0
- package/cpp/skia/include/docs/SkPDFDocument.h +11 -0
- package/cpp/skia/include/effects/SkGradientShader.h +9 -0
- package/cpp/skia/include/effects/SkRuntimeEffect.h +3 -7
- package/cpp/skia/include/gpu/GrBackendSemaphore.h +33 -47
- package/cpp/skia/include/gpu/GrBackendSurface.h +2 -3
- package/cpp/skia/include/gpu/GrContextOptions.h +0 -6
- package/cpp/skia/include/gpu/GrContextThreadSafeProxy.h +44 -28
- package/cpp/skia/include/gpu/GrDirectContext.h +12 -31
- package/cpp/skia/include/gpu/GrTypes.h +1 -16
- package/cpp/skia/include/gpu/MutableTextureState.h +35 -80
- package/cpp/skia/include/gpu/ShaderErrorHandler.h +11 -1
- package/cpp/skia/include/gpu/ganesh/SkImageGanesh.h +2 -2
- package/cpp/skia/include/gpu/ganesh/SkSurfaceGanesh.h +1 -1
- package/cpp/skia/include/gpu/ganesh/gl/GrGLDirectContext.h +3 -2
- package/cpp/skia/include/gpu/ganesh/vk/GrVkBackendSemaphore.h +20 -0
- package/cpp/skia/include/gpu/ganesh/vk/GrVkDirectContext.h +30 -0
- package/cpp/skia/include/gpu/gl/GrGLFunctions.h +1 -1
- package/cpp/skia/include/gpu/gl/GrGLInterface.h +2 -0
- package/cpp/skia/include/gpu/gl/glx/GrGLMakeGLXInterface.h +6 -0
- package/cpp/skia/include/gpu/graphite/BackendSemaphore.h +3 -3
- package/cpp/skia/include/gpu/graphite/BackendTexture.h +39 -27
- package/cpp/skia/include/gpu/graphite/Context.h +39 -13
- package/cpp/skia/include/gpu/graphite/ContextOptions.h +2 -0
- package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +2 -1
- package/cpp/skia/include/gpu/graphite/Image.h +106 -87
- package/cpp/skia/include/gpu/graphite/Recorder.h +24 -3
- package/cpp/skia/include/gpu/graphite/Surface.h +7 -2
- package/cpp/skia/include/gpu/graphite/dawn/DawnBackendContext.h +41 -2
- package/cpp/skia/include/gpu/graphite/dawn/DawnTypes.h +11 -6
- package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +1 -2
- package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +6 -6
- package/cpp/skia/include/gpu/mock/GrMockTypes.h +1 -0
- package/cpp/skia/include/gpu/vk/GrVkBackendContext.h +1 -1
- package/cpp/skia/include/gpu/vk/GrVkTypes.h +1 -44
- package/cpp/skia/include/gpu/vk/VulkanExtensions.h +1 -1
- package/cpp/skia/include/gpu/vk/VulkanMutableTextureState.h +25 -0
- package/cpp/skia/include/gpu/vk/VulkanTypes.h +44 -0
- package/cpp/skia/include/ports/SkFontConfigInterface.h +3 -6
- package/cpp/skia/include/private/SkEncodedInfo.h +5 -0
- package/cpp/skia/include/private/SkExif.h +102 -0
- package/cpp/skia/include/private/SkGainmapInfo.h +11 -1
- package/cpp/skia/include/private/base/SkAssert.h +16 -0
- package/cpp/skia/include/private/base/SkDeque.h +2 -7
- package/cpp/skia/include/private/base/SkLoadUserConfig.h +1 -1
- package/cpp/skia/include/private/base/SkTArray.h +69 -28
- package/cpp/skia/include/private/base/SkThreadAnnotations.h +18 -5
- package/cpp/skia/include/private/chromium/GrSurfaceCharacterization.h +26 -30
- package/cpp/skia/include/private/chromium/GrVkSecondaryCBDrawContext.h +4 -3
- package/cpp/skia/include/private/chromium/SkImageChromium.h +1 -1
- package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +8 -6
- package/cpp/skia/include/private/gpu/graphite/ContextOptionsPriv.h +29 -0
- package/cpp/skia/include/private/gpu/graphite/DawnTypesPriv.h +12 -9
- package/cpp/skia/include/private/gpu/graphite/VulkanGraphiteTypesPriv.h +16 -11
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_platform.h +2 -2
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std.h +312 -0
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std_decode.h +77 -0
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std.h +446 -0
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std_decode.h +67 -0
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codecs_common.h +36 -0
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan.h +9 -2
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_android.h +31 -3
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_core.h +10624 -5716
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_ios.h +2 -1
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_macos.h +2 -1
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_win32.h +28 -1
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_xcb.h +2 -1
- package/cpp/skia/include/utils/mac/SkCGUtils.h +23 -11
- package/cpp/skia/modules/skcms/skcms.h +2 -410
- package/cpp/skia/modules/skcms/src/Transform_inl.h +831 -704
- package/cpp/skia/modules/skcms/src/skcms_Transform.h +161 -0
- package/cpp/skia/modules/skcms/src/skcms_internals.h +136 -0
- package/cpp/skia/modules/skcms/src/skcms_public.h +404 -0
- package/cpp/skia/modules/skparagraph/include/FontArguments.h +1 -1
- package/cpp/skia/modules/skparagraph/include/FontCollection.h +2 -0
- package/cpp/skia/modules/skparagraph/include/Paragraph.h +2 -2
- package/cpp/skia/modules/skparagraph/include/TextStyle.h +4 -3
- package/cpp/skia/modules/skparagraph/include/TypefaceFontProvider.h +1 -3
- package/cpp/skia/modules/skresources/include/SkResources.h +28 -17
- package/cpp/skia/modules/skunicode/include/SkUnicode.h +12 -0
- package/cpp/skia/modules/svg/include/SkSVGDOM.h +4 -1
- package/cpp/skia/modules/svg/include/SkSVGRenderContext.h +4 -1
- package/cpp/skia/src/base/SkUTF.h +7 -0
- package/cpp/skia/src/core/SkTHash.h +20 -8
- package/lib/commonjs/dom/nodes/JsiSkDOM.d.ts +3 -2
- package/lib/commonjs/dom/nodes/JsiSkDOM.js +56 -57
- package/lib/commonjs/dom/nodes/JsiSkDOM.js.map +1 -1
- package/lib/commonjs/external/reanimated/index.d.ts +1 -0
- package/lib/commonjs/external/reanimated/index.js +13 -0
- package/lib/commonjs/external/reanimated/index.js.map +1 -1
- package/lib/commonjs/external/reanimated/interpolators.js +16 -2
- package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
- package/lib/commonjs/external/reanimated/moduleWrapper.d.ts +1 -0
- package/lib/commonjs/external/reanimated/moduleWrapper.js +5 -3
- package/lib/commonjs/external/reanimated/moduleWrapper.js.map +1 -1
- package/lib/commonjs/external/reanimated/textures.d.ts +5 -0
- package/lib/commonjs/external/reanimated/textures.js +52 -0
- package/lib/commonjs/external/reanimated/textures.js.map +1 -0
- package/lib/commonjs/headless/index.js +1 -1
- package/lib/commonjs/headless/index.js.map +1 -1
- package/lib/commonjs/mock/index.js +3 -0
- package/lib/commonjs/mock/index.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.js +6 -5
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/renderer/Container.d.ts +1 -1
- package/lib/commonjs/renderer/Container.js +2 -1
- package/lib/commonjs/renderer/Container.js.map +1 -1
- package/lib/commonjs/renderer/Offscreen.d.ts +1 -0
- package/lib/commonjs/renderer/Offscreen.js +18 -5
- package/lib/commonjs/renderer/Offscreen.js.map +1 -1
- package/lib/commonjs/renderer/Reconciler.d.ts +1 -1
- package/lib/commonjs/renderer/Reconciler.js +7 -4
- package/lib/commonjs/renderer/Reconciler.js.map +1 -1
- package/lib/commonjs/skia/types/Matrix4.d.ts +2 -2
- package/lib/commonjs/skia/types/Matrix4.js.map +1 -1
- package/lib/commonjs/skia/types/Shader/Shader.d.ts +1 -1
- package/lib/commonjs/skia/types/Shader/Shader.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPath.d.ts +2 -2
- package/lib/commonjs/skia/web/JsiSkPath.js +10 -2
- package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
- package/lib/commonjs/views/SkiaJSDomView.d.ts +31 -0
- package/lib/commonjs/views/SkiaJSDomView.js +161 -0
- package/lib/commonjs/views/SkiaJSDomView.js.map +1 -0
- package/lib/commonjs/views/SkiaJSDomView.web.d.ts +1 -0
- package/lib/commonjs/views/SkiaJSDomView.web.js +14 -0
- package/lib/commonjs/views/SkiaJSDomView.web.js.map +1 -0
- package/lib/module/dom/nodes/JsiSkDOM.d.ts +3 -2
- package/lib/module/dom/nodes/JsiSkDOM.js +56 -56
- package/lib/module/dom/nodes/JsiSkDOM.js.map +1 -1
- package/lib/module/external/reanimated/index.d.ts +1 -0
- package/lib/module/external/reanimated/index.js +1 -0
- package/lib/module/external/reanimated/index.js.map +1 -1
- package/lib/module/external/reanimated/interpolators.js +15 -2
- package/lib/module/external/reanimated/interpolators.js.map +1 -1
- package/lib/module/external/reanimated/moduleWrapper.d.ts +1 -0
- package/lib/module/external/reanimated/moduleWrapper.js +3 -2
- package/lib/module/external/reanimated/moduleWrapper.js.map +1 -1
- package/lib/module/external/reanimated/textures.d.ts +5 -0
- package/lib/module/external/reanimated/textures.js +35 -0
- package/lib/module/external/reanimated/textures.js.map +1 -0
- package/lib/module/headless/index.js +1 -1
- package/lib/module/headless/index.js.map +1 -1
- package/lib/module/mock/index.js +3 -0
- package/lib/module/mock/index.js.map +1 -1
- package/lib/module/renderer/Canvas.js +5 -4
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/renderer/Container.d.ts +1 -1
- package/lib/module/renderer/Container.js +2 -1
- package/lib/module/renderer/Container.js.map +1 -1
- package/lib/module/renderer/Offscreen.d.ts +1 -0
- package/lib/module/renderer/Offscreen.js +11 -3
- package/lib/module/renderer/Offscreen.js.map +1 -1
- package/lib/module/renderer/Reconciler.d.ts +1 -1
- package/lib/module/renderer/Reconciler.js +7 -4
- package/lib/module/renderer/Reconciler.js.map +1 -1
- package/lib/module/skia/types/Matrix4.d.ts +2 -2
- package/lib/module/skia/types/Matrix4.js.map +1 -1
- package/lib/module/skia/types/Shader/Shader.d.ts +1 -1
- package/lib/module/skia/types/Shader/Shader.js.map +1 -1
- package/lib/module/skia/web/JsiSkPath.d.ts +2 -2
- package/lib/module/skia/web/JsiSkPath.js +10 -2
- package/lib/module/skia/web/JsiSkPath.js.map +1 -1
- package/lib/module/views/SkiaJSDomView.d.ts +31 -0
- package/lib/module/views/SkiaJSDomView.js +136 -0
- package/lib/module/views/SkiaJSDomView.js.map +1 -0
- package/lib/module/views/SkiaJSDomView.web.d.ts +1 -0
- package/lib/module/views/SkiaJSDomView.web.js +2 -0
- package/lib/module/views/SkiaJSDomView.web.js.map +1 -0
- package/lib/typescript/src/dom/nodes/JsiSkDOM.d.ts +3 -2
- package/lib/typescript/src/external/reanimated/index.d.ts +1 -0
- package/lib/typescript/src/external/reanimated/moduleWrapper.d.ts +1 -0
- package/lib/typescript/src/external/reanimated/textures.d.ts +5 -0
- package/lib/typescript/src/renderer/Container.d.ts +1 -1
- package/lib/typescript/src/renderer/Offscreen.d.ts +1 -0
- package/lib/typescript/src/renderer/Reconciler.d.ts +1 -1
- package/lib/typescript/src/skia/types/Matrix4.d.ts +2 -2
- package/lib/typescript/src/skia/types/Shader/Shader.d.ts +1 -1
- package/lib/typescript/src/skia/web/JsiSkPath.d.ts +2 -2
- package/lib/typescript/src/views/SkiaJSDomView.d.ts +31 -0
- package/lib/typescript/src/views/SkiaJSDomView.web.d.ts +1 -0
- package/libs/android/arm64-v8a/libskia.a +0 -0
- package/libs/android/arm64-v8a/libskottie.a +0 -0
- package/libs/android/arm64-v8a/libskparagraph.a +0 -0
- package/libs/android/arm64-v8a/libsksg.a +0 -0
- package/libs/android/arm64-v8a/libskshaper.a +0 -0
- package/libs/android/arm64-v8a/libskunicode.a +0 -0
- package/libs/android/arm64-v8a/libsvg.a +0 -0
- package/libs/android/armeabi-v7a/libskia.a +0 -0
- package/libs/android/armeabi-v7a/libskottie.a +0 -0
- package/libs/android/armeabi-v7a/libskparagraph.a +0 -0
- package/libs/android/armeabi-v7a/libsksg.a +0 -0
- package/libs/android/armeabi-v7a/libskshaper.a +0 -0
- package/libs/android/armeabi-v7a/libskunicode.a +0 -0
- package/libs/android/armeabi-v7a/libsvg.a +0 -0
- package/libs/android/x86/libskia.a +0 -0
- package/libs/android/x86/libskottie.a +0 -0
- package/libs/android/x86/libskparagraph.a +0 -0
- package/libs/android/x86/libsksg.a +0 -0
- package/libs/android/x86/libskshaper.a +0 -0
- package/libs/android/x86/libskunicode.a +0 -0
- package/libs/android/x86/libsvg.a +0 -0
- package/libs/android/x86_64/libskia.a +0 -0
- package/libs/android/x86_64/libskottie.a +0 -0
- package/libs/android/x86_64/libskparagraph.a +0 -0
- package/libs/android/x86_64/libsksg.a +0 -0
- package/libs/android/x86_64/libskshaper.a +0 -0
- package/libs/android/x86_64/libskunicode.a +0 -0
- package/libs/android/x86_64/libsvg.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/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/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
- package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -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/libskunicode.xcframework/ios-arm64_arm64e/libskunicode.a +0 -0
- package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode.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 +1 -1
- package/src/dom/nodes/JsiSkDOM.ts +55 -56
- package/src/external/reanimated/index.ts +1 -0
- package/src/external/reanimated/interpolators.ts +17 -3
- package/src/external/reanimated/moduleWrapper.ts +1 -0
- package/src/external/reanimated/textures.tsx +50 -0
- package/src/headless/index.ts +1 -1
- package/src/mock/index.ts +3 -0
- package/src/renderer/Canvas.tsx +4 -3
- package/src/renderer/Container.tsx +3 -2
- package/src/renderer/Offscreen.tsx +12 -3
- package/src/renderer/Reconciler.tsx +5 -2
- package/src/skia/types/Matrix4.ts +2 -2
- package/src/skia/types/Shader/Shader.ts +6 -1
- package/src/skia/web/JsiSkPath.ts +23 -3
- package/src/views/SkiaJSDomView.tsx +126 -0
- package/src/views/SkiaJSDomView.web.tsx +1 -0
- package/android/cpp/jni/include/JniSkiaDrawView.h +0 -90
- package/cpp/rnskia/RNSkJsView.cpp +0 -236
- package/cpp/rnskia/RNSkJsView.h +0 -121
- package/cpp/skia/include/gpu/GrSurfaceInfo.h +0 -142
- package/cpp/skia/include/private/gpu/ganesh/GrGLTypesPriv.h +0 -107
- package/cpp/skia/include/private/gpu/ganesh/GrMockTypesPriv.h +0 -32
- package/cpp/skia/include/private/gpu/ganesh/GrMtlTypesPriv.h +0 -83
- package/cpp/skia/include/private/gpu/ganesh/GrVkTypesPriv.h +0 -47
- package/cpp/skia/include/private/gpu/vk/VulkanTypesPriv.h +0 -57
- package/cpp/skia/include/utils/SkBase64.h +0 -53
- package/cpp/skia/modules/skcms/skcms_internal.h +0 -56
@@ -55,7 +55,6 @@ import type {
|
|
55
55
|
Path1DPathEffectProps,
|
56
56
|
Path2DPathEffectProps,
|
57
57
|
} from "../types/PathEffects";
|
58
|
-
import { NATIVE_DOM } from "../../renderer/HostComponents";
|
59
58
|
import type { ParagraphProps } from "../types/Paragraph";
|
60
59
|
|
61
60
|
import {
|
@@ -125,200 +124,200 @@ import { LayerNode } from "./LayerNode";
|
|
125
124
|
import { ParagraphNode } from "./drawings/ParagraphNode";
|
126
125
|
|
127
126
|
export class JsiSkDOM implements SkDOM {
|
128
|
-
constructor(private ctx: NodeContext) {}
|
127
|
+
constructor(private ctx: NodeContext, private native: boolean) {}
|
129
128
|
|
130
129
|
Layer(props?: ChildrenProps) {
|
131
|
-
return
|
130
|
+
return this.native
|
132
131
|
? global.SkiaDomApi.LayerNode(props ?? {})
|
133
132
|
: new LayerNode(this.ctx, props ?? {});
|
134
133
|
}
|
135
134
|
|
136
135
|
Group(props?: GroupProps) {
|
137
|
-
return
|
136
|
+
return this.native
|
138
137
|
? global.SkiaDomApi.GroupNode(props ?? {})
|
139
138
|
: new GroupNode(this.ctx, props ?? {});
|
140
139
|
}
|
141
140
|
|
142
141
|
Paint(props: PaintProps) {
|
143
|
-
return
|
142
|
+
return this.native
|
144
143
|
? global.SkiaDomApi.PaintNode(props ?? {})
|
145
144
|
: new PaintNode(this.ctx, props);
|
146
145
|
}
|
147
146
|
|
148
147
|
// Drawings
|
149
148
|
Fill(props?: DrawingNodeProps) {
|
150
|
-
return
|
149
|
+
return this.native
|
151
150
|
? global.SkiaDomApi.FillNode(props ?? {})
|
152
151
|
: new FillNode(this.ctx, props);
|
153
152
|
}
|
154
153
|
|
155
154
|
Image(props: ImageProps) {
|
156
|
-
return
|
155
|
+
return this.native
|
157
156
|
? global.SkiaDomApi.ImageNode(props ?? {})
|
158
157
|
: new ImageNode(this.ctx, props);
|
159
158
|
}
|
160
159
|
|
161
160
|
Circle(props: CircleProps) {
|
162
|
-
return
|
161
|
+
return this.native
|
163
162
|
? global.SkiaDomApi.CircleNode(props ?? {})
|
164
163
|
: new CircleNode(this.ctx, props);
|
165
164
|
}
|
166
165
|
|
167
166
|
Path(props: PathProps) {
|
168
|
-
return
|
167
|
+
return this.native
|
169
168
|
? global.SkiaDomApi.PathNode(props ?? {})
|
170
169
|
: new PathNode(this.ctx, props);
|
171
170
|
}
|
172
171
|
|
173
172
|
Line(props: LineProps) {
|
174
|
-
return
|
173
|
+
return this.native
|
175
174
|
? global.SkiaDomApi.LineNode(props ?? {})
|
176
175
|
: new LineNode(this.ctx, props);
|
177
176
|
}
|
178
177
|
|
179
178
|
Oval(props: OvalProps) {
|
180
|
-
return
|
179
|
+
return this.native
|
181
180
|
? global.SkiaDomApi.OvalNode(props ?? {})
|
182
181
|
: new OvalNode(this.ctx, props);
|
183
182
|
}
|
184
183
|
|
185
184
|
Patch(props: PatchProps) {
|
186
|
-
return
|
185
|
+
return this.native
|
187
186
|
? global.SkiaDomApi.PatchNode(props ?? {})
|
188
187
|
: new PatchNode(this.ctx, props);
|
189
188
|
}
|
190
189
|
|
191
190
|
Points(props: PointsProps) {
|
192
|
-
return
|
191
|
+
return this.native
|
193
192
|
? global.SkiaDomApi.PointsNode(props ?? {})
|
194
193
|
: new PointsNode(this.ctx, props);
|
195
194
|
}
|
196
195
|
|
197
196
|
Rect(props: RectProps) {
|
198
|
-
return
|
197
|
+
return this.native
|
199
198
|
? global.SkiaDomApi.RectNode(props)
|
200
199
|
: new RectNode(this.ctx, props);
|
201
200
|
}
|
202
201
|
|
203
202
|
RRect(props: RoundedRectProps) {
|
204
|
-
return
|
203
|
+
return this.native
|
205
204
|
? global.SkiaDomApi.RRectNode(props)
|
206
205
|
: new RRectNode(this.ctx, props);
|
207
206
|
}
|
208
207
|
|
209
208
|
Vertices(props: VerticesProps) {
|
210
|
-
return
|
209
|
+
return this.native
|
211
210
|
? global.SkiaDomApi.VerticesNode(props)
|
212
211
|
: new VerticesNode(this.ctx, props);
|
213
212
|
}
|
214
213
|
|
215
214
|
Text(props: TextProps) {
|
216
|
-
return
|
215
|
+
return this.native
|
217
216
|
? global.SkiaDomApi.TextNode(props)
|
218
217
|
: new TextNode(this.ctx, props);
|
219
218
|
}
|
220
219
|
|
221
220
|
TextPath(props: TextPathProps) {
|
222
|
-
return
|
221
|
+
return this.native
|
223
222
|
? global.SkiaDomApi.TextPathNode(props)
|
224
223
|
: new TextPathNode(this.ctx, props);
|
225
224
|
}
|
226
225
|
|
227
226
|
TextBlob(props: TextBlobProps) {
|
228
|
-
return
|
227
|
+
return this.native
|
229
228
|
? global.SkiaDomApi.TextBlobNode(props)
|
230
229
|
: new TextBlobNode(this.ctx, props);
|
231
230
|
}
|
232
231
|
|
233
232
|
Glyphs(props: GlyphsProps) {
|
234
|
-
return
|
233
|
+
return this.native
|
235
234
|
? global.SkiaDomApi.GlyphsNode(props)
|
236
235
|
: new GlyphsNode(this.ctx, props);
|
237
236
|
}
|
238
237
|
|
239
238
|
DiffRect(props: DiffRectProps) {
|
240
|
-
return
|
239
|
+
return this.native
|
241
240
|
? global.SkiaDomApi.DiffRectNode(props)
|
242
241
|
: new DiffRectNode(this.ctx, props);
|
243
242
|
}
|
244
243
|
|
245
244
|
Picture(props: PictureProps) {
|
246
|
-
return
|
245
|
+
return this.native
|
247
246
|
? global.SkiaDomApi.PictureNode(props)
|
248
247
|
: new PictureNode(this.ctx, props);
|
249
248
|
}
|
250
249
|
|
251
250
|
ImageSVG(props: ImageSVGProps) {
|
252
|
-
return
|
251
|
+
return this.native
|
253
252
|
? global.SkiaDomApi.ImageSVGNode(props)
|
254
253
|
: new ImageSVGNode(this.ctx, props);
|
255
254
|
}
|
256
255
|
|
257
256
|
// BlurMaskFilters
|
258
257
|
BlurMaskFilter(props: BlurMaskFilterProps) {
|
259
|
-
return
|
258
|
+
return this.native
|
260
259
|
? global.SkiaDomApi.BlurMaskFilterNode(props)
|
261
260
|
: new BlurMaskFilterNode(this.ctx, props);
|
262
261
|
}
|
263
262
|
|
264
263
|
// ImageFilters
|
265
264
|
BlendImageFilter(props: BlendImageFilterProps) {
|
266
|
-
return
|
265
|
+
return this.native
|
267
266
|
? global.SkiaDomApi.BlendImageFilterNode(props)
|
268
267
|
: new BlendImageFilterNode(this.ctx, props);
|
269
268
|
}
|
270
269
|
|
271
270
|
DropShadowImageFilter(props: DropShadowImageFilterProps) {
|
272
|
-
return
|
271
|
+
return this.native
|
273
272
|
? global.SkiaDomApi.DropShadowImageFilterNode(props)
|
274
273
|
: new DropShadowImageFilterNode(this.ctx, props);
|
275
274
|
}
|
276
275
|
|
277
276
|
DisplacementMapImageFilter(props: DisplacementMapImageFilterProps) {
|
278
|
-
return
|
277
|
+
return this.native
|
279
278
|
? global.SkiaDomApi.DisplacementMapImageFilterNode(props)
|
280
279
|
: new DisplacementMapImageFilterNode(this.ctx, props);
|
281
280
|
}
|
282
281
|
|
283
282
|
BlurImageFilter(props: BlurImageFilterProps) {
|
284
|
-
return
|
283
|
+
return this.native
|
285
284
|
? global.SkiaDomApi.BlurImageFilterNode(props)
|
286
285
|
: new BlurImageFilterNode(this.ctx, props);
|
287
286
|
}
|
288
287
|
|
289
288
|
OffsetImageFilter(props: OffsetImageFilterProps) {
|
290
|
-
return
|
289
|
+
return this.native
|
291
290
|
? global.SkiaDomApi.OffsetImageFilterNode(props)
|
292
291
|
: new OffsetImageFilterNode(this.ctx, props);
|
293
292
|
}
|
294
293
|
|
295
294
|
MorphologyImageFilter(props: MorphologyImageFilterProps) {
|
296
|
-
return
|
295
|
+
return this.native
|
297
296
|
? global.SkiaDomApi.MorphologyImageFilterNode(props)
|
298
297
|
: new MorphologyImageFilterNode(this.ctx, props);
|
299
298
|
}
|
300
299
|
|
301
300
|
RuntimeShaderImageFilter(props: RuntimeShaderImageFilterProps) {
|
302
|
-
return
|
301
|
+
return this.native
|
303
302
|
? global.SkiaDomApi.RuntimeShaderImageFilterNode(props)
|
304
303
|
: new RuntimeShaderImageFilterNode(this.ctx, props);
|
305
304
|
}
|
306
305
|
|
307
306
|
// Color Filters
|
308
307
|
MatrixColorFilter(props: MatrixColorFilterProps) {
|
309
|
-
return
|
308
|
+
return this.native
|
310
309
|
? global.SkiaDomApi.MatrixColorFilterNode(props)
|
311
310
|
: new MatrixColorFilterNode(this.ctx, props);
|
312
311
|
}
|
313
312
|
|
314
313
|
BlendColorFilter(props: BlendColorFilterProps) {
|
315
|
-
return
|
314
|
+
return this.native
|
316
315
|
? global.SkiaDomApi.BlendColorFilterNode(props)
|
317
316
|
: new BlendColorFilterNode(this.ctx, props);
|
318
317
|
}
|
319
318
|
|
320
319
|
LumaColorFilter() {
|
321
|
-
return
|
320
|
+
return this.native
|
322
321
|
? global.SkiaDomApi.LumaColorFilterNode()
|
323
322
|
: new LumaColorFilterNode(this.ctx);
|
324
323
|
}
|
@@ -338,136 +337,136 @@ export class JsiSkDOM implements SkDOM {
|
|
338
337
|
}
|
339
338
|
|
340
339
|
LerpColorFilter(props: LerpColorFilterProps) {
|
341
|
-
return
|
340
|
+
return this.native
|
342
341
|
? global.SkiaDomApi.LerpColorFilterNode(props)
|
343
342
|
: new LerpColorFilterNode(this.ctx, props);
|
344
343
|
}
|
345
344
|
|
346
345
|
// Shaders
|
347
346
|
Shader(props: ShaderProps) {
|
348
|
-
return
|
347
|
+
return this.native
|
349
348
|
? global.SkiaDomApi.ShaderNode(props)
|
350
349
|
: new ShaderNode(this.ctx, props);
|
351
350
|
}
|
352
351
|
|
353
352
|
ImageShader(props: ImageShaderProps) {
|
354
|
-
return
|
353
|
+
return this.native
|
355
354
|
? global.SkiaDomApi.ImageShaderNode(props)
|
356
355
|
: new ImageShaderNode(this.ctx, props);
|
357
356
|
}
|
358
357
|
|
359
358
|
ColorShader(props: ColorProps) {
|
360
|
-
return
|
359
|
+
return this.native
|
361
360
|
? global.SkiaDomApi.ColorShaderNode(props)
|
362
361
|
: new ColorNode(this.ctx, props);
|
363
362
|
}
|
364
363
|
|
365
364
|
SweepGradient(props: SweepGradientProps) {
|
366
|
-
return
|
365
|
+
return this.native
|
367
366
|
? global.SkiaDomApi.SweepGradientNode(props)
|
368
367
|
: new SweepGradientNode(this.ctx, props);
|
369
368
|
}
|
370
369
|
|
371
370
|
Turbulence(props: TurbulenceProps) {
|
372
|
-
return
|
371
|
+
return this.native
|
373
372
|
? global.SkiaDomApi.TurbulenceNode(props)
|
374
373
|
: new TurbulenceNode(this.ctx, props);
|
375
374
|
}
|
376
375
|
|
377
376
|
FractalNoise(props: FractalNoiseProps) {
|
378
|
-
return
|
377
|
+
return this.native
|
379
378
|
? global.SkiaDomApi.FractalNoiseNode(props)
|
380
379
|
: new FractalNoiseNode(this.ctx, props);
|
381
380
|
}
|
382
381
|
|
383
382
|
LinearGradient(props: LinearGradientProps) {
|
384
|
-
return
|
383
|
+
return this.native
|
385
384
|
? global.SkiaDomApi.LinearGradientNode(props)
|
386
385
|
: new LinearGradientNode(this.ctx, props);
|
387
386
|
}
|
388
387
|
|
389
388
|
RadialGradient(props: RadialGradientProps) {
|
390
|
-
return
|
389
|
+
return this.native
|
391
390
|
? global.SkiaDomApi.RadialGradientNode(props)
|
392
391
|
: new RadialGradientNode(this.ctx, props);
|
393
392
|
}
|
394
393
|
|
395
394
|
TwoPointConicalGradient(props: TwoPointConicalGradientProps) {
|
396
|
-
return
|
395
|
+
return this.native
|
397
396
|
? global.SkiaDomApi.TwoPointConicalGradientNode(props)
|
398
397
|
: new TwoPointConicalGradientNode(this.ctx, props);
|
399
398
|
}
|
400
399
|
|
401
400
|
// Path Effects
|
402
401
|
CornerPathEffect(props: CornerPathEffectProps) {
|
403
|
-
return
|
402
|
+
return this.native
|
404
403
|
? global.SkiaDomApi.CornerPathEffectNode(props)
|
405
404
|
: new CornerPathEffectNode(this.ctx, props);
|
406
405
|
}
|
407
406
|
|
408
407
|
DiscretePathEffect(props: DiscretePathEffectProps) {
|
409
|
-
return
|
408
|
+
return this.native
|
410
409
|
? global.SkiaDomApi.DiscretePathEffectNode(props)
|
411
410
|
: new DiscretePathEffectNode(this.ctx, props);
|
412
411
|
}
|
413
412
|
|
414
413
|
DashPathEffect(props: DashPathEffectProps) {
|
415
|
-
return
|
414
|
+
return this.native
|
416
415
|
? global.SkiaDomApi.DashPathEffectNode(props)
|
417
416
|
: new DashPathEffectNode(this.ctx, props);
|
418
417
|
}
|
419
418
|
|
420
419
|
Path1DPathEffect(props: Path1DPathEffectProps) {
|
421
|
-
return
|
420
|
+
return this.native
|
422
421
|
? global.SkiaDomApi.Path1DPathEffectNode(props)
|
423
422
|
: new Path1DPathEffectNode(this.ctx, props);
|
424
423
|
}
|
425
424
|
|
426
425
|
Path2DPathEffect(props: Path2DPathEffectProps) {
|
427
|
-
return
|
426
|
+
return this.native
|
428
427
|
? global.SkiaDomApi.Path2DPathEffectNode(props)
|
429
428
|
: new Path2DPathEffectNode(this.ctx, props);
|
430
429
|
}
|
431
430
|
|
432
431
|
SumPathEffect() {
|
433
|
-
return
|
432
|
+
return this.native
|
434
433
|
? global.SkiaDomApi.SumPathEffectNode()
|
435
434
|
: new SumPathEffectNode(this.ctx);
|
436
435
|
}
|
437
436
|
|
438
437
|
Line2DPathEffect(props: Line2DPathEffectProps) {
|
439
|
-
return
|
438
|
+
return this.native
|
440
439
|
? global.SkiaDomApi.Line2DPathEffectNode(props)
|
441
440
|
: new Line2DPathEffectNode(this.ctx, props);
|
442
441
|
}
|
443
442
|
|
444
443
|
Blend(props: BlendProps) {
|
445
|
-
return
|
444
|
+
return this.native
|
446
445
|
? global.SkiaDomApi.BlendNode(props)
|
447
446
|
: new BlendNode(this.ctx, props);
|
448
447
|
}
|
449
448
|
|
450
449
|
BackdropFilter(props: ChildrenProps) {
|
451
|
-
return
|
450
|
+
return this.native
|
452
451
|
? global.SkiaDomApi.BackdropFilterNode(props)
|
453
452
|
: new BackdropFilterNode(this.ctx, props);
|
454
453
|
}
|
455
454
|
|
456
455
|
Box(props: BoxProps) {
|
457
|
-
return
|
456
|
+
return this.native
|
458
457
|
? global.SkiaDomApi.BoxNode(props)
|
459
458
|
: new BoxNode(this.ctx, props);
|
460
459
|
}
|
461
460
|
|
462
461
|
BoxShadow(props: BoxShadowProps) {
|
463
|
-
return
|
462
|
+
return this.native
|
464
463
|
? global.SkiaDomApi.BoxShadowNode(props)
|
465
464
|
: new BoxShadowNode(this.ctx, props);
|
466
465
|
}
|
467
466
|
|
468
467
|
// Paragraph
|
469
468
|
Paragraph(props: ParagraphProps) {
|
470
|
-
return
|
469
|
+
return this.native
|
471
470
|
? global.SkiaDomApi.ParagraphNode(props)
|
472
471
|
: new ParagraphNode(this.ctx, props);
|
473
472
|
}
|
@@ -8,6 +8,7 @@ import { useCallback, useMemo } from "react";
|
|
8
8
|
import type { SkPath, SkPoint } from "../../skia/types";
|
9
9
|
import { interpolatePaths, interpolateVector } from "../../animation";
|
10
10
|
import { Skia } from "../../skia";
|
11
|
+
import { Platform } from "../../Platform";
|
11
12
|
|
12
13
|
import {
|
13
14
|
useAnimatedReaction,
|
@@ -18,7 +19,7 @@ import {
|
|
18
19
|
|
19
20
|
export const notifyChange = (value: SharedValue<unknown>) => {
|
20
21
|
"worklet";
|
21
|
-
if (_WORKLET) {
|
22
|
+
if (_WORKLET || Platform.OS === "web") {
|
22
23
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
23
24
|
(value as any)._value = value.value;
|
24
25
|
}
|
@@ -86,8 +87,20 @@ export const usePathInterpolation = (
|
|
86
87
|
input: number[],
|
87
88
|
outputRange: SkPath[],
|
88
89
|
options?: ExtrapolationType
|
89
|
-
) =>
|
90
|
-
|
90
|
+
) => {
|
91
|
+
// Check if all paths in outputRange are interpolable
|
92
|
+
const allPathsInterpolable = outputRange
|
93
|
+
.slice(1)
|
94
|
+
.every((path) => outputRange[0].isInterpolatable(path));
|
95
|
+
if (!allPathsInterpolable) {
|
96
|
+
// Handle the case where not all paths are interpolable
|
97
|
+
// For example, throw an error or return early
|
98
|
+
throw new Error(
|
99
|
+
`Not all paths in the output range are interpolable.
|
100
|
+
See: https://shopify.github.io/react-native-skia/docs/animations/hooks#usepathinterpolation`
|
101
|
+
);
|
102
|
+
}
|
103
|
+
return useInterpolator(
|
91
104
|
() => Skia.Path.Make(),
|
92
105
|
value,
|
93
106
|
interpolatePaths,
|
@@ -95,6 +108,7 @@ export const usePathInterpolation = (
|
|
95
108
|
outputRange,
|
96
109
|
options
|
97
110
|
);
|
111
|
+
};
|
98
112
|
|
99
113
|
export const useVectorInterpolation = (
|
100
114
|
value: SharedValue<number>,
|
@@ -63,6 +63,7 @@ export const stopMapper: (mapperID: number) => void =
|
|
63
63
|
Reanimated2?.stopMapper || throwOnMissingReanimated;
|
64
64
|
|
65
65
|
export const runOnJS = Reanimated2?.runOnJS || throwOnMissingReanimated;
|
66
|
+
export const runOnUI = Reanimated2?.runOnUI || throwOnMissingReanimated;
|
66
67
|
|
67
68
|
export const useAnimatedReaction: <T>(
|
68
69
|
prepare: () => T,
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import { useEffect, useMemo } from "react";
|
2
|
+
import type { ReactElement } from "react";
|
3
|
+
import type { SharedValue } from "react-native-reanimated";
|
4
|
+
|
5
|
+
import { Skia } from "../../skia";
|
6
|
+
import type { SkImage, SkPicture, SkSize } from "../../skia/types";
|
7
|
+
import { drawAsPicture } from "../../renderer/Offscreen";
|
8
|
+
|
9
|
+
import { runOnUI, useSharedValue } from "./moduleWrapper";
|
10
|
+
|
11
|
+
// TODO: We're not sure yet why PixelRatio is not needed here.
|
12
|
+
const pd = 1; //Platform.PixelRatio;
|
13
|
+
|
14
|
+
const createTexture = (
|
15
|
+
texture: SharedValue<SkImage | null>,
|
16
|
+
picture: SkPicture,
|
17
|
+
size: SkSize
|
18
|
+
) => {
|
19
|
+
"worklet";
|
20
|
+
const surface = Skia.Surface.MakeOffscreen(
|
21
|
+
size.width * pd,
|
22
|
+
size.height * pd
|
23
|
+
)!;
|
24
|
+
const canvas = surface.getCanvas();
|
25
|
+
// see comment above
|
26
|
+
//canvas.save();
|
27
|
+
//canvas.scale(pd, pd);
|
28
|
+
canvas.drawPicture(picture);
|
29
|
+
//canvas.restore();
|
30
|
+
surface.flush();
|
31
|
+
texture.value = surface.makeImageSnapshot();
|
32
|
+
};
|
33
|
+
|
34
|
+
export const useTextureValue = (element: ReactElement, size: SkSize) => {
|
35
|
+
const picture = useMemo(() => {
|
36
|
+
return drawAsPicture(element);
|
37
|
+
}, [element]);
|
38
|
+
return useTextureValueFromPicture(picture, size);
|
39
|
+
};
|
40
|
+
|
41
|
+
export const useTextureValueFromPicture = (
|
42
|
+
picture: SkPicture,
|
43
|
+
size: SkSize
|
44
|
+
) => {
|
45
|
+
const texture = useSharedValue<SkImage | null>(null);
|
46
|
+
useEffect(() => {
|
47
|
+
runOnUI(createTexture)(texture, picture, size);
|
48
|
+
}, [texture, picture, size]);
|
49
|
+
return texture;
|
50
|
+
};
|
package/src/headless/index.ts
CHANGED
@@ -25,7 +25,7 @@ export const makeOffscreenSurface = (width: number, height: number) => {
|
|
25
25
|
};
|
26
26
|
|
27
27
|
export const drawOffscreen = (surface: SkSurface, element: ReactNode) => {
|
28
|
-
const root = new SkiaRoot(Skia);
|
28
|
+
const root = new SkiaRoot(Skia, false);
|
29
29
|
root.render(element);
|
30
30
|
const canvas = surface.getCanvas();
|
31
31
|
const ctx = new JsiDrawingContext(Skia, canvas);
|
package/src/mock/index.ts
CHANGED
@@ -31,9 +31,12 @@ export const Mock = (CanvasKit: CanvasKit) => {
|
|
31
31
|
// Reanimated hooks
|
32
32
|
useClock: NoopSharedValue,
|
33
33
|
usePathInterpolation: NoopSharedValue,
|
34
|
+
useTextureValue: NoopSharedValue,
|
35
|
+
useTextureValueFromPicture: NoopSharedValue,
|
34
36
|
useRawData: Noop,
|
35
37
|
useData: Noop,
|
36
38
|
useFont: () => Skia.Font(undefined, 0),
|
39
|
+
useFonts: Noop,
|
37
40
|
useTypeface: () => null,
|
38
41
|
useImage: () => null,
|
39
42
|
useSVG: () => null,
|
package/src/renderer/Canvas.tsx
CHANGED
@@ -15,9 +15,9 @@ import type {
|
|
15
15
|
import type { LayoutChangeEvent } from "react-native";
|
16
16
|
|
17
17
|
import { SkiaDomView } from "../views";
|
18
|
-
import { SkiaDomView as SkiaDomViewWeb } from "../views/SkiaDomView.web";
|
19
18
|
import { Skia } from "../skia/Skia";
|
20
19
|
import type { TouchHandler, SkiaBaseViewProps } from "../views";
|
20
|
+
import { SkiaJSDomView } from "../views/SkiaJSDomView";
|
21
21
|
|
22
22
|
import { SkiaRoot } from "./Reconciler";
|
23
23
|
import { NATIVE_DOM } from "./HostComponents";
|
@@ -75,7 +75,7 @@ export const Canvas = forwardRef<SkiaDomView, CanvasProps>(
|
|
75
75
|
}, [innerRef]);
|
76
76
|
|
77
77
|
const root = useMemo(
|
78
|
-
() => new SkiaRoot(Skia, redraw, getNativeId),
|
78
|
+
() => new SkiaRoot(Skia, NATIVE_DOM, redraw, getNativeId),
|
79
79
|
[redraw, getNativeId]
|
80
80
|
);
|
81
81
|
|
@@ -105,7 +105,8 @@ export const Canvas = forwardRef<SkiaDomView, CanvasProps>(
|
|
105
105
|
);
|
106
106
|
} else {
|
107
107
|
return (
|
108
|
-
<
|
108
|
+
<SkiaJSDomView
|
109
|
+
Skia={Skia}
|
109
110
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
110
111
|
ref={ref as any}
|
111
112
|
style={style}
|
@@ -13,9 +13,10 @@ export class Container {
|
|
13
13
|
constructor(
|
14
14
|
Skia: Skia,
|
15
15
|
public redraw: () => void = () => {},
|
16
|
-
public getNativeId: () => number = () => 0
|
16
|
+
public getNativeId: () => number = () => 0,
|
17
|
+
native: boolean
|
17
18
|
) {
|
18
|
-
this.Sk = new JsiSkDOM({ Skia });
|
19
|
+
this.Sk = new JsiSkDOM({ Skia }, native);
|
19
20
|
this._root = this.Sk.Group();
|
20
21
|
}
|
21
22
|
|
@@ -10,15 +10,24 @@ export const drawAsImage = (
|
|
10
10
|
width: number,
|
11
11
|
height: number
|
12
12
|
) => {
|
13
|
+
const picture = drawAsPicture(element);
|
13
14
|
const surface = Skia.Surface.MakeOffscreen(width, height);
|
14
15
|
if (!surface) {
|
15
16
|
throw new Error("Could not create offscreen surface");
|
16
17
|
}
|
17
18
|
const canvas = surface.getCanvas();
|
18
|
-
|
19
|
+
canvas.drawPicture(picture);
|
20
|
+
surface.flush();
|
21
|
+
return surface.makeImageSnapshot();
|
22
|
+
};
|
23
|
+
|
24
|
+
export const drawAsPicture = (element: ReactElement) => {
|
25
|
+
const recorder = Skia.PictureRecorder();
|
26
|
+
const canvas = recorder.beginRecording();
|
27
|
+
const root = new SkiaRoot(Skia, false);
|
19
28
|
root.render(element);
|
20
29
|
const ctx = new JsiDrawingContext(Skia, canvas);
|
21
30
|
root.dom.render(ctx);
|
22
|
-
|
23
|
-
return
|
31
|
+
const picture = recorder.finishRecordingAsPicture();
|
32
|
+
return picture;
|
24
33
|
};
|
@@ -21,10 +21,11 @@ export class SkiaRoot {
|
|
21
21
|
|
22
22
|
constructor(
|
23
23
|
Skia: Skia,
|
24
|
+
native = false,
|
24
25
|
redraw: () => void = () => {},
|
25
26
|
getNativeId: () => number = () => 0
|
26
27
|
) {
|
27
|
-
this.container = new Container(Skia, redraw, getNativeId);
|
28
|
+
this.container = new Container(Skia, redraw, getNativeId, native);
|
28
29
|
this.root = skiaReconciler.createContainer(
|
29
30
|
this.container,
|
30
31
|
0,
|
@@ -45,7 +46,9 @@ export class SkiaRoot {
|
|
45
46
|
}
|
46
47
|
|
47
48
|
unmount() {
|
48
|
-
skiaReconciler.updateContainer(null, this.root, null, () => {
|
49
|
+
skiaReconciler.updateContainer(null, this.root, null, () => {
|
50
|
+
hostDebug("unmountContainer");
|
51
|
+
});
|
49
52
|
}
|
50
53
|
|
51
54
|
get dom() {
|
@@ -356,13 +356,13 @@ export const convertToColumnMajor = (rowMajorMatrix: Matrix4) => {
|
|
356
356
|
colMajorMatrix[col * size + row] = rowMajorMatrix[row * size + col];
|
357
357
|
}
|
358
358
|
}
|
359
|
-
return colMajorMatrix;
|
359
|
+
return colMajorMatrix as unknown as Matrix4;
|
360
360
|
};
|
361
361
|
|
362
362
|
/**
|
363
363
|
* @worklet
|
364
364
|
*/
|
365
|
-
export const convertToAffineMatrix = (m4:
|
365
|
+
export const convertToAffineMatrix = (m4: Matrix4) => {
|
366
366
|
"worklet";
|
367
367
|
// Extracting the relevant components from the 4x4 matrix
|
368
368
|
const a = m4[0]; // Scale X
|
@@ -7,7 +7,12 @@ export const isShader = (obj: SkJSIInstance<string> | null): obj is SkShader =>
|
|
7
7
|
|
8
8
|
export type SkShader = SkJSIInstance<"Shader">;
|
9
9
|
|
10
|
-
export type Uniform =
|
10
|
+
export type Uniform =
|
11
|
+
| number
|
12
|
+
| Vector
|
13
|
+
| Float32Array
|
14
|
+
| readonly Uniform[]
|
15
|
+
| Uniform[];
|
11
16
|
|
12
17
|
export interface Uniforms {
|
13
18
|
[name: string]: Uniform;
|