@shopify/react-native-skia 2.0.7 → 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/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 +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 +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
@@ -0,0 +1,200 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright 2019 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 SkottieTextShaper_DEFINED
|
9
|
+
#define SkottieTextShaper_DEFINED
|
10
|
+
|
11
|
+
#include "include/core/SkFont.h"
|
12
|
+
#include "include/core/SkPoint.h"
|
13
|
+
#include "include/core/SkRefCnt.h"
|
14
|
+
#include "include/core/SkScalar.h"
|
15
|
+
#include "include/core/SkTypes.h"
|
16
|
+
#include "include/private/base/SkTypeTraits.h"
|
17
|
+
#include "include/utils/SkTextUtils.h"
|
18
|
+
|
19
|
+
#include <cstddef>
|
20
|
+
#include <cstdint>
|
21
|
+
#include <type_traits>
|
22
|
+
#include <vector>
|
23
|
+
|
24
|
+
class SkCanvas;
|
25
|
+
class SkFontMgr;
|
26
|
+
class SkPaint;
|
27
|
+
class SkString;
|
28
|
+
class SkTypeface;
|
29
|
+
struct SkRect;
|
30
|
+
|
31
|
+
namespace SkShapers { class Factory; }
|
32
|
+
|
33
|
+
namespace skottie {
|
34
|
+
|
35
|
+
// Helper implementing After Effects text shaping semantics on top of SkShaper.
|
36
|
+
|
37
|
+
class Shaper final {
|
38
|
+
public:
|
39
|
+
struct RunRec {
|
40
|
+
SkFont fFont;
|
41
|
+
size_t fSize;
|
42
|
+
|
43
|
+
static_assert(::sk_is_trivially_relocatable<decltype(fFont)>::value);
|
44
|
+
|
45
|
+
using sk_is_trivially_relocatable = std::true_type;
|
46
|
+
};
|
47
|
+
|
48
|
+
struct ShapedGlyphs {
|
49
|
+
std::vector<RunRec> fRuns;
|
50
|
+
|
51
|
+
// Consolidated storage for all runs.
|
52
|
+
std::vector<SkGlyphID> fGlyphIDs;
|
53
|
+
std::vector<SkPoint> fGlyphPos;
|
54
|
+
|
55
|
+
// fClusters[i] is an input string index, pointing to the start of the UTF sequence
|
56
|
+
// associated with fGlyphs[i]. The number of entries matches the number of glyphs.
|
57
|
+
// Only available with Flags::kClusters.
|
58
|
+
std::vector<size_t> fClusters;
|
59
|
+
|
60
|
+
enum class BoundsType { kConservative, kTight };
|
61
|
+
SkRect computeBounds(BoundsType) const;
|
62
|
+
|
63
|
+
void draw(SkCanvas*, const SkPoint& origin, const SkPaint&) const;
|
64
|
+
};
|
65
|
+
|
66
|
+
struct Fragment {
|
67
|
+
ShapedGlyphs fGlyphs;
|
68
|
+
SkPoint fOrigin;
|
69
|
+
|
70
|
+
// Only valid for kFragmentGlyphs
|
71
|
+
float fAdvance,
|
72
|
+
fAscent;
|
73
|
+
uint32_t fLineIndex; // 0-based index for the line this fragment belongs to.
|
74
|
+
bool fIsWhitespace; // True if the first code point in the corresponding
|
75
|
+
// cluster is whitespace.
|
76
|
+
};
|
77
|
+
|
78
|
+
struct Result {
|
79
|
+
std::vector<Fragment> fFragments;
|
80
|
+
size_t fMissingGlyphCount = 0;
|
81
|
+
// Relative text size scale, when using an auto-scaling ResizePolicy
|
82
|
+
// (otherwise 1.0). This is informative of the final text size, and is
|
83
|
+
// not required to render the Result.
|
84
|
+
float fScale = 1.0f;
|
85
|
+
|
86
|
+
SkRect computeVisualBounds() const;
|
87
|
+
};
|
88
|
+
|
89
|
+
enum class VAlign : uint8_t {
|
90
|
+
// Align the first line typographical top with the text box top (AE box text).
|
91
|
+
kTop,
|
92
|
+
// Align the first line typographical baseline with the text box top (AE point text).
|
93
|
+
kTopBaseline,
|
94
|
+
|
95
|
+
// Skottie vertical alignment extensions
|
96
|
+
|
97
|
+
// These are based on a hybrid extent box defined (in Y) as
|
98
|
+
//
|
99
|
+
// ------------------------------------------------------
|
100
|
+
// MIN(visual_top_extent , typographical_top_extent )
|
101
|
+
//
|
102
|
+
// ...
|
103
|
+
//
|
104
|
+
// MAX(visual_bottom_extent, typographical_bottom_extent)
|
105
|
+
// ------------------------------------------------------
|
106
|
+
kHybridTop, // extent box top -> text box top
|
107
|
+
kHybridCenter, // extent box center -> text box center
|
108
|
+
kHybridBottom, // extent box bottom -> text box bottom
|
109
|
+
|
110
|
+
// Visual alignement modes -- these are using tight visual bounds for the paragraph.
|
111
|
+
kVisualTop, // visual top -> text box top
|
112
|
+
kVisualCenter, // visual center -> text box center
|
113
|
+
kVisualBottom, // visual bottom -> text box bottom
|
114
|
+
};
|
115
|
+
|
116
|
+
enum class ResizePolicy : uint8_t {
|
117
|
+
// Use the specified text size.
|
118
|
+
kNone,
|
119
|
+
// Resize the text such that the extent box fits (snuggly) in the text box,
|
120
|
+
// both horizontally and vertically.
|
121
|
+
kScaleToFit,
|
122
|
+
// Same kScaleToFit if the text doesn't fit at the specified font size.
|
123
|
+
// Otherwise, same as kNone.
|
124
|
+
kDownscaleToFit,
|
125
|
+
};
|
126
|
+
|
127
|
+
enum class LinebreakPolicy : uint8_t {
|
128
|
+
// Break lines such that they fit in a non-empty paragraph box, horizontally.
|
129
|
+
kParagraph,
|
130
|
+
// Only break lines when requested explicitly (\r), regardless of paragraph box dimensions.
|
131
|
+
kExplicit,
|
132
|
+
};
|
133
|
+
|
134
|
+
// Initial text direction.
|
135
|
+
enum class Direction : uint8_t { kLTR, kRTL };
|
136
|
+
|
137
|
+
enum class Capitalization {
|
138
|
+
kNone,
|
139
|
+
kUpperCase,
|
140
|
+
};
|
141
|
+
|
142
|
+
enum Flags : uint32_t {
|
143
|
+
kNone = 0x00,
|
144
|
+
|
145
|
+
// Split out individual glyphs into separate Fragments
|
146
|
+
// (useful when the caller intends to manipulate glyphs independently).
|
147
|
+
kFragmentGlyphs = 0x01,
|
148
|
+
|
149
|
+
// Compute the advance and ascent for each fragment.
|
150
|
+
kTrackFragmentAdvanceAscent = 0x02,
|
151
|
+
|
152
|
+
// Return cluster information.
|
153
|
+
kClusters = 0x04,
|
154
|
+
};
|
155
|
+
|
156
|
+
struct TextDesc {
|
157
|
+
const sk_sp<SkTypeface>& fTypeface;
|
158
|
+
SkScalar fTextSize = 0,
|
159
|
+
fMinTextSize = 0, // when auto-sizing
|
160
|
+
fMaxTextSize = 0, // when auto-sizing
|
161
|
+
fLineHeight = 0,
|
162
|
+
fLineShift = 0,
|
163
|
+
fAscent = 0;
|
164
|
+
SkTextUtils::Align fHAlign = SkTextUtils::kLeft_Align;
|
165
|
+
VAlign fVAlign = Shaper::VAlign::kTop;
|
166
|
+
ResizePolicy fResize = Shaper::ResizePolicy::kNone;
|
167
|
+
LinebreakPolicy fLinebreak = Shaper::LinebreakPolicy::kExplicit;
|
168
|
+
Direction fDirection = Shaper::Direction::kLTR ;
|
169
|
+
Capitalization fCapitalization = Shaper::Capitalization::kNone;
|
170
|
+
size_t fMaxLines = 0; // when auto-sizing, 0 -> no max
|
171
|
+
uint32_t fFlags = 0;
|
172
|
+
const char* fLocale = nullptr;
|
173
|
+
const char* fFontFamily = nullptr;
|
174
|
+
};
|
175
|
+
|
176
|
+
// Performs text layout along an infinite horizontal line, starting at |point|.
|
177
|
+
// Only explicit line breaks (\r) are observed.
|
178
|
+
static Result Shape(const SkString& text, const TextDesc& desc, const SkPoint& point,
|
179
|
+
const sk_sp<SkFontMgr>&, const sk_sp<SkShapers::Factory>&);
|
180
|
+
|
181
|
+
// Performs text layout within |box|, injecting line breaks as needed to ensure
|
182
|
+
// horizontal fitting. The result is *not* guaranteed to fit vertically (it may extend
|
183
|
+
// below the box bottom).
|
184
|
+
static Result Shape(const SkString& text, const TextDesc& desc, const SkRect& box,
|
185
|
+
const sk_sp<SkFontMgr>&, const sk_sp<SkShapers::Factory>&);
|
186
|
+
|
187
|
+
#if !defined(SK_DISABLE_LEGACY_SHAPER_FACTORY)
|
188
|
+
static Result Shape(const SkString& text, const TextDesc& desc, const SkPoint& point,
|
189
|
+
const sk_sp<SkFontMgr>&);
|
190
|
+
static Result Shape(const SkString& text, const TextDesc& desc, const SkRect& box,
|
191
|
+
const sk_sp<SkFontMgr>&);
|
192
|
+
#endif
|
193
|
+
|
194
|
+
private:
|
195
|
+
Shaper() = delete;
|
196
|
+
};
|
197
|
+
|
198
|
+
} // namespace skottie
|
199
|
+
|
200
|
+
#endif // SkottieTextShaper_DEFINED
|
@@ -0,0 +1,56 @@
|
|
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 SkottieValue_DEFINED
|
9
|
+
#define SkottieValue_DEFINED
|
10
|
+
|
11
|
+
#include "include/core/SkColor.h"
|
12
|
+
#include "include/core/SkM44.h"
|
13
|
+
#include "include/core/SkPath.h"
|
14
|
+
|
15
|
+
#include <initializer_list>
|
16
|
+
#include <vector>
|
17
|
+
|
18
|
+
namespace skjson { class Value; }
|
19
|
+
|
20
|
+
namespace skottie {
|
21
|
+
|
22
|
+
using ScalarValue = SkScalar;
|
23
|
+
using Vec2Value = SkV2;
|
24
|
+
|
25
|
+
class VectorValue : public std::vector<float> {
|
26
|
+
public:
|
27
|
+
VectorValue() = default;
|
28
|
+
|
29
|
+
VectorValue(std::initializer_list<float> l) : INHERITED(l) {}
|
30
|
+
|
31
|
+
operator SkV3() const;
|
32
|
+
private:
|
33
|
+
using INHERITED = std::vector<float>;
|
34
|
+
};
|
35
|
+
|
36
|
+
class ColorValue final : public VectorValue {
|
37
|
+
public:
|
38
|
+
ColorValue() = default;
|
39
|
+
|
40
|
+
ColorValue(std::initializer_list<float> l) : INHERITED(l) {}
|
41
|
+
|
42
|
+
operator SkColor() const;
|
43
|
+
operator SkColor4f() const;
|
44
|
+
|
45
|
+
private:
|
46
|
+
using INHERITED = VectorValue;
|
47
|
+
};
|
48
|
+
|
49
|
+
class ShapeValue final : public std::vector<float> {
|
50
|
+
public:
|
51
|
+
operator SkPath() const;
|
52
|
+
};
|
53
|
+
|
54
|
+
} // namespace skottie
|
55
|
+
|
56
|
+
#endif // SkottieValue_DEFINED
|
@@ -0,0 +1,89 @@
|
|
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 SkottieAnimator_DEFINED
|
9
|
+
#define SkottieAnimator_DEFINED
|
10
|
+
|
11
|
+
#include "include/core/SkRefCnt.h"
|
12
|
+
|
13
|
+
#include <vector>
|
14
|
+
|
15
|
+
struct SkV2;
|
16
|
+
|
17
|
+
namespace skjson {
|
18
|
+
|
19
|
+
class ObjectValue;
|
20
|
+
|
21
|
+
} // namespace skjson
|
22
|
+
|
23
|
+
namespace skottie {
|
24
|
+
|
25
|
+
class SlotManager;
|
26
|
+
|
27
|
+
namespace internal {
|
28
|
+
|
29
|
+
class AnimationBuilder;
|
30
|
+
class AnimatorBuilder;
|
31
|
+
|
32
|
+
class Animator : public SkRefCnt {
|
33
|
+
public:
|
34
|
+
using StateChanged = bool;
|
35
|
+
StateChanged seek(float t) { return this->onSeek(t); }
|
36
|
+
|
37
|
+
protected:
|
38
|
+
Animator() = default;
|
39
|
+
|
40
|
+
virtual StateChanged onSeek(float t) = 0;
|
41
|
+
|
42
|
+
private:
|
43
|
+
Animator(const Animator&) = delete;
|
44
|
+
Animator& operator=(const Animator&) = delete;
|
45
|
+
};
|
46
|
+
|
47
|
+
class AnimatablePropertyContainer : public Animator {
|
48
|
+
public:
|
49
|
+
// This is the workhorse for property binding: depending on whether the property is animated,
|
50
|
+
// it will either apply immediately or instantiate and attach a keyframe animator, scoped to
|
51
|
+
// this container.
|
52
|
+
template <typename T>
|
53
|
+
bool bind(const AnimationBuilder&, const skjson::ObjectValue*, T*);
|
54
|
+
|
55
|
+
template <typename T>
|
56
|
+
bool bind(const AnimationBuilder& abuilder, const skjson::ObjectValue* jobject, T& v) {
|
57
|
+
return this->bind<T>(abuilder, jobject, &v);
|
58
|
+
}
|
59
|
+
|
60
|
+
// A flavor of bind<Vec2Value> which drives an additional/optional orientation target
|
61
|
+
// (rotation in degrees), when bound to a motion path property.
|
62
|
+
bool bindAutoOrientable(const AnimationBuilder& abuilder,
|
63
|
+
const skjson::ObjectValue* jobject,
|
64
|
+
SkV2* v, float* orientation);
|
65
|
+
|
66
|
+
bool isStatic() const { return fAnimators.empty() && !fHasSlotID; }
|
67
|
+
|
68
|
+
protected:
|
69
|
+
friend class skottie::SlotManager;
|
70
|
+
virtual void onSync() = 0;
|
71
|
+
|
72
|
+
void shrink_to_fit();
|
73
|
+
|
74
|
+
void attachDiscardableAdapter(sk_sp<AnimatablePropertyContainer>);
|
75
|
+
|
76
|
+
private:
|
77
|
+
StateChanged onSeek(float) final;
|
78
|
+
|
79
|
+
bool bindImpl(const AnimationBuilder&, const skjson::ObjectValue*, AnimatorBuilder&);
|
80
|
+
|
81
|
+
std::vector<sk_sp<Animator>> fAnimators;
|
82
|
+
bool fHasSynced = false;
|
83
|
+
bool fHasSlotID = false;
|
84
|
+
};
|
85
|
+
|
86
|
+
} // namespace internal
|
87
|
+
} // namespace skottie
|
88
|
+
|
89
|
+
#endif // SkottieAnimator_DEFINED
|
@@ -0,0 +1,82 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright 2022 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 SkottieFont_DEFINED
|
9
|
+
#define SkottieFont_DEFINED
|
10
|
+
|
11
|
+
#include "include/core/SkRefCnt.h"
|
12
|
+
#include "include/core/SkTypes.h"
|
13
|
+
#include "include/private/base/SkNoncopyable.h"
|
14
|
+
#include "include/utils/SkCustomTypeface.h"
|
15
|
+
#include "modules/sksg/include/SkSGRenderNode.h"
|
16
|
+
#include "src/core/SkTHash.h"
|
17
|
+
|
18
|
+
#include <memory>
|
19
|
+
#include <utility>
|
20
|
+
#include <vector>
|
21
|
+
|
22
|
+
class SkPath;
|
23
|
+
class SkTypeface;
|
24
|
+
struct SkSize;
|
25
|
+
|
26
|
+
namespace skjson { class ObjectValue; }
|
27
|
+
|
28
|
+
namespace skottie::internal {
|
29
|
+
|
30
|
+
class AnimationBuilder;
|
31
|
+
|
32
|
+
// Font backed by Lottie character data (glyph paths and glyph compositions).
|
33
|
+
class CustomFont final : SkNoncopyable {
|
34
|
+
public:
|
35
|
+
~CustomFont();
|
36
|
+
|
37
|
+
using GlyphCompMap = skia_private::THashMap<SkGlyphID, sk_sp<sksg::RenderNode>>;
|
38
|
+
|
39
|
+
class Builder final : SkNoncopyable {
|
40
|
+
public:
|
41
|
+
bool parseGlyph(const AnimationBuilder*, const skjson::ObjectValue&);
|
42
|
+
std::unique_ptr<CustomFont> detach();
|
43
|
+
|
44
|
+
private:
|
45
|
+
static bool ParseGlyphPath(const AnimationBuilder*, const skjson::ObjectValue&, SkPath*);
|
46
|
+
static sk_sp<sksg::RenderNode> ParseGlyphComp(const AnimationBuilder*,
|
47
|
+
const skjson::ObjectValue&,
|
48
|
+
SkSize*);
|
49
|
+
|
50
|
+
GlyphCompMap fGlyphComps;
|
51
|
+
SkCustomTypefaceBuilder fCustomBuilder;
|
52
|
+
};
|
53
|
+
|
54
|
+
// Helper for resolving (SkTypeface, SkGlyphID) tuples to a composition root.
|
55
|
+
// Used post-shaping, to substitute composition glyphs in the rendering tree.
|
56
|
+
class GlyphCompMapper final : public SkRefCnt {
|
57
|
+
public:
|
58
|
+
explicit GlyphCompMapper(std::vector<std::unique_ptr<CustomFont>>&& fonts)
|
59
|
+
: fFonts(std::move(fonts)) {}
|
60
|
+
|
61
|
+
~GlyphCompMapper() override = default;
|
62
|
+
|
63
|
+
sk_sp<sksg::RenderNode> getGlyphComp(const SkTypeface*, SkGlyphID) const;
|
64
|
+
|
65
|
+
private:
|
66
|
+
const std::vector<std::unique_ptr<CustomFont>> fFonts;
|
67
|
+
};
|
68
|
+
|
69
|
+
const sk_sp<SkTypeface>& typeface() const { return fTypeface; }
|
70
|
+
|
71
|
+
int glyphCompCount() const { return fGlyphComps.count(); }
|
72
|
+
|
73
|
+
private:
|
74
|
+
CustomFont(GlyphCompMap&&, sk_sp<SkTypeface> tf);
|
75
|
+
|
76
|
+
const GlyphCompMap fGlyphComps;
|
77
|
+
const sk_sp<SkTypeface> fTypeface;
|
78
|
+
};
|
79
|
+
|
80
|
+
} // namespace skottie::internal
|
81
|
+
|
82
|
+
#endif // SkottieFont_DEFINED
|
@@ -0,0 +1,155 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright 2019 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 SkottieTextAdapter_DEFINED
|
9
|
+
#define SkottieTextAdapter_DEFINED
|
10
|
+
|
11
|
+
#include "include/core/SkM44.h"
|
12
|
+
#include "include/core/SkPoint.h"
|
13
|
+
#include "include/core/SkRefCnt.h"
|
14
|
+
#include "modules/skottie/include/TextShaper.h"
|
15
|
+
#include "modules/skottie/src/SkottieValue.h"
|
16
|
+
#include "modules/skottie/src/animator/Animator.h"
|
17
|
+
#include "modules/skottie/src/text/Font.h"
|
18
|
+
#include "modules/skottie/src/text/TextAnimator.h"
|
19
|
+
#include "modules/skottie/src/text/TextValue.h"
|
20
|
+
#include "modules/sksg/include/SkSGPaint.h"
|
21
|
+
#include "modules/sksg/include/SkSGRenderEffect.h"
|
22
|
+
#include "modules/sksg/include/SkSGTransform.h"
|
23
|
+
|
24
|
+
#include <cstdint>
|
25
|
+
#include <memory>
|
26
|
+
#include <vector>
|
27
|
+
|
28
|
+
class SkFontMgr;
|
29
|
+
|
30
|
+
namespace skjson {
|
31
|
+
class ObjectValue;
|
32
|
+
}
|
33
|
+
namespace skottie {
|
34
|
+
class Logger;
|
35
|
+
}
|
36
|
+
namespace sksg {
|
37
|
+
class Group;
|
38
|
+
class RenderNode;
|
39
|
+
} // namespace sksg
|
40
|
+
|
41
|
+
namespace SkShapers { class Factory; }
|
42
|
+
|
43
|
+
namespace skottie {
|
44
|
+
namespace internal {
|
45
|
+
class AnimationBuilder;
|
46
|
+
|
47
|
+
class TextAdapter final : public AnimatablePropertyContainer {
|
48
|
+
public:
|
49
|
+
static sk_sp<TextAdapter> Make(const skjson::ObjectValue&,
|
50
|
+
const AnimationBuilder*,
|
51
|
+
sk_sp<SkFontMgr>,
|
52
|
+
sk_sp<CustomFont::GlyphCompMapper>,
|
53
|
+
sk_sp<Logger>,
|
54
|
+
sk_sp<::SkShapers::Factory>);
|
55
|
+
|
56
|
+
~TextAdapter() override;
|
57
|
+
|
58
|
+
const sk_sp<sksg::Group>& node() const { return fRoot; }
|
59
|
+
|
60
|
+
const TextValue& getText() const { return fText.fCurrentValue; }
|
61
|
+
void setText(const TextValue&);
|
62
|
+
|
63
|
+
protected:
|
64
|
+
void onSync() override;
|
65
|
+
|
66
|
+
private:
|
67
|
+
class GlyphDecoratorNode;
|
68
|
+
|
69
|
+
enum class AnchorPointGrouping : uint8_t {
|
70
|
+
kCharacter,
|
71
|
+
kWord,
|
72
|
+
kLine,
|
73
|
+
kAll,
|
74
|
+
};
|
75
|
+
|
76
|
+
TextAdapter(sk_sp<SkFontMgr>,
|
77
|
+
sk_sp<CustomFont::GlyphCompMapper>,
|
78
|
+
sk_sp<Logger>,
|
79
|
+
sk_sp<SkShapers::Factory>,
|
80
|
+
AnchorPointGrouping);
|
81
|
+
|
82
|
+
struct FragmentRec {
|
83
|
+
SkPoint fOrigin; // fragment position
|
84
|
+
|
85
|
+
const Shaper::ShapedGlyphs* fGlyphs = nullptr;
|
86
|
+
sk_sp<sksg::Matrix<SkM44>> fMatrixNode;
|
87
|
+
sk_sp<sksg::Color> fFillColorNode,
|
88
|
+
fStrokeColorNode;
|
89
|
+
sk_sp<sksg::BlurImageFilter> fBlur;
|
90
|
+
|
91
|
+
float fAdvance, // used for transform anchor point calculations
|
92
|
+
fAscent; // ^
|
93
|
+
};
|
94
|
+
|
95
|
+
void reshape();
|
96
|
+
void addFragment(Shaper::Fragment&, sksg::Group* container);
|
97
|
+
void buildDomainMaps(const Shaper::Result&);
|
98
|
+
std::vector<sk_sp<sksg::RenderNode>> buildGlyphCompNodes(Shaper::ShapedGlyphs&) const;
|
99
|
+
|
100
|
+
void pushPropsToFragment(const TextAnimator::ResolvedProps&, const FragmentRec&,
|
101
|
+
const SkV2& frag_offset, const SkV2& grouping_alignment,
|
102
|
+
const TextAnimator::DomainSpan*) const;
|
103
|
+
|
104
|
+
SkV2 fragmentAnchorPoint(const FragmentRec&, const SkV2&,
|
105
|
+
const TextAnimator::DomainSpan*) const;
|
106
|
+
uint32_t shaperFlags() const;
|
107
|
+
|
108
|
+
SkM44 fragmentMatrix(const TextAnimator::ResolvedProps&, const FragmentRec&, const SkV2&) const;
|
109
|
+
|
110
|
+
const sk_sp<sksg::Group> fRoot;
|
111
|
+
const sk_sp<SkFontMgr> fFontMgr;
|
112
|
+
const sk_sp<CustomFont::GlyphCompMapper> fCustomGlyphMapper;
|
113
|
+
sk_sp<Logger> fLogger;
|
114
|
+
sk_sp<SkShapers::Factory> fShapingFactory;
|
115
|
+
const AnchorPointGrouping fAnchorPointGrouping;
|
116
|
+
|
117
|
+
std::vector<sk_sp<TextAnimator>> fAnimators;
|
118
|
+
std::vector<FragmentRec> fFragments;
|
119
|
+
TextAnimator::DomainMaps fMaps;
|
120
|
+
|
121
|
+
// Helps detect external value changes.
|
122
|
+
struct TextValueTracker {
|
123
|
+
TextValue fCurrentValue;
|
124
|
+
|
125
|
+
bool hasChanged() const {
|
126
|
+
if (fCurrentValue != fPrevValue) {
|
127
|
+
fPrevValue = fCurrentValue;
|
128
|
+
return true;
|
129
|
+
}
|
130
|
+
return false;
|
131
|
+
}
|
132
|
+
|
133
|
+
const TextValue* operator->() const { return &fCurrentValue; }
|
134
|
+
|
135
|
+
private:
|
136
|
+
mutable TextValue fPrevValue;
|
137
|
+
};
|
138
|
+
|
139
|
+
TextValueTracker fText;
|
140
|
+
Vec2Value fGroupingAlignment = {0,0};
|
141
|
+
float fTextShapingScale = 1; // size adjustment from auto-scaling
|
142
|
+
|
143
|
+
// Optional text path.
|
144
|
+
struct PathInfo;
|
145
|
+
std::unique_ptr<PathInfo> fPathInfo;
|
146
|
+
|
147
|
+
bool fHasBlurAnimator : 1,
|
148
|
+
fRequiresAnchorPoint : 1,
|
149
|
+
fRequiresLineAdjustments : 1;
|
150
|
+
};
|
151
|
+
|
152
|
+
} // namespace internal
|
153
|
+
} // namespace skottie
|
154
|
+
|
155
|
+
#endif // SkottieTextAdapter_DEFINED
|
@@ -0,0 +1,121 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright 2019 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 SkottieTextAnimator_DEFINED
|
9
|
+
#define SkottieTextAnimator_DEFINED
|
10
|
+
|
11
|
+
#include "include/core/SkColor.h"
|
12
|
+
#include "include/core/SkM44.h"
|
13
|
+
#include "include/core/SkRefCnt.h"
|
14
|
+
#include "modules/skottie/src/SkottieValue.h"
|
15
|
+
|
16
|
+
#include <cstddef>
|
17
|
+
#include <vector>
|
18
|
+
|
19
|
+
namespace skjson {
|
20
|
+
class ObjectValue;
|
21
|
+
}
|
22
|
+
|
23
|
+
namespace skottie {
|
24
|
+
namespace internal {
|
25
|
+
class AnimatablePropertyContainer;
|
26
|
+
class AnimationBuilder;
|
27
|
+
class RangeSelector;
|
28
|
+
|
29
|
+
class TextAnimator final : public SkNVRefCnt<TextAnimator> {
|
30
|
+
public:
|
31
|
+
static sk_sp<TextAnimator> Make(const skjson::ObjectValue*,
|
32
|
+
const AnimationBuilder*,
|
33
|
+
AnimatablePropertyContainer* acontainer);
|
34
|
+
|
35
|
+
// Direct mapping of AE properties.
|
36
|
+
struct AnimatedProps {
|
37
|
+
VectorValue position,
|
38
|
+
scale = { 100, 100, 100 };
|
39
|
+
ColorValue fill_color,
|
40
|
+
stroke_color;
|
41
|
+
// unlike pos/scale which are animated vectors, rotation is separated in each dimension.
|
42
|
+
SkV3 rotation = { 0, 0, 0 };
|
43
|
+
Vec2Value blur = { 0, 0 },
|
44
|
+
line_spacing = { 0, 0 };
|
45
|
+
ScalarValue opacity = 100,
|
46
|
+
fill_opacity = 100,
|
47
|
+
stroke_opacity = 100,
|
48
|
+
tracking = 0,
|
49
|
+
stroke_width = 0;
|
50
|
+
};
|
51
|
+
|
52
|
+
struct ResolvedProps {
|
53
|
+
SkV3 position = { 0, 0, 0 },
|
54
|
+
scale = { 1, 1, 1 },
|
55
|
+
rotation = { 0, 0, 0 };
|
56
|
+
float opacity = 1,
|
57
|
+
tracking = 0,
|
58
|
+
stroke_width = 0;
|
59
|
+
SkColor fill_color = SK_ColorTRANSPARENT,
|
60
|
+
stroke_color = SK_ColorTRANSPARENT;
|
61
|
+
SkV2 blur = { 0, 0 },
|
62
|
+
line_spacing = { 0, 0 };
|
63
|
+
};
|
64
|
+
|
65
|
+
struct AnimatedPropsModulator {
|
66
|
+
ResolvedProps props; // accumulates properties across *all* animators
|
67
|
+
float coverage; // accumulates range selector coverage for a given animator
|
68
|
+
};
|
69
|
+
using ModulatorBuffer = std::vector<AnimatedPropsModulator>;
|
70
|
+
|
71
|
+
// Domain maps describe how a given index domain (words, lines, etc) relates
|
72
|
+
// to the full fragment index range.
|
73
|
+
//
|
74
|
+
// Each domain[i] represents a [domain[i].fOffset.. domain[i].fOffset+domain[i].fCount-1]
|
75
|
+
// fragment subset.
|
76
|
+
struct DomainSpan {
|
77
|
+
size_t fOffset,
|
78
|
+
fCount;
|
79
|
+
float fAdvance, // cumulative advance for all fragments in span
|
80
|
+
fAscent; // max ascent for all fragments in span
|
81
|
+
};
|
82
|
+
using DomainMap = std::vector<DomainSpan>;
|
83
|
+
|
84
|
+
struct DomainMaps {
|
85
|
+
DomainMap fNonWhitespaceMap,
|
86
|
+
fWordsMap,
|
87
|
+
fLinesMap;
|
88
|
+
};
|
89
|
+
|
90
|
+
void modulateProps(const DomainMaps&, ModulatorBuffer&) const;
|
91
|
+
|
92
|
+
bool hasBlur() const { return fHasBlur; }
|
93
|
+
|
94
|
+
bool requiresAnchorPoint() const { return fRequiresAnchorPoint; }
|
95
|
+
bool requiresLineAdjustments() const { return fRequiresLineAdjustments; }
|
96
|
+
|
97
|
+
private:
|
98
|
+
TextAnimator(std::vector<sk_sp<RangeSelector>>&&,
|
99
|
+
const skjson::ObjectValue&,
|
100
|
+
const AnimationBuilder*,
|
101
|
+
AnimatablePropertyContainer*);
|
102
|
+
|
103
|
+
ResolvedProps modulateProps(const ResolvedProps&, float amount) const;
|
104
|
+
|
105
|
+
const std::vector<sk_sp<RangeSelector>> fSelectors;
|
106
|
+
|
107
|
+
AnimatedProps fTextProps;
|
108
|
+
bool fHasFillColor : 1,
|
109
|
+
fHasStrokeColor : 1,
|
110
|
+
fHasFillOpacity : 1,
|
111
|
+
fHasStrokeOpacity : 1,
|
112
|
+
fHasOpacity : 1,
|
113
|
+
fHasBlur : 1,
|
114
|
+
fRequiresAnchorPoint : 1, // animator sensitive to transform origin?
|
115
|
+
fRequiresLineAdjustments : 1; // animator effects line-wide fragment adjustments
|
116
|
+
};
|
117
|
+
|
118
|
+
} // namespace internal
|
119
|
+
} // namespace skottie
|
120
|
+
|
121
|
+
#endif // SkottieTextAnimator_DEFINED
|