Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkottieProperty.cpp
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
9
15
16namespace skottie {
17
19 return fTypeface == other.fTypeface
20 && fText == other.fText
21 && fTextSize == other.fTextSize
22 && fStrokeWidth == other.fStrokeWidth
23 && fLineHeight == other.fLineHeight
24 && fLineShift == other.fLineShift
25 && fAscent == other.fAscent
26 && fMaxLines == other.fMaxLines
27 && fHAlign == other.fHAlign
28 && fVAlign == other.fVAlign
29 && fResize == other.fResize
30 && fLineBreak == other.fLineBreak
31 && fDirection == other.fDirection
33 && fBox == other.fBox
34 && fFillColor == other.fFillColor
35 && fStrokeColor == other.fStrokeColor
36 && fPaintOrder == other.fPaintOrder
37 && fStrokeJoin == other.fStrokeJoin
38 && fHasFill == other.fHasFill
39 && fHasStroke == other.fHasStroke
40 && fDecorator == other.fDecorator
41 && fLocale == other.fLocale
42 && fFontFamily == other.fFontFamily;
43}
44
46 return !(*this== other);
47}
48
50 return this->fAnchorPoint == other.fAnchorPoint
51 && this->fPosition == other.fPosition
52 && this->fScale == other.fScale
53 && this->fSkew == other.fSkew
54 && this->fSkewAxis == other.fSkewAxis;
55}
56
58 return !(*this == other);
59}
60
61// The SK_API attributes are important here due o them being declared as a template.
62
63template <> SK_API
65 : fNode(std::move(node)), fRevalidator(nullptr) {}
66
67template <> SK_API
69 : fNode(other.fNode), fRevalidator(other.fRevalidator) {}
70
71template <> SK_API
73
74template <> SK_API
76 return fNode->getColor();
77}
78
79template <> SK_API
81 fNode->setColor(c);
82
83 if (fRevalidator) {
84 fRevalidator->revalidate();
85 }
86}
87
88template <> SK_API
90 : fNode(std::move(node)), fRevalidator(nullptr) {}
91
92template <> SK_API
94 : fNode(other.fNode), fRevalidator(other.fRevalidator) {}
95
96template <> SK_API
98
99template <> SK_API
101 return fNode->getOpacity() * 100;
102}
103
104template <> SK_API
106 fNode->setOpacity(o / 100);
107
108 if (fRevalidator) {
109 fRevalidator->revalidate();
110 }
111}
112
113template <> SK_API
115 : fNode(std::move(node)), fRevalidator(nullptr) {}
116
117template <> SK_API
119 : fNode(other.fNode), fRevalidator(other.fRevalidator) {}
120
121template <> SK_API
123
124template <> SK_API
125TextPropertyValue TextPropertyHandle::get() const {
126 return fNode->getText();
127}
128
129template<> SK_API
130void TextPropertyHandle::set(const TextPropertyValue& t) {
131 fNode->setText(t);
132
133 if (fRevalidator) {
134 fRevalidator->revalidate();
135 }
136}
137
138template <> SK_API
140 : fNode(std::move(node)), fRevalidator(nullptr) {}
141
142template <> SK_API
144 : fNode(other.fNode), fRevalidator(other.fRevalidator) {}
145
146template <> SK_API
148
149template <> SK_API
150TransformPropertyValue TransformPropertyHandle::get() const {
151 return {
152 fNode->getAnchorPoint(),
153 fNode->getPosition(),
154 fNode->getScale(),
155 fNode->getRotation(),
156 fNode->getSkew(),
157 fNode->getSkewAxis()
158 };
159}
160
161template <> SK_API
162void TransformPropertyHandle::set(const TransformPropertyValue& t) {
163 fNode->setAnchorPoint(t.fAnchorPoint);
164 fNode->setPosition(t.fPosition);
165 fNode->setScale(t.fScale);
166 fNode->setRotation(t.fRotation);
167 fNode->setSkew(t.fSkew);
168 fNode->setSkewAxis(t.fSkewAxis);
169
170 if (fRevalidator) {
171 fRevalidator->revalidate();
172 }
173}
174
177
180
183
186
187void PropertyObserver::onEnterNode(const char node_name[], NodeType) {}
188
189void PropertyObserver::onLeavingNode(const char node_name[], NodeType) {}
190
191} // namespace skottie
#define SK_API
Definition SkAPI.h:35
void set(const ValueT &)
PropertyHandle(sk_sp< NodeT >)
virtual void onTransformProperty(const char node_name[], const LazyHandle< TransformPropertyHandle > &)
virtual void onLeavingNode(const char node_name[], NodeType node_type)
virtual void onOpacityProperty(const char node_name[], const LazyHandle< OpacityPropertyHandle > &)
virtual void onTextProperty(const char node_name[], const LazyHandle< TextPropertyHandle > &)
virtual void onEnterNode(const char node_name[], NodeType node_type)
std::function< std::unique_ptr< T >()> LazyHandle
virtual void onColorProperty(const char node_name[], const LazyHandle< ColorPropertyHandle > &)
PropertyHandle< TransformPropertyValue, internal::TransformAdapter2D > TransformPropertyHandle
PropertyHandle< ColorPropertyValue, sksg::Color > ColorPropertyHandle
PropertyHandle< TextPropertyValue, internal::TextAdapter > TextPropertyHandle
float OpacityPropertyValue
PropertyHandle< OpacityPropertyValue, sksg::OpacityEffect > OpacityPropertyHandle
SkColor ColorPropertyValue
Definition ref_ptr.h:256
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