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 // Call if layers need to be redrawn because we've looped playback or UI interaction. 31 void redrawLayers(); 32 33 std::unique_ptr<SkStreamSeekable> fStream; 34 std::unique_ptr<MSKPPlayer> fPlayer; 35 36 int fFrame = 0; 37 int fFPS = 15; 38 bool fPaused = false; 39 double fLastFrameTime = -1; 40 41 bool fShowFrameBounds = false; 42 43 // Default to transparent black, which is correct for Android MSKPS. 44 float fBackgroundColor[4] = {0, 0, 0, 0}; 45 46 std::vector<int> fAllLayerIDs; 47 std::vector<std::vector<int>> fFrameLayerIDs; 48 std::vector<SkString> fLayerIDStrings; 49 int fDrawLayerID = -1; // -1 means just draw the root layer 50 bool fListAllLayers = true; 51 52 using INHERITED = Slide; 53 }; 54 55 #endif 56