@shopify/react-native-skia 0.1.196 → 0.1.199
Sign up to get free protection for your applications and to get access to all the features.
- package/android/CMakeLists.txt +32 -31
- package/android/cpp/rnskia-android/SkiaOpenGLRenderer.cpp +4 -2
- package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +3 -0
- package/cpp/api/JsiSkImage.h +1 -1
- package/cpp/api/JsiSkShaderFactory.h +4 -4
- package/cpp/api/JsiSkSurface.h +0 -1
- package/cpp/api/JsiSkSurfaceFactory.h +2 -1
- package/cpp/rnskia/RNSkView.h +20 -40
- package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +2 -2
- package/cpp/rnskia/values/RNSkReadonlyValue.h +6 -7
- package/cpp/skia/include/android/SkCanvasAndroid.h +20 -0
- package/cpp/skia/include/android/SkHeifDecoder.h +43 -0
- package/cpp/skia/include/android/SkSurfaceAndroid.h +50 -0
- package/cpp/skia/include/codec/SkAvifDecoder.h +43 -0
- package/cpp/skia/include/codec/SkBmpDecoder.h +43 -0
- package/cpp/skia/include/codec/SkCodec.h +25 -1
- package/cpp/skia/include/codec/SkGifDecoder.h +43 -0
- package/cpp/skia/include/codec/SkIcoDecoder.h +43 -0
- package/cpp/skia/include/codec/SkJpegDecoder.h +43 -0
- package/cpp/skia/include/codec/SkJpegxlDecoder.h +43 -0
- package/cpp/skia/include/codec/SkPngDecoder.h +43 -0
- package/cpp/skia/include/codec/SkRawDecoder.h +49 -0
- package/cpp/skia/include/codec/SkWbmpDecoder.h +43 -0
- package/cpp/skia/include/codec/SkWebpDecoder.h +43 -0
- package/cpp/skia/include/core/SkBBHFactory.h +5 -1
- package/cpp/skia/include/core/SkBlender.h +0 -2
- package/cpp/skia/include/core/SkCanvas.h +4 -23
- package/cpp/skia/include/core/SkColorFilter.h +14 -1
- package/cpp/skia/include/core/SkColorTable.h +59 -0
- package/cpp/skia/include/core/SkContourMeasure.h +3 -0
- package/cpp/skia/include/core/SkDeferredDisplayList.h +8 -104
- package/cpp/skia/include/core/SkDeferredDisplayListRecorder.h +8 -91
- package/cpp/skia/include/core/SkDrawable.h +5 -2
- package/cpp/skia/include/core/SkGraphics.h +7 -19
- package/cpp/skia/include/core/SkImage.h +157 -249
- package/cpp/skia/include/core/SkImageGenerator.h +0 -31
- package/cpp/skia/include/core/SkMilestone.h +1 -1
- package/cpp/skia/include/core/SkPathMeasure.h +3 -3
- package/cpp/skia/include/core/SkPictureRecorder.h +1 -1
- package/cpp/skia/include/core/SkPoint.h +5 -563
- package/cpp/skia/include/core/SkPoint3.h +1 -0
- package/cpp/skia/include/core/SkPromiseImageTexture.h +4 -30
- package/cpp/skia/include/core/SkRect.h +8 -8
- package/cpp/skia/include/core/SkSamplingOptions.h +4 -2
- package/cpp/skia/include/core/SkScalar.h +1 -1
- package/cpp/skia/include/core/SkSerialProcs.h +5 -1
- package/cpp/skia/include/core/SkShader.h +14 -21
- package/cpp/skia/include/core/SkString.h +2 -0
- package/cpp/skia/include/core/SkSurface.h +169 -701
- package/cpp/skia/include/core/SkSurfaceCharacterization.h +8 -256
- package/cpp/skia/include/core/SkTiledImageUtils.h +97 -0
- package/cpp/skia/include/core/SkTypes.h +4 -2
- package/cpp/skia/include/core/SkYUVAPixmaps.h +0 -5
- package/cpp/skia/include/effects/SkGradientShader.h +10 -1
- package/cpp/skia/include/effects/SkImageFilters.h +62 -37
- package/cpp/skia/include/effects/SkPerlinNoiseShader.h +28 -29
- package/cpp/skia/include/effects/SkRuntimeEffect.h +17 -12
- package/cpp/skia/include/gpu/GrBackendSurface.h +12 -39
- package/cpp/skia/include/gpu/GrBackendSurfaceMutableState.h +6 -0
- package/cpp/skia/include/gpu/GrContextThreadSafeProxy.h +3 -3
- package/cpp/skia/include/gpu/GrDirectContext.h +103 -3
- package/cpp/skia/include/gpu/GrRecordingContext.h +10 -19
- package/cpp/skia/include/gpu/MutableTextureState.h +4 -0
- package/cpp/skia/include/gpu/ganesh/GrExternalTextureGenerator.h +54 -0
- package/cpp/skia/include/gpu/ganesh/SkImageGanesh.h +20 -76
- package/cpp/skia/include/gpu/ganesh/SkSurfaceGanesh.h +217 -0
- package/cpp/skia/include/gpu/ganesh/mtl/SkSurfaceMetal.h +73 -0
- package/cpp/skia/include/gpu/gl/GrGLTypes.h +13 -2
- package/cpp/skia/include/gpu/graphite/BackendSemaphore.h +78 -0
- package/cpp/skia/include/gpu/graphite/BackendTexture.h +1 -0
- package/cpp/skia/include/gpu/graphite/Image.h +277 -0
- package/cpp/skia/include/gpu/graphite/ImageProvider.h +1 -1
- package/cpp/skia/include/gpu/graphite/Recording.h +1 -4
- package/cpp/skia/include/gpu/graphite/Surface.h +81 -0
- package/cpp/skia/include/gpu/graphite/TextureInfo.h +5 -7
- package/cpp/skia/include/gpu/graphite/YUVABackendTextures.h +2 -2
- package/cpp/skia/include/gpu/mock/GrMockTypes.h +23 -8
- package/cpp/skia/include/ports/SkTypeface_fontations.h +21 -0
- package/cpp/skia/include/private/SkGainmapInfo.h +2 -0
- package/cpp/skia/include/private/SkGainmapShader.h +1 -0
- package/cpp/skia/include/private/SkJpegMetadataDecoder.h +19 -1
- package/cpp/skia/include/private/SkPathRef.h +13 -15
- package/cpp/skia/include/private/SkXmp.h +53 -0
- package/cpp/skia/include/private/base/SkFeatures.h +0 -4
- package/cpp/skia/include/private/base/SkFloatingPoint.h +11 -5
- package/cpp/skia/include/private/base/SkPoint_impl.h +569 -0
- package/cpp/skia/include/private/base/SkSpan_impl.h +3 -7
- package/cpp/skia/include/private/base/SkTArray.h +11 -11
- package/cpp/skia/include/private/chromium/GrDeferredDisplayList.h +120 -0
- package/cpp/skia/include/private/chromium/GrDeferredDisplayListRecorder.h +98 -0
- package/cpp/skia/include/private/chromium/GrPromiseImageTexture.h +43 -0
- package/cpp/skia/include/private/chromium/GrSurfaceCharacterization.h +215 -0
- package/cpp/skia/include/private/chromium/GrVkSecondaryCBDrawContext.h +6 -6
- package/cpp/skia/include/private/chromium/SkImageChromium.h +104 -0
- package/cpp/skia/include/private/chromium/Slug.h +7 -3
- package/cpp/skia/include/private/gpu/ganesh/GrContext_Base.h +7 -3
- package/cpp/skia/include/private/gpu/ganesh/GrGLTypesPriv.h +2 -0
- package/cpp/skia/include/private/gpu/ganesh/GrImageContext.h +3 -2
- package/cpp/skia/include/private/gpu/ganesh/GrMtlTypesPriv.h +10 -2
- package/cpp/skia/include/{gpu → private/gpu}/ganesh/GrTextureGenerator.h +2 -13
- package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +1 -1
- package/cpp/skia/include/private/gpu/graphite/DawnTypesPriv.h +7 -0
- package/cpp/skia/include/private/gpu/graphite/MtlGraphiteTypesPriv.h +19 -6
- package/cpp/skia/include/private/gpu/graphite/VulkanGraphiteTypesPriv.h +13 -0
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan.h +0 -1
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_android.h +14 -1
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_core.h +999 -79
- package/cpp/skia/modules/skcms/src/Transform_inl.h +36 -236
- package/cpp/skia/modules/skparagraph/include/Paragraph.h +2 -0
- package/cpp/skia/modules/skparagraph/include/ParagraphBuilder.h +16 -0
- package/cpp/skia/modules/skparagraph/include/TextStyle.h +6 -2
- package/cpp/skia/modules/skresources/include/SkResources.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGCircle.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGClipPath.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGContainer.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGDOM.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGDefs.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGEllipse.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFe.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeBlend.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeColorMatrix.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeComposite.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeDisplacementMap.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeFlood.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeGaussianBlur.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeImage.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeLightSource.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeLighting.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeOffset.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeTurbulence.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFilter.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGG.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGGradient.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGHiddenContainer.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGImage.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGLine.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGLinearGradient.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGMask.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGNode.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGPath.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGPattern.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGPoly.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGRadialGradient.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGRect.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGRenderContext.h +3 -3
- package/cpp/skia/modules/svg/include/SkSVGSVG.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGShape.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGStop.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGText.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGTransformableNode.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGTypes.h +21 -21
- package/cpp/skia/modules/svg/include/SkSVGUse.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGValue.h +2 -2
- package/cpp/skia/{include/private → src/core}/SkChecksum.h +32 -17
- package/cpp/skia/src/core/SkTHash.h +1 -1
- package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +3 -1
- package/ios/RNSkia-iOS/SkiaMetalRenderer.mm +3 -1
- package/lib/commonjs/renderer/Canvas.js +24 -13
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/skia/core/Data.d.ts +2 -2
- package/lib/commonjs/skia/core/Data.js.map +1 -1
- package/lib/commonjs/skia/core/RRect.js +5 -1
- package/lib/commonjs/skia/core/RRect.js.map +1 -1
- package/lib/commonjs/skia/core/Rect.js +32 -6
- package/lib/commonjs/skia/core/Rect.js.map +1 -1
- package/lib/commonjs/skia/types/Color.js.map +1 -1
- package/lib/commonjs/skia/types/JsiInstance.d.ts +2 -4
- package/lib/commonjs/skia/types/JsiInstance.js.map +1 -1
- package/lib/module/renderer/Canvas.js +25 -14
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/skia/core/Data.d.ts +2 -2
- package/lib/module/skia/core/Data.js.map +1 -1
- package/lib/module/skia/core/RRect.js +5 -1
- package/lib/module/skia/core/RRect.js.map +1 -1
- package/lib/module/skia/core/Rect.js +32 -6
- package/lib/module/skia/core/Rect.js.map +1 -1
- package/lib/module/skia/types/Color.js.map +1 -1
- package/lib/module/skia/types/JsiInstance.d.ts +2 -4
- package/lib/module/skia/types/JsiInstance.js.map +1 -1
- package/lib/typescript/src/skia/core/Data.d.ts +2 -2
- package/lib/typescript/src/skia/types/JsiInstance.d.ts +2 -4
- package/libs/android/arm64-v8a/libskia.a +0 -0
- package/libs/android/arm64-v8a/libskottie.a +0 -0
- package/libs/android/arm64-v8a/libsksg.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/libsksg.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/libsksg.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/libsksg.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/libsksg.xcframework/Info.plist +5 -5
- 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/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 -4
- package/src/renderer/Canvas.tsx +25 -19
- package/src/skia/core/Data.ts +3 -3
- package/src/skia/core/RRect.tsx +4 -2
- package/src/skia/core/Rect.ts +29 -12
- package/src/skia/types/Color.ts +1 -1
- package/src/skia/types/JsiInstance.ts +2 -5
- package/cpp/skia/include/effects/SkTableColorFilter.h +0 -29
- package/cpp/skia/include/private/SkOpts_spi.h +0 -23
- package/cpp/skia/include/private/SkSpinlock.h +0 -57
- package/cpp/skia/include/private/chromium/GrSlug.h +0 -16
- package/scripts/install-npm.js +0 -33
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -6,32 +6,32 @@
|
|
6
6
|
<array>
|
7
7
|
<dict>
|
8
8
|
<key>LibraryIdentifier</key>
|
9
|
-
<string>ios-
|
9
|
+
<string>ios-arm64_arm64e</string>
|
10
10
|
<key>LibraryPath</key>
|
11
11
|
<string>libsksg.a</string>
|
12
12
|
<key>SupportedArchitectures</key>
|
13
13
|
<array>
|
14
14
|
<string>arm64</string>
|
15
15
|
<string>arm64e</string>
|
16
|
-
<string>x86_64</string>
|
17
16
|
</array>
|
18
17
|
<key>SupportedPlatform</key>
|
19
18
|
<string>ios</string>
|
20
|
-
<key>SupportedPlatformVariant</key>
|
21
|
-
<string>simulator</string>
|
22
19
|
</dict>
|
23
20
|
<dict>
|
24
21
|
<key>LibraryIdentifier</key>
|
25
|
-
<string>ios-
|
22
|
+
<string>ios-arm64_arm64e_x86_64-simulator</string>
|
26
23
|
<key>LibraryPath</key>
|
27
24
|
<string>libsksg.a</string>
|
28
25
|
<key>SupportedArchitectures</key>
|
29
26
|
<array>
|
30
27
|
<string>arm64</string>
|
31
28
|
<string>arm64e</string>
|
29
|
+
<string>x86_64</string>
|
32
30
|
</array>
|
33
31
|
<key>SupportedPlatform</key>
|
34
32
|
<string>ios</string>
|
33
|
+
<key>SupportedPlatformVariant</key>
|
34
|
+
<string>simulator</string>
|
35
35
|
</dict>
|
36
36
|
</array>
|
37
37
|
<key>CFBundlePackageType</key>
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -6,32 +6,32 @@
|
|
6
6
|
<array>
|
7
7
|
<dict>
|
8
8
|
<key>LibraryIdentifier</key>
|
9
|
-
<string>ios-
|
9
|
+
<string>ios-arm64_arm64e</string>
|
10
10
|
<key>LibraryPath</key>
|
11
11
|
<string>libsvg.a</string>
|
12
12
|
<key>SupportedArchitectures</key>
|
13
13
|
<array>
|
14
14
|
<string>arm64</string>
|
15
15
|
<string>arm64e</string>
|
16
|
-
<string>x86_64</string>
|
17
16
|
</array>
|
18
17
|
<key>SupportedPlatform</key>
|
19
18
|
<string>ios</string>
|
20
|
-
<key>SupportedPlatformVariant</key>
|
21
|
-
<string>simulator</string>
|
22
19
|
</dict>
|
23
20
|
<dict>
|
24
21
|
<key>LibraryIdentifier</key>
|
25
|
-
<string>ios-
|
22
|
+
<string>ios-arm64_arm64e_x86_64-simulator</string>
|
26
23
|
<key>LibraryPath</key>
|
27
24
|
<string>libsvg.a</string>
|
28
25
|
<key>SupportedArchitectures</key>
|
29
26
|
<array>
|
30
27
|
<string>arm64</string>
|
31
28
|
<string>arm64e</string>
|
29
|
+
<string>x86_64</string>
|
32
30
|
</array>
|
33
31
|
<key>SupportedPlatform</key>
|
34
32
|
<string>ios</string>
|
33
|
+
<key>SupportedPlatformVariant</key>
|
34
|
+
<string>simulator</string>
|
35
35
|
</dict>
|
36
36
|
</array>
|
37
37
|
<key>CFBundlePackageType</key>
|
Binary file
|
Binary file
|
package/package.json
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
"setup-skia-web": "./scripts/setup-canvaskit.js"
|
8
8
|
},
|
9
9
|
"title": "React Native Skia",
|
10
|
-
"version": "0.1.
|
10
|
+
"version": "0.1.199",
|
11
11
|
"description": "High-performance React Native Graphics using Skia",
|
12
12
|
"main": "lib/module/index.js",
|
13
13
|
"files": [
|
@@ -34,7 +34,6 @@
|
|
34
34
|
"libs/ios/libskottie.xcframework",
|
35
35
|
"libs/ios/libsksg.xcframework",
|
36
36
|
"react-native-skia.podspec",
|
37
|
-
"scripts/install-npm.js",
|
38
37
|
"scripts/setup-canvaskit.js",
|
39
38
|
"dist/**"
|
40
39
|
],
|
@@ -43,8 +42,8 @@
|
|
43
42
|
"lint": "eslint . --ext .ts,.tsx --max-warnings 0 --cache",
|
44
43
|
"test": "jest",
|
45
44
|
"e2e": "E2E=true yarn test -i e2e",
|
46
|
-
"
|
47
|
-
"
|
45
|
+
"build": "bob build && merge-dirs lib/typescript/src lib/commonjs && merge-dirs lib/typescript/src lib/module",
|
46
|
+
"postinstall": "node scripts/install-npm.js"
|
48
47
|
},
|
49
48
|
"repository": {
|
50
49
|
"type": "git",
|
package/src/renderer/Canvas.tsx
CHANGED
@@ -4,6 +4,7 @@ import React, {
|
|
4
4
|
useMemo,
|
5
5
|
forwardRef,
|
6
6
|
useRef,
|
7
|
+
useLayoutEffect,
|
7
8
|
} from "react";
|
8
9
|
import type {
|
9
10
|
RefObject,
|
@@ -31,29 +32,34 @@ export interface CanvasProps extends SkiaBaseViewProps {
|
|
31
32
|
onTouch?: TouchHandler;
|
32
33
|
}
|
33
34
|
|
35
|
+
const useOnSizeEvent = (resultValue: SkiaBaseViewProps["onSize"]) => {
|
36
|
+
const onSize = useValue({
|
37
|
+
width: 0,
|
38
|
+
height: 0,
|
39
|
+
});
|
40
|
+
|
41
|
+
useLayoutEffect(() => {
|
42
|
+
if (!resultValue) {
|
43
|
+
return;
|
44
|
+
}
|
45
|
+
return onSize.addListener((newValue) => {
|
46
|
+
if (isValue(resultValue)) {
|
47
|
+
resultValue.current = newValue;
|
48
|
+
} else {
|
49
|
+
resultValue.value = newValue;
|
50
|
+
}
|
51
|
+
});
|
52
|
+
}, [resultValue, onSize]);
|
53
|
+
|
54
|
+
return onSize;
|
55
|
+
};
|
56
|
+
|
34
57
|
export const Canvas = forwardRef<SkiaDomView, CanvasProps>(
|
35
58
|
(
|
36
|
-
{
|
37
|
-
children,
|
38
|
-
style,
|
39
|
-
debug,
|
40
|
-
mode,
|
41
|
-
onTouch,
|
42
|
-
onSize: onSizeReanimatedOrSkia,
|
43
|
-
...props
|
44
|
-
},
|
59
|
+
{ children, style, debug, mode, onTouch, onSize: _onSize, ...props },
|
45
60
|
forwardedRef
|
46
61
|
) => {
|
47
|
-
const
|
48
|
-
const onSize = isValue(onSizeReanimatedOrSkia)
|
49
|
-
? onSizeReanimatedOrSkia
|
50
|
-
: size;
|
51
|
-
useEffect(() => {
|
52
|
-
if (!isValue(onSizeReanimatedOrSkia) && onSizeReanimatedOrSkia) {
|
53
|
-
return size.addListener((v) => (onSizeReanimatedOrSkia.value = v));
|
54
|
-
}
|
55
|
-
return undefined;
|
56
|
-
}, [onSizeReanimatedOrSkia, size]);
|
62
|
+
const onSize = useOnSizeEvent(_onSize);
|
57
63
|
const innerRef = useCanvasRef();
|
58
64
|
const ref = useCombinedRefs(forwardedRef, innerRef);
|
59
65
|
const redraw = useCallback(() => {
|
package/src/skia/core/Data.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { useEffect, useRef, useState } from "react";
|
2
2
|
|
3
3
|
import { Skia } from "../Skia";
|
4
|
-
import type { SkData, DataSourceParam,
|
4
|
+
import type { SkData, DataSourceParam, SkJSIInstance } from "../types";
|
5
5
|
import { Platform } from "../../Platform";
|
6
6
|
|
7
7
|
const factoryWrapper = <T>(
|
@@ -37,7 +37,7 @@ const loadData = <T>(
|
|
37
37
|
);
|
38
38
|
}
|
39
39
|
};
|
40
|
-
const useLoading = <T extends
|
40
|
+
const useLoading = <T extends SkJSIInstance<string>>(
|
41
41
|
source: DataSourceParam,
|
42
42
|
loader: () => Promise<T | null>
|
43
43
|
) => {
|
@@ -61,7 +61,7 @@ const useLoading = <T extends BaseSkJSIInstance>(
|
|
61
61
|
return data;
|
62
62
|
};
|
63
63
|
|
64
|
-
export const useRawData = <T extends
|
64
|
+
export const useRawData = <T extends SkJSIInstance<string>>(
|
65
65
|
source: DataSourceParam,
|
66
66
|
factory: (data: SkData) => T | null,
|
67
67
|
onError?: (err: Error) => void
|
package/src/skia/core/RRect.tsx
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
import { Skia } from "../Skia";
|
2
2
|
import type { SkRect } from "../types";
|
3
3
|
|
4
|
-
export const rrect = (r: SkRect, rx: number, ry: number) =>
|
5
|
-
|
4
|
+
export const rrect = (r: SkRect, rx: number, ry: number) => {
|
5
|
+
"worklet";
|
6
|
+
return Skia.RRectXY(r, rx, ry);
|
7
|
+
};
|
package/src/skia/core/Rect.ts
CHANGED
@@ -4,10 +4,13 @@ import { isRRect } from "../types";
|
|
4
4
|
|
5
5
|
import { vec } from "./Vector";
|
6
6
|
|
7
|
-
export const rect = (x: number, y: number, width: number, height: number) =>
|
8
|
-
|
7
|
+
export const rect = (x: number, y: number, width: number, height: number) => {
|
8
|
+
"worklet";
|
9
|
+
return Skia.XYWHRect(x, y, width, height);
|
10
|
+
};
|
9
11
|
|
10
12
|
export const bounds = (rects: SkRect[]) => {
|
13
|
+
"worklet";
|
11
14
|
const x = Math.min(...rects.map((r) => r.x));
|
12
15
|
const y = Math.min(...rects.map((r) => r.y));
|
13
16
|
const width = Math.max(...rects.map((r) => r.x + r.width));
|
@@ -15,19 +18,33 @@ export const bounds = (rects: SkRect[]) => {
|
|
15
18
|
return rect(x, y, width - x, height - y);
|
16
19
|
};
|
17
20
|
|
18
|
-
export const topLeft = (r: SkRect | SkRRect) =>
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
export const topLeft = (r: SkRect | SkRRect) => {
|
22
|
+
"worklet";
|
23
|
+
return isRRect(r) ? vec(r.rect.x, r.rect.y) : vec(r.x, r.y);
|
24
|
+
};
|
25
|
+
|
26
|
+
export const topRight = (r: SkRect | SkRRect) => {
|
27
|
+
"worklet";
|
28
|
+
return isRRect(r)
|
29
|
+
? vec(r.rect.x + r.rect.width, r.rect.y)
|
30
|
+
: vec(r.x + r.width, r.y);
|
31
|
+
};
|
32
|
+
|
33
|
+
export const bottomLeft = (r: SkRect | SkRRect) => {
|
34
|
+
"worklet";
|
35
|
+
return isRRect(r)
|
24
36
|
? vec(r.rect.x, r.rect.y + r.rect.height)
|
25
37
|
: vec(r.x, r.y + r.height);
|
26
|
-
|
27
|
-
|
38
|
+
};
|
39
|
+
export const bottomRight = (r: SkRect | SkRRect) => {
|
40
|
+
"worklet";
|
41
|
+
return isRRect(r)
|
28
42
|
? vec(r.rect.x + r.rect.width, r.rect.y + r.rect.height)
|
29
43
|
: vec(r.x + r.width, r.y + r.height);
|
30
|
-
|
31
|
-
|
44
|
+
};
|
45
|
+
export const center = (r: SkRect | SkRRect) => {
|
46
|
+
"worklet";
|
47
|
+
return isRRect(r)
|
32
48
|
? vec(r.rect.x + r.rect.width / 2, r.rect.y + r.rect.height / 2)
|
33
49
|
: vec(r.x + r.width / 2, r.y + r.height / 2);
|
50
|
+
};
|
package/src/skia/types/Color.ts
CHANGED
@@ -1,29 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright 2015 Google Inc.
|
3
|
-
*
|
4
|
-
* Use of this source code is governed by a BSD-style license that can be
|
5
|
-
* found in the LICENSE file.
|
6
|
-
*/
|
7
|
-
|
8
|
-
#ifndef SkTableColorFilter_DEFINED
|
9
|
-
#define SkTableColorFilter_DEFINED
|
10
|
-
|
11
|
-
#include "include/core/SkColorFilter.h"
|
12
|
-
|
13
|
-
// (DEPRECATED) These factory functions are deprecated. Please use the ones in
|
14
|
-
// SkColorFilters (i.e., Table and TableARGB).
|
15
|
-
class SK_API SkTableColorFilter {
|
16
|
-
public:
|
17
|
-
static sk_sp<SkColorFilter> Make(const uint8_t table[256]) {
|
18
|
-
return SkColorFilters::Table(table);
|
19
|
-
}
|
20
|
-
|
21
|
-
static sk_sp<SkColorFilter> MakeARGB(const uint8_t tableA[256],
|
22
|
-
const uint8_t tableR[256],
|
23
|
-
const uint8_t tableG[256],
|
24
|
-
const uint8_t tableB[256]) {
|
25
|
-
return SkColorFilters::TableARGB(tableA, tableR, tableG, tableB);
|
26
|
-
}
|
27
|
-
};
|
28
|
-
|
29
|
-
#endif
|
@@ -1,23 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright 2020 Google Inc.
|
3
|
-
*
|
4
|
-
* Use of this source code is governed by a BSD-style license that can be
|
5
|
-
* found in the LICENSE file.
|
6
|
-
*/
|
7
|
-
|
8
|
-
#ifndef SkOpts_spi_DEFINED
|
9
|
-
#define SkOpts_spi_DEFINED
|
10
|
-
|
11
|
-
#include "include/private/base/SkAPI.h"
|
12
|
-
|
13
|
-
#include <cstddef>
|
14
|
-
|
15
|
-
// These are exposed as SK_SPI (e.g. SkParagraph), the rest of SkOpts is
|
16
|
-
// declared in src/core
|
17
|
-
|
18
|
-
namespace SkOpts {
|
19
|
-
// The fastest high quality 32-bit hash we can provide on this platform.
|
20
|
-
extern uint32_t SK_SPI (*hash_fn)(const void* data, size_t bytes, uint32_t seed);
|
21
|
-
} // namespace SkOpts
|
22
|
-
|
23
|
-
#endif
|
@@ -1,57 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright 2015 Google Inc.
|
3
|
-
*
|
4
|
-
* Use of this source code is governed by a BSD-style license that can be
|
5
|
-
* found in the LICENSE file.
|
6
|
-
*/
|
7
|
-
|
8
|
-
#ifndef SkSpinlock_DEFINED
|
9
|
-
#define SkSpinlock_DEFINED
|
10
|
-
|
11
|
-
#include "include/core/SkTypes.h"
|
12
|
-
#include "include/private/base/SkThreadAnnotations.h"
|
13
|
-
#include <atomic>
|
14
|
-
|
15
|
-
class SK_CAPABILITY("mutex") SkSpinlock {
|
16
|
-
public:
|
17
|
-
constexpr SkSpinlock() = default;
|
18
|
-
|
19
|
-
void acquire() SK_ACQUIRE() {
|
20
|
-
// To act as a mutex, we need an acquire barrier when we acquire the lock.
|
21
|
-
if (fLocked.exchange(true, std::memory_order_acquire)) {
|
22
|
-
// Lock was contended. Fall back to an out-of-line spin loop.
|
23
|
-
this->contendedAcquire();
|
24
|
-
}
|
25
|
-
}
|
26
|
-
|
27
|
-
// Acquire the lock or fail (quickly). Lets the caller decide to do something other than wait.
|
28
|
-
bool tryAcquire() SK_TRY_ACQUIRE(true) {
|
29
|
-
// To act as a mutex, we need an acquire barrier when we acquire the lock.
|
30
|
-
if (fLocked.exchange(true, std::memory_order_acquire)) {
|
31
|
-
// Lock was contended. Let the caller decide what to do.
|
32
|
-
return false;
|
33
|
-
}
|
34
|
-
return true;
|
35
|
-
}
|
36
|
-
|
37
|
-
void release() SK_RELEASE_CAPABILITY() {
|
38
|
-
// To act as a mutex, we need a release barrier when we release the lock.
|
39
|
-
fLocked.store(false, std::memory_order_release);
|
40
|
-
}
|
41
|
-
|
42
|
-
private:
|
43
|
-
SK_API void contendedAcquire();
|
44
|
-
|
45
|
-
std::atomic<bool> fLocked{false};
|
46
|
-
};
|
47
|
-
|
48
|
-
class SK_SCOPED_CAPABILITY SkAutoSpinlock {
|
49
|
-
public:
|
50
|
-
SkAutoSpinlock(SkSpinlock& mutex) SK_ACQUIRE(mutex) : fSpinlock(mutex) { fSpinlock.acquire(); }
|
51
|
-
~SkAutoSpinlock() SK_RELEASE_CAPABILITY() { fSpinlock.release(); }
|
52
|
-
|
53
|
-
private:
|
54
|
-
SkSpinlock& fSpinlock;
|
55
|
-
};
|
56
|
-
|
57
|
-
#endif//SkSpinlock_DEFINED
|
@@ -1,16 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright 2021 Google LLC
|
3
|
-
*
|
4
|
-
* Use of this source code is governed by a BSD-style license that can be
|
5
|
-
* found in the LICENSE file.
|
6
|
-
*/
|
7
|
-
|
8
|
-
#ifndef GrSlug_DEFINED
|
9
|
-
#define GrSlug_DEFINED
|
10
|
-
|
11
|
-
#include "include/private/chromium/Slug.h"
|
12
|
-
|
13
|
-
// TODO: Update Chrome to use sktext::gpu classes and remove these
|
14
|
-
using GrSlug = sktext::gpu::Slug;
|
15
|
-
|
16
|
-
#endif // GrSlug_DEFINED
|
package/scripts/install-npm.js
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
const fs = require("fs");
|
2
|
-
const path = require("path");
|
3
|
-
|
4
|
-
console.log("Updating symlinks for Android build...");
|
5
|
-
|
6
|
-
const createSymlink = (p) => {
|
7
|
-
console.log(`Creating symlink to ${p}`, __dirname, process.cwd());
|
8
|
-
const srcDir = path.resolve(`./cpp/${p}`);
|
9
|
-
const dstDir = path.resolve(`./android/cpp/${p}`);
|
10
|
-
|
11
|
-
// Case in PNPM which might turn symlink into a directory:
|
12
|
-
// In that case, remove the directory before creating the symlink
|
13
|
-
if (fs.existsSync(dstDir)) {
|
14
|
-
const lstat = fs.lstatSync(dstDir);
|
15
|
-
const isSymbolicLink = lstat.isSymbolicLink();
|
16
|
-
if (lstat.isDirectory() && !isSymbolicLink) {
|
17
|
-
fs.rmSync(dstDir, { recursive: true });
|
18
|
-
}
|
19
|
-
}
|
20
|
-
|
21
|
-
if (!fs.existsSync(dstDir)) {
|
22
|
-
fs.symlinkSync(srcDir, dstDir, "junction");
|
23
|
-
}
|
24
|
-
};
|
25
|
-
|
26
|
-
// Copy common cpp files from the package root to the android folder
|
27
|
-
createSymlink("api");
|
28
|
-
createSymlink("jsi");
|
29
|
-
createSymlink("rnskia");
|
30
|
-
createSymlink("skia");
|
31
|
-
createSymlink("utils");
|
32
|
-
|
33
|
-
console.log("Symlinks created successfully.");
|