aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2018-06-13 13:03:04 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-13 19:43:16 +0000
commit527a297d6e2410277ff41c40dcbb56410d6a9118 (patch)
tree02f29c7954c2b9f7a2601f0b4005225fa647809d /gm
parent251494005e64c8bf7a1874842681fa111ad45fdc (diff)
Handle missing json resource gracefully in 3dgm
If the json resource is not found (it is not currently packaged with the APK), Viewer crashes. TBR= Change-Id: I0a0bdf7f97fdac8afc84d539c88d2a391e54855c Reviewed-on: https://skia-review.googlesource.com/134515 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'gm')
-rw-r--r--gm/3dgm.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/gm/3dgm.cpp b/gm/3dgm.cpp
index 8014c246d3..a2818bba19 100644
--- a/gm/3dgm.cpp
+++ b/gm/3dgm.cpp
@@ -43,8 +43,9 @@ public:
protected:
void onOnceBeforeDraw() override {
- auto stream = GetResourceAsStream("skotty/skotty_sample_2.json");
- fAnim = skottie::Animation::Make(stream.get());
+ if (auto stream = GetResourceAsStream("skotty/skotty_sample_2.json")) {
+ fAnim = skottie::Animation::Make(stream.get());
+ }
int index = 0;
for (float x = 0; x <= 1; ++x) {
@@ -99,6 +100,9 @@ protected:
}
void onDraw(SkCanvas* canvas) override {
+ if (!fAnim) {
+ return;
+ }
SkMatrix44 camera(SkMatrix44::kIdentity_Constructor),
perspective(SkMatrix44::kIdentity_Constructor),
mv(SkMatrix44::kIdentity_Constructor);