[skottie] Show inval rects on mouse click in SkottieSlide

Also fix a SlideDir sizing bug.

TBR=

Change-Id: Iee61bb6665dc56ddd6fc062a686a9c0ef87dea92
Reviewed-on: https://skia-review.googlesource.com/108902
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
This commit is contained in:
Florin Malita 2018-02-20 16:49:20 -05:00 committed by Skia Commit-Bot
parent cbb85a7275
commit 60d3bfcef5
3 changed files with 17 additions and 3 deletions

View File

@ -77,3 +77,16 @@ bool SkottieSlide::onChar(SkUnichar c) {
return INHERITED::onChar(c);
}
bool SkottieSlide::onMouse(SkScalar x, SkScalar y, sk_app::Window::InputState state, uint32_t) {
switch (state) {
case sk_app::Window::kUp_InputState:
fShowAnimationInval = !fShowAnimationInval;
fAnimation->setShowInval(fShowAnimationInval);
break;
default:
break;
}
return true;
}

View File

@ -27,6 +27,7 @@ public:
bool animate(const SkAnimTimer&) override;
bool onChar(SkUnichar) override;
bool onMouse(SkScalar x, SkScalar y, sk_app::Window::InputState, uint32_t modifiers) override;
private:
SkString fPath;

View File

@ -337,8 +337,8 @@ void SlideDir::unload() {
}
SkISize SlideDir::getDimensions() const {
return SkSize::Make(fWinSize.width(),
fCellSize.height() * (fSlides.count() / fColumns)).toCeil();
return SkSize::Make(fWinSize.width(),
fCellSize.height() * (1 + (fSlides.count() - 1) / fColumns)).toCeil();
}
void SlideDir::draw(SkCanvas* canvas) {
@ -414,5 +414,5 @@ const SlideDir::Rec* SlideDir::findCell(float x, float y) const {
row = static_cast<int>(y / fCellSize.height()),
idx = row * fColumns + col;
return idx <= fRecs.count() ? &fRecs[idx] : nullptr;
return idx < fRecs.count() ? &fRecs[idx] : nullptr;
}