95 {
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
131 auto parsed = this->
parseKFValue(abuilder, jkf, jkf[
"s"], v);
132
133
134
135 if (!parsed &&
i > 0 &&
i == jkfs.
size() - 1) {
138 parsed = this->
parseKFValue(abuilder, jkf, (*prev_kf)[
"e"], v);
139 }
140
141 return parsed;
142 };
143
144 bool constant_value = true;
145
147
148 for (
size_t i = 0;
i < jkfs.
size(); ++
i) {
150 if (!jkf) {
151 return false;
152 }
153
154 float t;
155 if (!Parse<float>((*jkf)["t"], &t)) {
156 return false;
157 }
158
159 Keyframe::Value v;
160 if (!parse_value(*jkf,
i, &v)) {
161 return false;
162 }
163
165 auto& prev_kf =
fKFs.back();
166
167
168 if (t <= prev_kf.t) {
169 return false;
170 }
171
172
173 if (v.equals(prev_kf.v, keyframe_type)) {
175 }
176 }
177
178 fKFs.push_back({t, v, this->parseMapping(*jkf)});
179
180 constant_value = constant_value && (v.equals(
fKFs.front().v, keyframe_type));
181 }
182
184 fCMs.shrink_to_fit();
185
186 if (constant_value) {
187
188
190 }
191
192#if(DUMP_KF_RECORDS)
193 SkDEBUGF(
"Animator[%p], values: %lu, KF records: %zu\n",
194 this,
fKFs.back().v_idx + 1,
fKFs.size());
195 for (
const auto& kf :
fKFs) {
196 SkDEBUGF(
" { t: %1.3f, v_idx: %lu, mapping: %lu }\n", kf.t, kf.v_idx, kf.mapping);
197 }
198#endif
199 return true;
200}
std::vector< SkCubicMap > fCMs
std::vector< Keyframe > fKFs
virtual bool parseKFValue(const AnimationBuilder &, const skjson::ObjectValue &, const skjson::Value &, Keyframe::Value *)=0
static constexpr uint32_t kConstantMapping