aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental
diff options
context:
space:
mode:
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);