blob: 1e47f94003ee8bd3dd137eaef89389d7c993e780 [file] [log] [blame]
Brian Salomon06c9e292021-04-29 14:10:23 -04001/*
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
14class SkStreamSeekable;
15
16class MSKPSlide : public Slide {
17public:
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
29private:
Brian Salomon33ec61132021-05-12 12:03:02 -040030 // Call if layers need to be redrawn because we've looped playback or UI interaction.
31 void redrawLayers();
32
Brian Salomon06c9e292021-04-29 14:10:23 -040033 std::unique_ptr<SkStreamSeekable> fStream;
Brian Salomon0bc48222021-04-23 19:14:02 -040034 std::unique_ptr<MSKPPlayer> fPlayer;
35
36 int fFrame = 0;
37 int fFPS = 15;
38 bool fPaused = false;
39 double fLastFrameTime = -1;
Brian Salomon06c9e292021-04-29 14:10:23 -040040
Brian Salomon8e880af2021-04-30 13:50:05 -040041 bool fShowFrameBounds = false;
42
43 // Default to transparent black, which is correct for Android MSKPS.
44 float fBackgroundColor[4] = {0, 0, 0, 0};
45
Brian Salomon33ec61132021-05-12 12:03:02 -040046 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
Brian Salomon06c9e292021-04-29 14:10:23 -040052 using INHERITED = Slide;
53};
54
55#endif