Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkottieProperty.h
Go to the documentation of this file.
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
15#include "include/core/SkRect.h"
18#include "include/core/SkSpan.h"
24
25#include <cstddef>
26#include <cstdint>
27#include <functional>
28#include <limits>
29#include <memory>
30#include <utility>
31
32class SkCanvas;
33
34namespace sksg {
35
36class Color;
37class OpacityEffect;
38
39} // namespace sksg
40
41namespace skottie {
42
45
46enum class TextPaintOrder : uint8_t {
49};
50
51// Optional callback invoked when drawing text layers.
52// Allows clients to render custom text decorations.
53class GlyphDecorator : public SkRefCnt {
54public:
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 {
64 float fScale; // Additional font scale applied by auto-sizing.
65 };
66
67 virtual void onDecorate(SkCanvas*, const TextInfo&) = 0;
68};
69
73 float fTextSize = 0,
74 fMinTextSize = 0, // when auto-sizing
75 fMaxTextSize = std::numeric_limits<float>::max(), // when auto-sizing
80 size_t fMaxLines = 0; // when auto-sizing
92 bool fHasFill = false,
93 fHasStroke = false;
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.
100 // Optional font family name, to be passed to the font manager for
101 // fallback.
103
104 bool operator==(const TextPropertyValue& other) const;
105 bool operator!=(const TextPropertyValue& other) const;
106};
107
119
120namespace internal { class SceneGraphRevalidator; }
121
122/**
123 * Property handles are adapters between user-facing AE model/values
124 * and the internal scene-graph representation.
125 */
126template <typename ValueT, typename NodeT>
128public:
131 : fNode(std::move(node))
132 , fRevalidator(std::move(revalidator)) {}
134
136
137 ValueT get() const;
138 void set(const ValueT&);
139
140private:
141 const sk_sp<NodeT> fNode;
143};
144
145namespace internal {
146
147class TextAdapter;
148class TransformAdapter2D;
149
150} // namespace internal
151
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 */
170public:
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[],
178 virtual void onOpacityProperty (const char node_name[],
180 virtual void onTextProperty (const char node_name[],
182 virtual void onTransformProperty(const char node_name[],
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
#define SK_API
Definition SkAPI.h:35
uint32_t SkColor
Definition SkColor.h:37
constexpr SkColor SK_ColorTRANSPARENT
Definition SkColor.h:99
@ kMiter_Join
extends to miter limit
Definition SkPaint.h:359
virtual void onDecorate(SkCanvas *, const TextInfo &)=0
PropertyHandle(sk_sp< NodeT > node, sk_sp< internal::SceneGraphRevalidator > revalidator)
void set(const ValueT &)
PropertyHandle(const PropertyHandle &)
PropertyHandle(sk_sp< NodeT >)
std::function< std::unique_ptr< T >()> LazyHandle
float SkScalar
Definition extension.cpp:12
float OpacityPropertyValue
SkColor ColorPropertyValue
Definition Skottie.h:32
Definition ref_ptr.h:256
static constexpr SkRect MakeEmpty()
Definition SkRect.h:595
SkSpan< const GlyphInfo > fGlyphs
sk_sp< SkTypeface > fTypeface
Shaper::Direction fDirection
bool operator!=(const TextPropertyValue &other) const
bool operator==(const TextPropertyValue &other) const
Shaper::LinebreakPolicy fLineBreak
sk_sp< GlyphDecorator > fDecorator
Shaper::Capitalization fCapitalization
Shaper::ResizePolicy fResize
SkTextUtils::Align fHAlign
bool operator!=(const TransformPropertyValue &other) const
bool operator==(const TransformPropertyValue &other) const