Brian Salomon | 06c9e29 | 2021-04-29 14:10:23 -0400 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2021 Google LLC |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef MSKPSlide_DEFINED |
| 9 | #define MSKPSlide_DEFINED |
| 10 | |
| 11 | #include "tools/MSKPPlayer.h" |
| 12 | #include "tools/viewer/Slide.h" |
| 13 | |
| 14 | class SkStreamSeekable; |
| 15 | |
| 16 | class MSKPSlide : public Slide { |
| 17 | public: |
| 18 | MSKPSlide(const SkString& name, const SkString& path); |
| 19 | MSKPSlide(const SkString& name, std::unique_ptr<SkStreamSeekable>); |
| 20 | |
| 21 | SkISize getDimensions() const override; |
| 22 | |
| 23 | void draw(SkCanvas* canvas) override; |
| 24 | bool animate(double nanos) override; |
| 25 | void load(SkScalar winWidth, SkScalar winHeight) override; |
| 26 | void unload() override; |
| 27 | void gpuTeardown() override; |
| 28 | |
| 29 | private: |
| 30 | std::unique_ptr<SkStreamSeekable> fStream; |
| 31 | std::unique_ptr<MSKPPlayer> fPlayer; |
| 32 | int fFrame = 0; |
| 33 | int fFPS = 15; // TODO: make this adjustable. This happens to work well for calendar.mskp |
| 34 | double fLastFrameTime = 0; |
| 35 | |
| 36 | using INHERITED = Slide; |
| 37 | }; |
| 38 | |
| 39 | #endif |