Debian Codegraph @

modules/skottie/src/text/RangeSelector.h

raw
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 SkottieRangeSelector_DEFINED
9 #define SkottieRangeSelector_DEFINED
10
11 #include "include/core/SkRefCnt.h"
12 #include "modules/skottie/src/text/TextAnimator.h"
13
14 #include <cstddef>
15 #include <cstdint>
16 #include <tuple>
17 namespace skjson {
18 class ObjectValue;
19 }
20
21 namespace skottie {
22 namespace internal {
23 class AnimatablePropertyContainer;
24 class AnimationBuilder;
25
26 class RangeSelector final : public SkNVRefCnt<RangeSelector> {
27 public:
28 static sk_sp<RangeSelector> Make(const skjson::ObjectValue*,
29 const AnimationBuilder*,
30 AnimatablePropertyContainer*);
31
32 enum class Units : uint8_t {
33 kPercentage, // values are percentages of domain size
34 kIndex, // values are direct domain indices
35 };
36
37 enum class Domain : uint8_t {
38 kChars, // domain indices map to glyph indices
39 kCharsExcludingSpaces, // domain indices map to glyph indices (ignoring spaces)
40 kWords, // domain indices map to word indices
41 kLines, // domain indices map to line indices
42 };
43
44 enum class Mode : uint8_t {
45 kAdd,
46 // kSubtract,
47 // kIntersect,
48 // kMin,
49 // kMax,
50 // kDifference,
51 };
52
53 enum class Shape : uint8_t {
54 kSquare,
55 kRampUp,
56 kRampDown,
57 kTriangle,
58 kRound,
59 kSmooth,
60 };
61
62 void modulateCoverage(const TextAnimator::DomainMaps&, TextAnimator::ModulatorBuffer&) const;
63
64 private:
65 RangeSelector(Units, Domain, Mode, Shape);
66
67 // Resolves this selector to a range in the coverage buffer index domain.
68 std::tuple<float, float> resolve(size_t domain_size) const;
69
70 const Units fUnits;
71 const Domain fDomain;
72 const Mode fMode;
73 const Shape fShape;
74
75 float fStart,
76 fEnd,
77 fOffset,
78 fAmount = 100,
79 fEaseLo = 0,
80 fEaseHi = 0,
81 fSmoothness = 100;
82 };
83
84 } // namespace internal
85 } // namespace skottie
86
87 #endif // SkottieRangeSelector_DEFINED