From 2985987cac72bf0a56fe75d751191d88d3b8582f Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Mon, 8 Jan 2018 08:25:27 -0500 Subject: add skotty-dir slide Shows a directory of skotties in a grid Bug: skia: Change-Id: I96b0700d8809c94a394cf517222123967afb20dc Reviewed-on: https://skia-review.googlesource.com/91407 Commit-Queue: Mike Reed Reviewed-by: Florin Malita --- experimental/skotty/Skotty.cpp | 8 +++++++- experimental/skotty/Skotty.h | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'experimental') diff --git a/experimental/skotty/Skotty.cpp b/experimental/skotty/Skotty.cpp index a13a04c03c..84cc08051f 100644 --- a/experimental/skotty/Skotty.cpp +++ b/experimental/skotty/Skotty.cpp @@ -752,7 +752,7 @@ Animation::Animation(SkString version, const SkSize& size, SkScalar fps, const J Animation::~Animation() = default; -void Animation::render(SkCanvas* canvas) const { +void Animation::render(SkCanvas* canvas, const SkRect* dstR) const { if (!fDom) return; @@ -760,6 +760,12 @@ void Animation::render(SkCanvas* canvas) const { fDom->revalidate(&ic, SkMatrix::I()); // TODO: proper inval + SkAutoCanvasRestore restore(canvas, true); + const SkRect srcR = SkRect::MakeSize(this->size()); + if (dstR) { + canvas->concat(SkMatrix::MakeRectToRect(srcR, *dstR, SkMatrix::kCenter_ScaleToFit)); + } + canvas->clipRect(srcR); fDom->render(canvas); if (!fShowInval) diff --git a/experimental/skotty/Skotty.h b/experimental/skotty/Skotty.h index c20feeb093..d02dc8d3ab 100644 --- a/experimental/skotty/Skotty.h +++ b/experimental/skotty/Skotty.h @@ -18,6 +18,7 @@ #include class SkCanvas; +struct SkRect; class SkStream; namespace Json { class Value; } @@ -34,7 +35,7 @@ public: ~Animation(); - void render(SkCanvas*) const; + void render(SkCanvas*, const SkRect* dst = nullptr) const; void animationTick(SkMSec); -- cgit v1.2.3