@shopify/react-native-skia 2.0.6 → 2.1.0
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/JsiSkPath.h +2 -1
- package/cpp/api/JsiSkPathFactory.h +1 -1
- 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 +16 -0
- package/cpp/api/recorder/Drawings.h +23 -0
- package/cpp/api/recorder/JsiRecorder.h +6 -0
- package/cpp/api/recorder/RNRecorder.h +9 -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 +5 -1
- package/lib/commonjs/dom/types/Drawings.js.map +1 -1
- package/lib/commonjs/dom/types/NodeType.d.ts +2 -1
- package/lib/commonjs/dom/types/NodeType.js +2 -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/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/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 +1 -0
- package/lib/commonjs/renderer/components/index.js +11 -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 +2 -1
- package/lib/commonjs/sksg/Elements.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 +1 -1
- 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 +5 -1
- package/lib/module/dom/types/Drawings.js.map +1 -1
- package/lib/module/dom/types/NodeType.d.ts +2 -1
- package/lib/module/dom/types/NodeType.js +2 -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/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/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 +1 -0
- package/lib/module/renderer/components/index.js +1 -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 +2 -1
- package/lib/module/sksg/Elements.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 +1 -1
- package/lib/module/sksg/Recorder/commands/ImageFilters.js.map +1 -1
- 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 +7 -0
- package/lib/typescript/lib/module/renderer/components/Skottie.d.ts +2 -0
- package/lib/typescript/lib/module/renderer/components/index.d.ts +1 -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 +5 -1
- package/lib/typescript/src/dom/types/NodeType.d.ts +2 -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/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/Skottie.d.ts +4 -0
- package/lib/typescript/src/renderer/components/index.d.ts +1 -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 +2 -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 +9 -9
- package/libs/apple/libskia.xcframework/Info.plist +14 -14
- package/libs/apple/libskottie.xcframework/Info.plist +13 -13
- package/libs/apple/libskparagraph.xcframework/Info.plist +15 -15
- package/libs/apple/libsksg.xcframework/Info.plist +13 -13
- package/libs/apple/libskshaper.xcframework/Info.plist +15 -15
- package/libs/apple/libskunicode_core.xcframework/Info.plist +9 -9
- package/libs/apple/libskunicode_libgrapheme.xcframework/Info.plist +13 -13
- package/libs/apple/libsvg.xcframework/Info.plist +15 -15
- 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 +6 -0
- package/src/dom/types/NodeType.ts +2 -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/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 +23 -0
- package/src/renderer/components/Skottie.tsx +8 -0
- package/src/renderer/components/index.ts +1 -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 +2 -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 +1 -1
- package/cpp/skia/include/pathops/SkPathOps.h +0 -17
@@ -0,0 +1,313 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright 2017 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 Skottie_DEFINED
|
9
|
+
#define Skottie_DEFINED
|
10
|
+
|
11
|
+
#include "include/core/SkRefCnt.h"
|
12
|
+
#include "include/core/SkScalar.h"
|
13
|
+
#include "include/core/SkSize.h"
|
14
|
+
#include "include/core/SkString.h"
|
15
|
+
#include "include/core/SkTypes.h"
|
16
|
+
#include "modules/skresources/include/SkResources.h"
|
17
|
+
|
18
|
+
// TODO(kjlubick) update clients and then remove the following:
|
19
|
+
#include "include/core/SkFontMgr.h" // IWYU pragma: keep
|
20
|
+
#include "modules/skottie/include/ExternalLayer.h" // IWYU pragma: keep
|
21
|
+
#include "modules/skottie/include/SkottieProperty.h" // IWYU pragma: keep
|
22
|
+
#include "modules/skottie/include/SlotManager.h" // IWYU pragma: keep
|
23
|
+
|
24
|
+
#include <cstddef>
|
25
|
+
#include <cstdint>
|
26
|
+
#include <vector>
|
27
|
+
|
28
|
+
class SkCanvas;
|
29
|
+
class SkStream;
|
30
|
+
struct SkRect;
|
31
|
+
|
32
|
+
namespace sksg {
|
33
|
+
|
34
|
+
class InvalidationController;
|
35
|
+
class RenderNode;
|
36
|
+
|
37
|
+
} // namespace sksg
|
38
|
+
|
39
|
+
namespace SkShapers { class Factory; }
|
40
|
+
|
41
|
+
namespace skottie {
|
42
|
+
|
43
|
+
namespace internal { class Animator; }
|
44
|
+
|
45
|
+
using ImageAsset = skresources::ImageAsset;
|
46
|
+
using ResourceProvider = skresources::ResourceProvider;
|
47
|
+
|
48
|
+
/**
|
49
|
+
* A Logger subclass can be used to receive Animation::Builder parsing errors and warnings.
|
50
|
+
*/
|
51
|
+
class SK_API Logger : public SkRefCnt {
|
52
|
+
public:
|
53
|
+
enum class Level {
|
54
|
+
kWarning,
|
55
|
+
kError,
|
56
|
+
};
|
57
|
+
|
58
|
+
virtual void log(Level, const char message[], const char* json = nullptr) = 0;
|
59
|
+
};
|
60
|
+
|
61
|
+
// Evaluates AE expressions.
|
62
|
+
template <class T>
|
63
|
+
class SK_API ExpressionEvaluator : public SkRefCnt {
|
64
|
+
public:
|
65
|
+
// Evaluate the expression at the current time.
|
66
|
+
virtual T evaluate(float t) = 0;
|
67
|
+
};
|
68
|
+
|
69
|
+
/**
|
70
|
+
* Creates ExpressionEvaluators to evaluate AE expressions and return the results.
|
71
|
+
*/
|
72
|
+
class SK_API ExpressionManager : public SkRefCnt {
|
73
|
+
public:
|
74
|
+
virtual sk_sp<ExpressionEvaluator<float>> createNumberExpressionEvaluator(
|
75
|
+
const char expression[]) = 0;
|
76
|
+
|
77
|
+
virtual sk_sp<ExpressionEvaluator<SkString>> createStringExpressionEvaluator(
|
78
|
+
const char expression[]) = 0;
|
79
|
+
|
80
|
+
virtual sk_sp<ExpressionEvaluator<std::vector<float>>> createArrayExpressionEvaluator(
|
81
|
+
const char expression[]) = 0;
|
82
|
+
};
|
83
|
+
|
84
|
+
/**
|
85
|
+
* Interface for receiving AE composition markers at Animation build time.
|
86
|
+
*/
|
87
|
+
class SK_API MarkerObserver : public SkRefCnt {
|
88
|
+
public:
|
89
|
+
// t0,t1 are in the Animation::seek() domain.
|
90
|
+
virtual void onMarker(const char name[], float t0, float t1) = 0;
|
91
|
+
};
|
92
|
+
|
93
|
+
class SK_API Animation : public SkNVRefCnt<Animation> {
|
94
|
+
public:
|
95
|
+
class SK_API Builder final {
|
96
|
+
public:
|
97
|
+
enum Flags : uint32_t {
|
98
|
+
kDeferImageLoading = 0x01, // Normally, all static image frames are resolved at
|
99
|
+
// load time via ImageAsset::getFrame(0). With this flag,
|
100
|
+
// frames are only resolved when needed, at seek() time.
|
101
|
+
kPreferEmbeddedFonts = 0x02, // Attempt to use the embedded fonts (glyph paths,
|
102
|
+
// normally used as fallback) over native Skia typefaces.
|
103
|
+
};
|
104
|
+
|
105
|
+
explicit Builder(uint32_t flags = 0);
|
106
|
+
Builder(const Builder&);
|
107
|
+
Builder(Builder&&);
|
108
|
+
~Builder();
|
109
|
+
|
110
|
+
struct Stats {
|
111
|
+
float fTotalLoadTimeMS = 0, // Total animation instantiation time.
|
112
|
+
fJsonParseTimeMS = 0, // Time spent building a JSON DOM.
|
113
|
+
fSceneParseTimeMS = 0; // Time spent constructing the animation scene graph.
|
114
|
+
size_t fJsonSize = 0, // Input JSON size.
|
115
|
+
fAnimatorCount = 0; // Number of dynamically animated properties.
|
116
|
+
};
|
117
|
+
|
118
|
+
/**
|
119
|
+
* Returns various animation build stats.
|
120
|
+
*
|
121
|
+
* @return Stats (see above).
|
122
|
+
*/
|
123
|
+
const Stats& getStats() const { return fStats; }
|
124
|
+
|
125
|
+
/**
|
126
|
+
* Specify a loader for external resources (images, etc.).
|
127
|
+
*/
|
128
|
+
Builder& setResourceProvider(sk_sp<ResourceProvider>);
|
129
|
+
|
130
|
+
/**
|
131
|
+
* Specify a font manager for loading animation fonts.
|
132
|
+
*/
|
133
|
+
Builder& setFontManager(sk_sp<SkFontMgr>);
|
134
|
+
|
135
|
+
/**
|
136
|
+
* Specify a PropertyObserver to receive callbacks during parsing.
|
137
|
+
*
|
138
|
+
* See SkottieProperty.h for more details.
|
139
|
+
*
|
140
|
+
*/
|
141
|
+
Builder& setPropertyObserver(sk_sp<PropertyObserver>);
|
142
|
+
|
143
|
+
/**
|
144
|
+
* Register a Logger with this builder.
|
145
|
+
*/
|
146
|
+
Builder& setLogger(sk_sp<Logger>);
|
147
|
+
|
148
|
+
/**
|
149
|
+
* Register a MarkerObserver with this builder.
|
150
|
+
*/
|
151
|
+
Builder& setMarkerObserver(sk_sp<MarkerObserver>);
|
152
|
+
|
153
|
+
/**
|
154
|
+
* Register a precomp layer interceptor.
|
155
|
+
* This allows substituting precomp layers with custom/externally managed content.
|
156
|
+
*/
|
157
|
+
Builder& setPrecompInterceptor(sk_sp<PrecompInterceptor>);
|
158
|
+
|
159
|
+
/**
|
160
|
+
* Registers an ExpressionManager to evaluate AE expressions.
|
161
|
+
* If unspecified, expressions in the animation JSON will be ignored.
|
162
|
+
*/
|
163
|
+
Builder& setExpressionManager(sk_sp<ExpressionManager>);
|
164
|
+
|
165
|
+
/**
|
166
|
+
* Registers a factory to be used when shaping text.
|
167
|
+
* If unspecified, text will be shaped with primitive shaping.
|
168
|
+
* See //modules/skshaper/utils/FactoryHelpers.h
|
169
|
+
*/
|
170
|
+
Builder& setTextShapingFactory(sk_sp<SkShapers::Factory>);
|
171
|
+
|
172
|
+
/**
|
173
|
+
* Animation factories.
|
174
|
+
*/
|
175
|
+
sk_sp<Animation> make(SkStream*);
|
176
|
+
sk_sp<Animation> make(const char* data, size_t length);
|
177
|
+
sk_sp<Animation> makeFromFile(const char path[]);
|
178
|
+
|
179
|
+
/**
|
180
|
+
* Get handle for SlotManager after animation is built.
|
181
|
+
*/
|
182
|
+
const sk_sp<SlotManager>& getSlotManager() const {return fSlotManager;}
|
183
|
+
|
184
|
+
private:
|
185
|
+
const uint32_t fFlags;
|
186
|
+
|
187
|
+
sk_sp<ResourceProvider> fResourceProvider;
|
188
|
+
sk_sp<SkFontMgr> fFontMgr;
|
189
|
+
sk_sp<PropertyObserver> fPropertyObserver;
|
190
|
+
sk_sp<Logger> fLogger;
|
191
|
+
sk_sp<MarkerObserver > fMarkerObserver;
|
192
|
+
sk_sp<PrecompInterceptor> fPrecompInterceptor;
|
193
|
+
sk_sp<ExpressionManager> fExpressionManager;
|
194
|
+
sk_sp<SkShapers::Factory> fShapingFactory;
|
195
|
+
sk_sp<SlotManager> fSlotManager;
|
196
|
+
Stats fStats;
|
197
|
+
};
|
198
|
+
|
199
|
+
/**
|
200
|
+
* Animation factories.
|
201
|
+
*
|
202
|
+
* Use the Builder helper above for more options/control.
|
203
|
+
*/
|
204
|
+
static sk_sp<Animation> Make(const char* data, size_t length);
|
205
|
+
static sk_sp<Animation> Make(SkStream*);
|
206
|
+
static sk_sp<Animation> MakeFromFile(const char path[]);
|
207
|
+
|
208
|
+
~Animation();
|
209
|
+
|
210
|
+
enum RenderFlag : uint32_t {
|
211
|
+
// When rendering into a known transparent buffer, clients can pass
|
212
|
+
// this flag to avoid some unnecessary compositing overhead for
|
213
|
+
// animations using layer blend modes.
|
214
|
+
kSkipTopLevelIsolation = 0x01,
|
215
|
+
// By default, content is clipped to the intrinsic animation
|
216
|
+
// bounds (as determined by its size). If this flag is set,
|
217
|
+
// then the animation can draw outside of the bounds.
|
218
|
+
kDisableTopLevelClipping = 0x02,
|
219
|
+
};
|
220
|
+
using RenderFlags = uint32_t;
|
221
|
+
|
222
|
+
/**
|
223
|
+
* Draws the current animation frame.
|
224
|
+
*
|
225
|
+
* It is undefined behavior to call render() on a newly created Animation
|
226
|
+
* before specifying an initial frame via one of the seek() variants.
|
227
|
+
*
|
228
|
+
* @param canvas destination canvas
|
229
|
+
* @param dst optional destination rect
|
230
|
+
* @param flags optional RenderFlags
|
231
|
+
*/
|
232
|
+
void render(SkCanvas* canvas, const SkRect* dst = nullptr) const;
|
233
|
+
void render(SkCanvas* canvas, const SkRect* dst, RenderFlags) const;
|
234
|
+
|
235
|
+
/**
|
236
|
+
* [Deprecated: use one of the other versions.]
|
237
|
+
*
|
238
|
+
* Updates the animation state for |t|.
|
239
|
+
*
|
240
|
+
* @param t normalized [0..1] frame selector (0 -> first frame, 1 -> final frame)
|
241
|
+
* @param ic optional invalidation controller (dirty region tracking)
|
242
|
+
*
|
243
|
+
*/
|
244
|
+
void seek(SkScalar t, sksg::InvalidationController* ic = nullptr) {
|
245
|
+
this->seekFrameTime(t * this->duration(), ic);
|
246
|
+
}
|
247
|
+
|
248
|
+
/**
|
249
|
+
* Update the animation state to match |t|, specified as a frame index
|
250
|
+
* i.e. relative to duration() * fps().
|
251
|
+
*
|
252
|
+
* Fractional values are allowed and meaningful - e.g.
|
253
|
+
*
|
254
|
+
* 0.0 -> first frame
|
255
|
+
* 1.0 -> second frame
|
256
|
+
* 0.5 -> halfway between first and second frame
|
257
|
+
*/
|
258
|
+
void seekFrame(double t, sksg::InvalidationController* ic = nullptr);
|
259
|
+
|
260
|
+
/** Update the animation state to match t, specifed in frame time
|
261
|
+
* i.e. relative to duration().
|
262
|
+
*/
|
263
|
+
void seekFrameTime(double t, sksg::InvalidationController* = nullptr);
|
264
|
+
|
265
|
+
/**
|
266
|
+
* Returns the animation duration in seconds.
|
267
|
+
*/
|
268
|
+
double duration() const { return fDuration; }
|
269
|
+
|
270
|
+
/**
|
271
|
+
* Returns the animation frame rate (frames / second).
|
272
|
+
*/
|
273
|
+
double fps() const { return fFPS; }
|
274
|
+
|
275
|
+
/**
|
276
|
+
* Animation in point, in frame index units.
|
277
|
+
*/
|
278
|
+
double inPoint() const { return fInPoint; }
|
279
|
+
|
280
|
+
/**
|
281
|
+
* Animation out point, in frame index units.
|
282
|
+
*/
|
283
|
+
double outPoint() const { return fOutPoint; }
|
284
|
+
|
285
|
+
const SkString& version() const { return fVersion; }
|
286
|
+
const SkSize& size() const { return fSize; }
|
287
|
+
|
288
|
+
private:
|
289
|
+
enum Flags : uint32_t {
|
290
|
+
kRequiresTopLevelIsolation = 1 << 0, // Needs to draw into a layer due to layer blending.
|
291
|
+
};
|
292
|
+
|
293
|
+
Animation(sk_sp<sksg::RenderNode>,
|
294
|
+
std::vector<sk_sp<internal::Animator>>&&,
|
295
|
+
SkString ver, const SkSize& size,
|
296
|
+
double inPoint, double outPoint, double duration, double fps, uint32_t flags);
|
297
|
+
|
298
|
+
const sk_sp<sksg::RenderNode> fSceneRoot;
|
299
|
+
const std::vector<sk_sp<internal::Animator>> fAnimators;
|
300
|
+
const SkString fVersion;
|
301
|
+
const SkSize fSize;
|
302
|
+
const double fInPoint,
|
303
|
+
fOutPoint,
|
304
|
+
fDuration,
|
305
|
+
fFPS;
|
306
|
+
const uint32_t fFlags;
|
307
|
+
|
308
|
+
using INHERITED = SkNVRefCnt<Animation>;
|
309
|
+
};
|
310
|
+
|
311
|
+
} // namespace skottie
|
312
|
+
|
313
|
+
#endif // Skottie_DEFINED
|
@@ -0,0 +1,190 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright 2018 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 SkottieProperty_DEFINED
|
9
|
+
#define SkottieProperty_DEFINED
|
10
|
+
|
11
|
+
#include "include/core/SkColor.h"
|
12
|
+
#include "include/core/SkMatrix.h"
|
13
|
+
#include "include/core/SkPaint.h"
|
14
|
+
#include "include/core/SkPoint.h"
|
15
|
+
#include "include/core/SkRect.h"
|
16
|
+
#include "include/core/SkRefCnt.h"
|
17
|
+
#include "include/core/SkScalar.h"
|
18
|
+
#include "include/core/SkSpan.h"
|
19
|
+
#include "include/core/SkString.h"
|
20
|
+
#include "include/core/SkTypeface.h"
|
21
|
+
#include "include/private/base/SkAPI.h"
|
22
|
+
#include "include/utils/SkTextUtils.h"
|
23
|
+
#include "modules/skottie/include/TextShaper.h"
|
24
|
+
|
25
|
+
#include <cstddef>
|
26
|
+
#include <cstdint>
|
27
|
+
#include <functional>
|
28
|
+
#include <limits>
|
29
|
+
#include <memory>
|
30
|
+
#include <utility>
|
31
|
+
|
32
|
+
class SkCanvas;
|
33
|
+
|
34
|
+
namespace sksg {
|
35
|
+
|
36
|
+
class Color;
|
37
|
+
class OpacityEffect;
|
38
|
+
|
39
|
+
} // namespace sksg
|
40
|
+
|
41
|
+
namespace skottie {
|
42
|
+
|
43
|
+
using ColorPropertyValue = SkColor;
|
44
|
+
using OpacityPropertyValue = float;
|
45
|
+
|
46
|
+
enum class TextPaintOrder : uint8_t {
|
47
|
+
kFillStroke,
|
48
|
+
kStrokeFill,
|
49
|
+
};
|
50
|
+
|
51
|
+
// Optional callback invoked when drawing text layers.
|
52
|
+
// Allows clients to render custom text decorations.
|
53
|
+
class GlyphDecorator : public SkRefCnt {
|
54
|
+
public:
|
55
|
+
struct GlyphInfo {
|
56
|
+
SkRect fBounds; // visual glyph bounds
|
57
|
+
SkMatrix fMatrix; // glyph matrix
|
58
|
+
size_t fCluster; // cluster index in the original text string
|
59
|
+
float fAdvance; // horizontal glyph advance
|
60
|
+
};
|
61
|
+
|
62
|
+
struct TextInfo {
|
63
|
+
SkSpan<const GlyphInfo> fGlyphs;
|
64
|
+
float fScale; // Additional font scale applied by auto-sizing.
|
65
|
+
};
|
66
|
+
|
67
|
+
virtual void onDecorate(SkCanvas*, const TextInfo&) = 0;
|
68
|
+
};
|
69
|
+
|
70
|
+
struct TextPropertyValue {
|
71
|
+
sk_sp<SkTypeface> fTypeface;
|
72
|
+
SkString fText;
|
73
|
+
float fTextSize = 0,
|
74
|
+
fMinTextSize = 0, // when auto-sizing
|
75
|
+
fMaxTextSize = std::numeric_limits<float>::max(), // when auto-sizing
|
76
|
+
fStrokeWidth = 0,
|
77
|
+
fLineHeight = 0,
|
78
|
+
fLineShift = 0,
|
79
|
+
fAscent = 0;
|
80
|
+
size_t fMaxLines = 0; // when auto-sizing
|
81
|
+
SkTextUtils::Align fHAlign = SkTextUtils::kLeft_Align;
|
82
|
+
Shaper::VAlign fVAlign = Shaper::VAlign::kTop;
|
83
|
+
Shaper::ResizePolicy fResize = Shaper::ResizePolicy::kNone;
|
84
|
+
Shaper::LinebreakPolicy fLineBreak = Shaper::LinebreakPolicy::kExplicit;
|
85
|
+
Shaper::Direction fDirection = Shaper::Direction::kLTR;
|
86
|
+
Shaper::Capitalization fCapitalization = Shaper::Capitalization::kNone;
|
87
|
+
SkRect fBox = SkRect::MakeEmpty();
|
88
|
+
SkColor fFillColor = SK_ColorTRANSPARENT,
|
89
|
+
fStrokeColor = SK_ColorTRANSPARENT;
|
90
|
+
TextPaintOrder fPaintOrder = TextPaintOrder::kFillStroke;
|
91
|
+
SkPaint::Join fStrokeJoin = SkPaint::Join::kMiter_Join;
|
92
|
+
bool fHasFill = false,
|
93
|
+
fHasStroke = false;
|
94
|
+
sk_sp<GlyphDecorator> fDecorator;
|
95
|
+
// The locale to be used for text shaping, in BCP47 form. This includes
|
96
|
+
// support for RFC6067 extensions, so one can e.g. select strict line
|
97
|
+
// breaking rules for certain scripts: ja-u-lb-strict.
|
98
|
+
// Pass an empty string to use the system locale.
|
99
|
+
SkString fLocale;
|
100
|
+
// Optional font family name, to be passed to the font manager for
|
101
|
+
// fallback.
|
102
|
+
SkString fFontFamily;
|
103
|
+
|
104
|
+
bool operator==(const TextPropertyValue& other) const;
|
105
|
+
bool operator!=(const TextPropertyValue& other) const;
|
106
|
+
};
|
107
|
+
|
108
|
+
struct TransformPropertyValue {
|
109
|
+
SkPoint fAnchorPoint,
|
110
|
+
fPosition;
|
111
|
+
SkVector fScale;
|
112
|
+
SkScalar fRotation,
|
113
|
+
fSkew,
|
114
|
+
fSkewAxis;
|
115
|
+
|
116
|
+
bool operator==(const TransformPropertyValue& other) const;
|
117
|
+
bool operator!=(const TransformPropertyValue& other) const;
|
118
|
+
};
|
119
|
+
|
120
|
+
namespace internal { class SceneGraphRevalidator; }
|
121
|
+
|
122
|
+
/**
|
123
|
+
* Property handles are adapters between user-facing AE model/values
|
124
|
+
* and the internal scene-graph representation.
|
125
|
+
*/
|
126
|
+
template <typename ValueT, typename NodeT>
|
127
|
+
class SK_API PropertyHandle final {
|
128
|
+
public:
|
129
|
+
explicit PropertyHandle(sk_sp<NodeT>);
|
130
|
+
PropertyHandle(sk_sp<NodeT> node, sk_sp<internal::SceneGraphRevalidator> revalidator)
|
131
|
+
: fNode(std::move(node))
|
132
|
+
, fRevalidator(std::move(revalidator)) {}
|
133
|
+
~PropertyHandle();
|
134
|
+
|
135
|
+
PropertyHandle(const PropertyHandle&);
|
136
|
+
|
137
|
+
ValueT get() const;
|
138
|
+
void set(const ValueT&);
|
139
|
+
|
140
|
+
private:
|
141
|
+
const sk_sp<NodeT> fNode;
|
142
|
+
const sk_sp<internal::SceneGraphRevalidator> fRevalidator;
|
143
|
+
};
|
144
|
+
|
145
|
+
namespace internal {
|
146
|
+
|
147
|
+
class TextAdapter;
|
148
|
+
class TransformAdapter2D;
|
149
|
+
|
150
|
+
} // namespace internal
|
151
|
+
|
152
|
+
using ColorPropertyHandle = PropertyHandle<ColorPropertyValue,
|
153
|
+
sksg::Color>;
|
154
|
+
using OpacityPropertyHandle = PropertyHandle<OpacityPropertyValue,
|
155
|
+
sksg::OpacityEffect>;
|
156
|
+
using TextPropertyHandle = PropertyHandle<TextPropertyValue,
|
157
|
+
internal::TextAdapter>;
|
158
|
+
using TransformPropertyHandle = PropertyHandle<TransformPropertyValue,
|
159
|
+
internal::TransformAdapter2D>;
|
160
|
+
|
161
|
+
/**
|
162
|
+
* A PropertyObserver can be used to track and manipulate certain properties of "interesting"
|
163
|
+
* Lottie nodes.
|
164
|
+
*
|
165
|
+
* When registered with an animation builder, PropertyObserver receives notifications for
|
166
|
+
* various properties of layer and shape nodes. The |node_name| argument corresponds to the
|
167
|
+
* name ("nm") node property.
|
168
|
+
*/
|
169
|
+
class SK_API PropertyObserver : public SkRefCnt {
|
170
|
+
public:
|
171
|
+
enum class NodeType {COMPOSITION, LAYER, EFFECT, OTHER};
|
172
|
+
|
173
|
+
template <typename T>
|
174
|
+
using LazyHandle = std::function<std::unique_ptr<T>()>;
|
175
|
+
|
176
|
+
virtual void onColorProperty (const char node_name[],
|
177
|
+
const LazyHandle<ColorPropertyHandle>&);
|
178
|
+
virtual void onOpacityProperty (const char node_name[],
|
179
|
+
const LazyHandle<OpacityPropertyHandle>&);
|
180
|
+
virtual void onTextProperty (const char node_name[],
|
181
|
+
const LazyHandle<TextPropertyHandle>&);
|
182
|
+
virtual void onTransformProperty(const char node_name[],
|
183
|
+
const LazyHandle<TransformPropertyHandle>&);
|
184
|
+
virtual void onEnterNode(const char node_name[], NodeType node_type);
|
185
|
+
virtual void onLeavingNode(const char node_name[], NodeType node_type);
|
186
|
+
};
|
187
|
+
|
188
|
+
} // namespace skottie
|
189
|
+
|
190
|
+
#endif // SkottieProperty_DEFINED
|
@@ -0,0 +1,113 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright 2023 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 SlotManager_DEFINED
|
9
|
+
#define SlotManager_DEFINED
|
10
|
+
|
11
|
+
#include "include/core/SkColor.h"
|
12
|
+
#include "include/core/SkRefCnt.h"
|
13
|
+
#include "include/core/SkString.h"
|
14
|
+
#include "include/private/base/SkAPI.h"
|
15
|
+
#include "include/private/base/SkTArray.h"
|
16
|
+
#include "modules/skottie/src/SkottieValue.h"
|
17
|
+
#include "modules/skottie/src/text/TextAdapter.h"
|
18
|
+
#include "src/core/SkTHash.h"
|
19
|
+
|
20
|
+
#include <optional>
|
21
|
+
|
22
|
+
struct SkV2;
|
23
|
+
|
24
|
+
namespace skresources {
|
25
|
+
class ImageAsset;
|
26
|
+
}
|
27
|
+
|
28
|
+
namespace skottie {
|
29
|
+
|
30
|
+
struct TextPropertyValue;
|
31
|
+
|
32
|
+
namespace internal {
|
33
|
+
class AnimationBuilder;
|
34
|
+
class SceneGraphRevalidator;
|
35
|
+
class AnimatablePropertyContainer;
|
36
|
+
} // namespace internal
|
37
|
+
|
38
|
+
using namespace skia_private;
|
39
|
+
|
40
|
+
class SK_API SlotManager final : public SkRefCnt {
|
41
|
+
|
42
|
+
public:
|
43
|
+
using SlotID = SkString;
|
44
|
+
|
45
|
+
SlotManager(sk_sp<skottie::internal::SceneGraphRevalidator>);
|
46
|
+
~SlotManager() override;
|
47
|
+
|
48
|
+
bool setColorSlot(const SlotID&, SkColor);
|
49
|
+
bool setImageSlot(const SlotID&, const sk_sp<skresources::ImageAsset>&);
|
50
|
+
bool setScalarSlot(const SlotID&, float);
|
51
|
+
bool setVec2Slot(const SlotID&, SkV2);
|
52
|
+
bool setTextSlot(const SlotID&, const TextPropertyValue&);
|
53
|
+
|
54
|
+
std::optional<SkColor> getColorSlot(const SlotID&) const;
|
55
|
+
sk_sp<const skresources::ImageAsset> getImageSlot(const SlotID&) const;
|
56
|
+
std::optional<float> getScalarSlot(const SlotID&) const;
|
57
|
+
std::optional<SkV2> getVec2Slot(const SlotID&) const;
|
58
|
+
std::optional<TextPropertyValue> getTextSlot(const SlotID&) const;
|
59
|
+
|
60
|
+
struct SlotInfo {
|
61
|
+
TArray<SlotID> fColorSlotIDs;
|
62
|
+
TArray<SlotID> fScalarSlotIDs;
|
63
|
+
TArray<SlotID> fVec2SlotIDs;
|
64
|
+
TArray<SlotID> fImageSlotIDs;
|
65
|
+
TArray<SlotID> fTextSlotIDs;
|
66
|
+
};
|
67
|
+
|
68
|
+
// Helper function to get all slot IDs and their value types
|
69
|
+
SlotInfo getSlotInfo() const;
|
70
|
+
|
71
|
+
private:
|
72
|
+
|
73
|
+
// pass value to the SlotManager for manipulation and node for invalidation
|
74
|
+
void trackColorValue(const SlotID&, ColorValue*,
|
75
|
+
sk_sp<skottie::internal::AnimatablePropertyContainer>);
|
76
|
+
sk_sp<skresources::ImageAsset> trackImageValue(const SlotID&, sk_sp<skresources::ImageAsset>);
|
77
|
+
void trackScalarValue(const SlotID&, ScalarValue*,
|
78
|
+
sk_sp<skottie::internal::AnimatablePropertyContainer>);
|
79
|
+
void trackVec2Value(const SlotID&, Vec2Value*,
|
80
|
+
sk_sp<skottie::internal::AnimatablePropertyContainer>);
|
81
|
+
void trackTextValue(const SlotID&, sk_sp<skottie::internal::TextAdapter>);
|
82
|
+
|
83
|
+
// ValuePair tracks a pointer to a value to change, and a means to invalidate the render tree.
|
84
|
+
// For the latter, we can take either a node in the scene graph that directly the scene graph,
|
85
|
+
// or an adapter which takes the value passed and interprets it before pushing to the scene
|
86
|
+
// (clamping, normalizing, etc.)
|
87
|
+
// Only one should be set, it is UB to create a ValuePair with both a node and an adapter.
|
88
|
+
template <typename T>
|
89
|
+
struct ValuePair
|
90
|
+
{
|
91
|
+
T value;
|
92
|
+
sk_sp<skottie::internal::AnimatablePropertyContainer> adapter;
|
93
|
+
};
|
94
|
+
|
95
|
+
class ImageAssetProxy;
|
96
|
+
template <typename T>
|
97
|
+
using SlotMap = THashMap<SlotID, TArray<T>>;
|
98
|
+
|
99
|
+
SlotMap<ValuePair<ColorValue*>> fColorMap;
|
100
|
+
SlotMap<ValuePair<ScalarValue*>> fScalarMap;
|
101
|
+
SlotMap<ValuePair<Vec2Value*>> fVec2Map;
|
102
|
+
SlotMap<sk_sp<ImageAssetProxy>> fImageMap;
|
103
|
+
SlotMap<sk_sp<skottie::internal::TextAdapter>> fTextMap;
|
104
|
+
|
105
|
+
const sk_sp<skottie::internal::SceneGraphRevalidator> fRevalidator;
|
106
|
+
|
107
|
+
friend class skottie::internal::AnimationBuilder;
|
108
|
+
friend class skottie::internal::AnimatablePropertyContainer;
|
109
|
+
};
|
110
|
+
|
111
|
+
} // namespace skottie
|
112
|
+
|
113
|
+
#endif // SlotManager_DEFINED
|