diff options
author | 2018-02-09 11:15:32 -0500 | |
---|---|---|
committer | 2018-02-09 16:40:41 +0000 | |
commit | c378fdcad8c9cd70b92a2761146d3db680815427 (patch) | |
tree | 74f5c54a77dfc132a058d6d24ba3ea600a302ae1 /tools | |
parent | cd5099c75fd9ddc530347b976cb0e91abf85da00 (diff) |
[skottie] Fix viewer slide sizing on Android
TBR=
Change-Id: Ibbf4d22ba01e39b80c1f76d9af6bef647454996f
Reviewed-on: https://skia-review.googlesource.com/106160
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/viewer/SkottieSlide.cpp | 8 | ||||
-rw-r--r-- | tools/viewer/SkottieSlide.h | 1 |
2 files changed, 6 insertions, 3 deletions
diff --git a/tools/viewer/SkottieSlide.cpp b/tools/viewer/SkottieSlide.cpp index 8880916a16..063330e925 100644 --- a/tools/viewer/SkottieSlide.cpp +++ b/tools/viewer/SkottieSlide.cpp @@ -16,8 +16,9 @@ SkottieSlide::SkottieSlide(const SkString& name, const SkString& path) fName = name; } -void SkottieSlide::load(SkScalar, SkScalar) { +void SkottieSlide::load(SkScalar w, SkScalar h) { fAnimation = skottie::Animation::MakeFromFile(fPath.c_str()); + fWinSize = SkSize::Make(w, h); fTimeBase = 0; // force a time reset if (fAnimation) { @@ -37,13 +38,14 @@ void SkottieSlide::unload() { } SkISize SkottieSlide::getDimensions() const { - return fAnimation? fAnimation->size().toCeil() : SkISize::Make(0, 0); + // We always scale to fill the window. + return fWinSize.toCeil(); } void SkottieSlide::draw(SkCanvas* canvas) { if (fAnimation) { SkAutoCanvasRestore acr(canvas, true); - const SkRect dstR = SkRect::Make(canvas->imageInfo().bounds()); + const auto dstR = SkRect::MakeSize(fWinSize); fAnimation->render(canvas, &dstR); } } diff --git a/tools/viewer/SkottieSlide.h b/tools/viewer/SkottieSlide.h index cbb70b2183..ffa3bba7e2 100644 --- a/tools/viewer/SkottieSlide.h +++ b/tools/viewer/SkottieSlide.h @@ -31,6 +31,7 @@ public: private: SkString fPath; std::unique_ptr<skottie::Animation> fAnimation; + SkSize fWinSize = SkSize::MakeEmpty(); SkMSec fTimeBase = 0; bool fShowAnimationInval = false; |