Revert "Revert "Add mskp player, use in viewer slide""
This reverts commit 0d174586c46923098eca1684e21a7049d5b62116.
Use SkTLazy instead of std::optional (C++17 library feature)
Bug: skia:11900
Change-Id: Ia41caa9322d812f9ba6644dd14ede7d0015cf8b3
Cq-Include-Trybots: luci.skia.skia.primary:Housekeeper-PerCommit-CreateDockerImage_Skia_Release,Build-Debian10-Clang-x86_64-Release-CMake
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402642
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/tools/viewer/MSKPSlide.h b/tools/viewer/MSKPSlide.h
new file mode 100644
index 0000000..41b3c9c
--- /dev/null
+++ b/tools/viewer/MSKPSlide.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2021 Google LLC
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef MSKPSlide_DEFINED
+#define MSKPSlide_DEFINED
+
+#include "tools/MSKPPlayer.h"
+#include "tools/viewer/Slide.h"
+
+class SkStreamSeekable;
+
+class MSKPSlide : public Slide {
+public:
+ MSKPSlide(const SkString& name, const SkString& path);
+ MSKPSlide(const SkString& name, std::unique_ptr<SkStreamSeekable>);
+
+ SkISize getDimensions() const override;
+
+ void draw(SkCanvas* canvas) override;
+ bool animate(double nanos) override;
+ void load(SkScalar winWidth, SkScalar winHeight) override;
+ void unload() override;
+ void gpuTeardown() override;
+
+private:
+ std::unique_ptr<SkStreamSeekable> fStream;
+ std::unique_ptr<MSKPPlayer> fPlayer;
+ int fFrame = 0;
+ int fFPS = 15; // TODO: make this adjustable. This happens to work well for calendar.mskp
+ double fLastFrameTime = 0;
+
+ using INHERITED = Slide;
+};
+
+#endif