aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2018-01-08 08:25:27 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-01-08 13:44:49 +0000
commit2985987cac72bf0a56fe75d751191d88d3b8582f (patch)
tree48669770bc0816ad876a1f23f95053c2a3535d52 /experimental
parent9524f2b71bec2d4fa3a2e25ee251c2f5a1563bc2 (diff)
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 <reed@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'experimental')
-rw-r--r--experimental/skotty/Skotty.cpp8
-rw-r--r--experimental/skotty/Skotty.h3
2 files changed, 9 insertions, 2 deletions
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 <memory>
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);