Skotty -> Skottie
Change-Id: If8b6516024c69b0fc256208874f6666a4e70e12c
Reviewed-on: https://skia-review.googlesource.com/95241
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
diff --git a/tools/viewer/SkottySlide.cpp b/tools/viewer/SkottieSlide.cpp
similarity index 77%
rename from tools/viewer/SkottySlide.cpp
rename to tools/viewer/SkottieSlide.cpp
index 99f182a..8880916 100644
--- a/tools/viewer/SkottySlide.cpp
+++ b/tools/viewer/SkottieSlide.cpp
@@ -5,19 +5,19 @@
* found in the LICENSE file.
*/
-#include "SkottySlide.h"
+#include "SkottieSlide.h"
#include "SkAnimTimer.h"
#include "SkCanvas.h"
-#include "Skotty.h"
+#include "Skottie.h"
-SkottySlide::SkottySlide(const SkString& name, const SkString& path)
+SkottieSlide::SkottieSlide(const SkString& name, const SkString& path)
: fPath(path) {
fName = name;
}
-void SkottySlide::load(SkScalar, SkScalar) {
- fAnimation = skotty::Animation::MakeFromFile(fPath.c_str());
+void SkottieSlide::load(SkScalar, SkScalar) {
+ fAnimation = skottie::Animation::MakeFromFile(fPath.c_str());
fTimeBase = 0; // force a time reset
if (fAnimation) {
@@ -32,15 +32,15 @@
}
}
-void SkottySlide::unload() {
+void SkottieSlide::unload() {
fAnimation.reset();
}
-SkISize SkottySlide::getDimensions() const {
+SkISize SkottieSlide::getDimensions() const {
return fAnimation? fAnimation->size().toCeil() : SkISize::Make(0, 0);
}
-void SkottySlide::draw(SkCanvas* canvas) {
+void SkottieSlide::draw(SkCanvas* canvas) {
if (fAnimation) {
SkAutoCanvasRestore acr(canvas, true);
const SkRect dstR = SkRect::Make(canvas->imageInfo().bounds());
@@ -48,7 +48,7 @@
}
}
-bool SkottySlide::animate(const SkAnimTimer& timer) {
+bool SkottieSlide::animate(const SkAnimTimer& timer) {
if (fTimeBase == 0) {
// Reset the animation time.
fTimeBase = timer.msec();
@@ -61,7 +61,7 @@
return true;
}
-bool SkottySlide::onChar(SkUnichar c) {
+bool SkottieSlide::onChar(SkUnichar c) {
switch (c) {
case 'I':
if (fAnimation) {
diff --git a/tools/viewer/SkottieSlide.h b/tools/viewer/SkottieSlide.h
new file mode 100644
index 0000000..6c278d4
--- /dev/null
+++ b/tools/viewer/SkottieSlide.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2017 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkottieSlide_DEFINED
+#define SkottieSlide_DEFINED
+
+#include "Slide.h"
+
+namespace skottie { class Animation; }
+
+class SkottieSlide : public Slide {
+public:
+ SkottieSlide(const SkString& name, const SkString& path);
+ ~SkottieSlide() override = default;
+
+ void load(SkScalar winWidth, SkScalar winHeight) override;
+ void unload() override;
+
+ SkISize getDimensions() const override;
+
+ void draw(SkCanvas*) override;
+ bool animate(const SkAnimTimer&) override;
+
+ bool onChar(SkUnichar) override;
+
+private:
+ SkString fPath;
+ std::unique_ptr<skottie::Animation> fAnimation;
+ SkMSec fTimeBase = 0;
+ bool fShowAnimationInval = false;
+
+ typedef Slide INHERITED;
+};
+
+class SkottieSlide2 : public Slide {
+public:
+ SkottieSlide2(const SkString& path);
+ ~SkottieSlide2() override = default;
+
+ void load(SkScalar winWidth, SkScalar winHeight) override;
+ void unload() override;
+
+ SkISize getDimensions() const override;
+
+ void draw(SkCanvas*) override;
+ bool animate(const SkAnimTimer&) override;
+ bool onMouse(SkScalar x, SkScalar y, sk_app::Window::InputState, uint32_t modifiers) override;
+private:
+ struct Rec {
+ std::unique_ptr<skottie::Animation> fAnimation;
+ SkMSec fTimeBase = 0;
+ SkString fName;
+ bool fShowAnimationInval = false;
+
+ Rec(std::unique_ptr<skottie::Animation> anim);
+ Rec(Rec&& o);
+ };
+
+ int findCell(float x, float y) const;
+
+ SkString fPath;
+ SkTArray<Rec> fAnims;
+
+ int fTrackingCell = -1;
+
+ typedef Slide INHERITED;
+};
+
+#endif // SkottieSlide_DEFINED
diff --git a/tools/viewer/SkottySlide2.cpp b/tools/viewer/SkottieSlide2.cpp
similarity index 81%
rename from tools/viewer/SkottySlide2.cpp
rename to tools/viewer/SkottieSlide2.cpp
index 180c7ad..0c643b7 100644
--- a/tools/viewer/SkottySlide2.cpp
+++ b/tools/viewer/SkottieSlide2.cpp
@@ -5,11 +5,11 @@
* found in the LICENSE file.
*/
-#include "SkottySlide.h"
+#include "SkottieSlide.h"
#include "SkAnimTimer.h"
#include "SkCanvas.h"
-#include "Skotty.h"
+#include "Skottie.h"
#include "SkOSFile.h"
#include "SkOSPath.h"
#include "SkStream.h"
@@ -21,38 +21,38 @@
const int SPACER_Y = 24;
const int MARGIN = 8;
-SkottySlide2::Rec::Rec(std::unique_ptr<skotty::Animation> anim) : fAnimation(std::move(anim))
+SkottieSlide2::Rec::Rec(std::unique_ptr<skottie::Animation> anim) : fAnimation(std::move(anim))
{}
-SkottySlide2::Rec::Rec(Rec&& o)
+SkottieSlide2::Rec::Rec(Rec&& o)
: fAnimation(std::move(o.fAnimation))
, fTimeBase(o.fTimeBase)
, fName(o.fName)
, fShowAnimationInval(o.fShowAnimationInval)
{}
-SkottySlide2::SkottySlide2(const SkString& path)
+SkottieSlide2::SkottieSlide2(const SkString& path)
: fPath(path)
{
- fName.set("skotty-dir");
+ fName.set("skottie-dir");
}
-void SkottySlide2::load(SkScalar, SkScalar) {
+void SkottieSlide2::load(SkScalar, SkScalar) {
SkString name;
SkOSFile::Iter iter(fPath.c_str(), "json");
while (iter.next(&name)) {
SkString path = SkOSPath::Join(fPath.c_str(), name.c_str());
- if (auto anim = skotty::Animation::MakeFromFile(path.c_str())) {
+ if (auto anim = skottie::Animation::MakeFromFile(path.c_str())) {
fAnims.push_back(Rec(std::move(anim))).fName = name;
}
}
}
-void SkottySlide2::unload() {
+void SkottieSlide2::unload() {
fAnims.reset();
}
-SkISize SkottySlide2::getDimensions() const {
+SkISize SkottieSlide2::getDimensions() const {
const int rows = (fAnims.count() + COL_COUNT - 1) / COL_COUNT;
return {
MARGIN + (COL_COUNT - 1) * SPACER_X + COL_COUNT * CELL_WIDTH + MARGIN,
@@ -60,7 +60,7 @@
};
}
-void SkottySlide2::draw(SkCanvas* canvas) {
+void SkottieSlide2::draw(SkCanvas* canvas) {
SkPaint paint;
paint.setTextSize(12);
paint.setAntiAlias(true);
@@ -83,7 +83,7 @@
}
}
-bool SkottySlide2::animate(const SkAnimTimer& timer) {
+bool SkottieSlide2::animate(const SkAnimTimer& timer) {
for (auto& rec : fAnims) {
if (rec.fTimeBase == 0) {
// Reset the animation time.
@@ -94,7 +94,7 @@
return true;
}
-bool SkottySlide2::onMouse(SkScalar x, SkScalar y, sk_app::Window::InputState state,
+bool SkottieSlide2::onMouse(SkScalar x, SkScalar y, sk_app::Window::InputState state,
uint32_t modifiers) {
if (fTrackingCell < 0 && state == sk_app::Window::kDown_InputState) {
fTrackingCell = this->findCell(x, y);
@@ -110,7 +110,7 @@
return fTrackingCell >= 0;
}
-int SkottySlide2::findCell(float x, float y) const {
+int SkottieSlide2::findCell(float x, float y) const {
x -= MARGIN;
y -= MARGIN;
int index = -1;
@@ -126,4 +126,3 @@
}
return index;
}
-
diff --git a/tools/viewer/SkottySlide.h b/tools/viewer/SkottySlide.h
deleted file mode 100644
index ed0662f..0000000
--- a/tools/viewer/SkottySlide.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2017 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkottySlide_DEFINED
-#define SkottySlide_DEFINED
-
-#include "Slide.h"
-
-namespace skotty { class Animation; }
-
-class SkottySlide : public Slide {
-public:
- SkottySlide(const SkString& name, const SkString& path);
- ~SkottySlide() override = default;
-
- void load(SkScalar winWidth, SkScalar winHeight) override;
- void unload() override;
-
- SkISize getDimensions() const override;
-
- void draw(SkCanvas*) override;
- bool animate(const SkAnimTimer&) override;
-
- bool onChar(SkUnichar) override;
-
-private:
- SkString fPath;
- std::unique_ptr<skotty::Animation> fAnimation;
- SkMSec fTimeBase = 0;
- bool fShowAnimationInval = false;
-
- typedef Slide INHERITED;
-};
-
-class SkottySlide2 : public Slide {
-public:
- SkottySlide2(const SkString& path);
- ~SkottySlide2() override = default;
-
- void load(SkScalar winWidth, SkScalar winHeight) override;
- void unload() override;
-
- SkISize getDimensions() const override;
-
- void draw(SkCanvas*) override;
- bool animate(const SkAnimTimer&) override;
- bool onMouse(SkScalar x, SkScalar y, sk_app::Window::InputState, uint32_t modifiers) override;
-private:
- struct Rec {
- std::unique_ptr<skotty::Animation> fAnimation;
- SkMSec fTimeBase = 0;
- SkString fName;
- bool fShowAnimationInval = false;
-
- Rec(std::unique_ptr<skotty::Animation> anim);
- Rec(Rec&& o);
- };
-
- int findCell(float x, float y) const;
-
- SkString fPath;
- SkTArray<Rec> fAnims;
-
- int fTrackingCell = -1;
-
- typedef Slide INHERITED;
-};
-
-#endif // SkottySlide_DEFINED
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index 59d5e50..1ba32ee 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -11,7 +11,7 @@
#include "ImageSlide.h"
#include "Resources.h"
#include "SampleSlide.h"
-#include "SkottySlide.h"
+#include "SkottieSlide.h"
#include "SKPSlide.h"
#include "GrContext.h"
@@ -486,7 +486,7 @@
// JSONs
for (const auto& json : FLAGS_jsons) {
- fSlides.push_back(sk_make_sp<SkottySlide2>(json));
+ fSlides.push_back(sk_make_sp<SkottieSlide2>(json));
SkOSFile::Iter it(json.c_str(), ".json");
SkString jsonName;
@@ -494,8 +494,8 @@
if (SkCommandLineFlags::ShouldSkip(FLAGS_match, jsonName.c_str())) {
continue;
}
- fSlides.push_back(sk_make_sp<SkottySlide>(jsonName, SkOSPath::Join(json.c_str(),
- jsonName.c_str())));
+ fSlides.push_back(sk_make_sp<SkottieSlide>(jsonName, SkOSPath::Join(json.c_str(),
+ jsonName.c_str())));
}
}
}