Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
TextAnimator.h
Go to the documentation of this file.
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
12#include "include/core/SkM44.h"
15
16#include <cstddef>
17#include <vector>
18
19namespace skjson {
20class ObjectValue;
21}
22
23namespace skottie {
24namespace internal {
25class AnimatablePropertyContainer;
26class AnimationBuilder;
27class RangeSelector;
28
29class TextAnimator final : public SkNVRefCnt<TextAnimator> {
30public:
32 const AnimationBuilder*,
33 AnimatablePropertyContainer* acontainer);
34
35 // Direct mapping of AE properties.
38 scale = { 100, 100, 100 };
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 };
50 };
51
53 SkV3 position = { 0, 0, 0 },
54 scale = { 1, 1, 1 },
55 rotation = { 0, 0, 0 };
56 float opacity = 1,
61 SkV2 blur = { 0, 0 },
62 line_spacing = { 0, 0 };
63 };
64
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,
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
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
97private:
100 const AnimationBuilder*,
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
uint32_t SkColor
Definition SkColor.h:37
constexpr SkColor SK_ColorTRANSPARENT
Definition SkColor.h:99
std::vector< DomainSpan > DomainMap
void modulateProps(const DomainMaps &, ModulatorBuffer &) const
std::vector< AnimatedPropsModulator > ModulatorBuffer
static sk_sp< TextAnimator > Make(const skjson::ObjectValue *, const AnimationBuilder *, AnimatablePropertyContainer *acontainer)
SkScalar ScalarValue
Definition SkM44.h:19
Definition SkM44.h:56