@shopify/react-native-skia 2.0.7 → 2.1.1
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/CMakeLists.txt +20 -1
- package/cpp/api/JsiSkApi.h +3 -0
- package/cpp/api/JsiSkImageFilterFactory.h +478 -39
- package/cpp/api/JsiSkSkottie.h +590 -0
- package/cpp/api/JsiSkottieFactory.h +65 -0
- package/cpp/api/recorder/Command.h +1 -0
- package/cpp/api/recorder/Convertor.h +32 -0
- package/cpp/api/recorder/Drawings.h +23 -0
- package/cpp/api/recorder/ImageFilters.h +20 -0
- package/cpp/api/recorder/JsiRecorder.h +6 -0
- package/cpp/api/recorder/RNRecorder.h +15 -0
- package/cpp/api/third_party/SkottieUtils.cpp +333 -0
- package/cpp/api/third_party/SkottieUtils.h +172 -0
- package/cpp/skia/modules/jsonreader/SkJSONReader.cpp +980 -0
- package/cpp/skia/modules/jsonreader/SkJSONReader.h +389 -0
- package/cpp/skia/modules/skottie/include/ExternalLayer.h +56 -0
- package/cpp/skia/modules/skottie/include/Skottie.h +313 -0
- package/cpp/skia/modules/skottie/include/SkottieProperty.h +190 -0
- package/cpp/skia/modules/skottie/include/SlotManager.h +113 -0
- package/cpp/skia/modules/skottie/include/TextShaper.h +200 -0
- package/cpp/skia/modules/skottie/src/SkottieValue.h +56 -0
- package/cpp/skia/modules/skottie/src/animator/Animator.h +89 -0
- package/cpp/skia/modules/skottie/src/text/Font.h +82 -0
- package/cpp/skia/modules/skottie/src/text/TextAdapter.h +155 -0
- package/cpp/skia/modules/skottie/src/text/TextAnimator.h +121 -0
- package/cpp/skia/modules/skottie/src/text/TextValue.h +28 -0
- package/cpp/skia/modules/sksg/include/SkSGClipEffect.h +61 -0
- package/cpp/skia/modules/sksg/include/SkSGColorFilter.h +135 -0
- package/cpp/skia/modules/sksg/include/SkSGDraw.h +57 -0
- package/cpp/skia/modules/sksg/include/SkSGEffectNode.h +50 -0
- package/cpp/skia/modules/sksg/include/SkSGGeometryEffect.h +181 -0
- package/cpp/skia/modules/sksg/include/SkSGGeometryNode.h +54 -0
- package/cpp/skia/modules/sksg/include/SkSGGradient.h +108 -0
- package/cpp/skia/modules/sksg/include/SkSGGroup.h +65 -0
- package/cpp/skia/modules/sksg/include/SkSGImage.h +59 -0
- package/cpp/skia/modules/sksg/include/SkSGInvalidationController.h +46 -0
- package/cpp/skia/modules/sksg/include/SkSGMaskEffect.h +65 -0
- package/cpp/skia/modules/sksg/include/SkSGMerge.h +74 -0
- package/cpp/skia/modules/sksg/include/SkSGNode.h +128 -0
- package/cpp/skia/modules/sksg/include/SkSGOpacityEffect.h +54 -0
- package/cpp/skia/modules/sksg/include/SkSGPaint.h +112 -0
- package/cpp/skia/modules/sksg/include/SkSGPath.h +68 -0
- package/cpp/skia/modules/sksg/include/SkSGPlane.h +47 -0
- package/cpp/skia/modules/sksg/include/SkSGRect.h +122 -0
- package/cpp/skia/modules/sksg/include/SkSGRenderEffect.h +283 -0
- package/cpp/skia/modules/sksg/include/SkSGRenderNode.h +157 -0
- package/cpp/skia/modules/sksg/include/SkSGScene.h +47 -0
- package/cpp/skia/modules/sksg/include/SkSGText.h +82 -0
- package/cpp/skia/modules/sksg/include/SkSGTransform.h +127 -0
- package/cpp/skia/src/base/SkArenaAlloc.h +371 -0
- package/lib/commonjs/dom/nodes/datatypes/Gradient.d.ts +15 -15
- package/lib/commonjs/dom/types/Drawings.d.ts +8 -1
- package/lib/commonjs/dom/types/Drawings.js.map +1 -1
- package/lib/commonjs/dom/types/NodeType.d.ts +3 -1
- package/lib/commonjs/dom/types/NodeType.js +4 -0
- package/lib/commonjs/dom/types/NodeType.js.map +1 -1
- package/lib/commonjs/renderer/__tests__/e2e/AdvancedImageFilters.spec.d.ts +1 -0
- package/lib/commonjs/renderer/__tests__/e2e/Camera.spec.d.ts +21 -0
- package/lib/commonjs/renderer/__tests__/e2e/ImageFilter.spec.d.ts +1 -0
- package/lib/commonjs/renderer/__tests__/e2e/LightingImageFilters.spec.d.ts +1 -0
- package/lib/commonjs/renderer/__tests__/e2e/Skottie.spec.d.ts +1 -0
- package/lib/commonjs/renderer/__tests__/setup.d.ts +5 -0
- package/lib/commonjs/renderer/components/ImageFilter.d.ts +4 -0
- package/lib/commonjs/renderer/components/ImageFilter.js +13 -0
- package/lib/commonjs/renderer/components/ImageFilter.js.map +1 -0
- package/lib/commonjs/renderer/components/Skottie.d.ts +4 -0
- package/lib/commonjs/renderer/components/Skottie.js +13 -0
- package/lib/commonjs/renderer/components/Skottie.js.map +1 -0
- package/lib/commonjs/renderer/components/index.d.ts +2 -0
- package/lib/commonjs/renderer/components/index.js +22 -0
- package/lib/commonjs/renderer/components/index.js.map +1 -1
- package/lib/commonjs/skia/types/ImageFilter/ImageFilterFactory.d.ts +252 -15
- package/lib/commonjs/skia/types/ImageFilter/ImageFilterFactory.js.map +1 -1
- package/lib/commonjs/skia/types/Matrix4.d.ts +11 -2
- package/lib/commonjs/skia/types/Matrix4.js +42 -1
- package/lib/commonjs/skia/types/Matrix4.js.map +1 -1
- package/lib/commonjs/skia/types/Recorder.d.ts +2 -1
- package/lib/commonjs/skia/types/Recorder.js.map +1 -1
- package/lib/commonjs/skia/types/Skia.d.ts +2 -0
- package/lib/commonjs/skia/types/Skia.js.map +1 -1
- package/lib/commonjs/skia/types/Skottie.d.ts +223 -0
- package/lib/commonjs/skia/types/Skottie.js +73 -0
- package/lib/commonjs/skia/types/Skottie.js.map +1 -0
- package/lib/commonjs/skia/types/index.d.ts +1 -0
- package/lib/commonjs/skia/types/index.js +11 -0
- package/lib/commonjs/skia/types/index.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImageFilterFactory.d.ts +29 -12
- package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js +88 -19
- package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkia.js +2 -0
- package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkottieAnimation.d.ts +59 -0
- package/lib/commonjs/skia/web/JsiSkottieAnimation.js +243 -0
- package/lib/commonjs/skia/web/JsiSkottieAnimation.js.map +1 -0
- package/lib/commonjs/skia/web/JsiSkottieFactory.d.ts +9 -0
- package/lib/commonjs/skia/web/JsiSkottieFactory.js +26 -0
- package/lib/commonjs/skia/web/JsiSkottieFactory.js.map +1 -0
- package/lib/commonjs/sksg/Elements.d.ts +3 -1
- package/lib/commonjs/sksg/Elements.js.map +1 -1
- package/lib/commonjs/sksg/Node.d.ts +1 -1
- package/lib/commonjs/sksg/Node.js +1 -1
- package/lib/commonjs/sksg/Node.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Core.d.ts +4 -2
- package/lib/commonjs/sksg/Recorder/Core.js +1 -0
- package/lib/commonjs/sksg/Recorder/Core.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Player.js +2 -0
- package/lib/commonjs/sksg/Recorder/Player.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +2 -1
- package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js +4 -0
- package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Recorder.d.ts +2 -1
- package/lib/commonjs/sksg/Recorder/Recorder.js +6 -0
- package/lib/commonjs/sksg/Recorder/Recorder.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Visitor.js +3 -0
- package/lib/commonjs/sksg/Recorder/Visitor.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Drawing.d.ts +2 -2
- package/lib/commonjs/sksg/Recorder/commands/Drawing.js +11 -4
- package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js +12 -2
- package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js.map +1 -1
- package/lib/module/dom/nodes/datatypes/Gradient.d.ts +15 -15
- package/lib/module/dom/types/Drawings.d.ts +8 -1
- package/lib/module/dom/types/Drawings.js.map +1 -1
- package/lib/module/dom/types/NodeType.d.ts +3 -1
- package/lib/module/dom/types/NodeType.js +4 -0
- package/lib/module/dom/types/NodeType.js.map +1 -1
- package/lib/module/renderer/__tests__/e2e/AdvancedImageFilters.spec.d.ts +1 -0
- package/lib/module/renderer/__tests__/e2e/Camera.spec.d.ts +21 -0
- package/lib/module/renderer/__tests__/e2e/ImageFilter.spec.d.ts +1 -0
- package/lib/module/renderer/__tests__/e2e/LightingImageFilters.spec.d.ts +1 -0
- package/lib/module/renderer/__tests__/e2e/Skottie.spec.d.ts +1 -0
- package/lib/module/renderer/__tests__/setup.d.ts +5 -0
- package/lib/module/renderer/components/ImageFilter.d.ts +4 -0
- package/lib/module/renderer/components/ImageFilter.js +5 -0
- package/lib/module/renderer/components/ImageFilter.js.map +1 -0
- package/lib/module/renderer/components/Skottie.d.ts +4 -0
- package/lib/module/renderer/components/Skottie.js +5 -0
- package/lib/module/renderer/components/Skottie.js.map +1 -0
- package/lib/module/renderer/components/index.d.ts +2 -0
- package/lib/module/renderer/components/index.js +2 -0
- package/lib/module/renderer/components/index.js.map +1 -1
- package/lib/module/skia/types/ImageFilter/ImageFilterFactory.d.ts +252 -15
- package/lib/module/skia/types/ImageFilter/ImageFilterFactory.js.map +1 -1
- package/lib/module/skia/types/Matrix4.d.ts +11 -2
- package/lib/module/skia/types/Matrix4.js +40 -0
- package/lib/module/skia/types/Matrix4.js.map +1 -1
- package/lib/module/skia/types/Recorder.d.ts +2 -1
- package/lib/module/skia/types/Recorder.js.map +1 -1
- package/lib/module/skia/types/Skia.d.ts +2 -0
- package/lib/module/skia/types/Skia.js.map +1 -1
- package/lib/module/skia/types/Skottie.d.ts +223 -0
- package/lib/module/skia/types/Skottie.js +74 -0
- package/lib/module/skia/types/Skottie.js.map +1 -0
- package/lib/module/skia/types/index.d.ts +1 -0
- package/lib/module/skia/types/index.js +1 -0
- package/lib/module/skia/types/index.js.map +1 -1
- package/lib/module/skia/web/JsiSkImageFilterFactory.d.ts +29 -12
- package/lib/module/skia/web/JsiSkImageFilterFactory.js +88 -19
- package/lib/module/skia/web/JsiSkImageFilterFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkia.js +2 -0
- package/lib/module/skia/web/JsiSkia.js.map +1 -1
- package/lib/module/skia/web/JsiSkottieAnimation.d.ts +59 -0
- package/lib/module/skia/web/JsiSkottieAnimation.js +236 -0
- package/lib/module/skia/web/JsiSkottieAnimation.js.map +1 -0
- package/lib/module/skia/web/JsiSkottieFactory.d.ts +9 -0
- package/lib/module/skia/web/JsiSkottieFactory.js +19 -0
- package/lib/module/skia/web/JsiSkottieFactory.js.map +1 -0
- package/lib/module/sksg/Elements.d.ts +3 -1
- package/lib/module/sksg/Elements.js.map +1 -1
- package/lib/module/sksg/Node.d.ts +1 -1
- package/lib/module/sksg/Node.js +1 -1
- package/lib/module/sksg/Node.js.map +1 -1
- package/lib/module/sksg/Recorder/Core.d.ts +4 -2
- package/lib/module/sksg/Recorder/Core.js +1 -0
- package/lib/module/sksg/Recorder/Core.js.map +1 -1
- package/lib/module/sksg/Recorder/Player.js +3 -1
- package/lib/module/sksg/Recorder/Player.js.map +1 -1
- package/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +2 -1
- package/lib/module/sksg/Recorder/ReanimatedRecorder.js +4 -0
- package/lib/module/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
- package/lib/module/sksg/Recorder/Recorder.d.ts +2 -1
- package/lib/module/sksg/Recorder/Recorder.js +6 -0
- package/lib/module/sksg/Recorder/Recorder.js.map +1 -1
- package/lib/module/sksg/Recorder/Visitor.js +3 -0
- package/lib/module/sksg/Recorder/Visitor.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Drawing.d.ts +2 -2
- package/lib/module/sksg/Recorder/commands/Drawing.js +9 -2
- package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/ImageFilters.js +12 -2
- package/lib/module/sksg/Recorder/commands/ImageFilters.js.map +1 -1
- package/lib/typescript/lib/commonjs/renderer/components/ImageFilter.d.ts +2 -0
- package/lib/typescript/lib/commonjs/renderer/components/Skottie.d.ts +2 -0
- package/lib/typescript/lib/commonjs/skia/types/Matrix4.d.ts +1 -0
- package/lib/typescript/lib/commonjs/skia/types/Skottie.d.ts +6 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFilterFactory.d.ts +22 -5
- package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +2 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkottieAnimation.d.ts +48 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkottieFactory.d.ts +6 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +1 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/Recorder.d.ts +1 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/commands/Drawing.d.ts +1 -1
- package/lib/typescript/lib/module/mock/index.d.ts +8 -0
- package/lib/typescript/lib/module/renderer/components/ImageFilter.d.ts +2 -0
- package/lib/typescript/lib/module/renderer/components/Skottie.d.ts +2 -0
- package/lib/typescript/lib/module/renderer/components/index.d.ts +2 -0
- package/lib/typescript/lib/module/skia/Skia.web.d.ts +1 -0
- package/lib/typescript/lib/module/skia/types/Matrix4.d.ts +1 -0
- package/lib/typescript/lib/module/skia/types/Skottie.d.ts +5 -0
- package/lib/typescript/lib/module/skia/types/index.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkImageFilterFactory.d.ts +22 -5
- package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +2 -0
- package/lib/typescript/lib/module/skia/web/JsiSkottieAnimation.d.ts +47 -0
- package/lib/typescript/lib/module/skia/web/JsiSkottieFactory.d.ts +5 -0
- package/lib/typescript/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +1 -0
- package/lib/typescript/lib/module/sksg/Recorder/Recorder.d.ts +1 -0
- package/lib/typescript/lib/module/sksg/Recorder/commands/Drawing.d.ts +1 -1
- package/lib/typescript/src/dom/nodes/datatypes/Gradient.d.ts +15 -15
- package/lib/typescript/src/dom/types/Drawings.d.ts +8 -1
- package/lib/typescript/src/dom/types/NodeType.d.ts +3 -1
- package/lib/typescript/src/renderer/__tests__/e2e/AdvancedImageFilters.spec.d.ts +1 -0
- package/lib/typescript/src/renderer/__tests__/e2e/Camera.spec.d.ts +21 -0
- package/lib/typescript/src/renderer/__tests__/e2e/ImageFilter.spec.d.ts +1 -0
- package/lib/typescript/src/renderer/__tests__/e2e/LightingImageFilters.spec.d.ts +1 -0
- package/lib/typescript/src/renderer/__tests__/e2e/Skottie.spec.d.ts +1 -0
- package/lib/typescript/src/renderer/__tests__/setup.d.ts +5 -0
- package/lib/typescript/src/renderer/components/ImageFilter.d.ts +4 -0
- package/lib/typescript/src/renderer/components/Skottie.d.ts +4 -0
- package/lib/typescript/src/renderer/components/index.d.ts +2 -0
- package/lib/typescript/src/skia/types/ImageFilter/ImageFilterFactory.d.ts +252 -15
- package/lib/typescript/src/skia/types/Matrix4.d.ts +11 -2
- package/lib/typescript/src/skia/types/Recorder.d.ts +2 -1
- package/lib/typescript/src/skia/types/Skia.d.ts +2 -0
- package/lib/typescript/src/skia/types/Skottie.d.ts +223 -0
- package/lib/typescript/src/skia/types/index.d.ts +1 -0
- package/lib/typescript/src/skia/web/JsiSkImageFilterFactory.d.ts +29 -12
- package/lib/typescript/src/skia/web/JsiSkottieAnimation.d.ts +59 -0
- package/lib/typescript/src/skia/web/JsiSkottieFactory.d.ts +9 -0
- package/lib/typescript/src/sksg/Elements.d.ts +3 -1
- package/lib/typescript/src/sksg/Node.d.ts +1 -1
- package/lib/typescript/src/sksg/Recorder/Core.d.ts +4 -2
- package/lib/typescript/src/sksg/Recorder/ReanimatedRecorder.d.ts +2 -1
- package/lib/typescript/src/sksg/Recorder/Recorder.d.ts +2 -1
- package/lib/typescript/src/sksg/Recorder/commands/Drawing.d.ts +2 -2
- package/libs/android/arm64-v8a/libjsonreader.a +0 -0
- package/libs/android/armeabi-v7a/libjsonreader.a +0 -0
- package/libs/android/x86/libjsonreader.a +0 -0
- package/libs/android/x86_64/libjsonreader.a +0 -0
- package/libs/apple/libpathops.xcframework/Info.plist +8 -8
- package/libs/apple/libskia.xcframework/Info.plist +14 -14
- package/libs/apple/libskottie.xcframework/Info.plist +14 -14
- package/libs/apple/libskparagraph.xcframework/Info.plist +16 -16
- package/libs/apple/libsksg.xcframework/Info.plist +5 -5
- package/libs/apple/libskshaper.xcframework/Info.plist +14 -14
- package/libs/apple/libskunicode_libgrapheme.xcframework/Info.plist +14 -14
- package/libs/apple/libsvg.xcframework/Info.plist +14 -14
- package/package.json +1 -1
- package/react-native-skia.podspec +4 -2
- package/src/__tests__/snapshots/matrix4/camera-corner.png +0 -0
- package/src/__tests__/snapshots/matrix4/camera-offset.png +0 -0
- package/src/__tests__/snapshots/matrix4/camera-top-left-center.png +0 -0
- package/src/__tests__/snapshots/matrix4/camera-zoom-out.png +0 -0
- package/src/__tests__/snapshots/matrix4/full-rect.png +0 -0
- package/src/__tests__/snapshots/matrix4/rect.png +0 -0
- package/src/__tests__/snapshots/matrix4/scaled-rect.png +0 -0
- package/src/__tests__/snapshots/matrix4/test-perspective.png +0 -0
- package/src/__tests__/snapshots/matrix4/test-perspective2.png +0 -0
- package/src/dom/types/Drawings.ts +11 -0
- package/src/dom/types/NodeType.ts +4 -0
- package/src/renderer/__tests__/e2e/AdvancedImageFilters.spec.tsx +492 -0
- package/src/renderer/__tests__/e2e/Camera.spec.tsx +475 -0
- package/src/renderer/__tests__/e2e/ImageFilter.spec.tsx +99 -0
- package/src/renderer/__tests__/e2e/LightingImageFilters.spec.tsx +1478 -0
- package/src/renderer/__tests__/e2e/Skottie.spec.tsx +440 -0
- package/src/renderer/__tests__/e2e/setup/skottie/basic_slots.json +1118 -0
- package/src/renderer/__tests__/e2e/setup/skottie/color-props.json +1 -0
- package/src/renderer/__tests__/e2e/setup/skottie/confetti.json +5899 -0
- package/src/renderer/__tests__/e2e/setup/skottie/drinks.json +43857 -0
- package/src/renderer/__tests__/e2e/setup/skottie/fingerprint.json +1 -0
- package/src/renderer/__tests__/e2e/setup/skottie/lego_loader.json +29540 -0
- package/src/renderer/__tests__/e2e/setup/skottie/new-drop.json +1 -0
- package/src/renderer/__tests__/e2e/setup/skottie/onboarding.json +1 -0
- package/src/renderer/__tests__/e2e/setup/skottie/text-layer.json +1 -0
- package/src/renderer/__tests__/setup.tsx +31 -0
- package/src/renderer/components/ImageFilter.tsx +8 -0
- package/src/renderer/components/Skottie.tsx +8 -0
- package/src/renderer/components/index.ts +2 -0
- package/src/skia/__tests__/assets/Avenir-Heavy.ttf +0 -0
- package/src/skia/types/ImageFilter/ImageFilterFactory.ts +391 -21
- package/src/skia/types/Matrix4.ts +108 -2
- package/src/skia/types/Recorder.ts +2 -0
- package/src/skia/types/Skia.ts +2 -0
- package/src/skia/types/Skottie.ts +266 -0
- package/src/skia/types/index.ts +1 -0
- package/src/skia/web/JsiSkImageFilterFactory.ts +266 -31
- package/src/skia/web/JsiSkia.ts +2 -0
- package/src/skia/web/JsiSkottieAnimation.ts +259 -0
- package/src/skia/web/JsiSkottieFactory.ts +25 -0
- package/src/sksg/Elements.tsx +4 -0
- package/src/sksg/Node.ts +1 -0
- package/src/sksg/Recorder/Core.ts +3 -0
- package/src/sksg/Recorder/Player.ts +3 -0
- package/src/sksg/Recorder/ReanimatedRecorder.ts +6 -0
- package/src/sksg/Recorder/Recorder.ts +5 -0
- package/src/sksg/Recorder/Visitor.ts +3 -0
- package/src/sksg/Recorder/commands/Drawing.ts +7 -3
- package/src/sksg/Recorder/commands/ImageFilters.ts +15 -2
@@ -0,0 +1,389 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright 2024 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 SkJSON_DEFINED
|
9
|
+
#define SkJSON_DEFINED
|
10
|
+
|
11
|
+
#include "include/core/SkTypes.h"
|
12
|
+
#include "include/private/base/SkNoncopyable.h"
|
13
|
+
#include "src/base/SkArenaAlloc.h"
|
14
|
+
|
15
|
+
#include <cstdint>
|
16
|
+
#include <cstring>
|
17
|
+
#include <string_view>
|
18
|
+
|
19
|
+
class SkString;
|
20
|
+
class SkWStream;
|
21
|
+
|
22
|
+
namespace skjson {
|
23
|
+
|
24
|
+
/**
|
25
|
+
* A fast and likely non-conforming JSON parser.
|
26
|
+
*
|
27
|
+
* Some known limitations/compromises:
|
28
|
+
*
|
29
|
+
* -- single-precision FP numbers
|
30
|
+
*
|
31
|
+
* -- missing string unescaping (no current users, could be easily added)
|
32
|
+
*
|
33
|
+
*
|
34
|
+
* Values are opaque, fixed-size (64 bits), immutable records.
|
35
|
+
*
|
36
|
+
* They can be converted to facade types for type-specific functionality.
|
37
|
+
*
|
38
|
+
* E.g.:
|
39
|
+
*
|
40
|
+
* if (v.is<ArrayValue>()) {
|
41
|
+
* for (const auto& item : v.as<ArrayValue>()) {
|
42
|
+
* if (const NumberValue* n = item) {
|
43
|
+
* printf("Found number: %f", **n);
|
44
|
+
* }
|
45
|
+
* }
|
46
|
+
* }
|
47
|
+
*
|
48
|
+
* if (v.is<ObjectValue>()) {
|
49
|
+
* const StringValue* id = v.as<ObjectValue>()["id"];
|
50
|
+
* if (id) {
|
51
|
+
* printf("Found object ID: %s", id->begin());
|
52
|
+
* } else {
|
53
|
+
* printf("Missing object ID");
|
54
|
+
* }
|
55
|
+
* }
|
56
|
+
*/
|
57
|
+
class alignas(8) Value {
|
58
|
+
public:
|
59
|
+
enum class Type {
|
60
|
+
kNull,
|
61
|
+
kBool,
|
62
|
+
kNumber,
|
63
|
+
kString,
|
64
|
+
kArray,
|
65
|
+
kObject,
|
66
|
+
};
|
67
|
+
|
68
|
+
/**
|
69
|
+
* @return The type of this value.
|
70
|
+
*/
|
71
|
+
Type getType() const;
|
72
|
+
|
73
|
+
/**
|
74
|
+
* @return True if the record matches the facade type T.
|
75
|
+
*/
|
76
|
+
template <typename T>
|
77
|
+
bool is() const { return this->getType() == T::kType; }
|
78
|
+
|
79
|
+
/**
|
80
|
+
* Unguarded conversion to facade types.
|
81
|
+
*
|
82
|
+
* @return The record cast as facade type T&.
|
83
|
+
*/
|
84
|
+
template <typename T>
|
85
|
+
const T& as() const {
|
86
|
+
SkASSERT(this->is<T>());
|
87
|
+
return *reinterpret_cast<const T*>(this);
|
88
|
+
}
|
89
|
+
|
90
|
+
/**
|
91
|
+
* Guarded conversion to facade types.
|
92
|
+
*
|
93
|
+
* @return The record cast as facade type T*.
|
94
|
+
*/
|
95
|
+
template <typename T>
|
96
|
+
operator const T*() const {
|
97
|
+
return this->is<T>() ? &this->as<T>() : nullptr;
|
98
|
+
}
|
99
|
+
|
100
|
+
/**
|
101
|
+
* @return The string representation of this value.
|
102
|
+
*/
|
103
|
+
SkString toString() const;
|
104
|
+
|
105
|
+
/**
|
106
|
+
* Helper for fluent key lookup: v["foo"]["bar"]["baz"]
|
107
|
+
*
|
108
|
+
* @return The lookup result value on success, otherwise NullValue.
|
109
|
+
*/
|
110
|
+
const Value& operator[](const char* key) const;
|
111
|
+
|
112
|
+
protected:
|
113
|
+
/*
|
114
|
+
Value implementation notes:
|
115
|
+
|
116
|
+
-- fixed 64-bit size
|
117
|
+
|
118
|
+
-- 8-byte aligned
|
119
|
+
|
120
|
+
-- union of:
|
121
|
+
|
122
|
+
bool
|
123
|
+
int32
|
124
|
+
float
|
125
|
+
char[8] (short string storage)
|
126
|
+
external payload (tagged) pointer
|
127
|
+
|
128
|
+
-- lowest 3 bits reserved for tag storage
|
129
|
+
|
130
|
+
*/
|
131
|
+
enum class Tag : uint8_t {
|
132
|
+
// n.b.: we picked kShortString == 0 on purpose,
|
133
|
+
// to enable certain short-string optimizations.
|
134
|
+
kShortString = 0b00000000, // inline payload
|
135
|
+
kNull = 0b00000001, // no payload
|
136
|
+
kBool = 0b00000010, // inline payload
|
137
|
+
kInt = 0b00000011, // inline payload
|
138
|
+
kFloat = 0b00000100, // inline payload
|
139
|
+
kString = 0b00000101, // ptr to external storage
|
140
|
+
kArray = 0b00000110, // ptr to external storage
|
141
|
+
kObject = 0b00000111, // ptr to external storage
|
142
|
+
};
|
143
|
+
inline static constexpr uint8_t kTagMask = 0b00000111;
|
144
|
+
|
145
|
+
void init_tagged(Tag);
|
146
|
+
void init_tagged_pointer(Tag, void*);
|
147
|
+
|
148
|
+
Tag getTag() const {
|
149
|
+
return static_cast<Tag>(fData8[0] & kTagMask);
|
150
|
+
}
|
151
|
+
|
152
|
+
// Access the record payload as T.
|
153
|
+
//
|
154
|
+
// Since the tag is stored in the lower bits, we skip the first word whenever feasible.
|
155
|
+
//
|
156
|
+
// E.g. (U == unused)
|
157
|
+
//
|
158
|
+
// uint8_t
|
159
|
+
// -----------------------------------------------------------------------
|
160
|
+
// |TAG| U | val8 | U | U | U | U | U | U |
|
161
|
+
// -----------------------------------------------------------------------
|
162
|
+
//
|
163
|
+
// uint16_t
|
164
|
+
// -----------------------------------------------------------------------
|
165
|
+
// |TAG| U | val16 | U | U |
|
166
|
+
// -----------------------------------------------------------------------
|
167
|
+
//
|
168
|
+
// uint32_t
|
169
|
+
// -----------------------------------------------------------------------
|
170
|
+
// |TAG| U | val32 |
|
171
|
+
// -----------------------------------------------------------------------
|
172
|
+
//
|
173
|
+
// T* (32b)
|
174
|
+
// -----------------------------------------------------------------------
|
175
|
+
// |TAG| U | T* (32bits) |
|
176
|
+
// -----------------------------------------------------------------------
|
177
|
+
//
|
178
|
+
// T* (64b)
|
179
|
+
// -----------------------------------------------------------------------
|
180
|
+
// |TAG| T* (61bits) |
|
181
|
+
// -----------------------------------------------------------------------
|
182
|
+
//
|
183
|
+
template <typename T>
|
184
|
+
const T* cast() const {
|
185
|
+
static_assert(sizeof (T) <= sizeof(Value), "");
|
186
|
+
static_assert(alignof(T) <= alignof(Value), "");
|
187
|
+
|
188
|
+
return (sizeof(T) > sizeof(*this) / 2)
|
189
|
+
? reinterpret_cast<const T*>(this) + 0 // need all the bits
|
190
|
+
: reinterpret_cast<const T*>(this) + 1; // skip the first word (where the tag lives)
|
191
|
+
}
|
192
|
+
|
193
|
+
template <typename T>
|
194
|
+
T* cast() { return const_cast<T*>(const_cast<const Value*>(this)->cast<T>()); }
|
195
|
+
|
196
|
+
// Access the pointer payload.
|
197
|
+
template <typename T>
|
198
|
+
const T* ptr() const {
|
199
|
+
static_assert(sizeof(uintptr_t) == sizeof(Value) ||
|
200
|
+
sizeof(uintptr_t) * 2 == sizeof(Value), "");
|
201
|
+
|
202
|
+
return (sizeof(uintptr_t) < sizeof(Value))
|
203
|
+
// For 32-bit, pointers are stored unmodified.
|
204
|
+
? *this->cast<const T*>()
|
205
|
+
// For 64-bit, we use the lower bits of the pointer as tag storage.
|
206
|
+
: reinterpret_cast<T*>(*this->cast<uintptr_t>() & ~static_cast<uintptr_t>(kTagMask));
|
207
|
+
}
|
208
|
+
|
209
|
+
private:
|
210
|
+
inline static constexpr size_t kValueSize = 8;
|
211
|
+
|
212
|
+
uint8_t fData8[kValueSize];
|
213
|
+
|
214
|
+
#if !defined(SK_CPU_LENDIAN)
|
215
|
+
// The current value layout assumes LE and will take some tweaking for BE.
|
216
|
+
static_assert(false, "Big-endian builds are not supported at this time.");
|
217
|
+
#endif
|
218
|
+
};
|
219
|
+
|
220
|
+
class NullValue final : public Value {
|
221
|
+
public:
|
222
|
+
inline static constexpr Type kType = Type::kNull;
|
223
|
+
|
224
|
+
NullValue();
|
225
|
+
};
|
226
|
+
|
227
|
+
class BoolValue final : public Value {
|
228
|
+
public:
|
229
|
+
inline static constexpr Type kType = Type::kBool;
|
230
|
+
|
231
|
+
explicit BoolValue(bool);
|
232
|
+
|
233
|
+
bool operator*() const {
|
234
|
+
SkASSERT(this->getTag() == Tag::kBool);
|
235
|
+
return *this->cast<bool>();
|
236
|
+
}
|
237
|
+
};
|
238
|
+
|
239
|
+
class NumberValue final : public Value {
|
240
|
+
public:
|
241
|
+
inline static constexpr Type kType = Type::kNumber;
|
242
|
+
|
243
|
+
explicit NumberValue(int32_t);
|
244
|
+
explicit NumberValue(float);
|
245
|
+
|
246
|
+
double operator*() const {
|
247
|
+
SkASSERT(this->getTag() == Tag::kInt || this->getTag() == Tag::kFloat);
|
248
|
+
|
249
|
+
return this->getTag() == Tag::kInt ? static_cast<double>(*this->cast<int32_t>())
|
250
|
+
: static_cast<double>(*this->cast<float>());
|
251
|
+
}
|
252
|
+
};
|
253
|
+
|
254
|
+
template <typename T, Value::Type vtype>
|
255
|
+
class VectorValue : public Value {
|
256
|
+
public:
|
257
|
+
using ValueT = T;
|
258
|
+
inline static constexpr Type kType = vtype;
|
259
|
+
|
260
|
+
size_t size() const {
|
261
|
+
SkASSERT(this->getType() == kType);
|
262
|
+
return *this->ptr<size_t>();
|
263
|
+
}
|
264
|
+
|
265
|
+
const T* begin() const {
|
266
|
+
SkASSERT(this->getType() == kType);
|
267
|
+
const auto* size_ptr = this->ptr<size_t>();
|
268
|
+
return reinterpret_cast<const T*>(size_ptr + 1);
|
269
|
+
}
|
270
|
+
|
271
|
+
const T* end() const {
|
272
|
+
SkASSERT(this->getType() == kType);
|
273
|
+
const auto* size_ptr = this->ptr<size_t>();
|
274
|
+
return reinterpret_cast<const T*>(size_ptr + 1) + *size_ptr;
|
275
|
+
}
|
276
|
+
|
277
|
+
const T& operator[](size_t i) const {
|
278
|
+
SkASSERT(this->getType() == kType);
|
279
|
+
SkASSERT(i < this->size());
|
280
|
+
|
281
|
+
return *(this->begin() + i);
|
282
|
+
}
|
283
|
+
};
|
284
|
+
|
285
|
+
class ArrayValue final : public VectorValue<Value, Value::Type::kArray> {
|
286
|
+
public:
|
287
|
+
ArrayValue(const Value* src, size_t size, SkArenaAlloc& alloc);
|
288
|
+
};
|
289
|
+
|
290
|
+
class StringValue final : public Value {
|
291
|
+
public:
|
292
|
+
inline static constexpr Type kType = Type::kString;
|
293
|
+
|
294
|
+
StringValue();
|
295
|
+
StringValue(const char* src, SkArenaAlloc& alloc);
|
296
|
+
StringValue(const char* src, size_t size, SkArenaAlloc& alloc);
|
297
|
+
|
298
|
+
size_t size() const {
|
299
|
+
switch (this->getTag()) {
|
300
|
+
case Tag::kShortString:
|
301
|
+
// We don't bother storing a length for short strings on the assumption
|
302
|
+
// that strlen is fast in this case. If this becomes problematic, we
|
303
|
+
// can either go back to storing (7-len) in the tag byte or write a fast
|
304
|
+
// short_strlen.
|
305
|
+
return strlen(this->cast<char>());
|
306
|
+
case Tag::kString:
|
307
|
+
return this->cast<VectorValue<char, Value::Type::kString>>()->size();
|
308
|
+
default:
|
309
|
+
return 0;
|
310
|
+
}
|
311
|
+
}
|
312
|
+
|
313
|
+
const char* begin() const {
|
314
|
+
return this->getTag() == Tag::kShortString
|
315
|
+
? this->cast<char>()
|
316
|
+
: this->cast<VectorValue<char, Value::Type::kString>>()->begin();
|
317
|
+
}
|
318
|
+
|
319
|
+
const char* end() const {
|
320
|
+
return this->getTag() == Tag::kShortString
|
321
|
+
? strchr(this->cast<char>(), '\0')
|
322
|
+
: this->cast<VectorValue<char, Value::Type::kString>>()->end();
|
323
|
+
}
|
324
|
+
|
325
|
+
std::string_view str() const { return std::string_view(this->begin(), this->size()); }
|
326
|
+
};
|
327
|
+
|
328
|
+
struct Member {
|
329
|
+
StringValue fKey;
|
330
|
+
Value fValue;
|
331
|
+
};
|
332
|
+
|
333
|
+
class ObjectValue final : public VectorValue<Member, Value::Type::kObject> {
|
334
|
+
public:
|
335
|
+
ObjectValue(const Member* src, size_t size, SkArenaAlloc& alloc);
|
336
|
+
|
337
|
+
const Value& operator[](const char* key) const {
|
338
|
+
static const Value gNullValue = NullValue();
|
339
|
+
|
340
|
+
const auto* member = this->find(key);
|
341
|
+
return member ? member->fValue : gNullValue;
|
342
|
+
}
|
343
|
+
|
344
|
+
// Writable access to the value associated with the given key.
|
345
|
+
// If the key is not present, it is added with a default NullValue.
|
346
|
+
Value& writable(const char* key, SkArenaAlloc&) const;
|
347
|
+
|
348
|
+
private:
|
349
|
+
const Member* find(const char*) const;
|
350
|
+
};
|
351
|
+
|
352
|
+
class DOM final : public SkNoncopyable {
|
353
|
+
public:
|
354
|
+
DOM(const char*, size_t);
|
355
|
+
|
356
|
+
const Value& root() const { return fRoot; }
|
357
|
+
|
358
|
+
void write(SkWStream*) const;
|
359
|
+
|
360
|
+
private:
|
361
|
+
SkArenaAlloc fAlloc;
|
362
|
+
Value fRoot;
|
363
|
+
};
|
364
|
+
|
365
|
+
inline Value::Type Value::getType() const {
|
366
|
+
switch (this->getTag()) {
|
367
|
+
case Tag::kNull: return Type::kNull;
|
368
|
+
case Tag::kBool: return Type::kBool;
|
369
|
+
case Tag::kInt: return Type::kNumber;
|
370
|
+
case Tag::kFloat: return Type::kNumber;
|
371
|
+
case Tag::kShortString: return Type::kString;
|
372
|
+
case Tag::kString: return Type::kString;
|
373
|
+
case Tag::kArray: return Type::kArray;
|
374
|
+
case Tag::kObject: return Type::kObject;
|
375
|
+
}
|
376
|
+
|
377
|
+
SkASSERT(false); // unreachable
|
378
|
+
return Type::kNull;
|
379
|
+
}
|
380
|
+
|
381
|
+
inline const Value& Value::operator[](const char* key) const {
|
382
|
+
static const Value gNullValue = NullValue();
|
383
|
+
|
384
|
+
return this->is<ObjectValue>() ? this->as<ObjectValue>()[key] : gNullValue;
|
385
|
+
}
|
386
|
+
|
387
|
+
} // namespace skjson
|
388
|
+
|
389
|
+
#endif // SkJSON_DEFINED
|
@@ -0,0 +1,56 @@
|
|
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 SkottieExternalLayer_DEFINED
|
9
|
+
#define SkottieExternalLayer_DEFINED
|
10
|
+
|
11
|
+
#include "include/core/SkRefCnt.h"
|
12
|
+
|
13
|
+
class SkCanvas;
|
14
|
+
struct SkSize;
|
15
|
+
|
16
|
+
namespace skottie {
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Interface for externally-rendered layers.
|
20
|
+
*/
|
21
|
+
class ExternalLayer : public SkRefCnt {
|
22
|
+
public:
|
23
|
+
/** Render layer content into the given canvas.
|
24
|
+
*
|
25
|
+
* @param canvas Destination canvas
|
26
|
+
* @param t Time in seconds, relative to the layer in-point (start time)
|
27
|
+
*/
|
28
|
+
virtual void render(SkCanvas* canvas, double t) = 0;
|
29
|
+
};
|
30
|
+
|
31
|
+
/**
|
32
|
+
* Interface for intercepting pre-composed layer creation.
|
33
|
+
*
|
34
|
+
* Embedders can register interceptors with animation builders, to substitute target layers
|
35
|
+
* with arbitrary/externally-controlled content (see ExternalLayer above).
|
36
|
+
*/
|
37
|
+
class PrecompInterceptor : public SkRefCnt {
|
38
|
+
public:
|
39
|
+
/**
|
40
|
+
* Invoked at animation build time, for each precomp layer.
|
41
|
+
*
|
42
|
+
* @param id The target composition ID (usually assigned automatically by BM: comp_0, ...)
|
43
|
+
* @param name The name of the precomp layer (by default it matches the target comp name,
|
44
|
+
* but can be changed in AE)
|
45
|
+
* @param size Lottie-specified precomp layer size
|
46
|
+
* @return An ExternalLayer implementation (to be used instead of the actual Lottie file
|
47
|
+
* content), or nullptr (to use the Lottie file content).
|
48
|
+
*/
|
49
|
+
virtual sk_sp<ExternalLayer> onLoadPrecomp(const char id[],
|
50
|
+
const char name[],
|
51
|
+
const SkSize& size) = 0;
|
52
|
+
};
|
53
|
+
|
54
|
+
} // namespace skottie
|
55
|
+
|
56
|
+
#endif // SkottieExternalLayer_DEFINED
|