OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef Viewer_DEFINED | 8 #ifndef Viewer_DEFINED |
9 #define Viewer_DEFINED | 9 #define Viewer_DEFINED |
10 | 10 |
11 #include "sk_app/Application.h" | 11 #include "sk_app/Application.h" |
12 #include "sk_app/CommandSet.h" | 12 #include "sk_app/CommandSet.h" |
13 #include "sk_app/Window.h" | 13 #include "sk_app/Window.h" |
14 #include "gm.h" | 14 #include "gm.h" |
15 #include "SkAnimTimer.h" | 15 #include "SkAnimTimer.h" |
16 #include "SkTouchGesture.h" | 16 #include "SkTouchGesture.h" |
17 #include "Slide.h" | 17 #include "Slide.h" |
18 | 18 |
19 class SkCanvas; | 19 class SkCanvas; |
20 | 20 |
21 class Viewer : public sk_app::Application { | 21 class Viewer : public sk_app::Application { |
22 public: | 22 public: |
23 Viewer(int argc, char** argv, void* platformData); | 23 Viewer(int argc, char** argv, void* platformData); |
24 ~Viewer() override; | 24 ~Viewer() override; |
25 | 25 |
26 void onPaint(SkCanvas* canvas); | 26 void onPaint(SkCanvas* canvas); |
27 void onIdle(double ms) override; | 27 void onIdle() override; |
28 bool onTouch(intptr_t owner, sk_app::Window::InputState state, float x, floa
t y); | 28 bool onTouch(intptr_t owner, sk_app::Window::InputState state, float x, floa
t y); |
29 void onUIStateChanged(const SkString& stateName, const SkString& stateValue)
; | 29 void onUIStateChanged(const SkString& stateName, const SkString& stateValue)
; |
30 | 30 |
31 private: | 31 private: |
32 void initSlides(); | 32 void initSlides(); |
33 void updateTitle(); | 33 void updateTitle(); |
34 void setupCurrentSlide(int previousSlide); | 34 void setupCurrentSlide(int previousSlide); |
35 | 35 |
36 void updateUIState(); | 36 void updateUIState(); |
37 | 37 |
38 void drawSlide(SkCanvas* canvs, bool inSplitScreen); | 38 void drawSlide(SkCanvas* canvs, bool inSplitScreen); |
39 void drawStats(SkCanvas* canvas); | 39 void drawStats(SkCanvas* canvas); |
40 | 40 |
41 void changeZoomLevel(float delta); | 41 void changeZoomLevel(float delta); |
42 SkMatrix computeMatrix(); | 42 SkMatrix computeMatrix(); |
43 | 43 |
44 sk_app::Window* fWindow; | 44 sk_app::Window* fWindow; |
45 | 45 |
46 static const int kMeasurementCount = 64; // should be power of 2 for fast m
od | 46 static const int kMeasurementCount = 64; // should be power of 2 for fast m
od |
47 double fMeasurements[kMeasurementCount]; | 47 double fMeasurements[kMeasurementCount]; |
48 int fCurrentMeasurement; | 48 int fCurrentMeasurement; |
49 | 49 |
50 SkAnimTimer fAnimTimer; | 50 SkAnimTimer fAnimTimer; |
51 SkTArray<sk_sp<Slide>> fSlides; | 51 SkTArray<sk_sp<Slide>> fSlides; |
52 int fCurrentSlide; | 52 int fCurrentSlide; |
53 | 53 |
54 bool fDisplayStats; | 54 bool fDisplayStats; |
| 55 bool fRefresh; // whether to continuously refresh for meas
uring render time |
55 | 56 |
56 // whether to split the screen and draw two copies of the slide, one with sR
GB and one without | 57 // whether to split the screen and draw two copies of the slide, one with sR
GB and one without |
57 bool fSplitScreen; | 58 bool fSplitScreen; |
58 | 59 |
59 sk_app::Window::BackendType fBackendType; | 60 sk_app::Window::BackendType fBackendType; |
60 | 61 |
61 // transform data | 62 // transform data |
62 SkScalar fZoomCenterX; | 63 SkScalar fZoomCenterX; |
63 SkScalar fZoomCenterY; | 64 SkScalar fZoomCenterY; |
64 SkScalar fZoomLevel; | 65 SkScalar fZoomLevel; |
65 SkScalar fZoomScale; | 66 SkScalar fZoomScale; |
66 | 67 |
67 sk_app::CommandSet fCommands; | 68 sk_app::CommandSet fCommands; |
68 | 69 |
69 SkTouchGesture fGesture; | 70 SkTouchGesture fGesture; |
70 | 71 |
71 // identity unless the window initially scales the content to fit the screen
. | 72 // identity unless the window initially scales the content to fit the screen
. |
72 SkMatrix fDefaultMatrix; | 73 SkMatrix fDefaultMatrix; |
73 SkMatrix fDefaultMatrixInv; | 74 SkMatrix fDefaultMatrixInv; |
74 | 75 |
75 Json::Value fAllSlideNames; // cache all slide names for fast upd
ateUIState | 76 Json::Value fAllSlideNames; // cache all slide names for fast upd
ateUIState |
76 }; | 77 }; |
77 | 78 |
78 | 79 |
79 #endif | 80 #endif |
OLD | NEW |