aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2018-06-19 12:55:53 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-19 20:01:28 +0000
commitf5ac906476cd26f2967a48340940e6af580fa71f (patch)
tree5e40def965cccd5f1007df81717d544bcd876e2b /modules
parent9d85d63468eede1324c88b6e174834eb096113fe (diff)
[skottie] Simplify Parse<SkPoint>
Some BM versions wrap point values as single or even multi-element arrays. Parse<SkScalar> already handles the former case - we can extend that behavior to also cover the latter and simplify Parse<SkPoint>. TBR= Change-Id: I2152928944f43dc03a5d8f0d65865ac43974fd7a Reviewed-on: https://skia-review.googlesource.com/135800 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'modules')
-rw-r--r--modules/skottie/src/SkottieJson.cpp14
1 files changed, 3 insertions, 11 deletions
diff --git a/modules/skottie/src/SkottieJson.cpp b/modules/skottie/src/SkottieJson.cpp
index 186cd42c31..23221af99e 100644
--- a/modules/skottie/src/SkottieJson.cpp
+++ b/modules/skottie/src/SkottieJson.cpp
@@ -24,7 +24,7 @@ template <>
bool Parse<SkScalar>(const Value& v, SkScalar* s) {
// Some versions wrap values as single-element arrays.
if (const skjson::ArrayValue* array = v) {
- if (array->size() == 1) {
+ if (array->size() > 0) {
return Parse((*array)[0], s);
}
}
@@ -80,16 +80,8 @@ bool Parse<SkPoint>(const Value& v, SkPoint* pt) {
return false;
const auto& ov = v.as<ObjectValue>();
- const auto& jvx = ov["x"];
- const auto& jvy = ov["y"];
-
- // Some BM versions seem to store x/y as single-element arrays.
- // TODO: We should be able to check size == 1 below, or just delegate to Parse<SkScalar>,
- // but that change introduces diffs. Investigate.
- const ArrayValue* jvxa = jvx;
- const ArrayValue* jvya = jvy;
- return Parse<SkScalar>(jvxa && jvxa->size() > 0 ? (*jvxa)[0] : jvx, &pt->fX)
- && Parse<SkScalar>(jvya && jvya->size() > 0 ? (*jvya)[0] : jvy, &pt->fY);
+ return Parse<SkScalar>(ov["x"], &pt->fX)
+ && Parse<SkScalar>(ov["y"], &pt->fY);
}
template <>