Skip to content

Commit 4206969

Browse files
fmalitaSkia Commit-Bot
authored andcommitted
[skottie] Relax constant keyframe parsing
Constant keyframes currently requiere an "h" property/marker. In order to support keyframed text parsing, relax this to consider any keyframe missing an end value as constant. TBR= Change-Id: Idf332dc0174ee0ee6773708518a0bbc284f8860f Reviewed-on: https://skia-review.googlesource.com/149265 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
1 parent b5729c9 commit 4206969

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

modules/skottie/src/SkottieAnimator.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -88,35 +88,35 @@ class KeyframeAnimatorBase : public sksg::Animator {
8888
fRecs.back().t1 = t0;
8989
}
9090

91-
const auto vidx0 = this->parseValue((*jframe)["s"], abuilder);
92-
if (vidx0 < 0)
91+
// Required start value.
92+
const auto v0_idx = this->parseValue((*jframe)["s"], abuilder);
93+
if (v0_idx < 0)
9394
continue;
9495

95-
// Defaults for constant frames.
96-
int vidx1 = vidx0, cmidx = -1;
97-
98-
if (!ParseDefault<bool>((*jframe)["h"], false)) {
99-
// Regular frame, requires an end value.
100-
vidx1 = this->parseValue((*jframe)["e"], abuilder);
101-
if (vidx1 < 0)
102-
continue;
96+
// Optional end value.
97+
const auto v1_idx = this->parseValue((*jframe)["e"], abuilder);
98+
if (v1_idx < 0) {
99+
// Constant keyframe.
100+
fRecs.push_back({t0, t0, v0_idx, v0_idx, -1 });
101+
continue;
102+
}
103103

104-
// default is linear lerp
105-
static constexpr SkPoint kDefaultC0 = { 0, 0 },
106-
kDefaultC1 = { 1, 1 };
107-
const auto c0 = ParseDefault<SkPoint>((*jframe)["i"], kDefaultC0),
108-
c1 = ParseDefault<SkPoint>((*jframe)["o"], kDefaultC1);
109-
110-
if (c0 != kDefaultC0 || c1 != kDefaultC1) {
111-
// TODO: is it worth de-duping these?
112-
cmidx = fCubicMaps.count();
113-
fCubicMaps.emplace_back();
114-
// TODO: why do we have to plug these inverted?
115-
fCubicMaps.back().setPts(c1, c0);
116-
}
104+
// default is linear lerp
105+
static constexpr SkPoint kDefaultC0 = { 0, 0 },
106+
kDefaultC1 = { 1, 1 };
107+
const auto c0 = ParseDefault<SkPoint>((*jframe)["i"], kDefaultC0),
108+
c1 = ParseDefault<SkPoint>((*jframe)["o"], kDefaultC1);
109+
110+
int cm_idx = -1;
111+
if (c0 != kDefaultC0 || c1 != kDefaultC1) {
112+
// TODO: is it worth de-duping these?
113+
cm_idx = fCubicMaps.count();
114+
fCubicMaps.emplace_back();
115+
// TODO: why do we have to plug these inverted?
116+
fCubicMaps.back().setPts(c1, c0);
117117
}
118118

119-
fRecs.push_back({t0, t0, vidx0, vidx1, cmidx });
119+
fRecs.push_back({t0, t0, v0_idx, v1_idx, cm_idx });
120120
}
121121

122122
// If we couldn't determine a valid t1 for the last frame, discard it.

0 commit comments

Comments
 (0)