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 #include "Viewer.h" | 8 #include "Viewer.h" |
9 | 9 |
10 #include "GMSlide.h" | 10 #include "GMSlide.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 return vv->onPaint(canvas); | 28 return vv->onPaint(canvas); |
29 } | 29 } |
30 | 30 |
31 static bool on_touch_handler(int owner, Window::InputState state, float x, float
y, void* userData) | 31 static bool on_touch_handler(int owner, Window::InputState state, float x, float
y, void* userData) |
32 { | 32 { |
33 Viewer* viewer = reinterpret_cast<Viewer*>(userData); | 33 Viewer* viewer = reinterpret_cast<Viewer*>(userData); |
34 | 34 |
35 return viewer->onTouch(owner, state, x, y); | 35 return viewer->onTouch(owner, state, x, y); |
36 } | 36 } |
37 | 37 |
38 DEFINE_bool2(fullscreen, f, true, "Run fullscreen."); | 38 DEFINE_bool2(fullscreen, f, false, "Run fullscreen."); |
39 DEFINE_string(key, "", "Space-separated key/value pairs to add to JSON identifyi
ng this builder."); | 39 DEFINE_string(key, "", "Space-separated key/value pairs to add to JSON identifyi
ng this builder."); |
40 DEFINE_string2(match, m, nullptr, | 40 DEFINE_string2(match, m, nullptr, |
41 "[~][^]substring[$] [...] of bench name to run.\n" | 41 "[~][^]substring[$] [...] of bench name to run.\n" |
42 "Multiple matches may be separated by spaces.\n" | 42 "Multiple matches may be separated by spaces.\n" |
43 "~ causes a matching bench to always be skipped\n" | 43 "~ causes a matching bench to always be skipped\n" |
44 "^ requires the start of the bench to match\n" | 44 "^ requires the start of the bench to match\n" |
45 "$ requires the end of the bench to match\n" | 45 "$ requires the end of the bench to match\n" |
46 "^ and $ requires an exact match\n" | 46 "^ and $ requires an exact match\n" |
47 "If a bench does not match any list entry,\n" | 47 "If a bench does not match any list entry,\n" |
48 "it is skipped unless some list entry starts with ~"); | 48 "it is skipped unless some list entry starts with ~"); |
49 DEFINE_string(skps, "skps", "Directory to read skps from."); | 49 DEFINE_string(skps, "skps", "Directory to read skps from."); |
| 50 DEFINE_bool(vulkan, true, "Run with Vulkan."); |
50 | 51 |
51 const char *kBackendTypeStrings[sk_app::Window::kBackendTypeCount] = { | 52 const char *kBackendTypeStrings[sk_app::Window::kBackendTypeCount] = { |
52 " [OpenGL]", | 53 " [OpenGL]", |
53 " [Vulkan]" | 54 " [Vulkan]" |
54 }; | 55 }; |
55 | 56 |
56 Viewer::Viewer(int argc, char** argv, void* platformData) | 57 Viewer::Viewer(int argc, char** argv, void* platformData) |
57 : fCurrentMeasurement(0) | 58 : fCurrentMeasurement(0) |
58 , fDisplayStats(false) | 59 , fDisplayStats(false) |
59 , fBackendType(sk_app::Window::kVulkan_BackendType) | 60 , fBackendType(sk_app::Window::kVulkan_BackendType) |
60 , fZoomCenterX(0.0f) | 61 , fZoomCenterX(0.0f) |
61 , fZoomCenterY(0.0f) | 62 , fZoomCenterY(0.0f) |
62 , fZoomLevel(0.0f) | 63 , fZoomLevel(0.0f) |
63 , fZoomScale(SK_Scalar1) | 64 , fZoomScale(SK_Scalar1) |
64 { | 65 { |
65 memset(fMeasurements, 0, sizeof(fMeasurements)); | 66 memset(fMeasurements, 0, sizeof(fMeasurements)); |
66 | 67 |
67 SkDebugf("Command line arguments: "); | 68 SkDebugf("Command line arguments: "); |
68 for (int i = 1; i < argc; ++i) { | 69 for (int i = 1; i < argc; ++i) { |
69 SkDebugf("%s ", argv[i]); | 70 SkDebugf("%s ", argv[i]); |
70 } | 71 } |
71 SkDebugf("\n"); | 72 SkDebugf("\n"); |
72 | 73 |
73 SkCommandLineFlags::Parse(argc, argv); | 74 SkCommandLineFlags::Parse(argc, argv); |
74 | 75 |
| 76 fBackendType = FLAGS_vulkan ? sk_app::Window::kVulkan_BackendType |
| 77 : sk_app::Window::kNativeGL_BackendType; |
| 78 |
75 fWindow = Window::CreateNativeWindow(platformData); | 79 fWindow = Window::CreateNativeWindow(platformData); |
76 fWindow->attach(fBackendType, DisplayParams()); | 80 fWindow->attach(fBackendType, DisplayParams()); |
77 | 81 |
78 // register callbacks | 82 // register callbacks |
79 fCommands.attach(fWindow); | 83 fCommands.attach(fWindow); |
80 fWindow->registerPaintFunc(on_paint_handler, this); | 84 fWindow->registerPaintFunc(on_paint_handler, this); |
81 fWindow->registerTouchFunc(on_touch_handler, this); | 85 fWindow->registerTouchFunc(on_touch_handler, this); |
82 | 86 |
83 // add key-bindings | 87 // add key-bindings |
84 fCommands.addCommand('s', "Overlays", "Toggle stats display", [this]() { | 88 fCommands.addCommand('s', "Overlays", "Toggle stats display", [this]() { |
(...skipping 25 matching lines...) Expand all Loading... |
110 this->setupCurrentSlide(previousSlide); | 114 this->setupCurrentSlide(previousSlide); |
111 }); | 115 }); |
112 fCommands.addCommand(Window::Key::kUp, "Up", "Transform", "Zoom in", [this](
) { | 116 fCommands.addCommand(Window::Key::kUp, "Up", "Transform", "Zoom in", [this](
) { |
113 this->changeZoomLevel(1.f / 32.f); | 117 this->changeZoomLevel(1.f / 32.f); |
114 fWindow->inval(); | 118 fWindow->inval(); |
115 }); | 119 }); |
116 fCommands.addCommand(Window::Key::kDown, "Down", "Transform", "Zoom out", [t
his]() { | 120 fCommands.addCommand(Window::Key::kDown, "Down", "Transform", "Zoom out", [t
his]() { |
117 this->changeZoomLevel(-1.f / 32.f); | 121 this->changeZoomLevel(-1.f / 32.f); |
118 fWindow->inval(); | 122 fWindow->inval(); |
119 }); | 123 }); |
| 124 #if 0 // this doesn't seem to work on any platform right now |
120 #ifndef SK_BUILD_FOR_ANDROID | 125 #ifndef SK_BUILD_FOR_ANDROID |
121 fCommands.addCommand('d', "Modes", "Change rendering backend", [this]() { | 126 fCommands.addCommand('d', "Modes", "Change rendering backend", [this]() { |
122 fWindow->detach(); | 127 fWindow->detach(); |
123 | 128 |
124 if (sk_app::Window::kVulkan_BackendType == fBackendType) { | 129 if (sk_app::Window::kVulkan_BackendType == fBackendType) { |
125 fBackendType = sk_app::Window::kNativeGL_BackendType; | 130 fBackendType = sk_app::Window::kNativeGL_BackendType; |
126 } | 131 } |
127 // TODO: get Vulkan -> OpenGL working without swapchain creation failure | 132 // TODO: get Vulkan -> OpenGL working on Windows without swapchain creat
ion failure |
128 //else if (sk_app::Window::kNativeGL_BackendType == fBackendType) { | 133 //else if (sk_app::Window::kNativeGL_BackendType == fBackendType) { |
129 // fBackendType = sk_app::Window::kVulkan_BackendType; | 134 // fBackendType = sk_app::Window::kVulkan_BackendType; |
130 //} | 135 //} |
131 | 136 |
132 fWindow->attach(fBackendType, DisplayParams()); | 137 fWindow->attach(fBackendType, DisplayParams()); |
133 this->updateTitle(); | 138 this->updateTitle(); |
| 139 fWindow->inval(); |
134 }); | 140 }); |
135 #endif | 141 #endif |
| 142 #endif |
136 | 143 |
137 // set up slides | 144 // set up slides |
138 this->initSlides(); | 145 this->initSlides(); |
139 | 146 |
140 fAnimTimer.run(); | 147 fAnimTimer.run(); |
141 | 148 |
142 // set up first frame | 149 // set up first frame |
143 fCurrentSlide = 0; | 150 fCurrentSlide = 0; |
144 setupCurrentSlide(-1); | 151 setupCurrentSlide(-1); |
145 | 152 |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 // Record measurements | 382 // Record measurements |
376 fMeasurements[fCurrentMeasurement++] = ms; | 383 fMeasurements[fCurrentMeasurement++] = ms; |
377 fCurrentMeasurement &= (kMeasurementCount - 1); // fast mod | 384 fCurrentMeasurement &= (kMeasurementCount - 1); // fast mod |
378 SkASSERT(fCurrentMeasurement < kMeasurementCount); | 385 SkASSERT(fCurrentMeasurement < kMeasurementCount); |
379 | 386 |
380 fAnimTimer.updateTime(); | 387 fAnimTimer.updateTime(); |
381 if (fSlides[fCurrentSlide]->animate(fAnimTimer) || fDisplayStats) { | 388 if (fSlides[fCurrentSlide]->animate(fAnimTimer) || fDisplayStats) { |
382 fWindow->inval(); | 389 fWindow->inval(); |
383 } | 390 } |
384 } | 391 } |
OLD | NEW |